Class Maths

java.lang.Object
uk.ac.starlink.ttools.func.Maths

public class Maths extends Object
Standard mathematical and trigonometric functions. Trigonometric functions work with angles in radians.
Since:
2 Sep 2004
Author:
Mark Taylor (Starlink)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Euler's number e, the base of natural logarithms.
    static final double
    Positive infinite floating point value.
    static final double
    Not-a-Number floating point value.
    static final double
    Pi, the ratio of the circumference of a circle to its diameter.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    acos(double x)
    Arc cosine of an angle.
    static double
    acosh(double x)
    Inverse hyperbolic cosine.
    static double
    asin(double x)
    Arc sine of an angle.
    static double
    asinh(double x)
    Inverse hyperbolic sine.
    static double
    atan(double x)
    Arc tangent of an angle.
    static double
    atan2(double y, double x)
    Converts rectangular coordinates (x,y) to polar (r,theta).
    static double
    atanh(double x)
    Inverse hyperbolic tangent.
    static double
    cos(double theta)
    Cosine of an angle.
    static double
    cosh(double x)
    Hyperbolic cosine.
    static double
    exp(double x)
    Euler's number e raised to a power.
    static double
    exp10(double x)
    Power of 10.
    static double
    hypot(double... xs)
    Returns the square root of the sum of squares of its arguments.
    static double
    ln(double x)
    Natural logarithm.
    static double
    log10(double x)
    Logarithm to base 10.
    static double
    pow(double a, double b)
    Exponentiation.
    static double
    sin(double theta)
    Sine of an angle.
    static double
    sinh(double x)
    Hyperbolic sine.
    static double
    sqrt(double x)
    Square root.
    static double
    square(double x)
    Raise to the power 2.
    static double
    tan(double theta)
    Tangent of an angle.
    static double
    tanh(double x)
    Hyperbolic tangent.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • E

      public static final double E
      Euler's number e, the base of natural logarithms.
      See Also:
    • PI

      public static final double PI
      Pi, the ratio of the circumference of a circle to its diameter.
      See Also:
    • Infinity

      public static final double Infinity
      Positive infinite floating point value.
      See Also:
    • NaN

      public static final double NaN
      Not-a-Number floating point value. Use with care; arithmetic and logical operations behave in strange ways near NaN (for instance, NaN!=NaN). For most purposes this is equivalent to the blank value.
      See Also:
  • Method Details

    • sin

      public static double sin(double theta)
      Sine of an angle.
      Parameters:
      theta - an angle, in radians.
      Returns:
      the sine of the argument.
    • cos

      public static double cos(double theta)
      Cosine of an angle.
      Parameters:
      theta - an angle, in radians.
      Returns:
      the cosine of the argument.
    • tan

      public static double tan(double theta)
      Tangent of an angle.
      Parameters:
      theta - an angle, in radians.
      Returns:
      the tangent of the argument.
    • asin

      public static double asin(double x)
      Arc sine of an angle. The result is in the range of -pi/2 through pi/2.
      Parameters:
      x - the value whose arc sine is to be returned.
      Returns:
      the arc sine of the argument (radians)
    • acos

      public static double acos(double x)
      Arc cosine of an angle. The result is in the range of 0.0 through pi.
      Parameters:
      x - the value whose arc cosine is to be returned.
      Returns:
      the arc cosine of the argument (radians)
    • atan

      public static double atan(double x)
      Arc tangent of an angle. The result is in the range of -pi/2 through pi/2.
      Parameters:
      x - the value whose arc tangent is to be returned.
      Returns:
      the arc tangent of the argument (radians)
    • ln

      public static double ln(double x)
      Natural logarithm.
      Parameters:
      x - argument
      Returns:
      loge(x)
    • exp

      public static double exp(double x)
      Euler's number e raised to a power.
      Parameters:
      x - the exponent to raise e to.
      Returns:
      the value ex, where e is the base of the natural logarithms.
    • log10

      public static double log10(double x)
      Logarithm to base 10.
      Parameters:
      x - argument
      Returns:
      log10(x)
    • exp10

      public static double exp10(double x)
      Power of 10. This convenience function is identical to pow(10,x).
      Parameters:
      x - argument
      Returns:
      10x
    • sqrt

      public static double sqrt(double x)
      Square root. The result is correctly rounded and positive.
      Parameters:
      x - a value.
      Returns:
      the positive square root of x. If the argument is NaN or less than zero, the result is NaN.
    • square

      public static double square(double x)
      Raise to the power 2.
      Parameters:
      x - a value
      Returns:
      x * x
    • hypot

      public static double hypot(double... xs)
      Returns the square root of the sum of squares of its arguments. In the 2-argument case, doing it like this may avoid intermediate overflow or underflow.
      Parameters:
      xs - one or more numeric values
      Returns:
      sqare root of sum of squares of arguments
      Examples:
      hypot(3,4) = 5, hypot(2,2,2,2) = 4
    • atan2

      public static double atan2(double y, double x)
      Converts rectangular coordinates (x,y) to polar (r,theta). This method computes the phase theta by computing an arc tangent of y/x in the range of -pi to pi.
      Parameters:
      y - the ordinate coordinate
      x - the abscissa coordinate
      Returns:
      the theta component (radians) of the point (r,theta) in polar coordinates that corresponds to the point (x,y) in Cartesian coordinates.
    • pow

      public static double pow(double a, double b)
      Exponentiation. The result is the value of the first argument raised to the power of the second argument.
      Parameters:
      a - the base.
      b - the exponent.
      Returns:
      the value ab.
    • sinh

      public static double sinh(double x)
      Hyperbolic sine.
      Parameters:
      x - parameter
      Returns:
      result
    • cosh

      public static double cosh(double x)
      Hyperbolic cosine.
      Parameters:
      x - parameter
      Returns:
      result
    • tanh

      public static double tanh(double x)
      Hyperbolic tangent.
      Parameters:
      x - parameter
      Returns:
      result
    • asinh

      public static double asinh(double x)
      Inverse hyperbolic sine.
      Parameters:
      x - parameter
      Returns:
      result
    • acosh

      public static double acosh(double x)
      Inverse hyperbolic cosine.
      Parameters:
      x - parameter
      Returns:
      result
    • atanh

      public static double atanh(double x)
      Inverse hyperbolic tangent.
      Parameters:
      x - parameter
      Returns:
      result