Skip to content
Open in Anthropic

Function Reference

TeXpr provides a wide range of mathematical functions, from basic trigonometry to complex number arithmetic.

Trigonometric Functions

All trigonometric functions expect arguments in radians.

LaTeXPurposeComplex Support
\sin{x}Sine
\cos{x}Cosine
\tan{x}Tangent
\cot{x}Cotangent
\sec{x}Secant
\csc{x}Cosecant

Hyperbolic Functions

LaTeXPurposeComplex Support
\sinh{x}Hyperbolic sine
\cosh{x}Hyperbolic cosine
\tanh{x}Hyperbolic tangent
\coth{x}Hyperbolic cotangent
\sech{x}Hyperbolic secant
\csch{x}Hyperbolic cosecant

Inverse Functions

LaTeXPurposeAlias
\arcsin{x}Inverse sine\asin{x}
\arccos{x}Inverse cosine\acos{x}
\arctan{x}Inverse tangent\atan{x}
\arccot{x}Inverse cotangent\acot{x}
\arcsec{x}Inverse secant\asec{x}
\arccsc{x}Inverse cosecant\acsc{x}
\asinh{x}Inverse hyperbolic sine-
\acosh{x}Inverse hyperbolic cosine-
\atanh{x}Inverse hyperbolic tangent-

Logarithmic & Exponential

LaTeXPurposeDescription
\ln{x}Natural logBase e
\log{x}Common logBase 10
\log_{b}{x}Arbitrary logBase b
\log2{x}Base 2 logAlias: \log_{2}
\exp{x}Exponentialex

Power & Roots

LaTeXPurposeExample
\sqrt{x}Square root\sqrt{16} = 4
\sqrt[n]{x}n-th root\sqrt[3]{27} = 3

Rounding & Absolute Value

LaTeXPurposeExample
\abs{x}Absolute value\abs{-5} = 5
\floor{x}Floor\floor{3.7} = 3
\ceil{x}Ceiling\ceil{3.2} = 4
\round{x}Round\round{3.5} = 4
\sgn{x}Sign function\sgn{-3} = -1

Number Theory & Misc

LaTeXPurposeDescription
\gcd{a, b}GCDGreatest Common Divisor
\lcm{a, b}LCMLeast Common Multiple
\min{a, b}MinimumSmaller of two values
\max{a, b}MaximumLarger of two values
\factorial{n}Factorialn!=12...n
\binom{n}{k}Binomial"n choose k"
\fibonacci{n}Fibonaccin-th Fibonacci number

Complex Numbers

Special functions for complex numbers z=a+bi.

LaTeXPurposeDescription
\Re{z}Real partReturns a
\Im{z}Imaginary partReturns b
\arg{z}ArgumentPhase angle in radians
\conjugate{z}ConjugateReturns abi
\overline{z}ConjugateAlias for \conjugate

Implementation Details

Most mathematical functions delegate directly to Dart's dart:math library for real numbers and a custom Complex implementation for complex numbers.

Precision

Calculations use IEEE 754 double-precision floating-point arithmetic. High-order functions like \factorial and \fibonacci return results as doubles and may lose precision for very large inputs (typically n>20 for factorial).

Domain Errors

If a function is called outside its domain (e.g., \ln{-1} with only real support enabled, or \sqrt{-1} without complex results expected), an EvaluatorException is thrown.

dart
try {
  evaluator.evaluate(r'\ln{-1}');
} on EvaluatorException catch (e) {
  print(e.message); // "Domain error: ln() argument must be positive"
}

Piecewise Definition

Support for piecewise functions is available via the \begin{cases} environment. See the Piecewise Functions Guide for full details on syntax and usage.

Made with ❤️ by TeXpr, Docs Inspired by ElysiaJS