org.apfloat

## Class ApcomplexMath

• ```public class ApcomplexMath
extends Object```
Various mathematical functions for arbitrary precision complex numbers.
Version:
1.8.1
Author:
Mikko Tommila
`ApfloatMath`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static Apfloat` `abs(Apcomplex z)`
Absolute value.
`static Apcomplex` `acos(Apcomplex z)`
Inverse cosine.
`static Apcomplex` `acosh(Apcomplex z)`
Inverse hyperbolic cosine.
`static Apcomplex` ```agm(Apcomplex a, Apcomplex b)```
Arithmetic-geometric mean.
`static Apcomplex[]` ```allRoots(Apcomplex z, int n)```
All values of the positive integer root.
`static Apfloat` `arg(Apcomplex z)`
Angle of the complex vector in the complex plane.
`static Apcomplex` `asin(Apcomplex z)`
Inverse sine.
`static Apcomplex` `asinh(Apcomplex z)`
Inverse hyperbolic sine.
`static Apcomplex` `atan(Apcomplex z)`
Inverse tangent.
`static Apcomplex` `atanh(Apcomplex z)`
Inverse hyperbolic tangent.
`static Apcomplex` `cbrt(Apcomplex z)`
Cube root.
`static Apcomplex` `cos(Apcomplex z)`
Cosine.
`static Apcomplex` `cosh(Apcomplex z)`
Hyperbolic cosine.
`static Apcomplex` `exp(Apcomplex z)`
Exponent function.
`static Apcomplex` ```inverseRoot(Apcomplex z, long n)```
Inverse positive integer root.
`static Apcomplex` ```inverseRoot(Apcomplex z, long n, long k)```
Inverse positive integer root.
`static Apcomplex` `log(Apcomplex z)`
Natural logarithm.
`static Apcomplex` ```log(Apcomplex z, Apcomplex w)```
Logarithm in arbitrary base.
`static Apcomplex` `negate(Apcomplex z)`
Deprecated.
`static Apfloat` `norm(Apcomplex z)`
Norm.
`static Apcomplex` ```pow(Apcomplex z, Apcomplex w)```
Arbitrary power.
`static Apcomplex` ```pow(Apcomplex z, long n)```
Integer power.
`static Apcomplex` `product(Apcomplex... z)`
Product of numbers.
`static Apcomplex` ```root(Apcomplex z, long n)```
Positive integer root.
`static Apcomplex` ```root(Apcomplex z, long n, long k)```
Positive integer root.
`static Apcomplex` ```scale(Apcomplex z, long scale)```
Multiply by a power of the radix.
`static Apcomplex` `sin(Apcomplex z)`
Sine.
`static Apcomplex` `sinh(Apcomplex z)`
Hyperbolic sine.
`static Apcomplex` `sqrt(Apcomplex z)`
Square root.
`static Apcomplex` `sum(Apcomplex... z)`
Sum of numbers.
`static Apcomplex` `tan(Apcomplex z)`
Tangent.
`static Apcomplex` `tanh(Apcomplex z)`
Hyperbolic tangent.
`static Apcomplex` `w(Apcomplex z)`
Lambert W function.
`static Apcomplex` ```w(Apcomplex z, long k)```
Lambert W function for the specified branch.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Method Detail

• #### negate

```@Deprecated
public static Apcomplex negate(Apcomplex z)
throws ApfloatRuntimeException```
Deprecated.
Negative value.
Parameters:
`z` - The argument.
Returns:
`-z`.
Throws:
`ApfloatRuntimeException`
• #### abs

```public static Apfloat abs(Apcomplex z)
throws ApfloatRuntimeException```
Absolute value.
Parameters:
`z` - The argument.
Returns:
`sqrt(x2 + y2)`, where `z = x + i y`.
Throws:
`ApfloatRuntimeException`
• #### norm

```public static Apfloat norm(Apcomplex z)
throws ApfloatRuntimeException```
Norm. Square of the magnitude.
Parameters:
`z` - The argument.
Returns:
`x2 + y2`, where `z = x + i y`.
Throws:
`ApfloatRuntimeException`
• #### arg

```public static Apfloat arg(Apcomplex z)
throws ArithmeticException,
ApfloatRuntimeException```
Angle of the complex vector in the complex plane.
Parameters:
`z` - The argument.
Returns:
`arctan(y / x)` from the appropriate branch, where `z = x + i y`.
Throws:
`ArithmeticException` - If `z` is zero.
`ApfloatRuntimeException`
• #### scale

```public static Apcomplex scale(Apcomplex z,
long scale)
throws ApfloatRuntimeException```
Multiply by a power of the radix.
Parameters:
`z` - The argument.
`scale` - The scaling factor.
Returns:
`z * z.radix()scale`.
Throws:
`ApfloatRuntimeException`
• #### pow

```public static Apcomplex pow(Apcomplex z,
long n)
throws ArithmeticException,
ApfloatRuntimeException```
Integer power.
Parameters:
`z` - Base of the power operator.
`n` - Exponent of the power operator.
Returns:
`z` to the `n`:th power, that is `zn`.
Throws:
`ArithmeticException` - If both `z` and `n` are zero.
`ApfloatRuntimeException`
• #### sqrt

```public static Apcomplex sqrt(Apcomplex z)
throws ApfloatRuntimeException```
Square root.
Parameters:
`z` - The argument.
Returns:
Square root of `z`.
Throws:
`ApfloatRuntimeException`
• #### cbrt

```public static Apcomplex cbrt(Apcomplex z)
throws ApfloatRuntimeException```
Cube root.
Parameters:
`z` - The argument.
Returns:
Cube root of `z`.
Throws:
`ApfloatRuntimeException`
• #### root

```public static Apcomplex root(Apcomplex z,
long n)
throws ArithmeticException,
ApfloatRuntimeException```
Positive integer root. The branch that has the smallest angle and same sign of imaginary part as `z` is always chosen.
Parameters:
`z` - The argument.
`n` - Which root to take.
Returns:
`n`:th root of `z`, that is `z1/n`.
Throws:
`ArithmeticException` - If `n` is zero.
`ApfloatRuntimeException`
• #### root

```public static Apcomplex root(Apcomplex z,
long n,
long k)
throws ArithmeticException,
ApfloatRuntimeException```
Positive integer root. The specified branch counting from the smallest angle and same sign of imaginary part as `z` is chosen.
Parameters:
`z` - The argument.
`n` - Which root to take.
`k` - Which branch to take.
Returns:
`n`:th root of `z`, that is `z1/nei2πsk/n` where `s` is the signum of the imaginary part of `z`.
Throws:
`ArithmeticException` - If `n` is zero.
`ApfloatRuntimeException`
Since:
1.5
• #### inverseRoot

```public static Apcomplex inverseRoot(Apcomplex z,
long n)
throws ArithmeticException,
ApfloatRuntimeException```
Inverse positive integer root. The branch that has the smallest angle and different sign of imaginary part than `z` is always chosen.
Parameters:
`z` - The argument.
`n` - Which inverse root to take.
Returns:
Inverse `n`:th root of `z`, that is `z-1/n`.
Throws:
`ArithmeticException` - If `z` or `n` is zero.
`ApfloatRuntimeException`
• #### inverseRoot

```public static Apcomplex inverseRoot(Apcomplex z,
long n,
long k)
throws ArithmeticException,
ApfloatRuntimeException```
Inverse positive integer root. The specified branch counting from the smallest angle and different sign of imaginary part than `z` is chosen.
Parameters:
`z` - The argument.
`n` - Which inverse root to take.
`k` - Which branch to take.
Returns:
Inverse `n`:th root of `z`, that is `z-1/ne-i2πk/n`.
Throws:
`ArithmeticException` - If `z` or `n` is zero.
`ApfloatRuntimeException`
• #### allRoots

```public static Apcomplex[] allRoots(Apcomplex z,
int n)
throws ArithmeticException,
ApfloatRuntimeException```
All values of the positive integer root.

Returns all of the `n` values of the root, in the order of the angle, starting from the smallest angle and same sign of imaginary part as `z`.

Parameters:
`z` - The argument.
`n` - Which root to take.
Returns:
All values of the `n`:th root of `z`, that is `z1/n`, in the order of the angle.
Throws:
`ArithmeticException` - If `n` is zero.
`ApfloatRuntimeException`
Since:
1.5
• #### agm

```public static Apcomplex agm(Apcomplex a,
Apcomplex b)
throws ApfloatRuntimeException```
Arithmetic-geometric mean.
Parameters:
`a` - First argument.
`b` - Second argument.
Returns:
Arithmetic-geometric mean of `a` and `b`.
Throws:
`ApfloatRuntimeException`
• #### log

```public static Apcomplex log(Apcomplex z)
throws ArithmeticException,
ApfloatRuntimeException```
Natural logarithm.

The logarithm is calculated using the arithmetic-geometric mean. See the Borweins' book for the formula.

Parameters:
`z` - The argument.
Returns:
Natural logarithm of `z`.
Throws:
`ArithmeticException` - If `z` is zero.
`ApfloatRuntimeException`
• #### log

```public static Apcomplex log(Apcomplex z,
Apcomplex w)
throws ArithmeticException,
ApfloatRuntimeException```
Logarithm in arbitrary base.

Parameters:
`z` - The argument.
`w` - The base.
Returns:
Base-`w` logarithm of `z`.
Throws:
`ArithmeticException` - If `z` or `w` is zero.
`ApfloatRuntimeException`
Since:
1.6
• #### exp

```public static Apcomplex exp(Apcomplex z)
throws ApfloatRuntimeException```
Exponent function. Calculated using Newton's iteration for the inverse of logarithm.
Parameters:
`z` - The argument.
Returns:
`ez`.
Throws:
`ApfloatRuntimeException`
• #### pow

```public static Apcomplex pow(Apcomplex z,
Apcomplex w)
throws ApfloatRuntimeException```
Arbitrary power. Calculated using `log()` and `exp()`.

Parameters:
`z` - The base.
`w` - The exponent.
Returns:
`zw`.
Throws:
`ArithmeticException` - If both `z` and `w` are zero.
`ApfloatRuntimeException`
• #### acos

```public static Apcomplex acos(Apcomplex z)
throws ApfloatRuntimeException```
Inverse cosine. Calculated using `log()`.
Parameters:
`z` - The argument.
Returns:
Inverse cosine of `z`.
Throws:
`ApfloatRuntimeException`
• #### acosh

```public static Apcomplex acosh(Apcomplex z)
throws ApfloatRuntimeException```
Inverse hyperbolic cosine. Calculated using `log()`.
Parameters:
`z` - The argument.
Returns:
Inverse hyperbolic cosine of `z`.
Throws:
`ApfloatRuntimeException`
• #### asin

```public static Apcomplex asin(Apcomplex z)
throws ApfloatRuntimeException```
Inverse sine. Calculated using `log()`.
Parameters:
`z` - The argument.
Returns:
Inverse sine of `z`.
Throws:
`ApfloatRuntimeException`
• #### asinh

```public static Apcomplex asinh(Apcomplex z)
throws ApfloatRuntimeException```
Inverse hyperbolic sine. Calculated using `log()`.
Parameters:
`z` - The argument.
Returns:
Inverse hyperbolic sine of `z`.
Throws:
`ApfloatRuntimeException`
• #### atan

```public static Apcomplex atan(Apcomplex z)
throws ArithmeticException,
ApfloatRuntimeException```
Inverse tangent. Calculated using `log()`.
Parameters:
`z` - The argument.
Returns:
Inverse tangent of `z`.
Throws:
`ArithmeticException` - If `z == i`.
`ApfloatRuntimeException`
• #### atanh

```public static Apcomplex atanh(Apcomplex z)
throws ArithmeticException,
ApfloatRuntimeException```
Inverse hyperbolic tangent. Calculated using `log()`.
Parameters:
`z` - The argument.
Returns:
Inverse hyperbolic tangent of `z`.
Throws:
`ArithmeticException` - If `z` is 1 or -1.
`ApfloatRuntimeException`
• #### cos

```public static Apcomplex cos(Apcomplex z)
throws ApfloatRuntimeException```
Cosine. Calculated using `exp()`.
Parameters:
`z` - The argument.
Returns:
Cosine of `z`.
Throws:
`ApfloatRuntimeException`
• #### cosh

```public static Apcomplex cosh(Apcomplex z)
throws ApfloatRuntimeException```
Hyperbolic cosine. Calculated using `exp()`.
Parameters:
`z` - The argument.
Returns:
Hyperbolic cosine of `z`.
Throws:
`ApfloatRuntimeException`
• #### sin

```public static Apcomplex sin(Apcomplex z)
throws ApfloatRuntimeException```
Sine. Calculated using `exp()`.
Parameters:
`z` - The argument.
Returns:
Sine of `z`.
Throws:
`ApfloatRuntimeException`
• #### sinh

```public static Apcomplex sinh(Apcomplex z)
throws ApfloatRuntimeException```
Hyperbolic sine. Calculated using `exp()`.
Parameters:
`z` - The argument.
Returns:
Hyperbolic sine of `z`.
Throws:
`ApfloatRuntimeException`
• #### tan

```public static Apcomplex tan(Apcomplex z)
throws ArithmeticException,
ApfloatRuntimeException```
Tangent. Calculated using `exp()`.
Parameters:
`z` - The argument.
Returns:
Tangent of `z`.
Throws:
`ArithmeticException` - If `z` is π/2 + n π where n is an integer.
`ApfloatRuntimeException`
• #### tanh

```public static Apcomplex tanh(Apcomplex z)
throws ArithmeticException,
ApfloatRuntimeException```
Hyperbolic tangent. Calculated using `exp()`.
Parameters:
`z` - The argument.
Returns:
Hyperbolic tangent of `z`.
Throws:
`ArithmeticException` - If `z` is i (π/2 + n π) where n is an integer.
`ApfloatRuntimeException`
• #### w

```public static Apcomplex w(Apcomplex z)
throws ApfloatRuntimeException```
Lambert W function. The W function gives the solution to the equation `W eW = z`. Also known as the product logarithm.

This function gives the solution to the principal branch, W0.

Parameters:
`z` - The argument.
Returns:
`W0(z)`.
Throws:
`ApfloatRuntimeException`
Since:
1.8.0
• #### w

```public static Apcomplex w(Apcomplex z,
long k)
throws ArithmeticException,
ApfloatRuntimeException```
Lambert W function for the specified branch.

Parameters:
`z` - The argument.
`k` - The branch.
Returns:
`Wk(z)`.
Throws:
`ArithmeticException` - If `z` is zero and `k` is not zero.
`ApfloatRuntimeException`
Since:
1.8.0
`w(Apcomplex)`
• #### product

```public static Apcomplex product(Apcomplex... z)
throws ApfloatRuntimeException```
Product of numbers. The precision used in the multiplications is only what is needed for the end result. This method may perform significantly better than simply multiplying the numbers sequentially.

If there are no arguments, the return value is `1`.

Parameters:
`z` - The argument(s).
Returns:
The product of the given numbers.
Throws:
`ApfloatRuntimeException`
Since:
1.3
• #### sum

```public static Apcomplex sum(Apcomplex... z)
throws ApfloatRuntimeException```
Sum of numbers. The precision used in the additions is only what is needed for the end result. This method may perform significantly better than simply adding the numbers sequentially.

If there are no arguments, the return value is `0`.

Parameters:
`z` - The argument(s).
Returns:
The sum of the given numbers.
Throws:
`ApfloatRuntimeException`
Since:
1.3