预订演示

请注意 : 本帮助页面不适用于最新版本的Enterprise Architect. 最新的帮助文档在这里.

前页 后页

csqrt

Complex square root.

SYNOPSIS:

void csqrt();
cmplx z, w;

csqrt(&z, &w);


DESCRIPTION:

If z = x + iy,  r = |z|, then

                      1/2
Im w  =  [ (r - x)/2 ]   ,

Re w  =  y / 2 Im w.


Note that -w is also a square root of z. The root chosen is always in the upper half plane.

Because of the potential for a cancellation error in r - x, the result is sharpened by doing a Heron iteration (see sqrt) in complex arithmetic.

ACCURACY:

                      Relative error:
arithmetic   domain     # trials      peak         rms
    DEC       -10,+10     25000       3.2e-17     9.6e-18
    IEEE      -10,+10    100000       3.2e-16     7.7e-17

JavaScript:

var x = {"r":4.5,"i":3.14} ;
var a = cephes.csqrt(x);

returns a, complex object of schema
{
"r" : double,
"i": double
}