MathScript · v1.0.0 pre-release

One C++23 library, from LU to CFD

Engineering software runs on heavy mathematics, and almost nobody writes their own. It is stitched together from other people’s libraries and paid platforms — hard to audit, hard to change, and hard to install where the build machine has no internet. MathScript does the mathematics itself, from matrix arithmetic up to fluid dynamics, in one C++ library with nothing to fetch.

LanguageC++23
Test suites816 CTest
Coverage gate90%
Static libraries35
Last pushrecently
Two decisions that shape everything
  • In-tree matrix kernels. Basic Linear Algebra Subprograms (BLAS) and Linear Algebra PACKage (LAPACK) are implemented here rather than fetched: no Eigen, no OpenBLAS. linalg owns LU, QR, Singular Value Decomposition (SVD), eig, Cholesky and the LAPACK-style kernels, so deployment is a compile rather than a dependency hunt.
  • A restricted C++ subset. No raw pointers, no exceptions, no unsafe casts — enforced at compile time. Production code returns Result<T>, so error handling is deterministic and visible in the type.
In plain English

What this is, in one minute

The problem

Stress, flow, signals, risk — the calculations underneath engineering software are rarely written by the team shipping it. They arrive from a dozen outside libraries and paid platforms that have to be fetched, licensed and trusted. When an answer looks wrong, the workings are in somebody else’s code; on a sealed build machine you may not be able to fetch them at all.

The solution

MathScript is one C++ library that does the mathematics itself: linear algebra, statistics, differential equations, finite elements, fluid flow, optimisation and a symbolic algebra system, across thirty-five static libraries. The matrix routines most projects import from BLAS and LAPACK are written here instead. All 816 test suites pass on the Windows build. v1.0.0 has not shipped yet.

Who it is for

Teams whose build machines cannot reach the internet — defence, medical, aerospace, banking — where every fetched dependency is another approval. Products that do their real work in C++ and their mathematics in Python, and carry two sets of problems for it. Teachers and students who want the method written out where it can be read.

The mathematics is in the tree, not in a dependency list. That is the argument, and the rest of this page is the evidence: what the thirty-five libraries hold, why a failure comes back in the return type instead of as an exception, and exactly what the test numbers cover.
Interactive

A symbolic Computer Algebra System (CAS), running in your browser

Type an expression. It is tokenised, parsed to an Abstract Syntax Tree (AST), differentiated symbolically, simplified, then evaluated numerically for the plot — alongside a Simpson-rule integral and bisection root-finding over the visible interval.

mathscript-repl

f(x) =
f(x) f′(x), symbolic roots of f

Symbolic derivative


          
∫ over domain
—
Roots found
—
AST nodes
—
Parse
—

Result<T>

Ok
Parsed and differentiated without error.

Supported: + - * / ^, sin cos tan exp log sqrt abs sinh cosh tanh asin acos atan, constants pi and e. The real CAS is considerably larger; this is the same idea at reading scale.

A tokeniser, recursive-descent parser, symbolic differentiator and simplifier written for this page. The C++ implementation lives in the symbolic library.
Not a reimplementation

The actual C++ library, compiled to WebAssembly

Everything above is JavaScript written for this page — honest, but a model of the real thing. Below is the real thing: libms_symbolic itself, compiled from the same source that builds the native library, running in your browser.

ms::sym_diff — WebAssembly

not loaded

Nothing is downloaded until you press load, and then it is fetched once. The module is 113 kilobytes (KB) of WebAssembly and 10 KB of loader — the full library build is 4.9 megabytes (MB), so this links only what these four calls reach. The panel shows the library version and the vector Instruction Set Architecture (ISA) the build reports.

Simplified
—
Derivative
—
Integral
—
Library
—
Vector ISA
—
The ISA line is the library telling the truth about itself. It asks ms::detect_isa(), the same call it makes natively. On your desktop that answers with one of the Advanced Vector Extensions (AVX2 or AVX-512); here there is one vector ISA and it says so.
Built with Emscripten from the MathScript tree. Three portability defects had to be fixed to get there, all of which also affect native builds on Apple clang and on ARM — see tools/wasm/README.md.
Scope

Thirty-five static libraries, six domains

Dense and sparse linear algebra, special functions, statistics and Machine Learning (ML). Ordinary Differential Equations (ODE) and Partial Differential Equations (PDE), the Finite Element Method (FEM) and Computational Fluid Dynamics (CFD). Optimisation, signal and image processing, number theory, graphs, geometry, topology, quantum primitives, control, finance, compression — and a symbolic CAS. With LU, QR, SVD, eigensolvers and Cholesky written in-tree.

Six library domains — core systems, numerical, statistics and machine learning, applied, symbolic and specialised — over a Result<T> base rail with no exceptions or raw pointers
scroll to see the whole diagram →
Thirty-five libraries, one error convention. The rail underneath is the point: failure is in the return type, not in an exception you find at the top of the stack.
Core

Core systems

Dense and sparse linear algebra with in-tree LU, QR, SVD, eigensolvers and Cholesky. Result<T> error handling throughout.

Numerical

ODE, PDE, FEM, CFD

Time integration, finite elements and computational fluid dynamics, plus special functions and quadrature.

Statistics

Statistics & ML

Distributions, inference, regression and the optimisation machinery underneath them.

Applied

Signal, image, control, finance

Transforms, filtering, image processing, control theory and quantitative finance primitives.

Symbolic

Computer algebra

A small symbolic CAS sitting alongside the numerics rather than bolted on top of them.

Specialised

Graphs, geometry, topology, quantum

Number theory, graph algorithms, computational geometry, topology and quantum primitives.

Shipping surface

Three executables, optional everything else

Everything past the three executables is a build option — a Qt Graphical User Interface (GUI), CUDA, the Message Passing Interface (MPI), and a Just-In-Time (JIT) compiler built on LLVM’s On-Request Compilation (ORC) layer.

mathscriptcCompiler / batch driver
mathscript-replInteractive session
mathscript-serverService mode
OptionalQt GUI, CUDA, MPI, LLVM ORC JIT
Verification

What 816 suites buy you

The Continuous Integration (CI) matrix behind the gates below covers two compilers: Microsoft Visual C++ (MSVC) on Windows and the GNU Compiler Collection (GCC) 13 on Linux.

GateSetting
CTest suites816, 100% passed
PlatformWindows MSVC Release
CI matrixMSVC + Linux GCC 13
Coverage gate90%
SanitizersEnabled
FuzzingEnabled
Benchmark regressions28, 10% tolerance
Pre-release means pre-release. v1.0.0 has not shipped. The 816-suite figure is from Windows MSVC Release; the Linux GCC 13 leg runs in CI but the headline number is the one measured on Windows.
Who it is for

A complete maths toolkit for programmers, in one piece

Serious calculation work usually means bolting together a dozen separate pieces of software and hoping they agree. This is one library that covers the lot.

01

Teams that are not allowed to download anything

Defence, medical, aerospace and banking build systems are often sealed off from the internet. Everything here is included, so there is nothing to fetch and nothing to get approved.

02

Teams tired of bolting Python onto a product

A lot of software does its real work in one language and its maths in another, which means two sets of problems. This keeps the maths in the same language as the product.

03

Teaching and learning

The methods are written out in full and can be read, rather than hidden inside a supplier's sealed component. Students can follow what is actually happening.

Recognise your situation here? This is open for beta testing now, and the people it is built for are the ones whose feedback actually changes it. Become a beta tester →
Why no exceptions

A numerical library that cannot throw at you

Numerical code fails in ordinary ways: a singular matrix, a non-convergent iteration, a domain error in a special function. Signalling that with an exception means every caller either wraps everything in try or discovers the failure at the top of the stack with no context. MathScript makes the failure part of the return type.

// Every production entry point returns Result<T>.
auto lu = linalg::lu_factor(A);
if (!lu) return lu.error();          // singular — handled, not thrown

auto x = lu->solve(b);
if (!x) return x.error();

// No raw pointers, no unsafe casts, no exceptions:
// the restricted subset is enforced at compile time.