Class BigComplexMath
- java.lang.Object
-
- ch.obermuhlner.math.big.BigComplexMath
-
public class BigComplexMath extends java.lang.ObjectProvides advanced functions operating onBigComplexs.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.math.BigDecimalTWO
-
Constructor Summary
Constructors Constructor Description BigComplexMath()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.math.BigDecimalabs(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.BigDecimalabsSquare(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 BigComplexacos(BigComplex x, java.math.MathContext mathContext)Calculates the arc cosine (inverted cosine) ofBigComplexx in the complex domain.static BigComplexacot(BigComplex x, java.math.MathContext mathContext)Calculates the arc cotangens (inverted cotangens) ofBigComplexx in the complex domain.static java.math.BigDecimalangle(BigComplex x, java.math.MathContext mathContext)Calculates the angle in radians of the given complex number using the specifiedMathContext.static BigComplexasin(BigComplex x, java.math.MathContext mathContext)Calculates the arc sine (inverted sine) ofBigComplexx in the complex domain.static BigComplexatan(BigComplex x, java.math.MathContext mathContext)Calculates the arc tangens (inverted tangens) ofBigComplexx in the complex domain.static BigComplexconjugate(BigComplex x)Calculates the conjugate of the given complex number using the specifiedMathContext.static BigComplexcos(BigComplex x, java.math.MathContext mathContext)Calculates the cosine (cosinus) ofBigComplexx in the complex domain.static BigComplexexp(BigComplex x, java.math.MathContext mathContext)Calculates the natural exponent ofBigComplexx (ex) in the complex domain.static BigComplexfactorial(BigComplex x, java.math.MathContext mathContext)Calculates the factorial of the specifiedBigComplex.static BigComplexgamma(BigComplex x, java.math.MathContext mathContext)Calculates the gamma function of the specifiedBigComplex.static BigComplexlog(BigComplex x, java.math.MathContext mathContext)Calculates the natural logarithm ofBigComplexx in the complex domain.static BigComplexpow(BigComplex x, long y, java.math.MathContext mathContext)CalculatesBigComplexx to the power oflongy (xy).static BigComplexpow(BigComplex x, BigComplex y, java.math.MathContext mathContext)CalculatesBigComplexx to the power ofBigComplexy (xy).static BigComplexpow(BigComplex x, java.math.BigDecimal y, java.math.MathContext mathContext)CalculatesBigComplexx to the power ofBigDecimaly (xy).static BigComplexreciprocal(BigComplex x, java.math.MathContext mathContext)Calculates the reciprocal of the given complex number using the specifiedMathContext.static BigComplexroot(BigComplex x, BigComplex n, java.math.MathContext mathContext)Calculates theBigComplexn'th root ofBigComplexx (n√x).static BigComplexroot(BigComplex x, java.math.BigDecimal n, java.math.MathContext mathContext)Calculates theBigDecimaln'th root ofBigComplexx (n√x).static BigComplexsin(BigComplex x, java.math.MathContext mathContext)Calculates the sine (sinus) ofBigComplexx in the complex domain.static BigComplexsqrt(BigComplex x, java.math.MathContext mathContext)Calculates the square root ofBigComplexx in the complex domain (√x).static BigComplextan(BigComplex x, java.math.MathContext mathContext)Calculates the tangens ofBigComplexx 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- theMathContextused to calculate the result- Returns:
- the calculated
BigComplexresult - 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
BigComplexresult - 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- theMathContextused to calculate the result- Returns:
- the calculated
BigComplexresult - 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- theMathContextused to calculate the result- Returns:
- the calculated
BigComplexresult - 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- theMathContextused to calculate the result- Returns:
- the calculated
BigComplexangle 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- theBigComplexmathContext- theMathContextused 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- theBigComplexmathContext- theMathContextused 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 ofBigComplexx (ex) in the complex domain.- Parameters:
x- theBigComplexto calculate the exponent formathContext- theMathContextused for the result- Returns:
- the calculated exponent
BigComplexwith the precision specified in themathContext
-
sin
public static BigComplex sin(BigComplex x, java.math.MathContext mathContext)
Calculates the sine (sinus) ofBigComplexx in the complex domain.- Parameters:
x- theBigComplexto calculate the sine formathContext- theMathContextused for the result- Returns:
- the calculated sine
BigComplexwith the precision specified in themathContext
-
cos
public static BigComplex cos(BigComplex x, java.math.MathContext mathContext)
Calculates the cosine (cosinus) ofBigComplexx in the complex domain.- Parameters:
x- theBigComplexto calculate the cosine formathContext- theMathContextused for the result- Returns:
- the calculated cosine
BigComplexwith the precision specified in themathContext
-
tan
public static BigComplex tan(BigComplex x, java.math.MathContext mathContext)
Calculates the tangens ofBigComplexx in the complex domain.- Parameters:
x- theBigComplexto calculate the tangens formathContext- theMathContextused for the result- Returns:
- the calculated tangens
BigComplexwith the precision specified in themathContext
-
atan
public static BigComplex atan(BigComplex x, java.math.MathContext mathContext)
Calculates the arc tangens (inverted tangens) ofBigComplexx in the complex domain.See: Wikipedia: Inverse trigonometric functions (Extension to complex plane)
- Parameters:
x- theBigComplexto calculate the arc tangens formathContext- theMathContextused for the result- Returns:
- the calculated arc tangens
BigComplexwith the precision specified in themathContext
-
acot
public static BigComplex acot(BigComplex x, java.math.MathContext mathContext)
Calculates the arc cotangens (inverted cotangens) ofBigComplexx in the complex domain.See: Wikipedia: Inverse trigonometric functions (Extension to complex plane)
- Parameters:
x- theBigComplexto calculate the arc cotangens formathContext- theMathContextused for the result- Returns:
- the calculated arc cotangens
BigComplexwith the precision specified in themathContext
-
asin
public static BigComplex asin(BigComplex x, java.math.MathContext mathContext)
Calculates the arc sine (inverted sine) ofBigComplexx in the complex domain.See: Wikipedia: Inverse trigonometric functions (Extension to complex plane)
- Parameters:
x- theBigComplexto calculate the arc sine formathContext- theMathContextused for the result- Returns:
- the calculated arc sine
BigComplexwith the precision specified in themathContext
-
acos
public static BigComplex acos(BigComplex x, java.math.MathContext mathContext)
Calculates the arc cosine (inverted cosine) ofBigComplexx in the complex domain.See: Wikipedia: Inverse trigonometric functions (Extension to complex plane)
- Parameters:
x- theBigComplexto calculate the arc cosine formathContext- theMathContextused for the result- Returns:
- the calculated arc cosine
BigComplexwith the precision specified in themathContext
-
sqrt
public static BigComplex sqrt(BigComplex x, java.math.MathContext mathContext)
Calculates the square root ofBigComplexx in the complex domain (√x).See Wikipedia: Square root (Square root of an imaginary number)
- Parameters:
x- theBigComplexto calculate the square root formathContext- theMathContextused for the result- Returns:
- the calculated square root
BigComplexwith the precision specified in themathContext
-
log
public static BigComplex log(BigComplex x, java.math.MathContext mathContext)
Calculates the natural logarithm ofBigComplexx in the complex domain.- Parameters:
x- theBigComplexto calculate the natural logarithm formathContext- theMathContextused for the result- Returns:
- the calculated natural logarithm
BigComplexwith the precision specified in themathContext
-
pow
public static BigComplex pow(BigComplex x, long y, java.math.MathContext mathContext)
CalculatesBigComplexx to the power oflongy (xy).The implementation tries to minimize the number of multiplications of
x(using squares whenever possible).- Parameters:
x- theBigComplexvalue to take to the powery- thelongvalue to serve as exponentmathContext- theMathContextused 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)
CalculatesBigComplexx to the power ofBigDecimaly (xy).- Parameters:
x- theBigComplexvalue to take to the powery- theBigDecimalvalue to serve as exponentmathContext- theMathContextused 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)
CalculatesBigComplexx to the power ofBigComplexy (xy).- Parameters:
x- theBigComplexvalue to take to the powery- theBigComplexvalue to serve as exponentmathContext- theMathContextused 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- theBigComplexvalue to calculate the n'th rootn- theBigDecimaldefining the rootmathContext- theMathContextused 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- theBigComplexvalue to calculate the n'th rootn- theBigComplexdefining the rootmathContext- theMathContextused for the result- Returns:
- the calculated n'th root of x with the precision specified in the
mathContext
-
-