Skip to content

geometryzen/stemcmicro

Repository files navigation

STEMCmicro Monorepo

Overview

stemcmicro is a Javascript (Typescript) library for symbolic mathematics.

It is motivated by the need to support learning activities in a web browser without requiring a symbolic mathematics server.

The roadmap is to create a highly modular and extensible ecosystem of packages to support diverse use cases.

Status

All packages are published together with the same version number.

version

npm downloads

GitHub license

PRs Welcome

Example

import { create_engine, ExprEngine } from "@stemcmicro/engine";
import { js_parse } from "@stemcmicro/js-parse";

describe("units", () => {
    it("create_engine", () => {
        const engine: ExprEngine = create_engine();
        try {
            const sourceText = [`G20 = algebra([1, 1, 1], ["ex", "ey", "ez"])`, `ex = G20[1]`, `ey = G20[2]`, `cross(ex,ey)`].join("\n");
            const { trees, errors } = js_parse(sourceText);
            if (errors.length > 0) {
            }
            for (let i = 0; i < trees.length; i++) {
                const tree = trees[i];
                const value = engine.valueOf(tree);
                if (!value.isnil) {
                    const s = engine.renderAsString(tree);
                    expect(s).toBe("cross(ex,ey)");
                    const t = engine.renderAsString(engine.simplify(value));
                    expect(t).toBe("ez");
                }
                value.release();
            }
        } finally {
            engine.release();
        }
    });
});

Features

  • arbitrary-precision arithmetic
  • complex quantities
  • geometric algebra
  • trigonometric functions
  • special functions
  • simplification
  • expansion
  • substitution
  • factoring
  • symbolic and numeric roots
  • units of measure
  • hyperreal numbers
  • matrices
  • derivatives and gradients
  • tensors
  • booleans
  • integrals
  • multi-integrals
  • open for extension

Getting Started

For a STEMCstudio example (click here to try)

Packages and API Documentation

Contributing

Please take a look at the contributing file.

References

STEMCmicro is a fork of Algebrite by Davide Della Casa. The fork adds Geometric Algebra, S.I. Units of Measure, and changes the way that expressions are matched and transformed.

Algebrite started as a port of the EigenMath CAS by George Weigt to TypeScript. Another fork of EigenMath: SMIB by Philippe Billet.

Another CAS of similar nature is SymPy made in Python.

Three other Javascript CAS are

  • javascript-cas by Anthony Foster supporting "differentiation, complex numbers, sums, vectors (dot products, cross products, gradient/curl etc)"
  • Coffeequate by Matthew Alger supporting "quadratic and linear equations, simplification of most algebraic expressions, uncertainties propagation, substitutions, variables, constants, and symbolic constants".
  • Algebra.js by Nicole White which among other things can build and solve equations via a "chainable" API.

About

Extensible Symbolic Mathematics in Browser

Resources

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages