Package org.apfloat

Class ApfloatMath

java.lang.Object
org.apfloat.ApfloatMath

public class ApfloatMath extends 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.13.0
Author:
Mikko Tommila
See Also:
  • Method Details

    • pow

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

      Square root.
      Parameters:
      x - The argument.
      Returns:
      Square root of x.
      Throws:
      ArithmeticException - If x 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 ArithmeticException, ApfloatRuntimeException
      Positive integer root.
      Parameters:
      x - The argument.
      n - Which root to take.
      Returns:
      n:th root of x, that is x1/n.
      Throws:
      ArithmeticException - If n is zero, or x is negative and n is even.
      ApfloatRuntimeException
    • inverseRoot

      public static Apfloat inverseRoot(Apfloat x, long n) throws ArithmeticException, ApfloatRuntimeException
      Inverse positive integer root.
      Parameters:
      x - The argument.
      n - Which inverse root to take.
      Returns:
      Inverse n:th root of x, that is x-1/n.
      Throws:
      ArithmeticException - If x or n is zero, or x is negative and n is even.
      ApfloatRuntimeException
    • inverseRoot

      public static Apfloat inverseRoot(Apfloat x, long n, long targetPrecision) throws IllegalArgumentException, 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 of x, that is x-1/n.
      Throws:
      IllegalArgumentException - If targetPrecision <= 0.
      ArithmeticException - If x or n is zero, or x is negative and n is even.
      ApfloatRuntimeException
    • inverseRoot

      public static Apfloat inverseRoot(Apfloat x, long n, long targetPrecision, Apfloat initialGuess) throws IllegalArgumentException, 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, or null if none is available.
      Returns:
      Inverse n:th root of x, that is x-1/n.
      Throws:
      IllegalArgumentException - If targetPrecision <= 0.
      ArithmeticException - If x or n is zero, or x is negative and n is even.
      ApfloatRuntimeException
    • inverseRoot

      public static Apfloat inverseRoot(Apfloat x, long n, long targetPrecision, Apfloat initialGuess, long initialPrecision) throws IllegalArgumentException, 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) and root(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, or null if none is available.
      initialPrecision - Precision of the initial guess, if available.
      Returns:
      Inverse n:th root of x, that is x-1/n.
      Throws:
      IllegalArgumentException - If targetPrecision <= 0 or initialPrecision <= 0.
      ArithmeticException - If x or n is zero, or x is negative and n 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, RoundingMode roundingMode) throws IllegalArgumentException, 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:
      IllegalArgumentException - If precision is less than zero or zero.
      ArithmeticException - If rounding is necessary (result is not exact) and rounding mode is RoundingMode.UNNECESSARY.
      ApfloatRuntimeException
      Since:
      1.7.0
    • roundToPrecision

      public static Apfloat roundToPrecision(Apfloat x, long precision, RoundingMode roundingMode) throws IllegalArgumentException, 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:
      IllegalArgumentException - If precision is less than zero or zero.
      ArithmeticException - If rounding is necessary (result is not exact) and rounding mode is RoundingMode.UNNECESSARY.
      ApfloatRuntimeException
      Since:
      1.11.0
    • roundToInteger

      public static Apint roundToInteger(Apfloat x, RoundingMode roundingMode) throws IllegalArgumentException, ArithmeticException, ApfloatRuntimeException
      Rounds x to integer using the specified rounding mode.
      Parameters:
      x - The number to round.
      roundingMode - The rounding mode to use.
      Returns:
      The rounded number.
      Throws:
      ArithmeticException - If rounding is necessary (result is not exact) and rounding mode is RoundingMode.UNNECESSARY.
      IllegalArgumentException
      ApfloatRuntimeException
      Since:
      1.11.0
    • roundToPlaces

      public static Apfloat roundToPlaces(Apfloat x, long places, RoundingMode roundingMode) throws IllegalArgumentException, ArithmeticException, ApfloatRuntimeException
      Rounds x 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:
      ArithmeticException - If rounding is necessary (result is not exact) and rounding mode is RoundingMode.UNNECESSARY.
      IllegalArgumentException
      ApfloatRuntimeException
      Since:
      1.11.0
    • roundToMultiple

      public static Apfloat roundToMultiple(Apfloat x, Apfloat y, RoundingMode roundingMode) throws IllegalArgumentException, ArithmeticException, ApfloatRuntimeException
      Rounds x to the nearest multiple of y 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:
      ArithmeticException - If rounding is necessary (result is not exact) and rounding mode is RoundingMode.UNNECESSARY.
      IllegalArgumentException
      ApfloatRuntimeException
      Since:
      1.11.0
    • negate

      @Deprecated public static Apfloat negate(Apfloat x) throws ApfloatRuntimeException
      Deprecated.
      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 of y.
      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 simply i = floor(x). For the fractional part f 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 of x / y such that x = i * y + f, where i is an integer, f has the same sign as x, and the absolute value of f is less than the absolute value of y.

      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. Calculates a * 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 calculating a.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. Calculates a * 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 calculating a.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
    • 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
    • pi

      Calculates π. Uses default radix.
      Parameters:
      precision - Number of digits of π to calculate.
      Returns:
      π accurate to precision digits, in the default radix.
      Throws:
      NumberFormatException - If the default radix is not valid.
      IllegalArgumentException - In case the precision is invalid.
      ApfloatRuntimeException
    • pi

      public static Apfloat pi(long precision, int radix) throws IllegalArgumentException, 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 base radix.
      Throws:
      NumberFormatException - If the radix is not valid.
      IllegalArgumentException - In case the precision is invalid.
      ApfloatRuntimeException
    • log

      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:
      ArithmeticException - If x <= 0.
      ApfloatRuntimeException
    • log

      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 of x.
      Throws:
      ArithmeticException - If x <= 0 or b <= 0.
      ApfloatRuntimeException
      Since:
      1.6
    • 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:
      NumberFormatException - If the radix is invalid.
      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

      Arbitrary power. Calculated using log() and exp().
      Parameters:
      x - The base.
      y - The exponent.
      Returns:
      xy.
      Throws:
      ArithmeticException - If both x and y are zero, or x is negative and y is not an integer.
      ApfloatRuntimeException
    • acosh

      Inverse hyperbolic cosine. Calculated using log().
      Parameters:
      x - The argument.
      Returns:
      Inverse hyperbolic cosine of x.
      Throws:
      ArithmeticException - If x < 1.
      ApfloatRuntimeException
    • asinh

      public static Apfloat asinh(Apfloat x) throws ApfloatRuntimeException
      Inverse hyperbolic sine. Calculated using log().
      Parameters:
      x - The argument.
      Returns:
      Inverse hyperbolic sine of x.
      Throws:
      ApfloatRuntimeException
    • atanh

      Inverse hyperbolic tangent. Calculated using log().
      Parameters:
      x - The argument.
      Returns:
      Inverse hyperbolic tangent of x.
      Throws:
      ArithmeticException - If abs(x) >= 1.
      ApfloatRuntimeException
    • cosh

      public static Apfloat cosh(Apfloat x) throws ApfloatRuntimeException
      Hyperbolic cosine. Calculated using exp().
      Parameters:
      x - The argument.
      Returns:
      Hyperbolic cosine of x.
      Throws:
      ApfloatRuntimeException
    • sinh

      public static Apfloat sinh(Apfloat x) throws ApfloatRuntimeException
      Hyperbolic sine. Calculated using exp().
      Parameters:
      x - The argument.
      Returns:
      Hyperbolic sine of x.
      Throws:
      ApfloatRuntimeException
    • tanh

      public static Apfloat tanh(Apfloat x) throws ApfloatRuntimeException
      Hyperbolic tangent. Calculated using exp().
      Parameters:
      x - The argument.
      Returns:
      Hyperbolic tangent of x.
      Throws:
      ApfloatRuntimeException
    • acos

      Inverse cosine. Calculated using complex functions.
      Parameters:
      x - The argument.
      Returns:
      Inverse cosine of x.
      Throws:
      ArithmeticException - If abs(x) > 1.
      ApfloatRuntimeException
    • asin

      Inverse sine. Calculated using complex functions.
      Parameters:
      x - The argument.
      Returns:
      Inverse sine of x.
      Throws:
      ArithmeticException - If abs(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 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:
      ArithmeticException - If y and x 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

      Tangent. Calculated using complex functions.
      Parameters:
      x - The argument (in radians).
      Returns:
      Tangent of x.
      Throws:
      ArithmeticException - If x is π/2 + n π where n is an integer.
      ApfloatRuntimeException
    • w

      Lambert W function. The W function gives the solution to the equation W 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:
      ArithmeticException - If x 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

      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:
      NumberFormatException - If the default radix is not valid.
      IllegalArgumentException - In case the precision is invalid.
      ApfloatRuntimeException
      Since:
      1.11.0
    • e

      public static Apfloat e(long precision, int radix) throws IllegalArgumentException, 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 base radix.
      Throws:
      NumberFormatException - If the radix is not valid.
      IllegalArgumentException - In case the precision is invalid.
      ApfloatRuntimeException
      Since:
      1.11.0
    • euler

      public static Apfloat euler(long precision) throws IllegalArgumentException, 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:
      NumberFormatException - If the default radix is not valid.
      IllegalArgumentException - In case the precision is invalid.
      ApfloatRuntimeException
      Since:
      1.10.0
    • euler

      public static Apfloat euler(long precision, int radix) throws IllegalArgumentException, 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 base radix.
      Throws:
      NumberFormatException - If the radix is not valid.
      IllegalArgumentException - In case the precision is invalid.
      ApfloatRuntimeException
      Since:
      1.10.0
    • catalan

      public static Apfloat catalan(long precision) throws IllegalArgumentException, 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:
      NumberFormatException - If the default radix is not valid.
      IllegalArgumentException - In case the precision is invalid.
      ApfloatRuntimeException
      Since:
      1.11.0
      Implementation notes:
      This implementation is slow.
    • catalan

      public static Apfloat catalan(long precision, int radix) throws IllegalArgumentException, 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 base radix.
      Throws:
      NumberFormatException - If the radix is not valid.
      IllegalArgumentException - In case the precision is invalid.
      ApfloatRuntimeException
      Since:
      1.11.0
      Implementation notes:
      This implementation is slow.
    • glaisher

      public static Apfloat glaisher(long precision) throws IllegalArgumentException, 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:
      NumberFormatException - If the default radix is not valid.
      IllegalArgumentException - In case the precision is invalid.
      ApfloatRuntimeException
      Since:
      1.11.0
      Implementation notes:
      This implementation is slow. At the time of implementation no efficient algorithm is known for the Glaisher‐Kinkelin constant.
    • glaisher

      public static Apfloat glaisher(long precision, int radix) throws IllegalArgumentException, 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 base radix.
      Throws:
      NumberFormatException - If the radix is not valid.
      IllegalArgumentException - In case the precision is invalid.
      ApfloatRuntimeException
      Since:
      1.11.0
      Implementation notes:
      This implementation is slow. At the time of implementation no efficient algorithm is known for the Glaisher‐Kinkelin constant.
    • khinchin

      public static Apfloat khinchin(long precision) throws IllegalArgumentException, 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:
      NumberFormatException - If the default radix is not valid.
      IllegalArgumentException - In case the precision is invalid.
      ApfloatRuntimeException
      Since:
      1.11.0
      Implementation notes:
      This implementation is slow. At the time of implementation no efficient algorithm is known for Khinchin's constant.
    • khinchin

      public static Apfloat khinchin(long precision, int radix) throws IllegalArgumentException, 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 base radix.
      Throws:
      NumberFormatException - If the radix is not valid.
      IllegalArgumentException - In case the precision is invalid.
      ApfloatRuntimeException
      Since:
      1.11.0
      Implementation notes:
      This implementation is slow. At the time of implementation no efficient algorithm is known for Khinchin's constant.
    • gamma

      Gamma function.

      Parameters:
      x - The argument.
      Returns:
      Γ(x)
      Throws:
      ArithmeticException - If x is a nonpositive integer.
      ApfloatRuntimeException
      Since:
      1.9.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. The asymptotic complexity is at least O(n2log n) and it is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the gamma function.
    • gamma

      public static Apfloat gamma(Apfloat a, Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Incomplete gamma function.

      Parameters:
      a - The first argument.
      x - The second argument.
      Returns:
      Γ(a, x)
      Throws:
      ArithmeticException - If a is not a positive integer and x is nonpositive.
      ApfloatRuntimeException
      Since:
      1.10.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. The asymptotic complexity is at least O(n2log n) and it is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the gamma function.
    • gamma

      public static Apfloat gamma(Apfloat a, Apfloat x0, Apfloat x1) throws 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:
      ArithmeticException - If a is not a positive integer and either x0 or x1 is nonpositive.
      ApfloatRuntimeException
      Since:
      1.10.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. The asymptotic complexity is at least O(n2log n) and it is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the gamma function.
    • logGamma

      public static Apfloat logGamma(Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Logarithm of the gamma function.

      Parameters:
      x - The argument.
      Returns:
      logΓ(x)
      Throws:
      ArithmeticException - If x is nonpositive.
      ApfloatRuntimeException
      Since:
      1.11.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. The asymptotic complexity is at least O(n2log n) and it is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the gamma function.
    • digamma

      public static Apfloat digamma(Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Digamma function.

      Parameters:
      x - The argument.
      Returns:
      ψ(x)
      Throws:
      ArithmeticException - If x is a nonpositive integer.
      ApfloatRuntimeException
      Since:
      1.11.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. The asymptotic complexity is at least O(n2log n) and it is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the digamma function.
    • polygamma

      public static Apfloat polygamma(long n, Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Polygamma function.

      Parameters:
      n - The order.
      x - The argument.
      Returns:
      ψ(n)(x)
      Throws:
      ArithmeticException - If n is negative or x is a nonpositive integer.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. The asymptotic complexity is at least O(n2log n) and it is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the polygamma function.
    • beta

      Beta function.

      Parameters:
      a - The first argument.
      b - The second argument.
      Returns:
      B(a, b)
      Throws:
      ArithmeticException - If a or b is a nonpositive integer but a + b is not. Also if both a and b are nonpositive integers.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. The asymptotic complexity is at least O(n2log n) and it is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the beta function.
    • beta

      Incomplete beta function.

      Parameters:
      x - The first argument.
      a - The second argument.
      b - The third argument.
      Returns:
      Bx(a, b)
      Throws:
      ArithmeticException - If a is a nonpositive integer or x is zero and a is nonpositive or x is negative and a is not an integer. Also if x > 1 and the result is not a polynomial.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. The asymptotic complexity is at least O(n2log n) and it is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • beta

      public static Apfloat beta(Apfloat x1, Apfloat x2, Apfloat a, Apfloat b) throws 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:
      ArithmeticException - If a is a nonpositive integer or x1 or x2 is zero and a is nonpositive or x1 or x2 is negative and a is not an integer. Also if x1 > 1 or x2 > 1 and the result is not a polynomial.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. The asymptotic complexity is at least O(n2log n) and it is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • pochhammer

      public static Apfloat pochhammer(Apfloat x, Apfloat n) throws ArithmeticException, ApfloatRuntimeException
      Pochhammer symbol.

      Parameters:
      x - The first argument.
      n - The second argument.
      Returns:
      (x)n
      Throws:
      ArithmeticException - If x + n is a nonpositive integer but x is not.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. The asymptotic complexity is at least O(n2log n) and it is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the pochhammer symbol.
    • binomial

      public static Apfloat binomial(Apfloat n, Apfloat k) throws ArithmeticException, ApfloatRuntimeException
      Binomial coefficient. Calculated using the gamma(Apfloat) function.
      Parameters:
      n - The first argument.
      k - The second argument.
      Returns:
      ( n k )
      Throws:
      ArithmeticException - If n is a negative integer and k is noninteger.
      ApfloatRuntimeException
      Since:
      1.11.0
    • zeta

      Riemann zeta function.

      Parameters:
      s - The argument.
      Returns:
      ζ(s)
      Throws:
      ArithmeticException - If s is 1.
      ApfloatRuntimeException
      Since:
      1.11.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few hundred digits. At the time of implementation no generic fast algorithm is known for the zeta function.
    • zeta

      Hurwitz zeta function.

      Parameters:
      s - The first argument.
      a - The second argument.
      Returns:
      ζ(s, a)
      Throws:
      ArithmeticException - If s is 1 or if a is a nonpositive integer or if s is not an integer and a is nonpositive.
      ApfloatRuntimeException
      Since:
      1.11.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few hundred digits. At the time of implementation no generic fast algorithm is known for the zeta function.
    • hypergeometric0F1

      public static Apfloat hypergeometric0F1(Apfloat a, Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Confluent hypergeometric function 0F1.

      Parameters:
      a - The first argument.
      x - The second argument.
      Returns:
      0F1(; a; x)
      Throws:
      ArithmeticException - If the function value is not finite.
      ApfloatRuntimeException
      Since:
      1.11.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • hypergeometric0F1Regularized

      public static Apfloat hypergeometric0F1Regularized(Apfloat a, Apfloat x) throws ApfloatRuntimeException
      Regularized confluent hypergeometric function 01.

      Parameters:
      a - The first argument.
      x - The second argument.
      Returns:
      01(; a; x)
      Throws:
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • hypergeometric1F1

      public static Apfloat hypergeometric1F1(Apfloat a, Apfloat b, Apfloat x) throws 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:
      ArithmeticException - If the function value is not finite.
      ApfloatRuntimeException
      Since:
      1.11.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • hypergeometric1F1Regularized

      public static Apfloat hypergeometric1F1Regularized(Apfloat a, Apfloat b, Apfloat x) throws ApfloatRuntimeException
      Regularized Kummer confluent hypergeometric function 11. 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:
      11(a; b; x)
      Throws:
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • hypergeometric2F1

      public static Apfloat hypergeometric2F1(Apfloat a, Apfloat b, Apfloat c, Apfloat x) throws 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:
      ArithmeticException - If the function value is not finite or real.
      ApfloatRuntimeException
      Since:
      1.11.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • hypergeometric2F1Regularized

      public static Apfloat hypergeometric2F1Regularized(Apfloat a, Apfloat b, Apfloat c, Apfloat x) throws ApfloatRuntimeException
      Regularized hypergeometric function 21. 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:
      21(a, b; c; x)
      Throws:
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • hypergeometricU

      public static Apfloat hypergeometricU(Apfloat a, Apfloat b, Apfloat x) throws 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:
      ArithmeticException - If the result would be complex or not finite.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • erf

      public static Apfloat erf(Apfloat x) throws ApfloatRuntimeException
      Error function.

      Parameters:
      x - The argument.
      Returns:
      erf(x)
      Throws:
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • 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
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • 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
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • inverseErf

      public static Apfloat inverseErf(Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Inverse error function.

      Parameters:
      x - The argument.
      Returns:
      erf−1(x)
      Throws:
      ArithmeticException - If |x| is ≥ 1.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • inverseErfc

      public static Apfloat inverseErfc(Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Inverse complementary error function.

      Parameters:
      x - The argument.
      Returns:
      erfc−1(x)
      Throws:
      ArithmeticException - If x is ≤ 0 or ≥ 2.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • 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
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • 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
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • expIntegralE

      public static Apfloat expIntegralE(Apfloat ν, Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Exponential integral E.

      Parameters:
      ν - The first argument.
      x - The second argument.
      Returns:
      Eν(x)
      Throws:
      ArithmeticException - If ν is < 0 and x is zero or ν is nonzero and x is negative.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • expIntegralEi

      public static Apfloat expIntegralEi(Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Exponential integral Ei.

      Parameters:
      x - The argument.
      Returns:
      Ei(x)
      Throws:
      ArithmeticException - If x is zero.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • logIntegral

      public static Apfloat logIntegral(Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Logarithmic integral.

      Parameters:
      x - The argument.
      Returns:
      li(x)
      Throws:
      ArithmeticException - If x is nonpositive or 1.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • sinIntegral

      public static Apfloat sinIntegral(Apfloat x) throws ApfloatRuntimeException
      Sine integral.

      Parameters:
      x - The argument.
      Returns:
      Si(x)
      Throws:
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • cosIntegral

      public static Apfloat cosIntegral(Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Cosine integral.

      Parameters:
      x - The argument.
      Returns:
      Ci(x)
      Throws:
      ArithmeticException - If x is nonpositive.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • 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
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • coshIntegral

      public static Apfloat coshIntegral(Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Hyperbolic cosine integral.

      Parameters:
      x - The argument.
      Returns:
      Chi(x)
      Throws:
      ArithmeticException - If x is nonpositive.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • airyAi

      public static Apfloat airyAi(Apfloat x) throws ApfloatRuntimeException
      Airy function Ai.

      Parameters:
      x - The argument.
      Returns:
      Ai(x)
      Throws:
      InfiniteExpansionException - If x is zero.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • airyAiPrime

      public static Apfloat airyAiPrime(Apfloat x) throws ApfloatRuntimeException
      Derivative of the Airy function Ai.

      Parameters:
      x - The argument.
      Returns:
      Ai′(x)
      Throws:
      InfiniteExpansionException - If x is zero.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • airyBi

      public static Apfloat airyBi(Apfloat x) throws ApfloatRuntimeException
      Airy function Bi.

      Parameters:
      x - The argument.
      Returns:
      Bi(x)
      Throws:
      InfiniteExpansionException - If x is zero.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • airyBiPrime

      public static Apfloat airyBiPrime(Apfloat x) throws ApfloatRuntimeException
      Derivative of the Airy function Bi.

      Parameters:
      x - The argument.
      Returns:
      Bi′(x)
      Throws:
      InfiniteExpansionException - If x is zero.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • besselJ

      public static Apfloat besselJ(Apfloat ν, Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Bessel function of the first kind.

      Parameters:
      ν - The order.
      x - The argument.
      Returns:
      Jν(x)
      Throws:
      ArithmeticException - If ν is < 0 and ν is not an integer and x is zero. Also if ν is not an integer and x is < 0.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • besselI

      public static Apfloat besselI(Apfloat ν, Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Modified Bessel function of the first kind.

      Parameters:
      ν - The order.
      x - The argument.
      Returns:
      Iν(x)
      Throws:
      ArithmeticException - If ν is < 0 and ν is not an integer and x is zero. Also if ν is not an integer and x is < 0.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • besselY

      public static Apfloat besselY(Apfloat ν, Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Bessel function of the second kind.

      Parameters:
      ν - The order.
      x - The argument.
      Returns:
      Yν(x)
      Throws:
      ArithmeticException - If x is ≤ 0.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • besselK

      public static Apfloat besselK(Apfloat ν, Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Modified Bessel function of the second kind.

      Parameters:
      ν - The order.
      x - The argument.
      Returns:
      Kν(x)
      Throws:
      ArithmeticException - If x is ≤ 0.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • ellipticK

      public static Apfloat ellipticK(Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Complete elliptic integral of the first kind.

      Parameters:
      x - The argument.
      Returns:
      K(x)
      Throws:
      InfiniteExpansionException - If x is zero.
      ArithmeticException - If x is ≥ 1.
      ApfloatRuntimeException
      Since:
      1.13.0
    • ellipticE

      public static Apfloat ellipticE(Apfloat x) throws ArithmeticException, ApfloatRuntimeException
      Complete elliptic integral of the second kind.

      Parameters:
      x - The argument.
      Returns:
      E(x)
      Throws:
      InfiniteExpansionException - If x is zero.
      ArithmeticException - If x is > 1.
      ApfloatRuntimeException
      Since:
      1.13.0
      Implementation notes:
      This implementation is slow, meaning that it isn't a fast algorithm. It is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the function.
    • 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 range 0 ≤ 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:
      NumberFormatException - If the default radix is not valid.
      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 range 0 ≤ 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 base radix.
      Throws:
      NumberFormatException - If the radix is not valid.
      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:
      NumberFormatException - If the default radix is not valid.
      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:
      NumberFormatException - If the radix is not valid.
      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 first n terms in the continued fraction representation of x.

      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:
      IllegalArgumentException - If n is less than one.
      Since:
      1.12.0
    • convergents

      public static Aprational[] convergents(Apfloat x, int n)
      Generates the first n convergents corresponding to the continued fraction of x.

      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:
      IllegalArgumentException - If n 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 of start's neighbors or start should be returned.
      Returns:
      The number adjacent to start in the direction of direction.
      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 from nextUp(Apfloat). If the precision of the argument is infinite, zero is returned.

      For example, ulp of 1. is 1, ulp of 1.1 is 0.1 and ulp of 1.001 is 0.001 (considering significant digits only).

      Parameters:
      x - The argument.
      Returns:
      The ulp of the argument.
      Since:
      1.10.0