My Coding > Mathematics > Complex numbers > Square root from complex number

Square root from complex number

It is important to calculate square roots from complex numbers. This technique is widely used for solving quadratic equations with imaginary coefficients. Therefore it is necessary to have a simple formula for calculating square roo from imaginary numbers.

Let \(z = a + bi\), where a and b are real numbers.

Then we can write \(\left|z\right| = \sqrt{a^2 + b^2}\)

We want to find the square root of z, which we can write as \(w = x + yi\), where x and y are real numbers.

Then we have \(\sqrt{a + ib} = x + iy\):

\[w^2 = (x + yi)^2 = x^2 + 2xyi + y^2i^2 = (x^2 - y^2) + 2xyi\]

Since \(w^2 = z\), we have system of equations:

\[x^2 - y^2 = a \\ 2xy = b\]

Let's solve it by calculating the following values:

\[(x^2 + y^2)^2 = (x^2)^2 + (y^2)^2 + 2x^2y^2 \\(x^2 - y^2)^2 = (x^2)^2 + (y^2)^2 - 2x^2y^2 \]

Subtracting one equation from the other we get:

\[(x^2 + y^2)^2 - (x^2 - y^2)^2 = 4x^2y^2\]

or

\[(x^2 + y^2)^2 = (x^2 - y^2)^2 + 4x^2y^2\]

Then after substitution back \(a\) and \(b\) values we get:

\[(x^2 + y^2)^2 = a^2 + b^2\]

Now it can be rewritten as:

\[x^2 + y^2 = \sqrt{a^2 + b^2} = \left|z\right| \\x^2 - y^2 = a \]

From second equation we get \(y^2 = x^2 - a\) and substitute it back to first one:

\[x^2 + x^2 - a = \left|z\right|\]

or

\[2x^2 = \left|z\right| + a\]

or

\[x^2 = \frac{\left|z\right| + a}{2}\]

and respectively:

\[y^2 = \frac{\left|z\right| + a}{2} - a = \frac{\left|z\right| - a}{2}\]

I'm writing it with so many details because I know that students sometimes fail to reproduce these steps.

Now we can calculate \(x\) and \(y\):

\[x = \pm\sqrt{\frac{\left|z\right| + a}{2}} \\y = \pm\sqrt{\frac{\left|z\right| - a}{2}}\]

And the last thing - we need to define the signs of \(x\) and \(y\). From the equation (see above), \(2xy = b\), we can conclude, that if \(b > 0\), then \(x\) and \(y\) have the same sign, and if \(b < 0\), then \(x\) and \(y\) have an opposite signs. Therefore, we can make a function of calculating the sign of \(b: sign(b) = \frac{b}{\left|b\right|}\), and now let's combine everything as a final equation:

\[\sqrt{a + ib} = \pm(\sqrt{\frac{\left|z\right| + a}{2}} + i\frac{b}{\left|b\right|}\sqrt{\frac{\left|z\right| - a}{2}})\]

For more details and some comments please check this video:


Published: 2023-05-08 18:49:21
Updated: 2023-05-08 22:19:50

Last 10 artitles


9 popular artitles

© 2020 MyCoding.uk -My blog about coding and further learning. This blog was writen with pure Perl and front-end output was performed with TemplateToolkit.