To find the square roots of a+ib, set x+iy to be a square root, so a+ib=(x+iy)2 for real x,y. Expanding,
a+ib=(x2−y2)+i(2xy).
Equating real and imaginary parts: x2−y2=a and 2xy=b. To pin down x2+y2 as well, note (x2+y2)2=(x2−y2)2+(2xy)2=a2+b2, so, since x2+y2 is positive,
x2+y2=a2+b2=∣a+ib∣=:∣z∣.
Now solving the pair x2−y2=a and x2+y2=∣z∣ simultaneously:
x2=2∣z∣+a,y2=2∣z∣−a⟹x=±2∣z∣+a,y=±2∣z∣−a.
Since 2xy=b: x and y must have the same sign when b>0, and opposite signs when b<0 (this is what fixes which combination of the two ± choices is valid — they are not independent). Writing sgn(b)=b/∣b∣ for b=0, the formula for the square root of a complex number is
a+ib=±(2∣z∣+a+isgn(b)2∣z∣−a),z=a+ib,b=0,
and the overall ± reflects that both w and −w square to the same a+ib whenever w2=a+ib. …