Class BigComplexMath
- java.lang.Object
-
- ch.obermuhlner.math.big.BigComplexMath
-
public class BigComplexMath extends java.lang.Object
Provides advanced functions operating onBigComplex
s.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.math.BigDecimal
TWO
-
Constructor Summary
Constructors Constructor Description BigComplexMath()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.math.BigDecimal
abs(BigComplex x, java.math.MathContext mathContext)
Calculates the absolute value (also known as magnitude, length or radius) of the given complex number using the specifiedMathContext
.static java.math.BigDecimal
absSquare(BigComplex x, java.math.MathContext mathContext)
Calculates the square of the absolute value (also known as magnitude, length or radius) of the given complex number using the specifiedMathContext
.static BigComplex
acos(BigComplex x, java.math.MathContext mathContext)
Calculates the arc cosine (inverted cosine) ofBigComplex
x in the complex domain.static BigComplex
acot(BigComplex x, java.math.MathContext mathContext)
Calculates the arc cotangens (inverted cotangens) ofBigComplex
x in the complex domain.static java.math.BigDecimal
angle(BigComplex x, java.math.MathContext mathContext)
Calculates the angle in radians of the given complex number using the specifiedMathContext
.static BigComplex
asin(BigComplex x, java.math.MathContext mathContext)
Calculates the arc sine (inverted sine) ofBigComplex
x in the complex domain.static BigComplex
atan(BigComplex x, java.math.MathContext mathContext)
Calculates the arc tangens (inverted tangens) ofBigComplex
x in the complex domain.static BigComplex
conjugate(BigComplex x)
Calculates the conjugate of the given complex number using the specifiedMathContext
.static BigComplex
cos(BigComplex x, java.math.MathContext mathContext)
Calculates the cosine (cosinus) ofBigComplex
x in the complex domain.static BigComplex
exp(BigComplex x, java.math.MathContext mathContext)
Calculates the natural exponent ofBigComplex
x (ex) in the complex domain.static BigComplex
factorial(BigComplex x, java.math.MathContext mathContext)
Calculates the factorial of the specifiedBigComplex
.static BigComplex
gamma(BigComplex x, java.math.MathContext mathContext)
Calculates the gamma function of the specifiedBigComplex
.static BigComplex
log(BigComplex x, java.math.MathContext mathContext)
Calculates the natural logarithm ofBigComplex
x in the complex domain.static BigComplex
pow(BigComplex x, long y, java.math.MathContext mathContext)
CalculatesBigComplex
x to the power oflong
y (xy).static BigComplex
pow(BigComplex x, BigComplex y, java.math.MathContext mathContext)
CalculatesBigComplex
x to the power ofBigComplex
y (xy).static BigComplex
pow(BigComplex x, java.math.BigDecimal y, java.math.MathContext mathContext)
CalculatesBigComplex
x to the power ofBigDecimal
y (xy).static BigComplex
reciprocal(BigComplex x, java.math.MathContext mathContext)
Calculates the reciprocal of the given complex number using the specifiedMathContext
.static BigComplex
root(BigComplex x, BigComplex n, java.math.MathContext mathContext)
Calculates theBigComplex
n'th root ofBigComplex
x (n√x).static BigComplex
root(BigComplex x, java.math.BigDecimal n, java.math.MathContext mathContext)
Calculates theBigDecimal
n'th root ofBigComplex
x (n√x).static BigComplex
sin(BigComplex x, java.math.MathContext mathContext)
Calculates the sine (sinus) ofBigComplex
x in the complex domain.static BigComplex
sqrt(BigComplex x, java.math.MathContext mathContext)
Calculates the square root ofBigComplex
x in the complex domain (√x).static BigComplex
tan(BigComplex x, java.math.MathContext mathContext)
Calculates the tangens ofBigComplex
x in the complex domain.
-
-
-
Method Detail
-
reciprocal
public static BigComplex reciprocal(BigComplex x, java.math.MathContext mathContext)
Calculates the reciprocal of the given complex number using the specifiedMathContext
.- Parameters:
x
- the complex number to calculate the reciprocalmathContext
- theMathContext
used to calculate the result- Returns:
- the calculated
BigComplex
result - See Also:
BigComplex.reciprocal(MathContext)
-
conjugate
public static BigComplex conjugate(BigComplex x)
Calculates the conjugate of the given complex number using the specifiedMathContext
.- Parameters:
x
- the complex number to calculate the conjugate- Returns:
- the calculated
BigComplex
result - See Also:
BigComplex.conjugate()
-
abs
public static java.math.BigDecimal abs(BigComplex x, java.math.MathContext mathContext)
Calculates the absolute value (also known as magnitude, length or radius) of the given complex number using the specifiedMathContext
.- Parameters:
x
- the complex number to calculate the absolute valuemathContext
- theMathContext
used to calculate the result- Returns:
- the calculated
BigComplex
result - See Also:
BigComplex.abs(MathContext)
-
absSquare
public static java.math.BigDecimal absSquare(BigComplex x, java.math.MathContext mathContext)
Calculates the square of the absolute value (also known as magnitude, length or radius) of the given complex number using the specifiedMathContext
.- Parameters:
x
- the complex number to calculate the square of the absolute valuemathContext
- theMathContext
used to calculate the result- Returns:
- the calculated
BigComplex
result - See Also:
BigComplex.absSquare(MathContext)
-
angle
public static java.math.BigDecimal angle(BigComplex x, java.math.MathContext mathContext)
Calculates the angle in radians of the given complex number using the specifiedMathContext
.- Parameters:
x
- the complex number to calculate the anglemathContext
- theMathContext
used to calculate the result- Returns:
- the calculated
BigComplex
angle in radians - See Also:
BigComplex.angle(MathContext)
-
factorial
public static BigComplex factorial(BigComplex x, java.math.MathContext mathContext)
Calculates the factorial of the specifiedBigComplex
.This implementation uses Spouge's approximation to calculate the factorial for non-integer values.
This involves calculating a series of constants that depend on the desired precision. Since this constant calculation is quite expensive (especially for higher precisions), the constants for a specific precision will be cached and subsequent calls to this method with the same precision will be much faster.
It is therefore recommended to do one call to this method with the standard precision of your application during the startup phase and to avoid calling it with many different precisions.
See: Wikipedia: Factorial - Extension of factorial to non-integer values of argument
- Parameters:
x
- theBigComplex
mathContext
- theMathContext
used for the result- Returns:
- the factorial
BigComplex
- Throws:
java.lang.ArithmeticException
- if x is a negative integer value (-1, -2, -3, ...)- See Also:
BigDecimalMath.factorial(BigDecimal, MathContext)
,gamma(BigComplex, MathContext)
-
gamma
public static BigComplex gamma(BigComplex x, java.math.MathContext mathContext)
Calculates the gamma function of the specifiedBigComplex
.This implementation uses
factorial(BigComplex, MathContext)
internally, therefore the performance implications described there apply also for this method.- Parameters:
x
- theBigComplex
mathContext
- theMathContext
used for the result- Returns:
- the gamma
BigComplex
- Throws:
java.lang.ArithmeticException
- if x-1 is a negative integer value (-1, -2, -3, ...)- See Also:
BigDecimalMath.gamma(BigDecimal, MathContext)
,factorial(BigComplex, MathContext)
-
exp
public static BigComplex exp(BigComplex x, java.math.MathContext mathContext)
Calculates the natural exponent ofBigComplex
x (ex) in the complex domain.- Parameters:
x
- theBigComplex
to calculate the exponent formathContext
- theMathContext
used for the result- Returns:
- the calculated exponent
BigComplex
with the precision specified in themathContext
-
sin
public static BigComplex sin(BigComplex x, java.math.MathContext mathContext)
Calculates the sine (sinus) ofBigComplex
x in the complex domain.- Parameters:
x
- theBigComplex
to calculate the sine formathContext
- theMathContext
used for the result- Returns:
- the calculated sine
BigComplex
with the precision specified in themathContext
-
cos
public static BigComplex cos(BigComplex x, java.math.MathContext mathContext)
Calculates the cosine (cosinus) ofBigComplex
x in the complex domain.- Parameters:
x
- theBigComplex
to calculate the cosine formathContext
- theMathContext
used for the result- Returns:
- the calculated cosine
BigComplex
with the precision specified in themathContext
-
tan
public static BigComplex tan(BigComplex x, java.math.MathContext mathContext)
Calculates the tangens ofBigComplex
x in the complex domain.- Parameters:
x
- theBigComplex
to calculate the tangens formathContext
- theMathContext
used for the result- Returns:
- the calculated tangens
BigComplex
with the precision specified in themathContext
-
atan
public static BigComplex atan(BigComplex x, java.math.MathContext mathContext)
Calculates the arc tangens (inverted tangens) ofBigComplex
x in the complex domain.See: Wikipedia: Inverse trigonometric functions (Extension to complex plane)
- Parameters:
x
- theBigComplex
to calculate the arc tangens formathContext
- theMathContext
used for the result- Returns:
- the calculated arc tangens
BigComplex
with the precision specified in themathContext
-
acot
public static BigComplex acot(BigComplex x, java.math.MathContext mathContext)
Calculates the arc cotangens (inverted cotangens) ofBigComplex
x in the complex domain.See: Wikipedia: Inverse trigonometric functions (Extension to complex plane)
- Parameters:
x
- theBigComplex
to calculate the arc cotangens formathContext
- theMathContext
used for the result- Returns:
- the calculated arc cotangens
BigComplex
with the precision specified in themathContext
-
asin
public static BigComplex asin(BigComplex x, java.math.MathContext mathContext)
Calculates the arc sine (inverted sine) ofBigComplex
x in the complex domain.See: Wikipedia: Inverse trigonometric functions (Extension to complex plane)
- Parameters:
x
- theBigComplex
to calculate the arc sine formathContext
- theMathContext
used for the result- Returns:
- the calculated arc sine
BigComplex
with the precision specified in themathContext
-
acos
public static BigComplex acos(BigComplex x, java.math.MathContext mathContext)
Calculates the arc cosine (inverted cosine) ofBigComplex
x in the complex domain.See: Wikipedia: Inverse trigonometric functions (Extension to complex plane)
- Parameters:
x
- theBigComplex
to calculate the arc cosine formathContext
- theMathContext
used for the result- Returns:
- the calculated arc cosine
BigComplex
with the precision specified in themathContext
-
sqrt
public static BigComplex sqrt(BigComplex x, java.math.MathContext mathContext)
Calculates the square root ofBigComplex
x in the complex domain (√x).See Wikipedia: Square root (Square root of an imaginary number)
- Parameters:
x
- theBigComplex
to calculate the square root formathContext
- theMathContext
used for the result- Returns:
- the calculated square root
BigComplex
with the precision specified in themathContext
-
log
public static BigComplex log(BigComplex x, java.math.MathContext mathContext)
Calculates the natural logarithm ofBigComplex
x in the complex domain.- Parameters:
x
- theBigComplex
to calculate the natural logarithm formathContext
- theMathContext
used for the result- Returns:
- the calculated natural logarithm
BigComplex
with the precision specified in themathContext
-
pow
public static BigComplex pow(BigComplex x, long y, java.math.MathContext mathContext)
CalculatesBigComplex
x to the power oflong
y (xy).The implementation tries to minimize the number of multiplications of
x
(using squares whenever possible).- Parameters:
x
- theBigComplex
value to take to the powery
- thelong
value to serve as exponentmathContext
- theMathContext
used for the result- Returns:
- the calculated x to the power of y with the precision specified in the
mathContext
-
pow
public static BigComplex pow(BigComplex x, java.math.BigDecimal y, java.math.MathContext mathContext)
CalculatesBigComplex
x to the power ofBigDecimal
y (xy).- Parameters:
x
- theBigComplex
value to take to the powery
- theBigDecimal
value to serve as exponentmathContext
- theMathContext
used for the result- Returns:
- the calculated x to the power of y with the precision specified in the
mathContext
-
pow
public static BigComplex pow(BigComplex x, BigComplex y, java.math.MathContext mathContext)
CalculatesBigComplex
x to the power ofBigComplex
y (xy).- Parameters:
x
- theBigComplex
value to take to the powery
- theBigComplex
value to serve as exponentmathContext
- theMathContext
used for the result- Returns:
- the calculated x to the power of y with the precision specified in the
mathContext
-
root
public static BigComplex root(BigComplex x, java.math.BigDecimal n, java.math.MathContext mathContext)
- Parameters:
x
- theBigComplex
value to calculate the n'th rootn
- theBigDecimal
defining the rootmathContext
- theMathContext
used for the result- Returns:
- the calculated n'th root of x with the precision specified in the
mathContext
-
root
public static BigComplex root(BigComplex x, BigComplex n, java.math.MathContext mathContext)
- Parameters:
x
- theBigComplex
value to calculate the n'th rootn
- theBigComplex
defining the rootmathContext
- theMathContext
used for the result- Returns:
- the calculated n'th root of x with the precision specified in the
mathContext
-
-