Nerdamer documentation
The library offers three main ways of interacting with symbolic mathematics. The documentation is organized around those interfaces so you can go directly to the form you are using.
eval() or new Function, so a string passed to nerdamer(...) should
not be treated as JavaScript source. The exception is buildFunction(), which explicitly compiles an
expression to a JavaScript-number function with new Function(...) and can therefore be affected by
Content Security Policy restrictions.
LANGUAGE setting to select the error-message language. See
Settings and configuration for the supported language codes
and an example.
Nerdamer Notation
Use the mathematical notation accepted by nerdamer('...'). This includes expressions, equations,
vectors, matrices, and functions such as factor, diff, and solve.
import nerdamer from 'nerdamer';
const result = nerdamer('factor(x^4-1)');
console.log(result.text());
Start with Expression syntax or browse the Nerdamer Notation function reference.
Nerdamer Scripting
Use Nerdamer Scripting when the text passed to nerdamer(...) needs assignments, user-defined functions,
conditions, loops, blocks, or local scope.
const result = nerdamer(`
block(
x: 4,
if(x > 3, x^2, x)
)
`);
console.log(result.text()); // 16
See Nerdamer Scripting, browse the
Scripting examples, or go directly to
User-defined functions to compare scripting with
nerdamer.setFunction(...).
JavaScript / TypeScript API
Use the API when you want to call the library directly from application code. The default
nerdamer import is callable and also exposes functions such as nerdamer.pretty(...),
nerdamer.setFunction(...), nerdamer.factor(...), and nerdamer.solve(...).
Public package paths are also available for direct imports of functions, classes, and types.
import nerdamer from 'nerdamer';
import { Matrix, determinant } from 'nerdamer/structures';
const formatted = nerdamer.pretty('x^2+1', 'TeX');
const M = new Matrix([1, 2], ['x', 'y']);
const d = determinant(M);
See the nerdamer API, the full
JavaScript / TypeScript API, text output and public helpers, or larger API examples that
combine several operations.
Where to go next
Getting started
Install the library and run your first expressions.
→Nerdamer Notation
Learn expression syntax, then browse the notation function reference.
→Nerdamer Scripting
Use variables, functions, conditions, loops, blocks, and local scope.
→nerdamer API
Reference for the callable default import and the functions and properties attached to it.
→JavaScript / TypeScript API
Reference for the nerdamer API, package imports, classes, functions, and types.
Text output & public helpers
Control rendered term ordering and use the promoted algebra, substitution, complex, and linear-algebra helpers.
→API examples
Solve a nonlinear system with a symbolic Jacobian and derive coupled-oscillator normal modes with exact matrix algebra.
→Migrating from Nerdamer 1.xx
Update existing 1.xx applications for version 2.xx.
→Playground
Try the library in the browser without installing anything.
