Curve Fit Equations

A curvefit equation is written as a 'C-style' formula.

Some examples

What you wantWhat you typeVariables in the equation
mx+bm*x+bm, b
Ax2A*x**2A
Ae-x2A*exp(-x**2)A
Asin(ωt-kx+φ)A*sin(\omega*t-k*x+\phi)A, \omega, \phi
tan(2π/180 x)tan(2*\pi/180*x)None. π is a constant here.

Some basic rules

Order of operations

Order of operations is like in C, BASIC, Fortran or almost any other programming language. If you aren't sure, just throw in some parentheses. The following table shows the order of operations from highest precedence to least precedence:

OperatorExampleExplanation
highest()(x*2)parentheses
precedence**a**bexponentiation
*a*bmultiplication
/a/bdivision
%a%bmodulo
lowest+a+baddition
precedence-a-bsubtraction

You can use other c-like operators such as ==, <=, && or ||.

Functions

FunctionExplanation
abs(x)absolute value of x, |x|
acos(x)inverse cosine in radians
asin(x)inverse sin in radians
atan(x)inverse tangent in radians
besj0(x)j_0 Bessel function of x*
besj1(x)j_1 Bessel function of x*
besy0(x)y_0 Bessel function of x*
besy1(x)y_1 Bessel function of x*
ceil(x)smallest integer not less than x (real part)
cos(x)cosine of x*
cosh(x)hyperbolic cosine of x*
erf(x)error function of x
erfc(x)1.0 - error function of x
exp(x)exponential function of x
floor(x)largest integer not greater than x
gamma(x)gamma function of x
int(x)integer part of x, truncated toward zero
log(x)natural logarithm (base e) of x
log10(x)logarithm (base 10) of x
rand(x)pseudo random number generator
sgn(x)1 if x > 0, -1 if x < 0, 0 if x = 0.
sin(x)sine of x*
sinh(x)hyperbolic sine x*
sqrt(x)square root of x (use x**(1/n) to get the nth root of x).
tan(x)tangent of x*
tanh(x)hyperbolic tangent of x*

*Angles are given in radians. If your data is in degrees, then convert to radians like this: sin(2*pi/180*x)