Computer Algebra System

Symbolic math.
For JavaScript & TypeScript.

Nerdamer is a lightweight Computer Algebra System for the JavaScript and TypeScript ecosystem.

Use it to simplify expressions, solve equations, work with calculus and linear algebra, or build your own math tools. Nerdamer includes a math parser, a JavaScript and TypeScript API, and a simple scripting language.

Installnpm install nerdamer
nerdamer
// exact arithmetic
1/3+1/6
1/2
// factor an expression
factor(x^4-1)
(-1+x)*(1+x)*(1+x^2)
// differentiate
diff(sin(x^2),x)
2*x*cos(x^2)
What is Nerdamer?

Computer algebra that runs with your JavaScript.

Nerdamer works with mathematical expressions symbolically. That means values such as x, fractions, roots, constants, and complex numbers can stay in mathematical form instead of being turned into decimal numbers right away.

You can use Nerdamer in the browser, in Node.js, or in a TypeScript project. It runs on the client, so a web page can do symbolic calculations without sending each expression to a server.

Current releases no longer use the 1.x core-plus-add-ons loading model. The complete package can be used directly, and application code can import documented public APIs from the package entry points. It is open source under the Apache-2.0 license.

Symbolic + numericalKeep expressions exact, then evaluate them when you need a number.
Browser + Node.jsUse the same math library in a web page, a server application, or a command-line project.
Typed public APIsUse the root package or documented JavaScript and TypeScript entry points in application code.
Open sourceRead the source, extend it, and use it in your own projects.
Features

From everyday algebra to larger symbolic problems.

Nerdamer covers the common building blocks of a computer algebra system while keeping the library approachable for small applications and classroom tools.

Symbolic algebra Simplify, expand, factor, substitute, work with rational expressions, and manipulate polynomials.

=

Equation solving Solve many equations and systems of equations symbolically or numerically.

Calculus Differentiate, integrate, evaluate limits, and work with sums, products, and transforms.

[ ]

Matrices and vectors Create matrices and vectors and perform common linear algebra operations.

Complex numbers Work with real and imaginary parts, arguments, rectangular form, and polar form.

1/3

Exact arithmetic Keep fractions, radicals, constants, and symbolic values exact when possible.

0.1

Arbitrary-precision decimals Choose the precision you need when a decimal answer is more useful.

{ }

Sets and assumptions Work with sets and add information about variables when a calculation needs it.

f(x)

Math parser Enter familiar mathematical expressions and call built-in or user-defined functions.

:=

Built-in scripting language Define variables and functions and use local values, conditions, and loops.

TS

JavaScript and TypeScript API Use Nerdamer from application code with typed public entry points.

TeX

Display and reuse results Convert expressions to text or TeX, evaluate them, or compile supported expressions to JavaScript functions.

Use it your way

Parser, application code, or a small math script.

You do not have to learn every part of Nerdamer before using it. Start with the style that fits what you are building.

Math-like inputParser

factor(x^4-1)
diff(sin(x^2),x)
solve(x^2-4,x)

Useful for calculators, forms, lessons, and anywhere users enter mathematical expressions.

JavaScript / TypeScriptAPI

import { factor } from 'nerdamer/algebra';

const result = factor('x^4-1');
console.log(result.text());

Import public functions and classes directly when Nerdamer is part of a larger application. See the API examples for larger programs.

Nerdamer languageScripting

square(x):=x^2;
f(x):=square(x)+1;
f(4)

Define reusable calculations and combine them into small programs without leaving Nerdamer notation.

Examples

Try a few expressions.

Community

Questions, suggestions, or something you built?

Leave a comment below. The same Disqus discussion from the original Nerdamer homepage is kept here.