Skip to content
Open in Anthropic

Built-in Constants

Constants are used as fallback when a variable is not provided by the user.

Available Constants

NameSymbolValueDescription
hbar1.054571817e-34Reduced Planck (J·s)
ee2.71828182845905Euler's number
piπ3.14159265358979Pi
tauτ6.283185307179592 * π
phiφ1.61803398874989Golden ratio
gammaγ0.57721566490153Euler-Mascheroni
OmegaΩ0.56714329040978Lambda W constant
deltaδ2.41421356237310Silver ratio (1+√2)
GG6.67430e-11Gravitational constant
zeta3ζ(3)1.20205690315959Apéry's constant
inftyInfinity
sqrt2√21.41421356237310Square root of 2
sqrt3√31.73205080756888Square root of 3
ln2ln(2)0.69314718055995Natural log of 2
ln10ln(10)2.30258509299405Natural log of 10

Usage

Constants can be accessed using their standard LaTeX commands or as variables:

dart
final evaluator = Texpr();

// LaTeX command notation (Recommended for multi-character)
evaluator.evaluateNumeric(r'\hbar');  // 1.05457...
evaluator.evaluateNumeric(r'\pi');     // 3.14159...

// Variable name notation
evaluator.evaluateNumeric('pi');  // 3.14159... (if allowImplicitMultiplication is false)
evaluator.evaluateNumeric('e');   // 2.71828...

TIP

Always use the backslash notation (e.g., \pi, \hbar) for multi-character constants to avoid ambiguity with implicit multiplication of single-letter variables.

Overriding Constants

User-provided variables override built-in constants by default:

dart
// Override 'e' with custom value
e.evaluate('e', {'e': 3.0});  // 3.0

// Constant used when variable not provided
e.evaluate('e');  // 2.71828...

Multi-character Constants

Multi-character constant names (like pi, phi) require using them as variable bindings since the parser only reads single characters:

dart
// Bind pi value to a single-letter variable
e.evaluate(r'\sin{p}', {'p': 3.14159});  // ~0

Made with ❤️ by TeXpr, Docs Inspired by ElysiaJS