ComplexMathSqr Method

Computes the square of a complex number.

Definition

Namespace: Meta.Numerics
Assembly: Meta.Numerics (in Meta.Numerics.dll) Version: 4.2.0+6d77d64445f7d5d91b12e331399c4362ecb25333
C#
public static Complex Sqr(
	Complex z
)

Parameters

z  Complex
The argument.

Return Value

Complex
The value of z2.

Remarks

Unlike Sqr(Double), there is slightly more to this method than shorthand for z * z. In terms of real and imaginary parts z = x + i y, the product z * z = (x * x - y * y) + i(x * y + x * y), which not only requires 6 flops to evaluate, but also computes the real part as an expression that can easily overflow or suffer from significant cancelation error. By instead computing z2 via as (x - y) * (x + y) + i 2 * x * y, this method not only requires fewer flops but is also less subject to overflow and cancelation error. You should therefore generally favor the computation of z2 using this method over its computation as z * z.

See Also