org.apfloat

## Class FixedPrecisionApcomplexHelper

• Direct Known Subclasses:
FixedPrecisionApfloatHelper

```public class FixedPrecisionApcomplexHelper
extends Object```
Fixed-precision mathematical functions for complex numbers.

All results of the mathematical operations are set to have the specified precision. Also all input arguments are set to the specified precision before the operation. If the specified precision is not infinite, this helper class also avoids `InfiniteExpansionException` e.g. in case where it would happen with `ApcomplexMath.acos(Apcomplex.ZERO)`.

Since:
1.5
Version:
1.8.0
Author:
Mikko Tommila
• ### Constructor Summary

Constructors
Constructor and Description
`FixedPrecisionApcomplexHelper(long precision)`
Constructs an apcomplex fixed-precison helper with the specified precision.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`Apfloat` `abs(Apcomplex z)`
Absolute value.
`Apcomplex` `acos(Apcomplex z)`
Arc cosine.
`Apcomplex` `acosh(Apcomplex z)`
Hyperbolic arc cosine.
`Apcomplex` ```add(Apcomplex z, Apcomplex w)```
`Apcomplex` ```agm(Apcomplex a, Apcomplex b)```
Arithmetic-geometric mean.
`Apcomplex[]` ```allRoots(Apcomplex z, int n)```
All branches of a root.
`Apfloat` `arg(Apcomplex z)`
Complex angle.
`Apcomplex` `asin(Apcomplex z)`
Arc sine.
`Apcomplex` `asinh(Apcomplex z)`
Hyperbolic arc sine.
`Apcomplex` `atan(Apcomplex z)`
Arc tangent.
`Apcomplex` `atanh(Apcomplex z)`
Hyperbolic arc tangent.
`Apcomplex` `cbrt(Apcomplex z)`
Cube root.
`Apcomplex` `conj(Apcomplex z)`
Complex conjugate.
`Apcomplex` `cos(Apcomplex z)`
Cosine.
`Apcomplex` `cosh(Apcomplex z)`
Hyperbolic cosine.
`Apcomplex` ```divide(Apcomplex z, Apcomplex w)```
Division.
`Apcomplex` `exp(Apcomplex z)`
Exponential function.
`Apfloat` `imag(Apcomplex z)`
Imaginary part.
`Apcomplex` ```inverseRoot(Apcomplex z, long n)```
Inverse root.
`Apcomplex` ```inverseRoot(Apcomplex z, long n, long k)```
Inverse root with branch.
`Apcomplex` `log(Apcomplex z)`
Natural logarithm.
`Apcomplex` ```log(Apcomplex z, Apcomplex w)```
Logarithm in specified base.
`Apcomplex` ```multiply(Apcomplex z, Apcomplex w)```
Multiplication.
`Apcomplex` `negate(Apcomplex z)`
Negation.
`Apfloat` `norm(Apcomplex z)`
Norm.
`Apcomplex` ```pow(Apcomplex z, Apcomplex w)```
Power.
`Apcomplex` ```pow(Apcomplex z, long n)```
Integer power.
`long` `precision()`
Returns the precision, which is used for the results.
`Apcomplex` `product(Apcomplex... z)`
Product.
`Apfloat` `real(Apcomplex z)`
Real part.
`Apcomplex` ```root(Apcomplex z, long n)```
Root.
`Apcomplex` ```root(Apcomplex z, long n, long k)```
Root with branch.
`Apcomplex` ```scale(Apcomplex z, long scale)```
`Apcomplex` `sin(Apcomplex z)`
Sine.
`Apcomplex` `sinh(Apcomplex z)`
Hyperbolic sine.
`Apcomplex` `sqrt(Apcomplex z)`
Square root.
`Apcomplex` ```subtract(Apcomplex z, Apcomplex w)```
Subtraction.
`Apcomplex` `sum(Apcomplex... z)`
Sum.
`Apcomplex` `tan(Apcomplex z)`
Tangent.
`Apcomplex` `tanh(Apcomplex z)`
Hyperbolic tangent.
`Apcomplex` `valueOf(Apcomplex z)`
Returns the value with the specified precision.
`Apcomplex` `w(Apcomplex z)`
Lambert W function.
`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`
• ### Constructor Detail

• #### FixedPrecisionApcomplexHelper

```public FixedPrecisionApcomplexHelper(long precision)
throws IllegalArgumentException```
Constructs an apcomplex fixed-precison helper with the specified precision. The results of all mathematical operations are set to the specified precision.
Parameters:
`precision` - The precision of the results.
Throws:
`IllegalArgumentException` - In case the precision is invalid.
• ### Method Detail

• #### valueOf

```public Apcomplex valueOf(Apcomplex z)
throws ApfloatRuntimeException```
Returns the value with the specified precision.
Parameters:
`z` - The value.
Returns:
The value with to the specified precision.
Throws:
`ApfloatRuntimeException`
• #### negate

```public Apcomplex negate(Apcomplex z)
throws ApfloatRuntimeException```
Negation.
Parameters:
`z` - The value to negate.
Returns:
`-z`.
Throws:
`ApfloatRuntimeException`
• #### conj

```public Apcomplex conj(Apcomplex z)
throws ApfloatRuntimeException```
Complex conjugate.
Parameters:
`z` - The operand.
Returns:
`x - i y` where `z` is `x + i y`.
Throws:
`ApfloatRuntimeException`

```public Apcomplex add(Apcomplex z,
Apcomplex w)
throws ApfloatRuntimeException```
Parameters:
`z` - The first operand.
`w` - The second operand.
Returns:
`z + w`.
Throws:
`ApfloatRuntimeException`
• #### subtract

```public Apcomplex subtract(Apcomplex z,
Apcomplex w)
throws ApfloatRuntimeException```
Subtraction.
Parameters:
`z` - The first operand.
`w` - The second operand.
Returns:
`z - w`.
Throws:
`ApfloatRuntimeException`
• #### multiply

```public Apcomplex multiply(Apcomplex z,
Apcomplex w)
throws ApfloatRuntimeException```
Multiplication.
Parameters:
`z` - The first operand.
`w` - The second operand.
Returns:
`z * w`.
Throws:
`ApfloatRuntimeException`
• #### divide

```public Apcomplex divide(Apcomplex z,
Apcomplex w)
throws ArithmeticException,
ApfloatRuntimeException```
Division.
Parameters:
`z` - The first operand.
`w` - The second operand.
Returns:
`z / w`.
Throws:
`ArithmeticException` - If `w` is zero.
`ApfloatRuntimeException`
• #### pow

```public Apcomplex pow(Apcomplex z,
Apcomplex w)
throws ArithmeticException,
ApfloatRuntimeException```
Power.
Parameters:
`z` - The first operand.
`w` - The second operand.
Returns:
`zw`.
Throws:
`ArithmeticException` - If `z` and `w` are zero.
`ApfloatRuntimeException`
• #### pow

```public Apcomplex pow(Apcomplex z,
long n)
throws ArithmeticException,
ApfloatRuntimeException```
Integer power.
Parameters:
`z` - The first operand.
`n` - The first operand.
Returns:
`zn`.
Throws:
`ArithmeticException` - If `z` and `n` are zero, or `z` is zero and `n` is negative.
`ApfloatRuntimeException`
• #### arg

```public Apfloat arg(Apcomplex z)
throws ArithmeticException,
ApfloatRuntimeException```
Complex angle.
Parameters:
`z` - The operand.
Returns:
The angle of `z` on the complex plane.
Throws:
`ArithmeticException` - If `z` is zero.
`ApfloatRuntimeException`
• #### imag

`public Apfloat imag(Apcomplex z)`
Imaginary part.
Parameters:
`z` - The operand.
Returns:
The imaginary part of `z`.
• #### real

`public Apfloat real(Apcomplex z)`
Real part.
Parameters:
`z` - The operand.
Returns:
The real part of `z`.
• #### abs

```public Apfloat abs(Apcomplex z)
throws ApfloatRuntimeException```
Absolute value.
Parameters:
`z` - The operand.
Returns:
The absolute value of `z`.
Throws:
`ApfloatRuntimeException`
• #### norm

```public Apfloat norm(Apcomplex z)
throws ApfloatRuntimeException```
Norm.
Parameters:
`z` - The operand.
Returns:
`x2 + y2` where `z` is `x + i y`.
Throws:
`ApfloatRuntimeException`
• #### acos

```public Apcomplex acos(Apcomplex z)
throws ApfloatRuntimeException```
Arc cosine.
Parameters:
`z` - The operand.
Returns:
The arc cosine of `z`.
Throws:
`ApfloatRuntimeException`
• #### acosh

```public Apcomplex acosh(Apcomplex z)
throws ApfloatRuntimeException```
Hyperbolic arc cosine.
Parameters:
`z` - The operand.
Returns:
The hyperbolic arc cosine of `z`.
Throws:
`ApfloatRuntimeException`
• #### asin

```public Apcomplex asin(Apcomplex z)
throws ApfloatRuntimeException```
Arc sine.
Parameters:
`z` - The operand.
Returns:
The arc sine of `z`.
Throws:
`ApfloatRuntimeException`
• #### asinh

```public Apcomplex asinh(Apcomplex z)
throws ApfloatRuntimeException```
Hyperbolic arc sine.
Parameters:
`z` - The operand.
Returns:
The hyperbolic arc sine of `z`.
Throws:
`ApfloatRuntimeException`
• #### atan

```public Apcomplex atan(Apcomplex z)
throws ApfloatRuntimeException```
Arc tangent.
Parameters:
`z` - The operand.
Returns:
The arc tangent of `z`.
Throws:
`ArithmeticException` - If `z` is `i`.
`ApfloatRuntimeException`
• #### atanh

```public Apcomplex atanh(Apcomplex z)
throws ArithmeticException,
ApfloatRuntimeException```
Hyperbolic arc tangent.
Parameters:
`z` - The operand.
Returns:
The hyperbolic arc tangent of `z`.
Throws:
`ArithmeticException` - If `z` is 1 or -1.
`ApfloatRuntimeException`
• #### cbrt

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

```public Apcomplex cos(Apcomplex z)
throws ApfloatRuntimeException```
Cosine.
Parameters:
`z` - The operand.
Returns:
The cosine of `z`.
Throws:
`ApfloatRuntimeException`
• #### cosh

```public Apcomplex cosh(Apcomplex z)
throws ApfloatRuntimeException```
Hyperbolic cosine.
Parameters:
`z` - The operand.
Returns:
The hyperbolic cosine of `z`.
Throws:
`ApfloatRuntimeException`
• #### exp

```public Apcomplex exp(Apcomplex z)
throws ApfloatRuntimeException```
Exponential function.
Parameters:
`z` - The operand.
Returns:
`ez`.
Throws:
`ApfloatRuntimeException`
• #### log

```public Apcomplex log(Apcomplex z)
throws ArithmeticException,
ApfloatRuntimeException```
Natural logarithm.
Parameters:
`z` - The operand.
Returns:
The natural logarithm of `z`.
Throws:
`ArithmeticException` - If `z` is zero.
`ApfloatRuntimeException`
• #### log

```public Apcomplex log(Apcomplex z,
Apcomplex w)
throws ArithmeticException,
ApfloatRuntimeException```
Logarithm in specified base.
Parameters:
`z` - The operand.
`w` - The base.
Returns:
The base-`w` logarithm of `z`.
Throws:
`ArithmeticException` - If `z` or `w` is zero.
`ApfloatRuntimeException`
Since:
1.6
• #### sin

```public Apcomplex sin(Apcomplex z)
throws ApfloatRuntimeException```
Sine.
Parameters:
`z` - The operand.
Returns:
The sine of `z`.
Throws:
`ApfloatRuntimeException`
• #### sinh

```public Apcomplex sinh(Apcomplex z)
throws ApfloatRuntimeException```
Hyperbolic sine.
Parameters:
`z` - The operand.
Returns:
The hyperbolic sine of `z`.
Throws:
`ApfloatRuntimeException`
• #### sqrt

```public Apcomplex sqrt(Apcomplex z)
throws ApfloatRuntimeException```
Square root.
Parameters:
`z` - The operand.
Returns:
The square root of `z`.
Throws:
`ApfloatRuntimeException`
• #### tan

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

```public Apcomplex tanh(Apcomplex z)
throws ArithmeticException,
ApfloatRuntimeException```
Hyperbolic tangent.
Parameters:
`z` - The operand.
Returns:
The hyperbolic tangent of `z`.
Throws:
`ArithmeticException` - If `z` is i (π/2 + n π) where n is an integer.
`ApfloatRuntimeException`
• #### agm

```public Apcomplex agm(Apcomplex a,
Apcomplex b)
throws ApfloatRuntimeException```
Arithmetic-geometric mean.
Parameters:
`a` - The first operand.
`b` - The first operand.
Returns:
The arithmetic-geometric mean of `a` and `b`.
Throws:
`ApfloatRuntimeException`
• #### inverseRoot

```public Apcomplex inverseRoot(Apcomplex z,
long n)
throws ArithmeticException,
ApfloatRuntimeException```
Inverse root.
Parameters:
`z` - The operand.
`n` - Which inverse root to take.
Returns:
`z-1/n`.
Throws:
`ArithmeticException` - If `z` or `n` is zero.
`ApfloatRuntimeException`
• #### inverseRoot

```public Apcomplex inverseRoot(Apcomplex z,
long n,
long k)
throws ArithmeticException,
ApfloatRuntimeException```
Inverse root with branch.
Parameters:
`z` - The operand.
`n` - Which inverse root to take.
`k` - Which branch to take.
Returns:
`z-1/ne-i2πk/n`.
Throws:
`ArithmeticException` - If `z` or `n` is zero.
`ApfloatRuntimeException`
• #### root

```public Apcomplex root(Apcomplex z,
long n)
throws ArithmeticException,
ApfloatRuntimeException```
Root.
Parameters:
`z` - The operand.
`n` - Which root to take.
Returns:
`z1/n`.
Throws:
`ArithmeticException` - If `n` is zero, or `z` is zero and `n` is negative.
`ApfloatRuntimeException`
• #### root

```public Apcomplex root(Apcomplex z,
long n,
long k)
throws ArithmeticException,
ApfloatRuntimeException```
Root with branch.
Parameters:
`z` - The operand.
`n` - Which root to take.
`k` - Which branch to take.
Returns:
`z1/nei2πsk/n` where `s` is the signum of the imaginary part of `z`.
Throws:
`ArithmeticException` - If `n` is zero, or `z` is zero and `n` is negative.
`ApfloatRuntimeException`
• #### allRoots

```public Apcomplex[] allRoots(Apcomplex z,
int n)
throws ArithmeticException,
ApfloatRuntimeException```
All branches of a root.
Parameters:
`z` - The operand.
`n` - Which root to take.
Returns:
`z1/n`.
Throws:
`ArithmeticException` - If `n` is zero, or `z` is zero and `n` is negative.
`ApfloatRuntimeException`
• #### scale

```public Apcomplex scale(Apcomplex z,
long scale)
throws ApfloatRuntimeException```
Parameters:
`z` - The operand.
`scale` - The amount to move the radix point.
Returns:
`z * z.radix()scale`.
Throws:
`ApfloatRuntimeException`
• #### w

```public Apcomplex w(Apcomplex z)
throws ApfloatRuntimeException```
Lambert W function.
Parameters:
`z` - The operand.
Returns:
`W0(z)`.
Throws:
`ApfloatRuntimeException`
Since:
1.8.0
• #### w

```public Apcomplex w(Apcomplex z,
long k)
throws ApfloatRuntimeException```
Lambert W function for the specified branch.
Parameters:
`z` - The operand.
`k` - The branch.
Returns:
`Wk(z)`.
Throws:
`ApfloatRuntimeException`
Since:
1.8.0
• #### product

```public Apcomplex product(Apcomplex... z)
throws ApfloatRuntimeException```
Product.
Parameters:
`z` - The operand(s).
Returns:
The product of the operands.
Throws:
`ApfloatRuntimeException`
• #### sum

```public Apcomplex sum(Apcomplex... z)
throws ApfloatRuntimeException```
Sum.
Parameters:
`z` - The operand(s).
Returns:
The sum of the operands.
Throws:
`ApfloatRuntimeException`
• #### precision

`public long precision()`
Returns the precision, which is used for the results.
Returns:
The precision of the results.