Migration

Moving from Nerdamer 1.xx

Version 2.xx is a TypeScript rewrite. Much everyday code still looks familiar, but package loading, structured value handling, stored state, solving results, and lower-level extension APIs have changed enough that a migration deserves more than a version-number swap.

Migrating to 2.xx provides first-class TypeScript support, clearer package imports, more cohesive structured values, and structured solver results.

Every effort has been made to carry forward the functionality available in 1.xx. Because 2.xx is a complete rewrite rather than a modification of the previous codebase, some features, aliases, edge cases, or less commonly used APIs may have been missed or may no longer be present. If you find functionality that existed in 1.xx but is missing from 2.xx, please file an issue on GitHub and include a small example showing the previous behavior. Missing functionality can then be reviewed for restoration where appropriate.

This migration guide describes the known differences, but it should not be considered an exhaustive list of every difference between the two versions.

If you cannot migrate yet, version 1.xx is still being maintained by the Nerdamer-Prime fork.

The short version

If your application mostly calls nerdamer('...'), reads .text() or .toTeX(), and uses common algebra/calculus functions, the move is relatively small. Code that depends on getCore(), expression history, 1.xx add-on loading, or the shape of solver results needs closer review.

What changes most often

Loading

The rewrite replaces the old core-plus-add-ons model with a complete package and documented package entry points. Imports do not attach add-ons to an already-loaded runtime.

Structured values

Version 1.xx already supported equations, vectors, matrices, sets, and other structured values. Version 2.xx connects those types through the parser and public APIs more consistently instead of relying on implicit wrappers and one-off conversions between subsystems.

Expression history

Version 2.xx does not maintain the old global list of every parsed expression.

Solving

Single-equation and system solving return structured containers rather than the old array-oriented shapes.

Internals

Old getCore() and registration hooks are replaced by supported public APIs and explicit package entry points.

Loading the library

Version 1.xx was assembled at runtime from a core file plus add-ons. The rewrite does not use that model. Import the complete package when you want the normal root API, or use a documented package entry point when application code needs a specific public API.

Nerdamer 1.xx
var nerdamer = require('nerdamer');
require('nerdamer/Algebra');
require('nerdamer/Calculus');
require('nerdamer/Solve');
require('nerdamer/Extra');

Each add-on extended the already-loaded runtime.

Nerdamer 2.xx
import nerdamer from 'nerdamer';

The root package provides the normal API without a separate add-on loading sequence.

Do not reproduce the 1.xx loading order.

Loading a “core” build and then attaching Algebra, Calculus, Solve, or Extra is a 1.xx pattern. In 2.xx, use the root package or documented package entry points.

TypeScript and package consumers can use documented package entry points for direct APIs. Those are package entry points, not browser add-ons:

import nerdamer from 'nerdamer';
import { Expression, Rational } from 'nerdamer/core';
import { Polynomial, gcd, partfrac } from 'nerdamer/algebra';
import { diff, integrate, limit } from 'nerdamer/calculus';
import { solve, PolynomialSolver } from 'nerdamer/solve';
import { Matrix, Vector, ValuesSet } from 'nerdamer/structures';

Structured parser results are more cohesive

Version 1.xx already supported Expression, Equation, Vector, Matrix, set, and other structured values. The difference in 2.xx is not that these types suddenly exist; it is that they participate in a more consistent parser and API model.

In 1.xx, different subsystems did not always pass these values between each other cleanly. Code paths sometimes wrapped a structured value as an Expression, converted it to another representation, or used a local adapter before another subsystem could consume it. The rewrite keeps the parsed value as its actual type and makes the surrounding APIs work with those types more consistently.

For migration purposes, code that can receive more than an ordinary algebraic expression should narrow the returned ParserEntity before calling type-specific methods rather than relying on an older implicit conversion.

Input kindTypical 2.xx resultWhat to review
x^2+1ExpressionUsually no migration change.
x^2=4EquationNarrow the returned type before using Expression-only methods.
[x,y,z]VectorUse vector operations directly instead of converting through an Expression representation.
matrix(...)MatrixWork with the matrix object and its matrix methods.
set / dictionary / collection notationStructured ParserEntityAccount for the corresponding container type.

Stored expression history is gone

Version 1.xx automatically retained parsed expressions. The related global history helpers are not part of 2.xx:

nerdamer.expressions();
nerdamer.getExpression(...);
nerdamer.getEquation(...);
nerdamer.clear();
nerdamer.flush();
nerdamer.numExpressions();
nerdamer.numEquations();

Store results in normal JavaScript variables instead:

const first = nerdamer('x^2+1');
const second = nerdamer('sin(x)');

Variables, constants, settings, and user functions

The common state/configuration calls remain available:

nerdamer.setVar('a', 5);
nerdamer.getVars();
nerdamer.clearVars();

nerdamer.setConstant('g', 9.81);
nerdamer.getConstant('g');
nerdamer.setConstant('g', 'delete');

nerdamer.setFunction('f', ['x'], 'x^2+1');

A substitution supplied directly to nerdamer(...) still takes priority over an assigned variable. The old single-value getVar() helper is not on the 2.xx root object; use getVars() for assigned values.

Root functions: what stayed and what moved

Nerdamer 1.xx name or areaNerdamer 2.xx direction
factor, simplify, gcd, lcm, divide, div, partfrac, degAvailable on the 2.xx root API.
diff, integrate, sum, product, defint, limit, laplace, ilaplaceAvailable on the 2.xx root API.
convertToLaTeXUse convertToTeX() for TeX math markup. convertToLaTeX() remains as a deprecated compatibility alias.
Fresnel S / CAvailable through Nerdamer Notation, the 2.xx root API, and nerdamer/calculus.
iltKept for 1.xx compatibility as an alias for ilaplace.
rootsUse solve() or the current polynomial solver APIs.
coeffsUse Expression.coeffs() or Polynomial.
lineNo matching 2.xx root shortcut.
sqcompRetained in Nerdamer Notation as sqcomp(...). JavaScript / TypeScript uses completeSquare(...).
Extra statistics helpersmean, median, mode, variance/stdev helpers, and zscore are not part of 2.xx.

Solving returns structured results

Single-equation solving returns a SolutionSet:

const solutions = nerdamer.solve('x^2-4', 'x');
solutions.text();

System solving uses solveSystem() and returns a Vector containing a Dictionary for each solution:

const solutions = nerdamer.solveSystem(
  ['x+y=3', 'x-y=1'],
  ['x', 'y']
);
// [{x => 2, y => 1}]

solveeqs(...) is the Nerdamer Notation spelling and is retained on the root API for compatibility. The old solveEquations name is not part of the 2.xx public API. Code that expected nested JavaScript arrays from system solving should be updated for the new container types.

Expression compatibility details

Common methods such as text(), toTeX(), evaluate(), sub(), variables(), solveFor(), arithmetic methods, expand(), simplify(), and factor() remain familiar. Several shorter aliases such as plus(), minus(), times(), div(), and subst() also remain.

One important distinction: equals() constructs an Equation, while eq() checks equality.

Replace low-level 1.xx extension hooks

Projects that reached through the old internals need the most migration work. The following 1.xx hooks are not restored as 2.xx root APIs:

getCore()
register()
replaceFunction()
addPeeker()
removePeeker()
load()
tree()
htmlTree()
rpn()

Use the supported package APIs instead of depending on the old internal object graph. setFunction() remains available for symbolic user functions.

Migration checklist

  1. Replace the 1.xx core-plus-add-ons loading sequence with the 2.xx root package or documented package entry points.
  2. Do not treat direct TypeScript package imports as runtime add-ons; they are API entry points.
  3. Replace stored-expression-history calls with ordinary JavaScript variables.
  4. Review code that assumes every parsed value is an Expression; 2.xx preserves structured parser values more consistently across APIs.
  5. Update code that expects the old array shape from system solving.
  6. Replace getCore(), register(), and similar internal hooks with supported APIs.
  7. Check dependencies on removed Extra statistics helpers and older root shortcuts.
  8. Run representative expressions in the Playground with 2.xx and 1.1.13 when behavior needs to be compared.

Where to go next