1

The square root $\pm(u+iv)$ of a complex number $x+iv$ with $y\neq0$ may be calculated from the formulas

$u=\pm\sqrt{\frac{x+\sqrt{x^2+y^2}}{2}}$

$v=\frac{y}{2u}$

compare the cases $x\geq0$ and $x<0$ with respect to the numerical stability. Modify the formulas if necessary to ensure numerical stability. I study this problem. Square root of a complex number but in my question proposed Numerical stability. and I don't know What does it mean and what can be done with numerical stability here?

Carl Christian
  • 12,583
  • 1
  • 14
  • 37
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Dec 11 '21 at 12:24
  • Welcome. Numerical stability means, in the context of algorithms, how sensitive your algorithm is to small computational rounding and bit-errors. For example, the process for finding the square root of $1+2i$ should produce the same - or very close - answer as it would for the input $1.00005892+1.999982i$, but a numerically unstable process might not give this, instead giving an "unstable" error. You should show more context and more of your thoughts. – FShrike Dec 11 '21 at 13:58
  • Furthermore, $n$th roots are far better found using the polar form of complex numbers! – FShrike Dec 11 '21 at 13:58

1 Answers1

2

You must first study the concept of catastrophic cancellation. This occurs when we subtract approximations of two real numbers that are relatively close to each other. This is a basic but extremely important point in numerical analysis. You will find very brief summary and analysis in this answer

Returning to the problem of complex square roots. The expression $$u = \sqrt{\frac{\sqrt{x^2+y^2}+x}{2}} $$ will not experience catastrophic cancellation as long as $x>0$. Afterwards, you can compute $v$ using $v = \frac{y}{2u}$.

However, the expression for $u$ will (almost certainly) experience catastrophic cancellation when $x<0$ and $y$ is nearly zero. If $x<0$, then you first compute $$v =\sqrt{\frac{\sqrt{x^2+y^2}-x}{2}}$$ and then $$u = \frac{y}{2v}.$$


If your complex number is given in polar form, then polar form of the square root can be computed using the naive formula. However, obtaining the polar form from the standard form in a reliable manner is not trivial.
Carl Christian
  • 12,583
  • 1
  • 14
  • 37