Class ApfloatMath
- java.lang.Object
-
- org.apfloat.ApfloatMath
-
public class ApfloatMath extends java.lang.Object
Various mathematical functions for arbitrary precision floating-point numbers.Due to different types of round-off errors that can occur in the implementation, no guarantees about e.g. monotonicity are given for any of the methods.
- Version:
- 1.14.0
- See Also:
ApintMath
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ApfloatMath.ApfloatHolder
Simple JavaBean to hold one apfloat.private static class
ApfloatMath.PiCalculator
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.Integer,Apfloat>
nextGaussian
private static java.util.Map<java.lang.Integer,java.lang.Long>
nextGaussianPrecision
private static java.util.concurrent.ConcurrentMap<java.lang.Integer,java.lang.Object>
radixGaussianKeys
private static java.util.Map<java.lang.Integer,Apfloat>
radixLog
private static java.util.concurrent.ConcurrentMap<java.lang.Integer,java.lang.Object>
radixLogKeys
private static java.util.Map<java.lang.Integer,Apfloat>
radixLogPi
private static java.util.Map<java.lang.Integer,Apfloat>
radixPi
private static java.util.Map<java.lang.Integer,ApfloatMath.PiCalculator>
radixPiCalculator
private static java.util.Map<java.lang.Integer,Apfloat>
radixPiInverseRoot
private static java.util.concurrent.ConcurrentMap<java.lang.Integer,java.lang.Object>
radixPiKeys
private static java.util.Map<java.lang.Integer,Apfloat>
radixPiP
private static java.util.Map<java.lang.Integer,Apfloat>
radixPiQ
private static java.util.Map<java.lang.Integer,Apfloat>
radixPiT
private static java.util.Map<java.lang.Integer,java.lang.Long>
radixPiTerms
private static java.util.Map<java.lang.Integer,Apfloat>
SHUTDOWN_MAP
-
Constructor Summary
Constructors Modifier Constructor Description private
ApfloatMath()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Apfloat
abs(Apfloat x)
Absolute value.static Apfloat
acos(Apfloat x)
Inverse cosine.(package private) static Apfloat
acos(Apfloat x, long precision)
static Apfloat
acosh(Apfloat x)
Inverse hyperbolic cosine.static Apfloat
agm(Apfloat a, Apfloat b)
Arithmetic-geometric mean.(package private) static Apfloat
agm(Apfloat a, Apfloat b, java.util.function.Consumer<Apfloat> consumer)
private static Apfloat
agmConsume(java.util.function.Consumer<Apfloat> consumer, Apfloat a, Apfloat c2, long workingPrecision)
static Apfloat
airyAi(Apfloat x)
Airy function Ai.(package private) static Apfloat
airyAi(Apfloat x, long precision)
static Apfloat
airyAiPrime(Apfloat x)
Derivative of the Airy function Ai.(package private) static Apfloat
airyAiPrime(Apfloat x, long precision)
static Apfloat
airyBi(Apfloat x)
Airy function Bi.(package private) static Apfloat
airyBi(Apfloat x, long precision)
static Apfloat
airyBiPrime(Apfloat x)
Derivative of the Airy function Bi.(package private) static Apfloat
airyBiPrime(Apfloat x, long precision)
static Apfloat
asin(Apfloat x)
Inverse sine.static Apfloat
asinh(Apfloat x)
Inverse hyperbolic sine.static Apfloat
atan(Apfloat x)
Inverse tangent.static Apfloat
atan2(Apfloat y, Apfloat x)
Converts cartesian coordinates to polar coordinates.static Apfloat
atanh(Apfloat x)
Inverse hyperbolic tangent.static Apfloat
bernoulliB(long n, Apfloat x)
Bernoulli polynomial.(package private) static Apfloat
bernoulliB(long n, Apfloat x, long precision)
static Apfloat
besselI(Apfloat ν, Apfloat x)
Modified Bessel function of the first kind.static Apfloat
besselJ(Apfloat ν, Apfloat x)
Bessel function of the first kind.static Apfloat
besselK(Apfloat ν, Apfloat x)
Modified Bessel function of the second kind.static Apfloat
besselY(Apfloat ν, Apfloat x)
Bessel function of the second kind.static Apfloat
beta(Apfloat a, Apfloat b)
Beta function.static Apfloat
beta(Apfloat x, Apfloat a, Apfloat b)
Incomplete beta function.static Apfloat
beta(Apfloat x1, Apfloat x2, Apfloat a, Apfloat b)
Generalized incomplete beta function.static Apfloat
binomial(Apfloat n, Apfloat k)
Binomial coefficient.private static Apfloat
calculatePi(long precision, int radix)
static Apfloat
catalan(long precision)
Calculates Catalan's constant, G.static Apfloat
catalan(long precision, int radix)
Calculates Catalan's constant, G.static Apfloat
cbrt(Apfloat x)
Cube root.static Apint
ceil(Apfloat x)
Ceiling function.static Apfloat
chebyshevT(Apfloat ν, Apfloat x)
Chebyshev function of the first kind.static Apfloat
chebyshevU(Apfloat ν, Apfloat x)
Chebyshev function of the second kind.private static void
checkHypergeometric2F1(Apfloat a, Apfloat b, Apfloat x)
private static void
checkMinusOneNonInteger(Apfloat ν, Apfloat x)
(package private) static void
cleanUp()
static Apint[]
continuedFraction(Apfloat x, int n)
Generates the firstn
terms in the continued fraction representation ofx
.static Aprational[]
convergents(Apfloat x, int n)
Generates the firstn
convergents corresponding to the continued fraction ofx
.static Apfloat
copySign(Apfloat x, Apfloat y)
Copy sign from one argument to another.static Apfloat
cos(Apfloat x)
Cosine.static Apfloat
cosh(Apfloat x)
Hyperbolic cosine.static Apfloat
coshIntegral(Apfloat x)
Hyperbolic cosine integral.static Apfloat
cosIntegral(Apfloat x)
Cosine integral.static Apfloat
digamma(Apfloat x)
Digamma function.(package private) static Apfloat
doubleFactorial(long n, long precision)
(package private) static Apfloat
doubleFactorial(long n, long precision, int radix)
static Apfloat
e(long precision)
Calculates e.static Apfloat
e(long precision, int radix)
Calculates e.private static Apfloat[]
e(long start, long end, long precision, int radix)
static Apfloat
ellipticE(Apfloat x)
Complete elliptic integral of the second kind.(package private) static Apfloat
ellipticE(Apfloat x, long precision)
static Apfloat
ellipticK(Apfloat x)
Complete elliptic integral of the first kind.(package private) static Apfloat
ellipticK(Apfloat x, long precision)
static Apfloat
erf(Apfloat x)
Error function.static Apfloat
erfc(Apfloat x)
Complementary error function.(package private) static Apfloat
erfcFixedPrecision(Apfloat x)
(package private) static Apfloat
erfFixedPrecision(Apfloat x)
static Apfloat
erfi(Apfloat x)
Imaginary error function.(package private) static Apfloat
erfiFixedPrecision(Apfloat x)
static Apfloat
euler(long precision)
Calculates γ, the Euler-Mascheroni constant.static Apfloat
euler(long precision, int radix)
Calculates γ, the Euler-Mascheroni constant.static Apfloat
eulerE(long n, Apfloat x)
Euler polynomial.(package private) static Apfloat
eulerE(long n, Apfloat x, long precision)
(package private) static Apfloat
eulerSmall(long precision, int radix)
static Apfloat
exp(Apfloat x)
Exponent function.static Apfloat
expIntegralE(Apfloat ν, Apfloat x)
Exponential integral E.static Apfloat
expIntegralEi(Apfloat x)
Exponential integral Ei.(package private) static Apfloat
factorial(long n, long precision)
(package private) static Apfloat
factorial(long n, long precision, int radix)
static Apfloat
fibonacci(Apfloat ν, Apfloat x)
Fibonacci function.static Apint
floor(Apfloat x)
Floor function.static Apfloat
fmod(Apfloat x, Apfloat y)
Returns x modulo y.static Apfloat
frac(Apfloat x)
Extracts fractional part.static Apfloat
fresnelC(Apfloat x)
Fresnel integral C.static Apfloat
fresnelS(Apfloat x)
Fresnel integral S.static Apfloat
gamma(Apfloat x)
Gamma function.static Apfloat
gamma(Apfloat a, Apfloat x)
Incomplete gamma function.static Apfloat
gamma(Apfloat a, Apfloat x0, Apfloat x1)
Generalized incomplete gamma function.static Apfloat
gegenbauerC(Apfloat ν, Apfloat x)
Renormalized Gegenbauer function.static Apfloat
gegenbauerC(Apfloat ν, Apfloat λ, Apfloat x)
Gegenbauer function.private static java.lang.Object
getRadixKey(java.util.Map<java.lang.Integer,java.lang.Object> radixKeys, int radix)
static Apfloat
glaisher(long precision)
Calculates the Glaisher‐Kinkelin constant, A.static Apfloat
glaisher(long precision, int radix)
Calculates the Glaisher‐Kinkelin constant, A.(package private) static Apfloat
halfPi(int radix, long precision)
static Apfloat
harmonicNumber(Apfloat x)
Harmonic number.static Apfloat
harmonicNumber(Apfloat x, Apfloat r)
Generalized harmonic number.static Apfloat
hermiteH(Apfloat ν, Apfloat x)
Hermite function.static Apfloat
hypergeometric0F1(Apfloat a, Apfloat x)
Confluent hypergeometric function 0F1.static Apfloat
hypergeometric0F1Regularized(Apfloat a, Apfloat x)
Regularized confluent hypergeometric function 0F̃1.static Apfloat
hypergeometric1F1(Apfloat a, Apfloat b, Apfloat x)
Kummer confluent hypergeometric function 1F1.static Apfloat
hypergeometric1F1Regularized(Apfloat a, Apfloat b, Apfloat x)
Regularized Kummer confluent hypergeometric function 1F̃1.static Apfloat
hypergeometric2F1(Apfloat a, Apfloat b, Apfloat c, Apfloat x)
Hypergeometric function 2F1.static Apfloat
hypergeometric2F1Regularized(Apfloat a, Apfloat b, Apfloat c, Apfloat x)
Regularized hypergeometric function 2F̃1.static Apfloat
hypergeometricU(Apfloat a, Apfloat b, Apfloat x)
Tricomi's confluent hypergeometric function U.static Apfloat
inverseErf(Apfloat x)
Inverse error function.static Apfloat
inverseErfc(Apfloat x)
Inverse complementary error function.private static long
inverseFactorial(long precision, int radix)
static Apfloat
inverseRoot(Apfloat x, long n)
Inverse positive integer root.static Apfloat
inverseRoot(Apfloat x, long n, long targetPrecision)
Inverse positive integer root.static Apfloat
inverseRoot(Apfloat x, long n, long targetPrecision, Apfloat initialGuess)
Inverse positive integer root.static Apfloat
inverseRoot(Apfloat x, long n, long targetPrecision, Apfloat initialGuess, long initialPrecision)
Inverse positive integer root.private static boolean
isEven(Apfloat x)
static Apfloat
jacobiP(Apfloat ν, Apfloat a, Apfloat b, Apfloat x)
Jacobi function.static Apfloat
khinchin(long precision)
Calculates Khinchin's constant, K.Uses the default radix.static Apfloat
khinchin(long precision, int radix)
Calculates Khinchin's constant, K.static Apfloat
laguerreL(Apfloat ν, Apfloat x)
Laguerre function.static Apfloat
laguerreL(Apfloat ν, Apfloat λ, Apfloat x)
Generalized Laguerre function.private static Apfloat
lastIterationExtendPrecision(int iterations, int precisingIteration, Apfloat x)
static Apfloat
legendreP(Apfloat ν, Apfloat x)
Legendre function.static Apfloat
legendreP(Apfloat ν, Apfloat μ, Apfloat x)
Associated Legendre function of the first kind.static Apfloat
legendreQ(Apfloat ν, Apfloat x)
Legendre function of the second kind.static Apfloat
legendreQ(Apfloat ν, Apfloat μ, Apfloat x)
Associated Legendre function of the second kind.static Apfloat
log(Apfloat x)
Natural logarithm.private static Apfloat
log(Apfloat x, boolean multiplyByPi)
static Apfloat
log(Apfloat x, Apfloat b)
Logarithm in arbitrary base.static Apfloat
logGamma(Apfloat x)
Logarithm of the gamma function.static Apfloat
logIntegral(Apfloat x)
Logarithmic integral.static Apfloat
logisticSigmoid(Apfloat x)
Logistic sigmoid.static Apfloat
logRadix(long precision, int radix)
Gets or calculates logarithm of a radix to required precision.private static Apfloat
logRadix(long precision, int radix, boolean multiplyByPi)
static Apfloat
max(Apfloat x, Apfloat y)
Returns the greater of the two values.static Apfloat
min(Apfloat x, Apfloat y)
Returns the smaller of the two values.static Apfloat[]
modf(Apfloat x)
Split to integer and fractional parts.static Apfloat
multiplyAdd(Apfloat a, Apfloat b, Apfloat c, Apfloat d)
Fused multiply-add.private static Apfloat
multiplyAddOrSubtract(Apfloat a, Apfloat b, Apfloat c, Apfloat d, boolean subtract)
static Apfloat
multiplySubtract(Apfloat a, Apfloat b, Apfloat c, Apfloat d)
Fused multiply-subtract.static Apfloat
negate(Apfloat x)
Deprecated.UseApfloat.negate()
.static Apfloat
nextAfter(Apfloat start, Apfloat direction)
Returns the number adjacent to the first argument in the direction of the second argument, considering the scale and precision of the first argument.static Apfloat
nextDown(Apfloat x)
Returns the number adjacent to the argument in the direction of negative infinity, considering the scale and precision of the argument.private static Apfloat
nextInDirection(Apfloat x, int direction)
static Apfloat
nextUp(Apfloat x)
Returns the number adjacent to the argument in the direction of positive infinity, considering the scale and precision of the argument.private static Apfloat
oddProduct(long n, long m, long precision, int radix)
static Apfloat
pi(long precision)
Calculates π.static Apfloat
pi(long precision, int radix)
Calculates π.static Apfloat
pochhammer(Apfloat x, Apfloat n)
Pochhammer symbol.static Apfloat
polygamma(long n, Apfloat x)
Polygamma function.static Apfloat
polylog(Apfloat ν, Apfloat x)
Polylogarithm.static Apfloat
pow(Apfloat x, long n)
Integer power.static Apfloat
pow(Apfloat x, Apfloat y)
Arbitrary power.static Apfloat
product(Apfloat... x)
Product of numbers.static Apfloat
random(long digits)
Generates a random number.static Apfloat
random(long digits, int radix)
Generates a random number.static Apfloat
randomGaussian(long digits)
Generates a random, Gaussian ("normally") distributed number value with mean 0 and standard deviation 1.static Apfloat
randomGaussian(long digits, int radix)
Generates a random, Gaussian ("normally") distributed number value with mean 0 and standard deviation 1.private static Apfloat
rawLog(Apfloat x, boolean multiplyByPi)
static Apfloat
root(Apfloat x, long n)
Positive integer root.static Apfloat
round(Apfloat x, long precision, java.math.RoundingMode roundingMode)
Deprecated.static Apint
roundToInteger(Apfloat x, java.math.RoundingMode roundingMode)
Roundsx
to integer using the specified rounding mode.static Apfloat
roundToMultiple(Apfloat x, Apfloat y, java.math.RoundingMode roundingMode)
Roundsx
to the nearest multiple ofy
using the specified rounding mode.static Apfloat
roundToPlaces(Apfloat x, long places, java.math.RoundingMode roundingMode)
Roundsx
to the specified number of places using the specified rounding mode.static Apfloat
roundToPrecision(Apfloat x, long precision, java.math.RoundingMode roundingMode)
Rounds the given number to the specified precision with the specified rounding mode.static Apfloat
scale(Apfloat x, long scale)
Multiply by a power of the radix.static Apfloat
sin(Apfloat x)
Sine.static Apfloat
sinc(Apfloat x)
Sinc.static Apfloat
sinh(Apfloat x)
Hyperbolic sine.static Apfloat
sinhIntegral(Apfloat x)
Hyperbolic sine integral.static Apfloat
sinIntegral(Apfloat x)
Sine integral.static Apfloat
sqrt(Apfloat x)
Square root.static Apfloat
sum(Apfloat... x)
Sum of numbers.static Apfloat
tan(Apfloat x)
Tangent.static Apfloat
tanh(Apfloat x)
Hyperbolic tangent.private static Apfloat
tanh(Apfloat x, boolean negate)
(package private) static Apfloat
tanhFixedPrecision(Apfloat x)
static Apfloat
toDegrees(Apfloat x)
Converts an angle measured in radians to degrees.static Apfloat
toRadians(Apfloat x)
Converts an angle measured in degrees to radians.static Apint
truncate(Apfloat x)
Truncates fractional part.static Apfloat
ulp(Apfloat x)
Returns the unit in the last place of the argument, considering the scale and precision.private static Apfloat
ulp(Apfloat x, int direction)
static Apfloat
w(Apfloat x)
Lambert W function.static Apfloat
zeta(Apfloat s)
Riemann zeta function.static Apfloat
zeta(Apfloat s, Apfloat a)
Hurwitz zeta function.
-
-
-
Field Detail
-
SHUTDOWN_MAP
private static final java.util.Map<java.lang.Integer,Apfloat> SHUTDOWN_MAP
-
radixPiKeys
private static java.util.concurrent.ConcurrentMap<java.lang.Integer,java.lang.Object> radixPiKeys
-
radixPi
private static java.util.Map<java.lang.Integer,Apfloat> radixPi
-
radixPiCalculator
private static java.util.Map<java.lang.Integer,ApfloatMath.PiCalculator> radixPiCalculator
-
radixPiT
private static java.util.Map<java.lang.Integer,Apfloat> radixPiT
-
radixPiQ
private static java.util.Map<java.lang.Integer,Apfloat> radixPiQ
-
radixPiP
private static java.util.Map<java.lang.Integer,Apfloat> radixPiP
-
radixPiInverseRoot
private static java.util.Map<java.lang.Integer,Apfloat> radixPiInverseRoot
-
radixPiTerms
private static java.util.Map<java.lang.Integer,java.lang.Long> radixPiTerms
-
radixLogKeys
private static java.util.concurrent.ConcurrentMap<java.lang.Integer,java.lang.Object> radixLogKeys
-
radixLog
private static java.util.Map<java.lang.Integer,Apfloat> radixLog
-
radixLogPi
private static java.util.Map<java.lang.Integer,Apfloat> radixLogPi
-
radixGaussianKeys
private static java.util.concurrent.ConcurrentMap<java.lang.Integer,java.lang.Object> radixGaussianKeys
-
nextGaussian
private static java.util.Map<java.lang.Integer,Apfloat> nextGaussian
-
nextGaussianPrecision
private static java.util.Map<java.lang.Integer,java.lang.Long> nextGaussianPrecision
-
-
Method Detail
-
pow
public static Apfloat pow(Apfloat x, long n) throws java.lang.ArithmeticException, ApfloatRuntimeException
Integer power.- Parameters:
x
- Base of the power operator.n
- Exponent of the power operator.- Returns:
x
to then
:th power, that isxn
.- Throws:
java.lang.ArithmeticException
- If bothx
andn
are zero.ApfloatRuntimeException
-
sqrt
public static Apfloat sqrt(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Square root.- Parameters:
x
- The argument.- Returns:
- Square root of
x
. - Throws:
java.lang.ArithmeticException
- Ifx
is negative.ApfloatRuntimeException
-
cbrt
public static Apfloat cbrt(Apfloat x) throws ApfloatRuntimeException
Cube root.- Parameters:
x
- The argument.- Returns:
- Cube root of
x
. - Throws:
ApfloatRuntimeException
-
root
public static Apfloat root(Apfloat x, long n) throws java.lang.ArithmeticException, ApfloatRuntimeException
Positive integer root.- Parameters:
x
- The argument.n
- Which root to take.- Returns:
n
:th root ofx
, that isx1/n
.- Throws:
java.lang.ArithmeticException
- Ifn
is zero, orx
is negative andn
is even.ApfloatRuntimeException
-
inverseRoot
public static Apfloat inverseRoot(Apfloat x, long n) throws java.lang.ArithmeticException, ApfloatRuntimeException
Inverse positive integer root.- Parameters:
x
- The argument.n
- Which inverse root to take.- Returns:
- Inverse
n
:th root ofx
, that isx-1/n
. - Throws:
java.lang.ArithmeticException
- Ifx
orn
is zero, orx
is negative andn
is even.ApfloatRuntimeException
-
inverseRoot
public static Apfloat inverseRoot(Apfloat x, long n, long targetPrecision) throws java.lang.IllegalArgumentException, java.lang.ArithmeticException, ApfloatRuntimeException
Inverse positive integer root.- Parameters:
x
- The argument.n
- Which inverse root to take.targetPrecision
- Precision of the desired result.- Returns:
- Inverse
n
:th root ofx
, that isx-1/n
. - Throws:
java.lang.IllegalArgumentException
- IftargetPrecision <= 0
.java.lang.ArithmeticException
- Ifx
orn
is zero, orx
is negative andn
is even.ApfloatRuntimeException
-
inverseRoot
public static Apfloat inverseRoot(Apfloat x, long n, long targetPrecision, Apfloat initialGuess) throws java.lang.IllegalArgumentException, java.lang.ArithmeticException, ApfloatRuntimeException
Inverse positive integer root.- Parameters:
x
- The argument.n
- Which inverse root to take.targetPrecision
- Precision of the desired result.initialGuess
- Initial guess for the result value, ornull
if none is available.- Returns:
- Inverse
n
:th root ofx
, that isx-1/n
. - Throws:
java.lang.IllegalArgumentException
- IftargetPrecision <= 0
.java.lang.ArithmeticException
- Ifx
orn
is zero, orx
is negative andn
is even.ApfloatRuntimeException
-
inverseRoot
public static Apfloat inverseRoot(Apfloat x, long n, long targetPrecision, Apfloat initialGuess, long initialPrecision) throws java.lang.IllegalArgumentException, java.lang.ArithmeticException, ApfloatRuntimeException
Inverse positive integer root.This method is the basis for most of apfloat's non-elementary operations. It is used e.g. in
Apfloat.divide(Apfloat)
,sqrt(Apfloat)
androot(Apfloat,long)
.- Parameters:
x
- The argument.n
- Which inverse root to take.targetPrecision
- Precision of the desired result.initialGuess
- Initial guess for the result value, ornull
if none is available.initialPrecision
- Precision of the initial guess, if available.- Returns:
- Inverse
n
:th root ofx
, that isx-1/n
. - Throws:
java.lang.IllegalArgumentException
- IftargetPrecision <= 0
orinitialPrecision <= 0
.java.lang.ArithmeticException
- Ifx
orn
is zero, orx
is negative andn
is even.ApfloatRuntimeException
-
floor
public static Apint floor(Apfloat x) throws ApfloatRuntimeException
Floor function. Returns the largest (closest to positive infinity) value that is not greater than the argument and is equal to a mathematical integer.- Parameters:
x
- The argument.- Returns:
x
rounded towards negative infinity.- Throws:
ApfloatRuntimeException
-
ceil
public static Apint ceil(Apfloat x) throws ApfloatRuntimeException
Ceiling function. Returns the smallest (closest to negative infinity) value that is not less than the argument and is equal to a mathematical integer.- Parameters:
x
- The argument.- Returns:
x
rounded towards positive infinity.- Throws:
ApfloatRuntimeException
-
truncate
public static Apint truncate(Apfloat x) throws ApfloatRuntimeException
Truncates fractional part.- Parameters:
x
- The argument.- Returns:
x
rounded towards zero.- Throws:
ApfloatRuntimeException
-
frac
public static Apfloat frac(Apfloat x) throws ApfloatRuntimeException
Extracts fractional part.- Parameters:
x
- The argument.- Returns:
- The fractional part of
x
. - Throws:
ApfloatRuntimeException
- Since:
- 1.7.0
-
round
@Deprecated public static Apfloat round(Apfloat x, long precision, java.math.RoundingMode roundingMode) throws java.lang.IllegalArgumentException, java.lang.ArithmeticException, ApfloatRuntimeException
Deprecated.Rounds the given number to the specified precision with the specified rounding mode.- Parameters:
x
- The number to round.precision
- The precision to round to.roundingMode
- The rounding mode to use.- Returns:
- The rounded number.
- Throws:
java.lang.IllegalArgumentException
- Ifprecision
is less than zero or zero.java.lang.ArithmeticException
- If rounding is necessary (result is not exact) and rounding mode isRoundingMode.UNNECESSARY
.ApfloatRuntimeException
- Since:
- 1.7.0
-
roundToPrecision
public static Apfloat roundToPrecision(Apfloat x, long precision, java.math.RoundingMode roundingMode) throws java.lang.IllegalArgumentException, java.lang.ArithmeticException, ApfloatRuntimeException
Rounds the given number to the specified precision with the specified rounding mode.- Parameters:
x
- The number to round.precision
- The precision to round to.roundingMode
- The rounding mode to use.- Returns:
- The rounded number.
- Throws:
java.lang.IllegalArgumentException
- Ifprecision
is less than zero or zero.java.lang.ArithmeticException
- If rounding is necessary (result is not exact) and rounding mode isRoundingMode.UNNECESSARY
.ApfloatRuntimeException
- Since:
- 1.11.0
-
roundToInteger
public static Apint roundToInteger(Apfloat x, java.math.RoundingMode roundingMode) throws java.lang.IllegalArgumentException, java.lang.ArithmeticException, ApfloatRuntimeException
Roundsx
to integer using the specified rounding mode.- Parameters:
x
- The number to round.roundingMode
- The rounding mode to use.- Returns:
- The rounded number.
- Throws:
java.lang.ArithmeticException
- If rounding is necessary (result is not exact) and rounding mode isRoundingMode.UNNECESSARY
.java.lang.IllegalArgumentException
ApfloatRuntimeException
- Since:
- 1.11.0
-
roundToPlaces
public static Apfloat roundToPlaces(Apfloat x, long places, java.math.RoundingMode roundingMode) throws java.lang.IllegalArgumentException, java.lang.ArithmeticException, ApfloatRuntimeException
Roundsx
to the specified number of places using the specified rounding mode.- Parameters:
x
- The number to round.places
- The number of places to round to (in base 10, the number of decimal places).roundingMode
- The rounding mode to use.- Returns:
- The rounded number.
- Throws:
java.lang.ArithmeticException
- If rounding is necessary (result is not exact) and rounding mode isRoundingMode.UNNECESSARY
.java.lang.IllegalArgumentException
ApfloatRuntimeException
- Since:
- 1.11.0
-
roundToMultiple
public static Apfloat roundToMultiple(Apfloat x, Apfloat y, java.math.RoundingMode roundingMode) throws java.lang.IllegalArgumentException, java.lang.ArithmeticException, ApfloatRuntimeException
Roundsx
to the nearest multiple ofy
using the specified rounding mode.- Parameters:
x
- The number to round.y
- The integer multiple to round to.roundingMode
- The rounding mode to use.- Returns:
- The rounded number.
- Throws:
java.lang.ArithmeticException
- If rounding is necessary (result is not exact) and rounding mode isRoundingMode.UNNECESSARY
.java.lang.IllegalArgumentException
ApfloatRuntimeException
- Since:
- 1.11.0
-
negate
@Deprecated public static Apfloat negate(Apfloat x) throws ApfloatRuntimeException
Deprecated.UseApfloat.negate()
.Returns an apfloat whose value is-x
.- Parameters:
x
- The argument.- Returns:
-x
.- Throws:
ApfloatRuntimeException
-
abs
public static Apfloat abs(Apfloat x) throws ApfloatRuntimeException
Absolute value.- Parameters:
x
- The argument.- Returns:
- Absolute value of
x
. - Throws:
ApfloatRuntimeException
-
copySign
public static Apfloat copySign(Apfloat x, Apfloat y) throws ApfloatRuntimeException
Copy sign from one argument to another.- Parameters:
x
- The value whose sign is to be adjusted.y
- The value whose sign is to be used.- Returns:
x
with its sign changed to match the sign ofy
.- Throws:
ApfloatRuntimeException
- Since:
- 1.1
-
scale
public static Apfloat scale(Apfloat x, long scale) throws ApfloatRuntimeException
Multiply by a power of the radix.- Parameters:
x
- The argument.scale
- The scaling factor.- Returns:
x * x.radix()scale
.- Throws:
ApfloatRuntimeException
-
modf
public static Apfloat[] modf(Apfloat x) throws ApfloatRuntimeException
Split to integer and fractional parts. The integer part is simplyi = floor(x)
. For the fractional partf
the following is always true:0 <= f < 1
- Parameters:
x
- The argument.- Returns:
- An array of two apfloats,
[i, f]
, the first being the integer part and the last being the fractional part. - Throws:
ApfloatRuntimeException
-
fmod
public static Apfloat fmod(Apfloat x, Apfloat y) throws ApfloatRuntimeException
Returns x modulo y.This function calculates the remainder
f
ofx / y
such thatx = i * y + f
, wherei
is an integer,f
has the same sign asx
, and the absolute value off
is less than the absolute value ofy
.If
y
is zero, then zero is returned.- Parameters:
x
- The dividend.y
- The divisor.- Returns:
- The remainder when x is divided by y.
- Throws:
ApfloatRuntimeException
-
multiplyAdd
public static Apfloat multiplyAdd(Apfloat a, Apfloat b, Apfloat c, Apfloat d) throws ApfloatRuntimeException
Fused multiply-add. Calculatesa * b + c * d
so that the precision used in the multiplications is only what is needed for the end result. Performance can this way be better than by calculatinga.multiply(b).add(c.multiply(d))
.- Parameters:
a
- First argument.b
- Second argument.c
- Third argument.d
- Fourth argument.- Returns:
a * b + c * d
.- Throws:
ApfloatRuntimeException
-
multiplySubtract
public static Apfloat multiplySubtract(Apfloat a, Apfloat b, Apfloat c, Apfloat d) throws ApfloatRuntimeException
Fused multiply-subtract. Calculatesa * b - c * d
so that the precision used in the multiplications is only what is needed for the end result. Performance can this way be better than by calculatinga.multiply(b).subtract(c.multiply(d))
.- Parameters:
a
- First argument.b
- Second argument.c
- Third argument.d
- Fourth argument.- Returns:
a * b - c * d
.- Throws:
ApfloatRuntimeException
-
multiplyAddOrSubtract
private static Apfloat multiplyAddOrSubtract(Apfloat a, Apfloat b, Apfloat c, Apfloat d, boolean subtract) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
agm
public static Apfloat agm(Apfloat a, Apfloat b) throws ApfloatRuntimeException
Arithmetic-geometric mean.- Parameters:
a
- First argument.b
- Second argument.- Returns:
- Arithmetic-geometric mean of a and b.
- Throws:
ApfloatRuntimeException
-
agm
static Apfloat agm(Apfloat a, Apfloat b, java.util.function.Consumer<Apfloat> consumer) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
agmConsume
private static Apfloat agmConsume(java.util.function.Consumer<Apfloat> consumer, Apfloat a, Apfloat c2, long workingPrecision)
-
pi
public static Apfloat pi(long precision) throws java.lang.IllegalArgumentException, java.lang.NumberFormatException, ApfloatRuntimeException
Calculates π. Uses default radix.- Parameters:
precision
- Number of digits of π to calculate.- Returns:
- π accurate to
precision
digits, in the default radix. - Throws:
java.lang.NumberFormatException
- If the default radix is not valid.java.lang.IllegalArgumentException
- In case the precision is invalid.ApfloatRuntimeException
-
pi
public static Apfloat pi(long precision, int radix) throws java.lang.IllegalArgumentException, java.lang.NumberFormatException, ApfloatRuntimeException
Calculates π.- Parameters:
precision
- Number of digits of π to calculate.radix
- The radix in which the number should be presented.- Returns:
- π accurate to
precision
digits, in baseradix
. - Throws:
java.lang.NumberFormatException
- If the radix is not valid.java.lang.IllegalArgumentException
- In case the precision is invalid.ApfloatRuntimeException
-
calculatePi
private static Apfloat calculatePi(long precision, int radix) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
log
public static Apfloat log(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Natural logarithm.The logarithm is calculated using the arithmetic-geometric mean. See the Borweins' book for the formula.
- Parameters:
x
- The argument.- Returns:
- Natural logarithm of
x
. - Throws:
java.lang.ArithmeticException
- Ifx <= 0
.ApfloatRuntimeException
-
log
public static Apfloat log(Apfloat x, Apfloat b) throws java.lang.ArithmeticException, ApfloatRuntimeException
Logarithm in arbitrary base.The logarithm is calculated using the arithmetic-geometric mean. See the Borweins' book for the formula.
- Parameters:
x
- The argument.b
- The base.- Returns:
- Base-
b
logarithm ofx
. - Throws:
java.lang.ArithmeticException
- Ifx <= 0
orb <= 0
.ApfloatRuntimeException
- Since:
- 1.6
-
log
private static Apfloat log(Apfloat x, boolean multiplyByPi) throws java.lang.ArithmeticException, ApfloatRuntimeException
- Throws:
java.lang.ArithmeticException
ApfloatRuntimeException
-
rawLog
private static Apfloat rawLog(Apfloat x, boolean multiplyByPi) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
logRadix
public static Apfloat logRadix(long precision, int radix) throws ApfloatRuntimeException
Gets or calculates logarithm of a radix to required precision. The calculated value is stored in a cache for later usage.- Parameters:
precision
- The needed precision.radix
- The radix.- Returns:
- Natural logarithm of
radix
to the specified precision. - Throws:
java.lang.NumberFormatException
- If the radix is invalid.ApfloatRuntimeException
-
logRadix
private static Apfloat logRadix(long precision, int radix, boolean multiplyByPi) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
exp
public static Apfloat exp(Apfloat x) throws ApfloatRuntimeException
Exponent function. Calculated using Newton's iteration for the inverse of logarithm.- Parameters:
x
- The argument.- Returns:
ex
.- Throws:
ApfloatRuntimeException
-
pow
public static Apfloat pow(Apfloat x, Apfloat y) throws java.lang.ArithmeticException, ApfloatRuntimeException
Arbitrary power. Calculated usinglog()
andexp()
.- Parameters:
x
- The base.y
- The exponent.- Returns:
xy
.- Throws:
java.lang.ArithmeticException
- If bothx
andy
are zero, orx
is negative andy
is not an integer.ApfloatRuntimeException
-
acosh
public static Apfloat acosh(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Inverse hyperbolic cosine. Calculated usinglog()
.- Parameters:
x
- The argument.- Returns:
- Inverse hyperbolic cosine of
x
. - Throws:
java.lang.ArithmeticException
- Ifx < 1
.ApfloatRuntimeException
-
asinh
public static Apfloat asinh(Apfloat x) throws ApfloatRuntimeException
Inverse hyperbolic sine. Calculated usinglog()
.- Parameters:
x
- The argument.- Returns:
- Inverse hyperbolic sine of
x
. - Throws:
ApfloatRuntimeException
-
atanh
public static Apfloat atanh(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Inverse hyperbolic tangent. Calculated usinglog()
.- Parameters:
x
- The argument.- Returns:
- Inverse hyperbolic tangent of
x
. - Throws:
java.lang.ArithmeticException
- Ifabs(x) >= 1
.ApfloatRuntimeException
-
cosh
public static Apfloat cosh(Apfloat x) throws ApfloatRuntimeException
Hyperbolic cosine. Calculated usingexp()
.- Parameters:
x
- The argument.- Returns:
- Hyperbolic cosine of
x
. - Throws:
ApfloatRuntimeException
-
sinh
public static Apfloat sinh(Apfloat x) throws ApfloatRuntimeException
Hyperbolic sine. Calculated usingexp()
.- Parameters:
x
- The argument.- Returns:
- Hyperbolic sine of
x
. - Throws:
ApfloatRuntimeException
-
tanh
public static Apfloat tanh(Apfloat x) throws ApfloatRuntimeException
Hyperbolic tangent. Calculated usingexp()
.- Parameters:
x
- The argument.- Returns:
- Hyperbolic tangent of
x
. - Throws:
ApfloatRuntimeException
-
tanhFixedPrecision
static Apfloat tanhFixedPrecision(Apfloat x) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
tanh
private static Apfloat tanh(Apfloat x, boolean negate) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
acos
public static Apfloat acos(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Inverse cosine. Calculated using complex functions.- Parameters:
x
- The argument.- Returns:
- Inverse cosine of
x
. - Throws:
java.lang.ArithmeticException
- Ifabs(x) > 1
.ApfloatRuntimeException
-
halfPi
static Apfloat halfPi(int radix, long precision)
-
asin
public static Apfloat asin(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Inverse sine. Calculated using complex functions.- Parameters:
x
- The argument.- Returns:
- Inverse sine of
x
. - Throws:
java.lang.ArithmeticException
- Ifabs(x) > 1
.ApfloatRuntimeException
-
atan
public static Apfloat atan(Apfloat x) throws ApfloatRuntimeException
Inverse tangent. Calculated using complex functions.- Parameters:
x
- The argument.- Returns:
- Inverse tangent of
x
. - Throws:
ApfloatRuntimeException
-
atan2
public static Apfloat atan2(Apfloat y, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Converts cartesian coordinates to polar coordinates. Calculated using complex functions.Computes the phase angle by computing an arc tangent of
y/x
in the range of -π < angle <= π.- Parameters:
y
- The argument.x
- The argument.- Returns:
- The angle of the point
(x, y)
in the plane. - Throws:
java.lang.ArithmeticException
- Ify
andx
are both zero.ApfloatRuntimeException
-
cos
public static Apfloat cos(Apfloat x) throws ApfloatRuntimeException
Cosine. Calculated using complex functions.- Parameters:
x
- The argument (in radians).- Returns:
- Cosine of
x
. - Throws:
ApfloatRuntimeException
-
sin
public static Apfloat sin(Apfloat x) throws ApfloatRuntimeException
Sine. Calculated using complex functions.- Parameters:
x
- The argument (in radians).- Returns:
- Sine of
x
. - Throws:
ApfloatRuntimeException
-
tan
public static Apfloat tan(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Tangent. Calculated using complex functions.- Parameters:
x
- The argument (in radians).- Returns:
- Tangent of
x
. - Throws:
java.lang.ArithmeticException
- Ifx
is π/2 + n π where n is an integer.ApfloatRuntimeException
-
sinc
public static Apfloat sinc(Apfloat x) throws ApfloatRuntimeException
Sinc.- Parameters:
x
- The argument.- Returns:
- sinc(x)
- Throws:
ApfloatRuntimeException
- Since:
- 1.14.0
-
w
public static Apfloat w(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Lambert W function. The W function gives the solution to the equationW eW = x
. Also known as the product logarithm.This function only gives the solution to the principal branch, W0. For the real-valued W-1 branch, use
ApcomplexMath.w(Apcomplex,long)
.- Parameters:
x
- The argument.- Returns:
W0(x)
.- Throws:
java.lang.ArithmeticException
- Ifx
is less than -1/e.ApfloatRuntimeException
- Since:
- 1.8.0
-
toDegrees
public static Apfloat toDegrees(Apfloat x) throws ApfloatRuntimeException
Converts an angle measured in radians to degrees.- Parameters:
x
- The angle, in radians.- Returns:
- The angle in degrees.
- Throws:
ApfloatRuntimeException
- Since:
- 1.8.0
-
toRadians
public static Apfloat toRadians(Apfloat x) throws ApfloatRuntimeException
Converts an angle measured in degrees to radians.- Parameters:
x
- The angle, in degrees.- Returns:
- The angle in radians.
- Throws:
ApfloatRuntimeException
- Since:
- 1.8.0
-
product
public static Apfloat product(Apfloat... x) 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:
x
- The argument(s).- Returns:
- The product of the given numbers.
- Throws:
ApfloatRuntimeException
- Since:
- 1.3
-
sum
public static Apfloat sum(Apfloat... x) 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:
x
- The argument(s).- Returns:
- The sum of the given numbers.
- Throws:
ApfloatRuntimeException
- Since:
- 1.3
-
e
public static Apfloat e(long precision) throws java.lang.IllegalArgumentException, java.lang.NumberFormatException, ApfloatRuntimeException
Calculates e. Uses default radix.- Parameters:
precision
- Number of digits of e to calculate.- Returns:
- e accurate to
precision
digits, in the default radix. - Throws:
java.lang.NumberFormatException
- If the default radix is not valid.java.lang.IllegalArgumentException
- In case the precision is invalid.ApfloatRuntimeException
- Since:
- 1.11.0
-
e
public static Apfloat e(long precision, int radix) throws java.lang.IllegalArgumentException, java.lang.NumberFormatException, ApfloatRuntimeException
Calculates e.- Parameters:
precision
- Number of digits of e to calculate.radix
- The radix in which the number should be presented.- Returns:
- e accurate to
precision
digits, in baseradix
. - Throws:
java.lang.NumberFormatException
- If the radix is not valid.java.lang.IllegalArgumentException
- In case the precision is invalid.ApfloatRuntimeException
- Since:
- 1.11.0
-
inverseFactorial
private static long inverseFactorial(long precision, int radix)
-
e
private static Apfloat[] e(long start, long end, long precision, int radix)
-
euler
public static Apfloat euler(long precision) throws java.lang.IllegalArgumentException, java.lang.NumberFormatException, ApfloatRuntimeException
Calculates γ, the Euler-Mascheroni constant. Uses default radix.- Parameters:
precision
- Number of digits of γ to calculate.- Returns:
- γ accurate to
precision
digits, in the default radix. - Throws:
java.lang.NumberFormatException
- If the default radix is not valid.java.lang.IllegalArgumentException
- In case the precision is invalid.ApfloatRuntimeException
- Since:
- 1.10.0
-
euler
public static Apfloat euler(long precision, int radix) throws java.lang.IllegalArgumentException, java.lang.NumberFormatException, ApfloatRuntimeException
Calculates γ, the Euler-Mascheroni constant.- Parameters:
precision
- Number of digits of γ to calculate.radix
- The radix in which the number should be presented.- Returns:
- γ accurate to
precision
digits, in baseradix
. - Throws:
java.lang.NumberFormatException
- If the radix is not valid.java.lang.IllegalArgumentException
- In case the precision is invalid.ApfloatRuntimeException
- Since:
- 1.10.0
-
eulerSmall
static Apfloat eulerSmall(long precision, int radix) throws java.lang.IllegalArgumentException, java.lang.NumberFormatException, ApfloatRuntimeException
- Throws:
java.lang.IllegalArgumentException
java.lang.NumberFormatException
ApfloatRuntimeException
-
catalan
public static Apfloat catalan(long precision) throws java.lang.IllegalArgumentException, java.lang.NumberFormatException, ApfloatRuntimeException
Calculates Catalan's constant, G. Uses the default radix.- Parameters:
precision
- Number of digits of G to calculate.- Returns:
- G accurate to
precision
digits, in the default radix. - Throws:
java.lang.NumberFormatException
- If the default radix is not valid.java.lang.IllegalArgumentException
- In case the precision is invalid.ApfloatRuntimeException
- Since:
- 1.11.0
-
catalan
public static Apfloat catalan(long precision, int radix) throws java.lang.IllegalArgumentException, java.lang.NumberFormatException, ApfloatRuntimeException
Calculates Catalan's constant, G. Uses the specified radix.- Parameters:
precision
- Number of digits of G to calculate.radix
- The radix in which the number should be presented.- Returns:
- G accurate to
precision
digits, in baseradix
. - Throws:
java.lang.NumberFormatException
- If the radix is not valid.java.lang.IllegalArgumentException
- In case the precision is invalid.ApfloatRuntimeException
- Since:
- 1.11.0
-
glaisher
public static Apfloat glaisher(long precision) throws java.lang.IllegalArgumentException, java.lang.NumberFormatException, ApfloatRuntimeException
Calculates the Glaisher‐Kinkelin constant, A. Uses the default radix.- Parameters:
precision
- Number of digits of A to calculate.- Returns:
- A accurate to
precision
digits, in the default radix. - Throws:
java.lang.NumberFormatException
- If the default radix is not valid.java.lang.IllegalArgumentException
- In case the precision is invalid.ApfloatRuntimeException
- Since:
- 1.11.0
-
glaisher
public static Apfloat glaisher(long precision, int radix) throws java.lang.IllegalArgumentException, java.lang.NumberFormatException, ApfloatRuntimeException
Calculates the Glaisher‐Kinkelin constant, A. Uses the specified radix.- Parameters:
precision
- Number of digits of A to calculate.radix
- The radix in which the number should be presented.- Returns:
- A accurate to
precision
digits, in baseradix
. - Throws:
java.lang.NumberFormatException
- If the radix is not valid.java.lang.IllegalArgumentException
- In case the precision is invalid.ApfloatRuntimeException
- Since:
- 1.11.0
-
khinchin
public static Apfloat khinchin(long precision) throws java.lang.IllegalArgumentException, java.lang.NumberFormatException, ApfloatRuntimeException
Calculates Khinchin's constant, K.Uses the default radix.- Parameters:
precision
- Number of digits of K to calculate.- Returns:
- K accurate to
precision
digits, in the default radix. - Throws:
java.lang.NumberFormatException
- If the default radix is not valid.java.lang.IllegalArgumentException
- In case the precision is invalid.ApfloatRuntimeException
- Since:
- 1.11.0
-
khinchin
public static Apfloat khinchin(long precision, int radix) throws java.lang.IllegalArgumentException, java.lang.NumberFormatException, ApfloatRuntimeException
Calculates Khinchin's constant, K. Uses the specified radix.- Parameters:
precision
- Number of digits of K to calculate.radix
- The radix in which the number should be presented.- Returns:
- K accurate to
precision
digits, in baseradix
. - Throws:
java.lang.NumberFormatException
- If the radix is not valid.java.lang.IllegalArgumentException
- In case the precision is invalid.ApfloatRuntimeException
- Since:
- 1.11.0
-
gamma
public static Apfloat gamma(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Gamma function.- Parameters:
x
- The argument.- Returns:
Γ(x)
- Throws:
java.lang.ArithmeticException
- Ifx
is a nonpositive integer.ApfloatRuntimeException
- Since:
- 1.9.0
-
gamma
public static Apfloat gamma(Apfloat a, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Incomplete gamma function.- Parameters:
a
- The first argument.x
- The second argument.- Returns:
Γ(a, x)
- Throws:
java.lang.ArithmeticException
- Ifa
is not a positive integer andx
is nonpositive.ApfloatRuntimeException
- Since:
- 1.10.0
-
gamma
public static Apfloat gamma(Apfloat a, Apfloat x0, Apfloat x1) throws java.lang.ArithmeticException, ApfloatRuntimeException
Generalized incomplete gamma function.This function is defined as:
Γ(a, x0, x1) = Γ(a, x0) - Γ(a, x1)
The lower gamma function can be calculated with:
γ(a, x) = Γ(a, 0, x)
- Parameters:
a
- The first argument.x0
- The second argument.x1
- The third argument.- Returns:
Γ(a, x0, x1)
- Throws:
java.lang.ArithmeticException
- Ifa
is not a positive integer and eitherx0
orx1
is nonpositive.ApfloatRuntimeException
- Since:
- 1.10.0
-
logGamma
public static Apfloat logGamma(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Logarithm of the gamma function.- Parameters:
x
- The argument.- Returns:
logΓ(x)
- Throws:
java.lang.ArithmeticException
- Ifx
is nonpositive.ApfloatRuntimeException
- Since:
- 1.11.0
-
digamma
public static Apfloat digamma(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Digamma function.- Parameters:
x
- The argument.- Returns:
ψ(x)
- Throws:
java.lang.ArithmeticException
- Ifx
is a nonpositive integer.ApfloatRuntimeException
- Since:
- 1.11.0
-
polygamma
public static Apfloat polygamma(long n, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Polygamma function.- Parameters:
n
- The order.x
- The argument.- Returns:
ψ(n)(x)
- Throws:
java.lang.ArithmeticException
- Ifn
is negative orx
is a nonpositive integer.ApfloatRuntimeException
- Since:
- 1.13.0
-
beta
public static Apfloat beta(Apfloat a, Apfloat b) throws java.lang.ArithmeticException, ApfloatRuntimeException
Beta function.- Parameters:
a
- The first argument.b
- The second argument.- Returns:
- B(a, b)
- Throws:
java.lang.ArithmeticException
- Ifa
orb
is a nonpositive integer buta + b
is not. Also if botha
andb
are nonpositive integers.ApfloatRuntimeException
- Since:
- 1.13.0
-
beta
public static Apfloat beta(Apfloat x, Apfloat a, Apfloat b) throws java.lang.ArithmeticException, ApfloatRuntimeException
Incomplete beta function.- Parameters:
x
- The first argument.a
- The second argument.b
- The third argument.- Returns:
- Bx(a, b)
- Throws:
java.lang.ArithmeticException
- Ifa
is a nonpositive integer orx
is zero anda
is nonpositive orx
is negative anda
is not an integer. Also ifx
> 1 and the result is not a polynomial.ApfloatRuntimeException
- Since:
- 1.13.0
-
beta
public static Apfloat beta(Apfloat x1, Apfloat x2, Apfloat a, Apfloat b) throws java.lang.ArithmeticException, ApfloatRuntimeException
Generalized incomplete beta function.- Parameters:
x1
- The first argument.x2
- The second argument.a
- The third argument.b
- The fourth argument.- Returns:
- B(x1, x2)(a, b)
- Throws:
java.lang.ArithmeticException
- Ifa
is a nonpositive integer orx1
orx2
is zero anda
is nonpositive orx1
orx2
is negative anda
is not an integer. Also ifx1
> 1 orx2
> 1 and the result is not a polynomial.ApfloatRuntimeException
- Since:
- 1.13.0
-
pochhammer
public static Apfloat pochhammer(Apfloat x, Apfloat n) throws java.lang.ArithmeticException, ApfloatRuntimeException
Pochhammer symbol.- Parameters:
x
- The first argument.n
- The second argument.- Returns:
(x)n
- Throws:
java.lang.ArithmeticException
- Ifx + n
is a nonpositive integer butx
is not.ApfloatRuntimeException
- Since:
- 1.13.0
-
binomial
public static Apfloat binomial(Apfloat n, Apfloat k) throws java.lang.ArithmeticException, ApfloatRuntimeException
Binomial coefficient. Calculated using thegamma(Apfloat)
function.- Parameters:
n
- The first argument.k
- The second argument.- Returns:
- Throws:
java.lang.ArithmeticException
- Ifn
is a negative integer andk
is noninteger.ApfloatRuntimeException
- Since:
- 1.11.0
-
zeta
public static Apfloat zeta(Apfloat s) throws java.lang.ArithmeticException, ApfloatRuntimeException
Riemann zeta function.- Parameters:
s
- The argument.- Returns:
ζ(s)
- Throws:
java.lang.ArithmeticException
- Ifs
is1
.ApfloatRuntimeException
- Since:
- 1.11.0
-
zeta
public static Apfloat zeta(Apfloat s, Apfloat a) throws java.lang.ArithmeticException, ApfloatRuntimeException
Hurwitz zeta function.- Parameters:
s
- The first argument.a
- The second argument.- Returns:
ζ(s, a)
- Throws:
java.lang.ArithmeticException
- Ifs
is1
or ifa
is a nonpositive integer or ifs
is not an integer anda
is nonpositive.ApfloatRuntimeException
- Since:
- 1.11.0
-
hypergeometric0F1
public static Apfloat hypergeometric0F1(Apfloat a, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Confluent hypergeometric function 0F1.- Parameters:
a
- The first argument.x
- The second argument.- Returns:
- 0F1(; a; x)
- Throws:
java.lang.ArithmeticException
- If the function value is not finite.ApfloatRuntimeException
- Since:
- 1.11.0
-
hypergeometric0F1Regularized
public static Apfloat hypergeometric0F1Regularized(Apfloat a, Apfloat x) throws ApfloatRuntimeException
Regularized confluent hypergeometric function 0F̃1.- Parameters:
a
- The first argument.x
- The second argument.- Returns:
- 0F̃1(; a; x)
- Throws:
ApfloatRuntimeException
- Since:
- 1.13.0
-
hypergeometric1F1
public static Apfloat hypergeometric1F1(Apfloat a, Apfloat b, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Kummer confluent hypergeometric function 1F1. Also known as the confluent hypergeometric function of the first kind.- Parameters:
a
- The first argument.b
- The second argument.x
- The third argument.- Returns:
- 1F1(a; b; x)
- Throws:
java.lang.ArithmeticException
- If the function value is not finite.ApfloatRuntimeException
- Since:
- 1.11.0
-
hypergeometric1F1Regularized
public static Apfloat hypergeometric1F1Regularized(Apfloat a, Apfloat b, Apfloat x) throws ApfloatRuntimeException
Regularized Kummer confluent hypergeometric function 1F̃1. Also known as the regularized confluent hypergeometric function of the first kind.- Parameters:
a
- The first argument.b
- The second argument.x
- The third argument.- Returns:
- 1F̃1(a; b; x)
- Throws:
ApfloatRuntimeException
- Since:
- 1.13.0
-
hypergeometric2F1
public static Apfloat hypergeometric2F1(Apfloat a, Apfloat b, Apfloat c, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Hypergeometric function 2F1. Also known as the Gaussian or ordinary hypergeometric function.- Parameters:
a
- The first argument.b
- The second argument.c
- The third argument.x
- The fourth argument.- Returns:
- 2F1(a, b; c; x)
- Throws:
java.lang.ArithmeticException
- If the function value is not finite or real.ApfloatRuntimeException
- Since:
- 1.11.0
-
checkHypergeometric2F1
private static void checkHypergeometric2F1(Apfloat a, Apfloat b, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
- Throws:
java.lang.ArithmeticException
ApfloatRuntimeException
-
hypergeometric2F1Regularized
public static Apfloat hypergeometric2F1Regularized(Apfloat a, Apfloat b, Apfloat c, Apfloat x) throws ApfloatRuntimeException
Regularized hypergeometric function 2F̃1. Also known as the regularized Gaussian or ordinary hypergeometric function.- Parameters:
a
- The first argument.b
- The second argument.c
- The third argument.x
- The fourth argument.- Returns:
- 2F̃1(a, b; c; x)
- Throws:
ApfloatRuntimeException
- Since:
- 1.13.0
-
hypergeometricU
public static Apfloat hypergeometricU(Apfloat a, Apfloat b, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Tricomi's confluent hypergeometric function U. Also known as the confluent hypergeometric function of the second kind.- Parameters:
a
- The first argument.b
- The second argument.x
- The third argument.- Returns:
- U(a, b, x)
- Throws:
java.lang.ArithmeticException
- If the result would be complex or not finite.ApfloatRuntimeException
- Since:
- 1.13.0
-
erf
public static Apfloat erf(Apfloat x) throws ApfloatRuntimeException
Error function.- Parameters:
x
- The argument.- Returns:
- erf(x)
- Throws:
ApfloatRuntimeException
- Since:
- 1.13.0
-
erfFixedPrecision
static Apfloat erfFixedPrecision(Apfloat x) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
erfc
public static Apfloat erfc(Apfloat x) throws ApfloatRuntimeException
Complementary error function.- Parameters:
x
- The argument.- Returns:
- erfc(x)
- Throws:
ApfloatRuntimeException
- Since:
- 1.13.0
-
erfcFixedPrecision
static Apfloat erfcFixedPrecision(Apfloat x) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
erfi
public static Apfloat erfi(Apfloat x) throws ApfloatRuntimeException
Imaginary error function.- Parameters:
x
- The argument.- Returns:
- erfi(x)
- Throws:
ApfloatRuntimeException
- Since:
- 1.13.0
-
erfiFixedPrecision
static Apfloat erfiFixedPrecision(Apfloat x) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
inverseErf
public static Apfloat inverseErf(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Inverse error function.- Parameters:
x
- The argument.- Returns:
- erf−1(x)
- Throws:
java.lang.ArithmeticException
- If|x|
is ≥ 1.ApfloatRuntimeException
- Since:
- 1.13.0
-
inverseErfc
public static Apfloat inverseErfc(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Inverse complementary error function.- Parameters:
x
- The argument.- Returns:
- erfc−1(x)
- Throws:
java.lang.ArithmeticException
- Ifx
is ≤ 0 or ≥ 2.ApfloatRuntimeException
- Since:
- 1.13.0
-
fresnelS
public static Apfloat fresnelS(Apfloat x) throws ApfloatRuntimeException
Fresnel integral S.- Parameters:
x
- The argument.- Returns:
- S(x)
- Throws:
ApfloatRuntimeException
- Since:
- 1.13.0
-
fresnelC
public static Apfloat fresnelC(Apfloat x) throws ApfloatRuntimeException
Fresnel integral C.- Parameters:
x
- The argument.- Returns:
- C(x)
- Throws:
ApfloatRuntimeException
- Since:
- 1.13.0
-
expIntegralE
public static Apfloat expIntegralE(Apfloat ν, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Exponential integral E.- Parameters:
\u03bd
- The first argument.x
- The second argument.- Returns:
- Eν(x)
- Throws:
java.lang.ArithmeticException
- Ifν
is < 0 andx
is zero orν
is nonzero andx
is negative.ApfloatRuntimeException
- Since:
- 1.13.0
-
expIntegralEi
public static Apfloat expIntegralEi(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Exponential integral Ei.- Parameters:
x
- The argument.- Returns:
- Ei(x)
- Throws:
java.lang.ArithmeticException
- Ifx
is zero.ApfloatRuntimeException
- Since:
- 1.13.0
-
logIntegral
public static Apfloat logIntegral(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Logarithmic integral.- Parameters:
x
- The argument.- Returns:
- li(x)
- Throws:
java.lang.ArithmeticException
- Ifx
is nonpositive or 1.ApfloatRuntimeException
- Since:
- 1.13.0
-
sinIntegral
public static Apfloat sinIntegral(Apfloat x) throws ApfloatRuntimeException
Sine integral.- Parameters:
x
- The argument.- Returns:
- Si(x)
- Throws:
ApfloatRuntimeException
- Since:
- 1.13.0
-
cosIntegral
public static Apfloat cosIntegral(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Cosine integral.- Parameters:
x
- The argument.- Returns:
- Ci(x)
- Throws:
java.lang.ArithmeticException
- Ifx
is nonpositive.ApfloatRuntimeException
- Since:
- 1.13.0
-
sinhIntegral
public static Apfloat sinhIntegral(Apfloat x) throws ApfloatRuntimeException
Hyperbolic sine integral.- Parameters:
x
- The argument.- Returns:
- Shi(x)
- Throws:
ApfloatRuntimeException
- Since:
- 1.13.0
-
coshIntegral
public static Apfloat coshIntegral(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Hyperbolic cosine integral.- Parameters:
x
- The argument.- Returns:
- Chi(x)
- Throws:
java.lang.ArithmeticException
- Ifx
is nonpositive.ApfloatRuntimeException
- Since:
- 1.13.0
-
airyAi
public static Apfloat airyAi(Apfloat x) throws ApfloatRuntimeException
Airy function Ai.- Parameters:
x
- The argument.- Returns:
- Ai(x)
- Throws:
InfiniteExpansionException
- Ifx
is zero.ApfloatRuntimeException
- Since:
- 1.13.0
-
airyAi
static Apfloat airyAi(Apfloat x, long precision) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
airyAiPrime
public static Apfloat airyAiPrime(Apfloat x) throws ApfloatRuntimeException
Derivative of the Airy function Ai.- Parameters:
x
- The argument.- Returns:
- Ai′(x)
- Throws:
InfiniteExpansionException
- Ifx
is zero.ApfloatRuntimeException
- Since:
- 1.13.0
-
airyAiPrime
static Apfloat airyAiPrime(Apfloat x, long precision) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
airyBi
public static Apfloat airyBi(Apfloat x) throws ApfloatRuntimeException
Airy function Bi.- Parameters:
x
- The argument.- Returns:
- Bi(x)
- Throws:
InfiniteExpansionException
- Ifx
is zero.ApfloatRuntimeException
- Since:
- 1.13.0
-
airyBi
static Apfloat airyBi(Apfloat x, long precision) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
airyBiPrime
public static Apfloat airyBiPrime(Apfloat x) throws ApfloatRuntimeException
Derivative of the Airy function Bi.- Parameters:
x
- The argument.- Returns:
- Bi′(x)
- Throws:
InfiniteExpansionException
- Ifx
is zero.ApfloatRuntimeException
- Since:
- 1.13.0
-
airyBiPrime
static Apfloat airyBiPrime(Apfloat x, long precision) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
besselJ
public static Apfloat besselJ(Apfloat ν, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Bessel function of the first kind.- Parameters:
\u03bd
- The order.x
- The argument.- Returns:
- Jν(x)
- Throws:
java.lang.ArithmeticException
- Ifν
is < 0 andν
is not an integer andx
is zero. Also ifν
is not an integer andx
is < 0.ApfloatRuntimeException
- Since:
- 1.13.0
-
besselI
public static Apfloat besselI(Apfloat ν, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Modified Bessel function of the first kind.- Parameters:
\u03bd
- The order.x
- The argument.- Returns:
- Iν(x)
- Throws:
java.lang.ArithmeticException
- Ifν
is < 0 andν
is not an integer andx
is zero. Also ifν
is not an integer andx
is < 0.ApfloatRuntimeException
- Since:
- 1.13.0
-
besselY
public static Apfloat besselY(Apfloat ν, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Bessel function of the second kind.- Parameters:
\u03bd
- The order.x
- The argument.- Returns:
- Yν(x)
- Throws:
java.lang.ArithmeticException
- Ifx
is ≤ 0.ApfloatRuntimeException
- Since:
- 1.13.0
-
besselK
public static Apfloat besselK(Apfloat ν, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Modified Bessel function of the second kind.- Parameters:
\u03bd
- The order.x
- The argument.- Returns:
- Kν(x)
- Throws:
java.lang.ArithmeticException
- Ifx
is ≤ 0.ApfloatRuntimeException
- Since:
- 1.13.0
-
ellipticK
public static Apfloat ellipticK(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Complete elliptic integral of the first kind.Note that this function uses the definition:
- Parameters:
x
- The argument.- Returns:
- K(x)
- Throws:
InfiniteExpansionException
- Ifx
is zero.java.lang.ArithmeticException
- Ifx
is ≥ 1.ApfloatRuntimeException
- Since:
- 1.13.0
-
ellipticK
static Apfloat ellipticK(Apfloat x, long precision) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
ellipticE
public static Apfloat ellipticE(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Complete elliptic integral of the second kind.Note that this function uses the definition:
- Parameters:
x
- The argument.- Returns:
- E(x)
- Throws:
InfiniteExpansionException
- Ifx
is zero.java.lang.ArithmeticException
- Ifx
is > 1.ApfloatRuntimeException
- Since:
- 1.13.0
-
ellipticE
static Apfloat ellipticE(Apfloat x, long precision) throws java.lang.ArithmeticException, ApfloatRuntimeException
- Throws:
java.lang.ArithmeticException
ApfloatRuntimeException
-
hermiteH
public static Apfloat hermiteH(Apfloat ν, Apfloat x) throws ApfloatRuntimeException
Hermite function. For integer values ofν
gives the Hermite polynomial.- Parameters:
\u03bd
- The first argument.x
- The second argument.- Returns:
- Hν(x)
- Throws:
ApfloatRuntimeException
- Since:
- 1.14.0
-
laguerreL
public static Apfloat laguerreL(Apfloat ν, Apfloat x) throws ApfloatRuntimeException
Laguerre function. For integer values ofν
gives the Laguerre polynomial.- Parameters:
\u03bd
- The first argument.x
- The second argument.- Returns:
- Lν(x)
- Throws:
ApfloatRuntimeException
- Since:
- 1.14.0
-
laguerreL
public static Apfloat laguerreL(Apfloat ν, Apfloat λ, Apfloat x) throws ApfloatRuntimeException
Generalized Laguerre function. For integer values ofν
gives the generalized Laguerre polynomial.- Parameters:
\u03bd
- The first argument.\u03bb
- The second argument.x
- The third argument.- Returns:
- Lνλ(x)
- Throws:
ApfloatRuntimeException
- Since:
- 1.14.0
-
legendreP
public static Apfloat legendreP(Apfloat ν, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Legendre function. For integer values ofν
gives the Legendre polynomial.- Parameters:
\u03bd
- The first argument.x
- The second argument.- Returns:
- Pν(x)
- Throws:
java.lang.ArithmeticException
- Ifν
is not an integer andx
≤ -1.ApfloatRuntimeException
- Since:
- 1.14.0
-
legendreP
public static Apfloat legendreP(Apfloat ν, Apfloat μ, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Associated Legendre function of the first kind. Gives Legendre functions of type 2.- Parameters:
\u03bd
- The first argument.\u03bc
- The second argument.x
- The third argument.- Returns:
- Pνμ(x)
- Throws:
java.lang.ArithmeticException
- Ifx
is ≤ -1 or ≥ 1 andν
orμ
is not an integer orμ
is not even orμ
is not positive and-μ
≤ν
<μ
.ApfloatRuntimeException
- Since:
- 1.14.0
-
isEven
private static boolean isEven(Apfloat x)
-
legendreQ
public static Apfloat legendreQ(Apfloat ν, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Legendre function of the second kind.- Parameters:
\u03bd
- The first argument.x
- The second argument.- Returns:
- Qν(x)
- Throws:
java.lang.ArithmeticException
- Ifx
is ≥ 1 or ≤ -1.ApfloatRuntimeException
- Since:
- 1.14.0
-
legendreQ
public static Apfloat legendreQ(Apfloat ν, Apfloat μ, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Associated Legendre function of the second kind. Gives Legendre functions of type 2.- Parameters:
\u03bd
- The first argument.\u03bc
- The second argument.x
- The third argument.- Returns:
- Qνμ(x)
- Throws:
java.lang.ArithmeticException
- Ifx
is ≥ 1 or ≤ -1.ApfloatRuntimeException
- Since:
- 1.14.0
-
chebyshevT
public static Apfloat chebyshevT(Apfloat ν, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Chebyshev function of the first kind. For integer values ofν
gives the Chebyshev polynomial of the first kind.- Parameters:
\u03bd
- The first argument.x
- The second argument.- Returns:
- Tν(x)
- Throws:
java.lang.ArithmeticException
- Ifx
is < -1 andν
is not an integer.ApfloatRuntimeException
- Since:
- 1.14.0
-
chebyshevU
public static Apfloat chebyshevU(Apfloat ν, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Chebyshev function of the second kind. For integer values ofν
gives the Chebyshev polynomial of the second kind.- Parameters:
\u03bd
- The first argument.x
- The second argument.- Returns:
- Uν(x)
- Throws:
java.lang.ArithmeticException
- Ifx
is ≤ -1 andν
is not an integer.ApfloatRuntimeException
- Since:
- 1.14.0
-
gegenbauerC
public static Apfloat gegenbauerC(Apfloat ν, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Renormalized Gegenbauer function.- Parameters:
\u03bd
- The first argument.x
- The second argument.- Returns:
- Cν(0)(x)
- Throws:
java.lang.ArithmeticException
- Ifν
is zero. Also ifx
is < -1 andν
is not an integer.ApfloatRuntimeException
- Since:
- 1.14.0
-
gegenbauerC
public static Apfloat gegenbauerC(Apfloat ν, Apfloat λ, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Gegenbauer function. For nonnegative integer values ofν
gives the Gegenbauer polynomial.- Parameters:
\u03bd
- The first argument.\u03bb
- The second argument.x
- The third argument.- Returns:
- Cνλ(x)
- Throws:
java.lang.ArithmeticException
- Ifx
is < -1 andν
is not an integer. Also ifx
is -1 andλ
is > 1/2. Also ifx
is -1 andλ
is 1/2 andν
is not an integer.ApfloatRuntimeException
- Since:
- 1.14.0
-
jacobiP
public static Apfloat jacobiP(Apfloat ν, Apfloat a, Apfloat b, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Jacobi function. For nonnegative integer values ofν
gives the Jacobi polynomial.- Parameters:
\u03bd
- The first argument.a
- The second argument.b
- The third argument.x
- The fourth argument.- Returns:
- Pν(a,b)(x)
- Throws:
java.lang.ArithmeticException
- Ifν
is not a positive integer and eitherx
is -1 andb
is > 0 orx
is < -1. Also ifν + a
is a negative integer andν
is not an integer.ApfloatRuntimeException
- Since:
- 1.14.0
-
fibonacci
public static Apfloat fibonacci(Apfloat ν, Apfloat x) throws ApfloatRuntimeException
Fibonacci function. For nonnegative integer values ofν
gives the Fibonacci polynomial.- Parameters:
\u03bd
- The first argument.x
- The second argument.- Returns:
- Fν(x)
- Throws:
ApfloatRuntimeException
- Since:
- 1.14.0
-
eulerE
public static Apfloat eulerE(long n, Apfloat x) throws java.lang.IllegalArgumentException, ApfloatRuntimeException
Euler polynomial.- Parameters:
n
- The first argument.x
- The second argument.- Returns:
- En(x)
- Throws:
java.lang.IllegalArgumentException
- Ifn
< 0.ApfloatRuntimeException
- Since:
- 1.14.0
-
eulerE
static Apfloat eulerE(long n, Apfloat x, long precision) throws java.lang.IllegalArgumentException, ApfloatRuntimeException
- Throws:
java.lang.IllegalArgumentException
ApfloatRuntimeException
-
bernoulliB
public static Apfloat bernoulliB(long n, Apfloat x) throws java.lang.IllegalArgumentException, ApfloatRuntimeException
Bernoulli polynomial.- Parameters:
n
- The first argument.x
- The second argument.- Returns:
- Bn(x)
- Throws:
java.lang.IllegalArgumentException
- Ifn
< 0.ApfloatRuntimeException
- Since:
- 1.14.0
-
bernoulliB
static Apfloat bernoulliB(long n, Apfloat x, long precision) throws java.lang.IllegalArgumentException, ApfloatRuntimeException
- Throws:
java.lang.IllegalArgumentException
ApfloatRuntimeException
-
harmonicNumber
public static Apfloat harmonicNumber(Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Harmonic number.- Parameters:
x
- The argument.- Returns:
- Hx
- Throws:
java.lang.ArithmeticException
- Ifx
is a negative integer.ApfloatRuntimeException
- Since:
- 1.14.0
-
harmonicNumber
public static Apfloat harmonicNumber(Apfloat x, Apfloat r) throws java.lang.ArithmeticException, ApfloatRuntimeException
Generalized harmonic number.- Parameters:
x
- The first argument.r
- The second argument.- Returns:
- Hx(r)
- Throws:
java.lang.ArithmeticException
- Ifx
is a negative integer, unlessr
is a nonpositive integer. Also ifx
is < -1 andr
is not an integer.ApfloatRuntimeException
- Since:
- 1.14.0
-
polylog
public static Apfloat polylog(Apfloat ν, Apfloat x) throws java.lang.ArithmeticException, ApfloatRuntimeException
Polylogarithm.- Parameters:
\u03bd
- The first argument.x
- The second argument.- Returns:
- Liν(x)
- Throws:
java.lang.ArithmeticException
- Ifν
is ≤ 1 andx
is 1 or ifx
is > 1.ApfloatRuntimeException
- Since:
- 1.14.0
-
logisticSigmoid
public static Apfloat logisticSigmoid(Apfloat x) throws ApfloatRuntimeException
Logistic sigmoid.- Parameters:
x
- The argument.- Returns:
- σ(x)
- Throws:
ApfloatRuntimeException
- Since:
- 1.14.0
-
random
public static Apfloat random(long digits)
Generates a random number. Uses the default radix. Returned values are chosen pseudorandomly with (approximately) uniform distribution from the range0 ≤ x < 1
. The generated random numbers may have leading zeros and may thus not always have exactly the requested number of significant digits. The precision of the numbers is the requested number of digits minus the number of leading zeros. Trailing zeros do not affect the precision.- Parameters:
digits
- Maximum number of digits in the number.- Returns:
- A random number, uniformly distributed between
0 ≤ x < 1
. - Throws:
java.lang.NumberFormatException
- If the default radix is not valid.java.lang.IllegalArgumentException
- In case the number of specified digits is invalid.- Since:
- 1.9.0
-
random
public static Apfloat random(long digits, int radix)
Generates a random number. Returned values are chosen pseudorandomly with (approximately) uniform distribution from the range0 ≤ x < 1
. The generated random numbers may have leading zeros and may thus not always have exactly the requested number of significant digits. The precision of the numbers is the requested number of digits minus the number of leading zeros. Trailing zeros do not affect the precision.- Parameters:
digits
- Maximum number of digits in the number.radix
- The radix in which the number should be generated.- Returns:
- A random number, uniformly distributed between
0 ≤ x < 1
, in baseradix
. - Throws:
java.lang.NumberFormatException
- If the radix is not valid.java.lang.IllegalArgumentException
- In case the number of specified digits is invalid.- Since:
- 1.9.0
-
randomGaussian
public static Apfloat randomGaussian(long digits)
Generates a random, Gaussian ("normally") distributed number value with mean 0 and standard deviation 1. Uses the default radix.- Parameters:
digits
- Maximum number of digits in the number.- Returns:
- A random number, Gaussian ("normally") distributed with mean 0 and standard deviation 1.
- Throws:
java.lang.NumberFormatException
- If the default radix is not valid.java.lang.IllegalArgumentException
- In case the number of specified digits is invalid.- Since:
- 1.9.0
-
randomGaussian
public static Apfloat randomGaussian(long digits, int radix)
Generates a random, Gaussian ("normally") distributed number value with mean 0 and standard deviation 1. Uses the default radix.- Parameters:
digits
- Maximum number of digits in the number.radix
- The radix in which the number should be generated.- Returns:
- A random number, Gaussian ("normally") distributed with mean 0 and standard deviation 1.
- Throws:
java.lang.NumberFormatException
- If the radix is not valid.java.lang.IllegalArgumentException
- In case the number of specified digits is invalid.- Since:
- 1.9.0
-
continuedFraction
public static Apint[] continuedFraction(Apfloat x, int n)
Generates the firstn
terms in the continued fraction representation ofx
.Note that the result length might be less than
n
, depending on the input value and precision. The last terms could be incorrect due to accumulating round-off errors.- Parameters:
x
- The number whose continued fraction terms should be generated.n
- The maximum number of terms to generate.- Returns:
- The continued fraction.
- Throws:
java.lang.IllegalArgumentException
- Ifn
is less than one.- Since:
- 1.12.0
-
convergents
public static Aprational[] convergents(Apfloat x, int n)
Generates the firstn
convergents corresponding to the continued fraction ofx
.Note that the result length might be less than
n
, depending on the input value and precision. The last convergents could be incorrect due to accumulating round-off errors.- Parameters:
x
- The number whose continued fraction convergents should be generated.n
- The maximum number of convergents to generate.- Returns:
- The convergents.
- Throws:
java.lang.IllegalArgumentException
- Ifn
is less than one.- Since:
- 1.12.0
-
max
public static Apfloat max(Apfloat x, Apfloat y)
Returns the greater of the two values.- Parameters:
x
- An argument.y
- Another argument.- Returns:
- The greater of the two values.
- Since:
- 1.9.0
-
min
public static Apfloat min(Apfloat x, Apfloat y)
Returns the smaller of the two values.- Parameters:
x
- An argument.y
- Another argument.- Returns:
- The smaller of the two values.
- Since:
- 1.9.0
-
nextAfter
public static Apfloat nextAfter(Apfloat start, Apfloat direction)
Returns the number adjacent to the first argument in the direction of the second argument, considering the scale and precision of the first argument. If the precision of the first argument is infinite, the first argument is returned. If both arguments compare as equal then the first argument is returned.- Parameters:
start
- The starting value.direction
- Value indicating which ofstart
's neighbors orstart
should be returned.- Returns:
- The number adjacent to
start
in the direction ofdirection
. - Since:
- 1.10.0
-
nextUp
public static Apfloat nextUp(Apfloat x)
Returns the number adjacent to the argument in the direction of positive infinity, considering the scale and precision of the argument. If the precision of the argument is infinite, the argument is returned.- Parameters:
x
- The starting value.- Returns:
- The adjacent value closer to positive infinity.
- Since:
- 1.10.0
-
nextDown
public static Apfloat nextDown(Apfloat x)
Returns the number adjacent to the argument in the direction of negative infinity, considering the scale and precision of the argument. If the precision of the argument is infinite, the argument is returned.- Parameters:
x
- The starting value.- Returns:
- The adjacent value closer to negative infinity.
- Since:
- 1.10.0
-
ulp
public static Apfloat ulp(Apfloat x)
Returns the unit in the last place of the argument, considering the scale and precision. This is same as the difference between the argument and the value returned fromnextUp(Apfloat)
. If the precision of the argument is infinite, zero is returned.For example, ulp of
1.
is1
, ulp of1.1
is0.1
and ulp of1.001
is0.001
(considering significant digits only).- Parameters:
x
- The argument.- Returns:
- The ulp of the argument.
- Since:
- 1.10.0
-
lastIterationExtendPrecision
private static Apfloat lastIterationExtendPrecision(int iterations, int precisingIteration, Apfloat x) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
getRadixKey
private static java.lang.Object getRadixKey(java.util.Map<java.lang.Integer,java.lang.Object> radixKeys, int radix)
-
factorial
static Apfloat factorial(long n, long precision) throws java.lang.ArithmeticException, java.lang.NumberFormatException, ApfloatRuntimeException
- Throws:
java.lang.ArithmeticException
java.lang.NumberFormatException
ApfloatRuntimeException
-
factorial
static Apfloat factorial(long n, long precision, int radix) throws java.lang.ArithmeticException, java.lang.NumberFormatException, ApfloatRuntimeException
- Throws:
java.lang.ArithmeticException
java.lang.NumberFormatException
ApfloatRuntimeException
-
oddProduct
private static Apfloat oddProduct(long n, long m, long precision, int radix) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
doubleFactorial
static Apfloat doubleFactorial(long n, long precision) throws java.lang.ArithmeticException, java.lang.NumberFormatException, ApfloatRuntimeException
- Throws:
java.lang.ArithmeticException
java.lang.NumberFormatException
ApfloatRuntimeException
-
doubleFactorial
static Apfloat doubleFactorial(long n, long precision, int radix) throws java.lang.ArithmeticException, java.lang.NumberFormatException, ApfloatRuntimeException
- Throws:
java.lang.ArithmeticException
java.lang.NumberFormatException
ApfloatRuntimeException
-
cleanUp
static void cleanUp()
-
-