Math | Science @ Science @ MentDB Weak

Math
Mathematical functions, expressions (math eval, math calc), symbolic derivative (math diff) and simplification. The expressions accept the operators + - * / ^, the constants pi and e, the session variables [x], the CODATA constants _c, _h, _me... and the special functions (Bessel, gamma, zeta...).

math abs <number>math base_to_base <number> <fromBase> <toBase>math acos <number>math acosh <number>math asin <number>math asinh <number>math atan <number>math atan2 <number1> <number2>math atanh <number>math avg <json_array>math beta <a> <b>math bit_and <number1> <number2>math bit_or <number1> <number2>math bit_xor <number1> <number2>math cbrt <number>math ceil <number>math ceiling <number>math cos <number>math cosh <number>math cot <number>math csc <number>math decimal_format <number> <pattern> <decimalSeparator> <groupingSeparator>math deg_to_rad <number>math emath erf <number>math erf_inv <number>math erfc <number>math eval <expression>math eval <expression> <json_vars>math calc <expression>math diff <expression> <variable>math diff <expression> <variable> <order>math simplify <expression>math exp <number>math expm1 <number>math floor <number>math frac_part <number>math gamma <number>math hypot <number1> <number2>math lngamma <number>math log <number>math log10 <number>math log1p <number>math log_base <number> <base>math max <number1> <number2>math min <number1> <number2>math mod <number1> <number2>math nroot <number> <n>math order_int <jsonArray>math order_long <jsonArray>math order_double <jsonArray>math order_float <jsonArray>math percent <number> <p>math pimath pow <number1> <number2>math power <number1> <number2>math rad_to_deg <number>math random <number>math rint <number>math round <number1> <number2>math round_sig <number> <digits>math round_uncertainty <value> <uncertainty>math sec <number>math sign <number>math signum <number>math sin <number>math sinh <number>math sqrt <number>math tan <number>math tanh <number>math trunc <number>math ulp <number>

math abs <number>


Description

Get the absolute value of a number

Parameters

number: A number - Number - required

Examples (5)
admin
math abs -56
mentdb
56
Absolute value of a decimal number
admin
math abs -3.75
mentdb
3.75
A positive number is unchanged
admin
math abs 12
mentdb
12
Distance between two values on a line: |2.5 - 7|
admin
math abs (math eval "2.5-7")
mentdb
4.5
Absolute error of a measure (9.79) against the reference 9.80665
admin
math abs (math eval "9.79-9.80665")
mentdb
0.016650000000000276

math base_to_base <number> <fromBase> <toBase>


Description

Get a number in another base

Parameters

number: A number - Number - required
fromBase: A number - Number - required
toBase: A number - Number - required

Examples (7)
admin
math base_to_base 3 10 2
mentdb
11
255 in hexadecimal
admin
math base_to_base 255 10 16
mentdb
ff
Binary to decimal
admin
math base_to_base 101101 2 10
mentdb
45
Decimal to binary
admin
math base_to_base 2024 10 2
mentdb
11111101000
Hexadecimal to decimal (color component ff)
admin
math base_to_base ff 16 10
mentdb
255
Octal Unix permissions 755 to binary
admin
math base_to_base 755 8 2
mentdb
111101101
Base 36
admin
math base_to_base 1000000 10 36
mentdb
lfls

math acos <number>


Description

Get the arc cosine of a number

Parameters

number: A number - Number - required

Examples (6)
admin
math acos 42
mentdb
NaN
acos(0.5) = pi/3
admin
math acos 0.5
mentdb
1.0471975511965979
acos(-1) = pi
admin
math acos -1
mentdb
3.141592653589793
acos(1) = 0
admin
math acos 1
mentdb
0
Angle between two unit vectors with a dot product of 0.5, in degrees
admin
math rad_to_deg (math acos 0.5)
mentdb
60.00000000000001
acos(0) = pi/2
admin
math acos 0
mentdb
1.5707963267948966

math acosh <number>


Description

Get the inverse hyperbolic cosine of a number

Parameters

number: A number - Number - required

Examples (5)
admin
math acosh 2
mentdb
1.3169578969248166
acosh(1) = 0
admin
math acosh 1
mentdb
0
acosh(10)
admin
math acosh 10
mentdb
2.993222846126381
Inverse of cosh: acosh(cosh(2)) = 2
admin
math acosh (math cosh 2)
mentdb
2
Below 1: NaN
admin
math acosh 0.5
mentdb
NaN

math asin <number>


Description

Get the arc sine of a number

Parameters

number: A number - Number - required

Examples (6)
admin
math asin 0.5
mentdb
0.5235987755982989
asin(1) = pi/2
admin
math asin 1
mentdb
1.5707963267948966
Outside [-1, 1]: NaN
admin
math asin 2
mentdb
NaN
asin(-0.5) = -pi/6
admin
math asin -0.5
mentdb
-0.5235987755982989
Refraction (Snell): angle in water for 30 degrees in air, n = 1.333, in degrees
admin
math rad_to_deg (math asin (math eval "sin(pi/6)/1.333"))
mentdb
22.030108725578987
asin(0) = 0
admin
math asin 0
mentdb
0

math asinh <number>


Description

Get the inverse hyperbolic sine of a number

Parameters

number: A number - Number - required

Examples (5)
admin
math asinh 1
mentdb
0.8813735870195429
asinh(0) = 0
admin
math asinh 0
mentdb
0
asinh(-2)
admin
math asinh -2
mentdb
-1.4436354751788103
Inverse of sinh
admin
math asinh (math sinh 1.5)
mentdb
1.5
Large x: ln(2x)
admin
math asinh 1e6
mentdb
14.50865773852447

math atan <number>


Description

Get the arc tangent of a number

Parameters

number: A number - Number - required

Examples (6)
admin
math atan 42
mentdb
1.5469913006098266
atan(1) = pi/4
admin
math atan 1
mentdb
0.7853981633974483
atan(-1)
admin
math atan -1
mentdb
-0.7853981633974483
atan(0) = 0
admin
math atan 0
mentdb
0
Slope of 10 % in degrees
admin
math rad_to_deg (math atan 0.1)
mentdb
5.710593137499643
Large x: pi/2
admin
math atan 1e12
mentdb
1.5707963267938967

math atan2 <number1> <number2>


Description

Get the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta)

Parameters

number1: A number - Number - required
number2: A number - Number - required

Examples (6)
admin
math atan2 4 2
mentdb
1.1071487177940904
Angle of the point (x = -1, y = 1): 3*pi/4
admin
math atan2 1 -1
mentdb
2.356194490192345
Angle of the point (0, -2)
admin
math atan2 -2 0
mentdb
-1.5707963267948966
Quadrant 3: the point (-1, -1)
admin
math atan2 -1 -1
mentdb
-2.356194490192345
Phase of the complex number 3+4i, in degrees
admin
math rad_to_deg (math atan2 4 3)
mentdb
53.13010235415598
On the negative x axis: pi
admin
math atan2 0 -1
mentdb
3.141592653589793

math atanh <number>


Description

Get the inverse hyperbolic tangent of a number

Parameters

number: A number - Number - required

Examples (6)
admin
math atanh 0.5
mentdb
0.5493061443340549
atanh(0.9)
admin
math atanh 0.9
mentdb
1.4722194895832204
atanh(0) = 0
admin
math atanh 0
mentdb
0
Inverse of tanh
admin
math atanh (math tanh 0.7)
mentdb
0.7000000000000002
At 1: infinity
admin
math atanh 1
mentdb
Infinity
Outside [-1, 1]: NaN (use math calc for the complex value)
admin
math atanh 2
mentdb
NaN

math avg <json_array>


Description

Get the average of a JSON array of values

Parameters

json_array: A JSON array (of double values) - String - required

Examples (5)
admin
math avg "[10 20]"
mentdb
15.0
Average of measurements
admin
math avg "[9.78, 9.82, 9.80, 9.81]"
mentdb
9.8025
Negative values
admin
math avg "[-2, 4, -6, 8]"
mentdb
1.0
One value
admin
math avg "[42]"
mentdb
42.0
Average of the results of a command
admin
math avg (stat zscore "[1, 2, 3, 4, 5]")
mentdb
4.4408920985006264E-17

math beta <a> <b>


Description

Get the Beta function B(a, b) = Gamma(a).Gamma(b)/Gamma(a+b) (a, b > 0)

Parameters

a: A number > 0 - Number - required
b: A number > 0 - Number - required

Examples (5)
admin
math beta 2 3
mentdb
0.08333333333333333
B(0.5, 0.5) = pi
admin
math beta 0.5 0.5
mentdb
3.1415926535897936
B(1, 4) = 1/4
admin
math beta 1 4
mentdb
0.25
Symmetry: B(a, b) = B(b, a)
admin
math beta 4 1
mentdb
0.25
Large arguments
admin
math beta 50 60
mentdb
5.84256439064177E-34

math bit_and <number1> <number2>


Description

The bitwise AND operation

Parameters

number1: A number - Number - required
number2: A number - Number - required

Examples (4)
admin
math bit_and 4456 234
mentdb
104
Mask the 4 low bits of 0b10111011 (187)
admin
math bit_and 187 15
mentdb
11
Is the number even? (n AND 1 = 0)
admin
math bit_and 1234 1
mentdb
0
Network mask: 192 AND 255
admin
math bit_and 192 255
mentdb
192

math bit_or <number1> <number2>


Description

The bitwise OR operation

Parameters

number1: A number - Number - required
number2: A number - Number - required

Examples (4)
admin
math bit_or 4456 234
mentdb
4586
Set the bit 3 of 5
admin
math bit_or 5 8
mentdb
13
Combine flags 1, 2 and 8
admin
math bit_or (math bit_or 1 2) 8
mentdb
11
Same bits: no change
admin
math bit_or 12 12
mentdb
12

math bit_xor <number1> <number2>


Description

The bitwise XOR operation

Parameters

number1: A number - Number - required
number2: A number - Number - required

Examples (4)
admin
math bit_xor 4456 234
mentdb
4482
XOR twice gives the value back
admin
math bit_xor (math bit_xor 1234 999) 999
mentdb
1234
Bits that differ between 12 (1100) and 10 (1010)
admin
math bit_xor 12 10
mentdb
6
XOR with itself = 0
admin
math bit_xor 255 255
mentdb
0

math cbrt <number>


Description

Returns the cube root of a double value

Parameters

number: A number - Number - required

Examples (5)
admin
math cbrt 42
mentdb
3.4760266448864496
Cube root of a negative number
admin
math cbrt -27
mentdb
-3
Side of a cube of 2 m3
admin
math cbrt 2
mentdb
1.2599210498948732
Perfect cube
admin
math cbrt 1000
mentdb
10
Radius of a sphere of 1 L (4/3 pi r^3 = 0.001 m3), in m
admin
math cbrt (math eval "0.001*3/(4*pi)")
mentdb
0.06203504908994

math ceil <number>


Description

Get the smallest integer value not less than the number specified as argument

Parameters

number: A number - Number - required

Examples (5)
admin
math ceil 1.2
mentdb
2
Negative numbers go toward 0
admin
math ceil -1.2
mentdb
-1
Number of boxes of 12 for 50 items (50/12 = 4.17)
admin
math ceil 4.17
mentdb
5
An integer is unchanged
admin
math ceil 5
mentdb
5
Small decimals
admin
math ceil 0.0001
mentdb
1

math ceiling <number>


Description

Get the smallest integer value not less than the number specified as argument

Parameters

number: A number - Number - required

Examples (4)
admin
math ceiling 1.2
mentdb
2
Same as math ceil
admin
math ceiling 7.0001
mentdb
8
Negative number
admin
math ceiling -7.9
mentdb
-7
Number of buses of 50 seats for 437 people
admin
math ceiling (math eval "437/50")
mentdb
9

math cos <number>


Description

Get the cosine of a number

Parameters

number: A number - Number - required

Examples (7)
admin
math cos 42
mentdb
-0.39998531498835127
cos(0) = 1
admin
math cos 0
mentdb
1
cos(pi) = -1
admin
math cos (math pi)
mentdb
-1
The angle is in radians: 60 degrees
admin
math cos (math deg_to_rad 60)
mentdb
0.5000000000000001
cos(pi/2): almost 0 (rounding of pi)
admin
math cos 1.5707963267948966
mentdb
6.123233995736766E-17
Horizontal component of a force of 100 N at 30 degrees
admin
math eval "100*cos(30)" "{\"_angle\": \"deg\"}"
mentdb
86.60254037844388
Periodicity: cos(2 pi) = 1
admin
math cos (math eval "2*pi")
mentdb
1

math cosh <number>


Description

Get the hyperbolic cosine of a number

Parameters

number: A number - Number - required

Examples (5)
admin
math cosh 42
mentdb
8.696374707602505E17
cosh(0) = 1
admin
math cosh 0
mentdb
1
cosh(1)
admin
math cosh 1
mentdb
1.543080634815244
Catenary: height of a chain y = a cosh(x/a) for a = 2, x = 1
admin
math eval "2*cosh(1/2)"
mentdb
2.2552519304127614
Even function: cosh(-1) = cosh(1)
admin
math cosh -1
mentdb
1.543080634815244

math cot <number>


Description

Get the cotangent of a number

Parameters

number: A number - Number - required

Examples (4)
admin
math cot 42
mentdb
0.4364167060752729
cot(pi/4) = 1
admin
math cot 0.7853981633974483
mentdb
1.0000000000000002
cot(pi/2) = 0 (almost)
admin
math cot 1.5707963267948966
mentdb
6.123233995736766E-17
cot(1) = 1/tan(1)
admin
math cot 1
mentdb
0.6420926159343306

math csc <number>


Description

Get the cosecant (1/sin) of a number

Parameters

number: A number - Number - required

Examples (4)
admin
math csc 1.5707963267948966
mentdb
1
csc(pi/6) = 2
admin
math csc 0.5235987755982988
mentdb
2.0000000000000004
csc(1) = 1/sin(1)
admin
math csc 1
mentdb
1.1883951057781212
csc(0): infinite
admin
math csc 0
mentdb
Infinity

math decimal_format <number> <pattern> <decimalSeparator> <groupingSeparator>


Description

Convert a number to another formatted decimal number

Parameters

number: A number - Number - required
pattern: The pattern - String - required
decimalSeparator: The decimal separator - String - required
groupingSeparator: The grouping separator - String - required

Examples (7)
admin
math decimal_format 42.456 "##.##" "." " "
mentdb
42.46
Thousands separator and 2 decimals
admin
math decimal_format 1234567.891 "#,##0.00" "," " "
mentdb
1 234 567,89
Percentage
admin
math decimal_format 0.256 "0.0%" "." ","
mentdb
25.6%
Fixed 3 decimals
admin
math decimal_format 3.14159 "0.000" "." ","
mentdb
3.142
Leading zeros
admin
math decimal_format 42 "00000" "." ","
mentdb
00042
Scientific notation
admin
math decimal_format 0.000123456 "0.00E0" "." ","
mentdb
1.23E-4
Currency with a French separator
admin
math decimal_format 1234.5 "#,##0.00 EUR" "," " "
mentdb
1 234,50 EUR

math deg_to_rad <number>


Description

Converts an angle measured in degrees to an approximately equivalent angle measured in radians

Parameters

number: A number - Number - required

Examples (6)
admin
math deg_to_rad 42
mentdb
0.7330382858376184
180 degrees = pi radians
admin
math deg_to_rad 180
mentdb
3.141592653589793
90 degrees
admin
math deg_to_rad 90
mentdb
1.5707963267948966
Full turn: 2 pi
admin
math deg_to_rad 360
mentdb
6.283185307179586
Negative angle
admin
math deg_to_rad -45
mentdb
-0.7853981633974483
1 degree
admin
math deg_to_rad 1
mentdb
0.017453292519943295

math e


Description

Get the approximate value of Euler's number.

Examples (4)
admin
math e
mentdb
2.718281828459045
e^2 with math pow
admin
math pow (math e) 2
mentdb
7.3890560989306495
ln(e) = 1
admin
math log (math e)
mentdb
1
Continuous compounding: 1000 at 5 % for 10 years
admin
math eval "1000*e^(0.05*10)"
mentdb
1648.7212707001281

math erf <number>


Description

Get the error function erf(x)

Parameters

number: A number - Number - required

Examples (6)
admin
math erf 1
mentdb
0.8427007929497151
erf(0) = 0
admin
math erf 0
mentdb
0
Probability that a normal value is within 2 standard deviations: erf(2/sqrt(2))
admin
math erf 1.4142135623730951
mentdb
0.9544997361036417
Odd function: erf(-1) = -erf(1)
admin
math erf -1
mentdb
-0.8427007929497151
Large x: 1
admin
math erf 5
mentdb
0.9999999999984626
Normal law: P(-1 < Z < 1) = erf(1/sqrt(2))
admin
math erf 0.7071067811865476
mentdb
0.6826894921370861

math erf_inv <number>


Description

Get the inverse error function (x in ]-1, 1[)

Parameters

number: A number - Number - required

Examples (6)
admin
math erf_inv 0.5
mentdb
0.47693627620446977
Inverse of erf(1)
admin
math erf_inv 0.8427007929497149
mentdb
0.9999999999999998
erf_inv(0) = 0
admin
math erf_inv 0
mentdb
0
erf_inv(-0.5)
admin
math erf_inv -0.5
mentdb
-0.47693627620446977
Close to 1
admin
math erf_inv 0.999999
mentdb
3.458910737275499
Outside ]-1, 1[
admin
math erf_inv 1.5
mentdb
Sorry, an error appears (erf_inv is defined for x in ]-1, 1[).

math erfc <number>


Description

Get the complementary error function erfc(x) = 1 - erf(x)

Parameters

number: A number - Number - required

Examples (6)
admin
math erfc 1
mentdb
0.15729920705028488
erfc(3): no cancellation for the small values
admin
math erfc 3
mentdb
2.2090496998585448E-5
erfc(0) = 1
admin
math erfc 0
mentdb
1
erfc(x) = 1 - erf(x)
admin
math erfc 0.5
mentdb
0.47950012218695337
Negative x: up to 2
admin
math erfc -2
mentdb
1.9953222650189528
Very small values without underflow
admin
math erfc 10
mentdb
2.0884875837625685E-45

math eval <expression>


Description

Evaluate a mathematical expression.
Expression syntax (also used by the 'num' functions):
- operators: + - * / ^ (or **), parentheses; ^ is right associative (2^3^2 = 512) and -x^2 = -(x^2)
- numbers: 12, 1.5, .5, 1e-3; constants: pi, e
- functions: sin cos tan sec csc cot asin acos atan sinh cosh tanh asinh acosh atanh (radians), exp expm1 ln (natural) log log10 (base 10) log1p sqrt cbrt abs floor ceil round sign deg_to_rad rad_to_deg, atan2(y,x) pow(x,y) hypot(x,y) min(a,b) max(a,b) mod(a,b) log_base(x,b)
- parts of a complex number (math calc): re im arg conj; special functions (see the page Special functions): bessel_j bessel_y bessel_i bessel_k sph_bessel_j sph_bessel_y legendre assoc_legendre hermite laguerre chebyshev_t chebyshev_u gamma lgamma digamma polygamma beta gamma_inc gamma_incc beta_inc erf erfc erf_inv zeta
- variables: names made of letters, digits and _ (case sensitive); the multiplication must be written (2*x, not 2x)
- the expressions are compiled once and kept in a cache

Parameters

expression: The expression - String - required

Examples (14)
admin
math eval "2+3*4"
mentdb
14
admin
math eval "sqrt(16)+2^10"
mentdb
1028
Operator precedence and powers
admin
math eval "2^3^2"
mentdb
512
Functions and constants
admin
math eval "sqrt(2)*sin(pi/4)"
mentdb
1
Special functions
admin
math eval "gamma(0.5)^2"
mentdb
3.1415926535897936
Scientific notation
admin
math eval "6.022e23*1.5e-3"
mentdb
9.033E20
Parentheses
admin
math eval "(1+2)*(3+4)"
mentdb
21
Unary minus and power: -2^2 = -4
admin
math eval "-2^2"
mentdb
-4
Logarithms: ln, log (base 10), log_base
admin
math eval "ln(e^3)+log(1000)+log_base(8, 2)"
mentdb
9
Hyperbolic functions
admin
math eval "cosh(1)^2-sinh(1)^2"
mentdb
1.0000000000000007
CODATA constants (with math calc): energy of 1 mol of photons of 500 nm in J
admin
math calc "_NA*_h*_c/500e-9"
mentdb
239253.13127739402
Rounding functions
admin
math eval "floor(2.7)+ceil(2.1)+round(2.5)"
mentdb
7
Golden ratio
admin
math eval "(1+sqrt(5))/2"
mentdb
1.618033988749895
Error: unknown function
admin
math eval "foo(2)"
mentdb
Sorry, an error appears (unknown function 'foo' at position 1 in 'foo(2)').

math eval <expression> <json_vars>


Description

Evaluate a mathematical expression with variables (JSON object of numbers).
See 'math eval expression' for the syntax.
Option "_angle": "rad" (default), "deg" or "grad": unit of sin, cos, tan, sec, csc, cot (argument) and of asin, acos, atan, atan2 (result). In degrees and grads, the remarkable angles give exact values (sin 30 = 0.5, tan 45 = 1).

Parameters

expression: The expression - String - required
json_vars: A JSON object: the value of each variable - String - required

Examples (11)
admin
math eval "a*x^2+b" "{\"a\": 2, \"x\": 3, \"b\": 1}"
mentdb
19
admin
math eval "sin(30)+asin(0.5)" "{\"_angle\": \"deg\"}"
mentdb
30.5
Kinetic energy E = m v^2 / 2
admin
math eval "m*v^2/2" "{\"m\": 1200, \"v\": 27.8}"
mentdb
463704
Angles in degrees with the option _angle
admin
math eval "sin(a)^2+cos(a)^2" "{\"a\": 30, \"_angle\": \"deg\"}"
mentdb
1
Pendulum period T = 2 pi sqrt(L/g)
admin
math eval "2*pi*sqrt(L/g)" "{\"L\": 0.75, \"g\": 9.81}"
mentdb
1.7373047071809469
Ideal gas: pressure p = nRT/V in Pa (R written as a variable)
admin
math eval "n*R*T/V" "{\"n\": 2, \"R\": 8.314462618, \"T\": 300, \"V\": 0.05}"
mentdb
99773.551416
Compound interest
admin
math eval "C*(1+r)^n" "{\"C\": 1000, \"r\": 0.04, \"n\": 10}"
mentdb
1480.2442849183444
Body mass index
admin
math eval "m/h^2" "{\"m\": 72, \"h\": 1.78}"
mentdb
22.724403484408533
Several variables with special functions
admin
math eval "bessel_j(n, k*r)" "{\"n\": 1, \"k\": 2.405, \"r\": 0.8}"
mentdb
0.5804625562292492
Angle unit grad
admin
math eval "sin(x)" "{\"x\": 100, \"_angle\": \"grad\"}"
mentdb
1
Error: a variable has no value
admin
math eval "a*x+b" "{\"a\": 2, \"x\": 3}"
mentdb
Sorry, an error appears (the variable 'b' is not defined).

math calc <expression>


Description

Calculator: evaluate a mathematical expression with the session variables (used by the CALC tab of the editor).
See 'math eval expression' for the syntax.
- the session variables are written like in MQL: [x], [var1]; they must contain a number: -> "[r]" 2; math calc "pi*[r]^2"
- a name _c, _h, _me... is a CODATA constant (see 'const list'); pi and e are the mathematical constants
- the session variable [_angle] gives the unit of the trigonometric functions: rad (default), deg or grad
- the result is also stored in the session variable [ans], so the next calculation can use [ans]
- complex numbers: i is the imaginary unit (3+4i, (1+2i)*(3-i), exp(i*pi)), with re, im, abs, arg, conj; an expression without a real value gives its complex value (sqrt(-4) = 2i, ln(-1) = 3.141592653589793i), as Python cmath
- the session variable [_format] gives the display format: auto (default), fix n (n decimals), sci n (n significant digits, 1.235E-4), eng n (exponent multiple of 3, 123.5E-6); [ans] keeps all the digits

Parameters

expression: The expression - String - required

Examples (25)
admin
math calc "sqrt(16)+2^10"
mentdb
1028
admin
math calc "[ans]/4"
mentdb
257
Complex numbers: i is the imaginary unit
admin
math calc "(3+4i)*(1-2i)"
mentdb
11-2i
No real value: the complex value (as Python cmath)
admin
math calc "sqrt(-4)"
mentdb
2i
Euler identity
admin
math calc "exp(i*pi)"
mentdb
-1
Impedance of R = 100 ohm, L = 0.1 H at 50 Hz: modulus
admin
-> "[Z]" (math calc "100+2*3.141592653589793*50*0.1i"); math calc "abs([Z])"
mentdb
104.81870272097883
Display format: 4 significant digits
admin
-> "[_format]" "sci 4"; math calc "_h*_c/500e-9"
mentdb
3.973E-19
Display format: 2 decimals
admin
-> "[_format]" "fix 2"; math calc "1234567.891"
mentdb
1234567.89
Back to the full display
admin
-> "[_format]" "auto"; -> "[_angle]" "rad"; math calc "[ans]"
mentdb
1234567.891
With session variables
admin
-> "[r]" 0.5; math calc "pi*[r]^2"
mentdb
0.7853981633974483
With CODATA constants: energy of a photon of 500 nm in J
admin
math calc "_h*_c/500e-9"
mentdb
3.972891714297857E-19
The last result is in [ans]
admin
math calc "2^10"; math calc "[ans]/4"
mentdb
256
Complex modulus and argument (radians)
admin
math calc "abs(1+i)"
mentdb
1.4142135623730951
Argument of -1 in degrees
admin
-> "[_angle]" "deg"; math calc "arg(-1)"
mentdb
180
Back to radians
admin
-> "[_angle]" "rad"; math calc "arg(i)"
mentdb
1.5707963267948966
Real and imaginary parts
admin
math calc "re((1+2i)^2)+im((1+2i)^2)"
mentdb
1
Conjugate: z * conj(z) = |z|^2
admin
math calc "(3+4i)*conj(3+4i)"
mentdb
25
Square roots of a negative number
admin
math calc "sqrt(-2)"
mentdb
1.4142135623730951i
Logarithm of a negative number
admin
math calc "ln(-10)"
mentdb
2.302585092994046+3.141592653589793i
Complex power
admin
math calc "(1+i)^10"
mentdb
32i
i^i is a real number
admin
math calc "i^i"
mentdb
0.20787957635076193
Engineering format: exponent multiple of 3
admin
-> "[_format]" "eng 3"; math calc "0.000123456"
mentdb
123E-6
Format of a complex result
admin
-> "[_format]" "fix 3"; math calc "exp(i)"
mentdb
0.540+0.841i
Back to the full display
admin
-> "[_format]" "auto"; math calc "exp(i)"
mentdb
0.5403023058681398+0.8414709848078965i
Store a result in a session variable, then use it
admin
-> "[v0]" (math calc "sqrt(2*_g0*20)"); math calc "[v0]*3.6"
mentdb
71.30054249442986

math diff <expression> <variable>


Description

Symbolic derivative of an expression with respect to a variable (the result is an expression, simplified).
- same syntax as 'math eval', with the special functions; the other variables, the session variables [a] and the constants _c, pi, e stay as symbols
- the trigonometric functions are in radians
- the parameters of the special functions (order of bessel_j, degree of legendre...) must not depend on the variable; zeta, min and max have no derivative rule (use 'num derivative' for a value)

Parameters

expression: The expression - String - required
variable: The variable, ex: x, t, [v] - String - required

Examples (13)
admin
math diff "x^2*sin(x)" "x"
mentdb
2*x*sin(x) + x^2*cos(x)
admin
math diff "a*exp(-k*t)" "t"
mentdb
-a*k*exp(-k*t)
Chain rule
admin
math diff "sin(x^2)" "x"
mentdb
2*x*cos(x^2)
Quotient
admin
math diff "x/(x^2+1)" "x"
mentdb
1/(x^2 + 1) - 2*x^2/(x^2 + 1)^2
With other symbols and the constants
admin
math diff "a*exp(-k*t)*cos(w*t)" "t"
mentdb
-a*k*exp(-k*t)*cos(w*t) - a*w*exp(-k*t)*sin(w*t)
Special functions
admin
math diff "bessel_j(0, k*r)" "r"
mentdb
-k*bessel_j(1, k*r)
Power with a variable exponent
admin
math diff "x^x" "x"
mentdb
x^x*(ln(x) + 1)
Logarithm
admin
math diff "ln(x^2+1)" "x"
mentdb
2*x/((x^2 + 1))
Inverse trigonometric function
admin
math diff "atan(x)" "x"
mentdb
1/(x^2 + 1)
Velocity from a position x(t)
admin
math diff "5*t^2+2*t+1" "t"
mentdb
10*t + 2
Partial derivative with respect to y
admin
math diff "x^2*y+y^3" "y"
mentdb
x^2 + 3*y^2
Square root
admin
math diff "sqrt(1-x^2)" "x"
mentdb
-x/sqrt(1 - x^2)
Error function (Gaussian)
admin
math diff "erf(x)" "x"
mentdb
2*exp(-x^2)/sqrt(pi)

math diff <expression> <variable> <order>


Description

Symbolic derivative of order n (0 to 20) of an expression with respect to a variable

Parameters

expression: The expression - String - required
variable: The variable, ex: x, t, [v] - String - required
order: The order of the derivative (integer from 0 to 20) - Number - required

Examples (7)
admin
math diff "exp(-x^2)" "x" 2
mentdb
-2*exp(-x^2) + 4*x^2*exp(-x^2)
admin
math diff "x^5" "x" 3
mentdb
60*x^2
Second derivative of the Gaussian
admin
math diff "exp(-x^2/2)" "x" 2
mentdb
-exp(-x^2/2) + x^2*exp(-x^2/2)
Third derivative of a polynomial
admin
math diff "x^5-3*x^2" "x" 3
mentdb
60*x^2
Acceleration from a position
admin
math diff "5*t^3-2*t" "t" 2
mentdb
30*t
Fourth derivative of sin: sin
admin
math diff "sin(x)" "x" 4
mentdb
sin(x)
Order 0: the expression
admin
math diff "x^2+1" "x" 0
mentdb
x^2 + 1

math simplify <expression>


Description

Simplify an expression: numbers computed, like terms and powers of the same base grouped (x+x = 2*x, x^2*x = x^3), x^0 = 1, x^1 = x, 0*x = 0...
No trigonometric identity and no factorization: the form stays close to the expression given

Parameters

expression: The expression - String - required

Examples (8)
admin
math simplify "x+x+2*x"
mentdb
4*x
admin
math simplify "x^2*x/x^3+0*y"
mentdb
1
Like powers
admin
math simplify "x^2*x^3/x"
mentdb
x^4
Numbers and like terms
admin
math simplify "2*x+3+x-1"
mentdb
3*x + 2
Multiplication by 1 and addition of 0
admin
math simplify "1*x+0"
mentdb
x
Constant folding
admin
math simplify "2*3*x+4/2"
mentdb
6*x + 2
Same terms with a coefficient
admin
math simplify "3*x^2-x^2"
mentdb
2*x^2
A derivative made simpler
admin
math simplify (math diff "x^3+2*x" "x")
mentdb
3*x^2 + 2

math exp <number>


Description

Returns Euler's number e raised to the power of a double value

Parameters

number: A number - Number - required

Examples (7)
admin
math exp 42
mentdb
1.739274941520501E18
exp(1) = e
admin
math exp 1
mentdb
2.718281828459045
Radioactive decay: fraction left after 2 half-lives, exp(-2 ln 2)
admin
math exp -1.3862943611198906
mentdb
0.25
exp(0) = 1
admin
math exp 0
mentdb
1
Inverse of ln
admin
math exp (math log 5)
mentdb
4.999999999999999
Very negative: 0 (underflow)
admin
math exp -800
mentdb
0
Population growth: N0 = 100, r = 0.3 per hour, after 10 h
admin
math eval "100*exp(0.3*10)"
mentdb
2008.5536923187667

math expm1 <number>


Description

Returns e^x - 1

Parameters

number: A number - Number - required

Examples (5)
admin
math expm1 42
mentdb
1.739274941520501E18
Small x: exp(x) - 1 without cancellation
admin
math expm1 1e-10
mentdb
1.00000000005E-10
expm1(0) = 0
admin
math expm1 0
mentdb
0
expm1(1) = e - 1
admin
math expm1 1
mentdb
1.718281828459045
Negative values
admin
math expm1 -1e-8
mentdb
-9.999999950000001E-9

math floor <number>


Description

Get the largest integer value not greater than the number specified as argument

Parameters

number: A number - Number - required

Examples (4)
admin
math floor 1.2
mentdb
1
Negative numbers go away from 0
admin
math floor -1.2
mentdb
-2
An integer is unchanged
admin
math floor 3
mentdb
3
Number of whole hours in 200 minutes
admin
math floor (math eval "200/60")
mentdb
3

math frac_part <number>


Description

Get the fractional part x - trunc(x), same sign as x (computed in decimal)

Parameters

number: A number - Number - required

Examples (4)
admin
math frac_part 3.14
mentdb
0.14
Fractional part of a negative number
admin
math frac_part -2.75
mentdb
-0.75
An integer: 0
admin
math frac_part 8
mentdb
0
Decimal part of a duration of 2.25 h
admin
math frac_part 2.25
mentdb
0.25

math gamma <number>


Description

Get the Gamma function (gamma(n) = (n-1)! for the integers, exact up to 171). Not defined for 0 and the negative integers.

Parameters

number: A number - Number - required

Examples (6)
admin
math gamma 5
mentdb
24
gamma(0.5) = sqrt(pi)
admin
math gamma 0.5
mentdb
1.772453850905516
gamma(n+1) = n!
admin
math gamma 11
mentdb
3628800
gamma(1) = 1
admin
math gamma 1
mentdb
1
Half integers: gamma(2.5) = 3 sqrt(pi)/4
admin
math gamma 2.5
mentdb
1.329340388179137
Poles: 0, -1, -2...
admin
math gamma -2
mentdb
Sorry, an error appears (the Gamma function is not defined for 0 and the negative integers).

math hypot <number1> <number2>


Description

Returns sqrt(x^2 + y^2) without intermediate overflow or underflow

Parameters

number1: A number - Number - required
number2: A number - Number - required

Examples (4)
admin
math hypot 4456 234
mentdb
4462.139845410496
Hypotenuse of the triangle 3-4-5
admin
math hypot 3 4
mentdb
5
No overflow for large values
admin
math hypot 1e200 1e200
mentdb
1.414213562373095E200
Modulus of an impedance R = 100, X = 31.4
admin
math hypot 100 31.4
mentdb
104.81393037187375

math lngamma <number>


Description

Get the natural logarithm of the Gamma function (x > 0)

Parameters

number: A number - Number - required

Examples (4)
admin
math lngamma 100
mentdb
359.1342053695754
ln(1000!) without overflow
admin
math lngamma 1001
mentdb
5912.128178488163
ln(gamma(5)) = ln(24)
admin
math lngamma 5
mentdb
3.1780538303479458
Combinations C(1000, 500) in logarithm
admin
math eval "lgamma(1001)-2*lgamma(501)"
mentdb
689.467261567851

math log <number>


Description

Get the natural logarithm of the argument

Parameters

number: A number - Number - required

Examples (6)
admin
math log 42
mentdb
3.7376696182833684
Natural logarithm: log(e) = 1
admin
math log 2.718281828459045
mentdb
1
log(1) = 0
admin
math log 1
mentdb
0
Negative number: NaN
admin
math log -1
mentdb
NaN
0: -infinity
admin
math log 0
mentdb
-Infinity
Half-life from a rate constant k = 0.1 per s
admin
math eval "ln(2)/0.1"
mentdb
6.931471805599452

math log10 <number>


Description

Get the base 10 logarithm of the argument

Parameters

number: A number - Number - required

Examples (6)
admin
math log10 42
mentdb
1.6232492903979006
log10(1000) = 3
admin
math log10 1000
mentdb
3
Decibels: 10 log10(P2/P1) for a power ratio of 2
admin
math log10 2
mentdb
0.3010299956639812
pH of a solution [H+] = 3.2e-5 mol/L
admin
math eval "-log10(3.2e-5)"
mentdb
4.494850021680094
Sound level of 1e-5 W/m2 in dB
admin
math eval "10*log10(1e-5/1e-12)"
mentdb
70
Number of digits of 123456: floor(log10) + 1
admin
math eval "floor(log10(123456))+1"
mentdb
6

math log1p <number>


Description

Returns the natural logarithm of the sum of the argument and 1

Parameters

number: A number - Number - required

Examples (5)
admin
math log1p 42
mentdb
3.7612001156935624
Small x: ln(1+x) without cancellation
admin
math log1p 1e-12
mentdb
9.999999999995E-13
log1p(0) = 0
admin
math log1p 0
mentdb
0
Interest of 0.01 %: ln(1.0001)
admin
math log1p 0.0001
mentdb
9.999500033330834E-5
-1: -infinity
admin
math log1p -1
mentdb
-Infinity

math log_base <number> <base>


Description

Get the logarithm of a number in a specific base

Parameters

number: A number - Number - required
base: The base - Number - required

Examples (6)
admin
math log_base 1000 10
mentdb
3
log2(1024) = 10
admin
math log_base 1024 2
mentdb
10
Logarithm in base 3
admin
math log_base 81 3
mentdb
4
Bits for 1000 values: log2(1000)
admin
math log_base 1000 2
mentdb
9.965784284662087
Base 10
admin
math log_base 0.001 10
mentdb
-3
Number of halvings to go from 1 to 1/1000
admin
math eval "log_base(1000, 2)"
mentdb
9.965784284662087

math max <number1> <number2>


Description

Returns the greater of the two numbers sent as parameters.

Parameters

number1: A number - Number - required
number2: A number - Number - required

Examples (4)
admin
math max 4456 234
mentdb
4456
Max of two negative numbers
admin
math max -3 -7
mentdb
-3
Mixed signs
admin
math max -1.5 0
mentdb
0
Nested: the maximum of 3 values
admin
math max 4 (math max 9 2)
mentdb
9

math min <number1> <number2>


Description

Returns the smaller of the numbers sent as parameters.

Parameters

number1: A number - Number - required
number2: A number - Number - required

Examples (4)
admin
math min 4456 234
mentdb
234
Min of two decimals
admin
math min 2.5 2.49
mentdb
2.49
Negative numbers
admin
math min -3 -7
mentdb
-7
Clamp a value to 100
admin
math min 137 100
mentdb
100

math mod <number1> <number2>


Description

Returns the modulo of the two numbers sent as parameters.

Parameters

number1: A number - Number - required
number2: A number - Number - required

Examples (5)
admin
math mod 4456 234
mentdb
10
Remainder of a negative number (sign of the dividend)
admin
math mod -7 3
mentdb
-1
Even or odd
admin
math mod 17 2
mentdb
1
Hours on a 24 h clock: 30 h -> 6 h
admin
math mod 30 24
mentdb
6
Multiple of 3?
admin
math mod 123456 3
mentdb
0

math nroot <number> <n>


Description

Get the real n-th root (a negative number has a real root for an odd n; negative n: 1/root)

Parameters

number: A number - Number - required
n: A non zero integer - Number - required

Examples (5)
admin
math nroot -27 3
mentdb
-3
Fifth root of 32
admin
math nroot 32 5
mentdb
2
Error: even root of a negative number
admin
math nroot -16 4
mentdb
Sorry, an error appears (a negative number has no real root of even order).
Fourth root of 81
admin
math nroot 81 4
mentdb
3
Average growth factor per year over 5 years from 100 to 150
admin
math nroot 1.5 5
mentdb
1.0844717711976986

math order_int <jsonArray>


Description

Return an ordered array of integers

Parameters

jsonArray: A JSON array - String - required

Examples (3)
admin
math order_int "[8, 6, 5]"
mentdb
[5,6,8]
Negative numbers
admin
math order_int "[3, -1, 0, -5, 2]"
mentdb
[-5,-1,0,2,3]
Duplicates are kept
admin
math order_int "[4, 1, 4, 2, 1]"
mentdb
[1,1,2,4,4]

math order_long <jsonArray>


Description

Return an ordered array of longs

Parameters

jsonArray: A JSON array - String - required

Examples (3)
admin
math order_long "[8, 6, 5]"
mentdb
[5,6,8]
Large integers
admin
math order_long "[9000000000, 12, 7000000000]"
mentdb
[12,7000000000,9000000000]
Negative numbers
admin
math order_long "[5, -2, 0]"
mentdb
[-2,0,5]

math order_double <jsonArray>


Description

Return an ordered array of doubles

Parameters

jsonArray: A JSON array - String - required

Examples (4)
admin
math order_double "[8, 6, 5]"
mentdb
[5.0,6.0,8.0]
Sort decimals
admin
math order_double "[3.2, -1.5, 2.25, 0]"
mentdb
[-1.5,0.0,2.25,3.2]
Scientific notation
admin
math order_double "[1e-3, 5e-4, 2e-2]"
mentdb
[5.0E-4,0.001,0.02]
Measures of a sample
admin
math order_double "[12.1, 11.4, 13.2, 10.9, 12.8]"
mentdb
[10.9,11.4,12.1,12.8,13.2]

math order_float <jsonArray>


Description

Return an ordered array of floats

Parameters

jsonArray: A JSON array - String - required

Examples (3)
admin
math order_float "[8, 6, 5]"
mentdb
[5.0,6.0,8.0]
Decimal numbers
admin
math order_float "[2.5, -1.25, 0.5]"
mentdb
[-1.25,0.5,2.5]
Already sorted
admin
math order_float "[1, 2, 3]"
mentdb
[1.0,2.0,3.0]

math percent <number> <p>


Description

Get p percent of x: x*p/100 (computed in decimal)

Parameters

number: The number x - Number - required
p: The percentage - Number - required

Examples (5)
15 % of 80
admin
math percent 80 15
mentdb
12
VAT of 8.5 % on 250
admin
math percent 250 8.5
mentdb
21.25
VAT of 20 % on 59.90
admin
math percent 59.90 20
mentdb
11.98
More than 100 %
admin
math percent 40 150
mentdb
60
Discount of 12.5 % on 240
admin
math percent 240 12.5
mentdb
30

math pi


Description

Get the value of pi

Examples (5)
admin
math pi
mentdb
3.141592653589793
Area of a disk of radius 2
admin
math calc "pi*2^2"
mentdb
12.566370614359172
Circumference of a circle of radius 3
admin
math eval "2*pi*3"
mentdb
18.84955592153876
Area of a disc of diameter 10 cm, in cm2
admin
math eval "pi*5^2"
mentdb
78.53981633974483
More digits with bigdec pi
admin
bigdec pi 30
mentdb
3.14159265358979323846264338328

math pow <number1> <number2>


Description

Returns 'number1' raised to the power of 'number2'.

Parameters

number1: A number - Number - required
number2: A number - Number - required

Examples (7)
admin
math pow 0.5 7
mentdb
0.0078125
Square root as a power
admin
math pow 2 0.5
mentdb
1.4142135623730951
Negative exponent
admin
math pow 10 -3
mentdb
0.001
Negative base, integer exponent
admin
math pow -2 3
mentdb
-8
Negative base, decimal exponent: NaN (use math calc for the complex value)
admin
math pow -8 0.3333333333333333
mentdb
NaN
0^0 = 1
admin
math pow 0 0
mentdb
1
Fourth power of an amplitude
admin
math pow 1.5 4
mentdb
5.0625

math power <number1> <number2>


Description

Returns 'number1' raised to the power of 'number2'.

Parameters

number1: A number - Number - required
number2: A number - Number - required

Examples (5)
admin
math power 0.5 7
mentdb
0.0078125
Same as math pow
admin
math power 2 10
mentdb
1024
Square root as a power
admin
math power 9 0.5
mentdb
3
Large result
admin
math power 10 300
mentdb
1.0E300
Overflow: infinity
admin
math power 10 400
mentdb
Infinity

math rad_to_deg <number>


Description

Converts an angle measured in radians to an approximately equivalent angle measured in degrees

Parameters

number: A number - Number - required

Examples (5)
admin
math rad_to_deg 42
mentdb
2406.4227395494577
pi radians = 180 degrees
admin
math rad_to_deg 3.141592653589793
mentdb
180
1 radian in degrees
admin
math rad_to_deg 1
mentdb
57.29577951308232
pi/6
admin
math rad_to_deg 0.5235987755982988
mentdb
29.999999999999996
Negative angle
admin
math rad_to_deg -1.5707963267948966
mentdb
-90

math random <number>


Description

Get a random number between 0 and the given argument 'number'.

Parameters

number: A number - Number - required

Examples (3)
admin
math random 42
mentdb
17
A random integer between 0 and 5 (dice - 1)
admin
math random 6
mentdb
0
Random integer between 0 and 99 (the result changes each time)
admin
math floor (math random 100)
mentdb
81

math rint <number>


Description

Returns the double value that is closest to the argument and is equal to a mathematical integer

Parameters

number: A number - Number - required

Examples (6)
admin
math rint 42
mentdb
42
Half to even: 2.5 -> 2
admin
math rint 2.5
mentdb
2
3.5 -> 4
admin
math rint 3.5
mentdb
4
Banker rounding: 0.5 goes to the even integer
admin
math rint 0.5
mentdb
0
Negative number
admin
math rint -2.5
mentdb
-2
Not a half: normal rounding
admin
math rint 2.6
mentdb
3

math round <number1> <number2>


Description

Rounds 'number 1' to the precision specified by 'number 2'.

Parameters

number1: A number - Number - required
number2: A number - Number - required

Examples (6)
admin
math round 1.23654 2
mentdb
1.24
Round to 0 decimal
admin
math round 2.5 0
mentdb
3
Round to 3 decimals
admin
math round 3.14159265 3
mentdb
3.142
Round to 1 decimal
admin
math round 9.8066 1
mentdb
9.8
No decimal
admin
math round 1234.5678 0
mentdb
1235
Negative number
admin
math round -2.675 2
mentdb
-2.67

math round_sig <number> <digits>


Description

Round a number to n significant figures (the significant zeros are kept: 2.0001 with 3 figures gives 2.00). The rounding is done on the decimal value (HALF_UP).

Parameters

number: A number - Number - required
digits: The number of significant figures (1 to 100) - Number - required

Examples (7)
admin
math round_sig 0.0123456 3
mentdb
0.0123
admin
math round_sig 2.0001 3
mentdb
2.00
3 significant digits of a large number
admin
math round_sig 299792458 3
mentdb
300000000
2 significant digits
admin
math round_sig 0.000123456 2
mentdb
0.00012
Avogadro number with 4 significant digits
admin
math round_sig 6.02214076e23 4
mentdb
602200000000000000000000
1 significant digit
admin
math round_sig 0.0456 1
mentdb
0.05
Negative number
admin
math round_sig -123.456 2
mentdb
-120

math round_uncertainty <value> <uncertainty>


Description

Write a measurement as "value ± uncertainty" with the usual rounding (Particle Data Group rule): the 3 first digits of the uncertainty give 2 significant figures (100 to 354), 1 significant figure (355 to 949), or 2 after rounding up (950 to 999); the value is rounded at the same decimal place.
The very big and very small numbers are written with a common power of ten: (1.235 ± 0.034)e-8

Parameters

value: The value - Number - required
uncertainty: The uncertainty (strictly positive) - Number - required

Examples (7)
admin
math round_uncertainty 9.81234 0.0456
mentdb
9.81 ± 0.05
admin
math round_uncertainty 1.23456 0.012
mentdb
1.235 ± 0.012
Uncertainty with 2 digits when it starts with 1
admin
math round_uncertainty 1.23456 0.0123
mentdb
1.235 ± 0.012
A large value
admin
math round_uncertainty 299792.458 12.3
mentdb
299792 ± 12
Uncertainty with a leading 1: 2 digits are kept
admin
math round_uncertainty 12.3456 0.0156
mentdb
12.346 ± 0.016
Large uncertainty
admin
math round_uncertainty 1234.5 87
mentdb
1230 ± 90
Result of a fit: tau = 1.954461 +- 0.076915
admin
math round_uncertainty 1.954461 0.076915
mentdb
1.95 ± 0.08

math sec <number>


Description

Get the secant (1/cos) of a number

Parameters

number: A number - Number - required

Examples (4)
admin
math sec 0
mentdb
1
sec(pi/3) = 2
admin
math sec 1.0471975511965979
mentdb
2.0000000000000004
sec(pi/4) = sqrt(2)
admin
math sec 0.7853981633974483
mentdb
1.414213562373095
sec(pi) = -1
admin
math sec 3.141592653589793
mentdb
-1

math sign <number>


Description

Get the sign of a number

Parameters

number: A number - Number - required

Examples (5)
admin
math sign 42
mentdb
1
Sign of a negative number
admin
math sign -0.001
mentdb
-1
Sign of 0
admin
math sign 0
mentdb
0
Negative number
admin
math sign -12.5
mentdb
-1
Very small positive number
admin
math sign 1e-300
mentdb
1

math signum <number>


Description

Get the sign of a number: returns 1 if the number is positive and -1 if the number is negative.

Parameters

number: A number - Number - required

Examples (4)
admin
math signum 42
mentdb
1
Same as math sign
admin
math signum -42
mentdb
-1
Zero
admin
math signum 0
mentdb
0
Decimal number
admin
math signum 0.25
mentdb
1

math sin <number>


Description

Get the sine of a number

Parameters

number: A number - Number - required

Examples (7)
admin
math sin 42
mentdb
-0.9165215479156338
sin(pi/6) = 0.5
admin
math sin 0.5235987755982988
mentdb
0.49999999999999994
The angle is in radians: 30 degrees
admin
math sin (math deg_to_rad 30)
mentdb
0.49999999999999994
sin(pi) = 0 (almost: rounding of pi)
admin
math sin 3.141592653589793
mentdb
1.2246467991473532E-16
Height of a ramp of 5 m at 12 degrees
admin
math eval "5*sin(12)" "{\"_angle\": \"deg\"}"
mentdb
1.0395584540887968
sin(-x) = -sin(x)
admin
math sin -1
mentdb
-0.8414709848078965
Small x: sin(x) = x
admin
math sin 1e-8
mentdb
1.0E-8

math sinh <number>


Description

Get the hyperbolic sine of a number

Parameters

number: A number - Number - required

Examples (5)
admin
math sinh 42
mentdb
8.696374707602505E17
sinh(1)
admin
math sinh 1
mentdb
1.1752011936438014
sinh(0) = 0
admin
math sinh 0
mentdb
0
Odd function
admin
math sinh -1
mentdb
-1.1752011936438014
Large x: overflow to infinity
admin
math sinh 1000
mentdb
Infinity

math sqrt <number>


Description

Get the square root of a non-negative number

Parameters

number: A number - Number - required

Examples (6)
admin
math sqrt 42
mentdb
6.48074069840786
sqrt(2)
admin
math sqrt 2
mentdb
1.4142135623730951
Negative number: NaN (use complex sqrt)
admin
math sqrt -4
mentdb
NaN
Perfect square
admin
math sqrt 144
mentdb
12
Standard deviation from a variance of 6.25
admin
math sqrt 6.25
mentdb
2.5
Very small number
admin
math sqrt 1e-20
mentdb
1.0E-10

math tan <number>


Description

Get the tangent of a number

Parameters

number: A number - Number - required

Examples (5)
admin
math tan 42
mentdb
2.2913879924374863
tan(pi/4) = 1
admin
math tan 0.7853981633974483
mentdb
0.9999999999999999
tan(0) = 0
admin
math tan 0
mentdb
0
Height of a tree seen at 35 degrees from 20 m
admin
math eval "20*tan(35)" "{\"_angle\": \"deg\"}"
mentdb
14.004150764194193
Near pi/2: very large
admin
math tan 1.5707963267948966
mentdb
1.633123935319537E16

math tanh <number>


Description

Get the hyperbolic tangent of a number

Parameters

number: A number - Number - required

Examples (5)
admin
math tanh 42
mentdb
1
tanh(1)
admin
math tanh 1
mentdb
0.7615941559557649
Large x: 1
admin
math tanh 20
mentdb
1
tanh(0) = 0
admin
math tanh 0
mentdb
0
Odd function
admin
math tanh -0.5
mentdb
-0.46211715726000974

math trunc <number>


Description

Get the integer part toward 0 (trunc -2.7 = -2)

Parameters

number: A number - Number - required

Examples (5)
admin
math trunc -2.7
mentdb
-2
Integer part of a positive number
admin
math trunc 2.7
mentdb
2
An integer is unchanged
admin
math trunc 7
mentdb
7
Small negative number: -0 is 0
admin
math trunc -0.4
mentdb
0
Integer part of a duration of 3.75 h
admin
math trunc 3.75
mentdb
3

math ulp <number>


Description

Returns the size of an ulp of the argument. An ulp of a double value is the positive distance between this floating-point value and the next larger double value in magnitude

Parameters

number: A number - Number - required

Examples (5)
admin
math ulp 42
mentdb
7.105427357601002E-15
Spacing of the doubles near 1 (machine epsilon)
admin
math ulp 1
mentdb
2.220446049250313E-16
Precision of a double near 1e10
admin
math ulp 1e10
mentdb
1.9073486328125E-6
Near 0
admin
math ulp 1e-300
mentdb
1.6578092E-316
Relative precision of the doubles: ulp(1)/2
admin
math eval "2^-53"
mentdb
1.1102230246251565E-16
start: 2026-10-29end: 2026-10-29v_start: 421v_end: