Proyecto

General

Perfil

Acciones

Built in Functions

There are a number of built-in functions, that usually just map with the corresponding java.util.Math methods (so all of the same restrictions apply), this functions are:

Trigonometric Functions:

  • sin(x): Sine of an angle expressed in radians
  • cos(x): Cosine of an angle expressed in radians
  • tan(x): Tangent of an angle expressed in radians

Inverse Trigonometric:

  • asin(x): Arc sine in the range [-π/2, π/2)
  • acos(x): Arc cosine in the range [0, π)
  • atan(x): Arc tangent in the range [-π/2, π/2)

Hyperbolic Functions:

  • sinh(x): Hyperbolic sine (e^x - e^(-x)) / 2
  • cosh(x): Hyperbolic cosine (e^x + e^(-x)) / 2
  • tanh(x): Hyperbolic tangent (e^x - e^(-x)) / (e^x + e^(-x))

Logarithms

  • log(x): Base 10 logarithm of x
  • log1p(x): Base 10 logarithm of (x + 1)
  • log10(x): Base 10 logarithm of x
  • log2(x): Base 2 logarithm of x

Misc

  • pow(b, e): b to the power of e
  • sqrt(x): Square root of x
  • cbrt(x): Cube root of x
  • exp(x): e to the power of x
  • expm1(x): e to the power of x minus 1 (e^x - 1)
  • signum(x):Note Signum of x (-1, 0, 1 for < 0, = 0 and > 0 respectively)
  • abs(x): Absolute value of x
  • ceil(x): First integer closest to negative infinity greater than or equal x
  • floor(x): First integer closest to positive infinity less than or equal x

Constants

  • pi(): Ratio of the circumference of a circle to its diameter 3.14159265358979323846
  • e(): Base of the natural logarithm 2.7182818284590452354

Disabling built-in functions

Since version 0.6-riddler (28c731ea) you can disable all built-in functions like this:

    Expression e = new ExpressionBuilder("x + 3")
                      .disableBuiltInFunctions() //<--
                      .variable("x")
                      .build();

Remember that since constants are also defined as functions this will also disable them.

Code

The code for the functions is here.

Tags:

Actualizado por Federico Vera hace más de 6 años · 10 revisiones

Volver al inicio