Start here

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.

User input is parsed, not evaluated as JavaScript. Nerdamer Notation and Nerdamer Scripting are handled by the library's parser. Normal parsing, simplification, solving, evaluation, and symbolic manipulation do not use 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.
New to Nerdamer? Start with Getting started. If you are unsure which interface fits your project, see Choosing how to use Nerdamer.
Localized errors. The library includes built-in error messages for each supported language. Use the 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