Built-ins
MathFlow comes with a rich set of built-in constants and functions for mathematical computation. These are available in every context by default.
Constants
pi
: Ratio of a circle's circumference to its diameter (3.14159...
)e
: Euler's number, the base of natural logarithms (2.71828...
)
Functions
Arithmetic & Numbers
add(x, y, ...)
: Sum of argumentssub(x, y)
: Subtractionmul(x, y, ...)
: Product of argumentsdiv(x, y)
: Divisionabs(x)
: Absolute valueceil(x)
: Ceilingfloor(x)
: Floorsqrt(x)
: Square rootpow(x, y)
: x to the power ycbrt(x)
: Cube rootroot(x, y)
: y-th root of xtrunc(x)
: Truncate to integer
Logarithms & Exponentials
exp(x)
: e^xln(x)
: Natural logarithmlog(x, y)
: Logarithm of x base ylog10(x)
: Base-10 logarithmlog2(x)
: Base-2 logarithm
Trigonometry
Angle mode can be degrees or radians - See Preferences for details.
sin(x)
,cos(x)
,tan(x)
: Sine, cosine, tangentasin(x)
,acos(x)
,atan(x)
: Inverse trigonometric functionscsc(x)
,sec(x)
,cot(x)
: Cosecant, secant, cotangentsinh(x)
,cosh(x)
,tanh(x)
: Hyperbolic functionsasinh(x)
,acosh(x)
,atanh(x)
: Inverse hyperbolic functionsdeg(x)
: Convert radians to degreesrad(x)
: Convert degrees to radianshypot(x, y)
: sqrt(x² + y²)versin(x)
: 1 - cos(x)coversin(x)
: (1 - cos(x)) / 2
Examples
js
import { createContext } from '@mathflowjs/mathflow';
const ctx = createContext();
ctx.solve('log(100, 10)'); // 2
ctx.solve('sin(90)'); // 1 (if angles = 'deg')
ctx.solve('sqrt(16)'); // 4
ctx.solve('hypot(3, 4)'); // 5
See also: Preferences for angle mode and precision settings.