Skip to content
Built-in Functions

Built-in Functions

The listing below gives an overview of the built-in functions. The up-to-date list is always available from within Frida by typing hf at the main prompt.

Elementary functions

Function Description
ln(x) Natural logarithm; NaN if x ≤ 0
lg(x) Decadic logarithm; NaN if x ≤ 0
sqrt(x) Square root; NaN if x < 0
abs(x) Absolute value
sign(x) Sign: −1, 0, or 1
exp(x) Exponential

Safe variants

These return 0 instead of NaN for out-of-domain arguments, which is useful when a few data points lie outside the valid range but you do not want the whole expression to evaluate to NaN:

Function Description
ln0(x) Natural logarithm; 0 if x ≤ 0
lg0(x) Decadic logarithm; 0 if x ≤ 0
sqrt0(x) Square root; 0 if x < 0

Trigonometric functions

Function Description
sin(x) Sine (x in radians)
cos(x) Cosine (x in radians)
tan(x) Tangent (x in radians)
cot(x) Cotangent (x in radians)
sind(x) Sine (x in degrees)
cosd(x) Cosine (x in degrees)
tand(x) Tangent (x in degrees)
cotd(x) Cotangent (x in degrees)
asin(x) Arc sine (result in radians; NaN if |x| > 1)
acos(x) Arc cosine (result in radians; NaN if |x| > 1)
atan(x) Arc tangent (result in radians)
acot(x) Arc cotangent (result in radians)
asind(x) Arc sine (result in degrees; NaN if |x| > 1)
acosd(x) Arc cosine (result in degrees; NaN if |x| > 1)
atand(x) Arc tangent (result in degrees)
acotd(x) Arc cotangent (result in degrees)
sinh(x) Hyperbolic sine
cosh(x) Hyperbolic cosine
tanh(x) Hyperbolic tangent
coth(x) Hyperbolic cotangent
sinc(x) Cardinal sine: sin(x)/x

Special functions

Function Description
gamma(x) Gamma function (= factorial of x−1)
lgamma(x) Natural logarithm of the gamma function
fac(x) Factorial of nearest integer of x
cata(x) Catalan number of nearest integer of x
erf(x) Error function
erfc(x) Complementary error function
erfi(x) Imaginary error function
erfcx(x) Scaled complementary error function: exp(x²)·erfc(x)
dawson(x) Dawson function: exp(−x²)·∫₀ˣ exp(t²) dt
j0(x) Spherical Bessel function j₀
j1(x) Spherical Bessel function j₁
isnan(x) 1 if x is NaN, 0 otherwise
ceil(x) Smallest integer ≥ x
floor(x) Largest integer ≤ x
nint(x) Nearest integer

Two-argument functions

Function Description
min2(x,y) Smaller of x and y
max2(x,y) Larger of x and y
ran(x,y) Uniform random number in [x, y]
hypot(x,y) √(x²+y²)
atan2(x,y) Polar angle of point (x, y) in radians
atan2d(x,y) Polar angle of point (x, y) in degrees
gauss(x,s) Normalised Gaussian: exp(−x²/2s²) / (√(2π) s)
gnn(x,s) Unnormalised Gaussian: exp(−x²/2s²)
cauchy(x,w) Cauchy–Lorentz: w / (π(x²+w²))
diehl(η) Normalised Gauss⊛Cauchy convolution (pseudo-Voigt); η = Cauchy/Gauss width
lndiehl(η) Natural log of diehl(η)
re_wofz(x,y) Real part of the Faddeeva function w(x+iy)
im_wofz(x,y) Imaginary part of the Faddeeva function
abs_wofz(x,y) Absolute value of the Faddeeva function
arg_wofz(x,y) Phase of the Faddeeva function

Three-argument functions

Voigt profile

Function Description
voigt(x,σ,γ) Voigt profile: convolution of Gaussian(σ) and Lorentzian(γ)
voigt_hwhm(σ,γ) Half-width at half-maximum of the Voigt profile

KWW (stretched exponential) transforms

The KWW functions compute Fourier transforms of the stretched exponential exp(−(t/τ)^β). See http://joachimwuttke.de/kww/ for details.

Function Description
kwwc(ω,τ,β) Cosine transform: ∫₀^∞ cos(ωt) exp(−(t/τ)^β) dt
kwws(ω,τ,β) Sine transform
kwwp(ω,τ,β) Primitive of the cosine transform
kwwmc(ω,⟨τ⟩,β) Cosine transform averaged over a τ distribution
kwwms(ω,⟨τ⟩,β) Sine transform averaged over a τ distribution
kwwmp(ω,⟨τ⟩,β) Primitive averaged over a τ distribution

Havriliak–Negami

Function Description
rehavneg(x,y,z) Real part of the Havriliak–Negami function
imhavneg(x,y,z) Imaginary part of the Havriliak–Negami function

Other physics functions

Function Description
cauchy2(x,y,z) Two-parameter Cauchy function
debye1(x) Debye function D₁(x)
debye3(x) Debye function D₃(x)
debyeu2(x) Debye mean-squared-displacement temperature dependence
debyeui(x) Debye internal energy
debyecv(x) Debye heat capacity
zorn(I,⟨I⟩,s) Multiple-scattering corrected elastic intensity (Zorn)
zorn2(q,⟨u²⟩,s) Gaussian elastic intensity corrected for multiple scattering (Si111)
heat_sphere(t,r) Temperature evolution in a sphere

Calculator examples

. ln(0)                         # NaN
. ln0(0)                        # 0
. sqrt(-1)                      # NaN
. sqrt0(-1)                     # 0
. sin(pi/4)^2 + cos(pi/4)^2    # 1
. gauss(0, 1)                   # 0.3989
. kwwc(0, 1, 0.5)              # KWW at ω=0, τ=1, β=0.5
. isnan(ln(-1))                 # 1