Built in Functions » History » Revision 2
« Previous |
Revision 2/10
(diff)
| Next »
Federico Vera, 2018-06-09 23:55
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 ofx -
log1p(x): Base 10 logarithm of(x + 1) -
log10(x): Base 10 logarithm ofx -
log2(x): Base 2 logarithm ofx
Misc¶
-
pow(b, e):bto the power ofe -
sqrt(x): Square root ofx -
cbrt(x): Cube root ofx -
exp(x):eto the power ofx -
expm1(x):eto the power ofxminus 1 (e^x - 1) -
signum(x)1: Signum ofx(-1, 0, 1for< 0,= 0and> 0respectively) -
abs(x): Absolute value ofx -
ceil(x): First integer closest to negative infinity greater than or equalx -
floor(x): First integer closest to positive infinity less than or equalx
Constants¶
-
pi(): Ratio of the circumference of a circle to its diameter3.14159265358979323846 -
e(): Base of the natural logarithm2.7182818284590452354
Disabling built-in functions¶
Since version 0.6-riddler (commit) 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.
1 This is the only method not implemented using it's corresponding java.util.Math method.
Updated by Federico Vera over 7 years ago · 10 revisions