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.
- In-tree matrix kernels. Basic Linear Algebra Subprograms (BLAS) and Linear Algebra PACKage (LAPACK) are implemented here rather than fetched: no Eigen, no OpenBLAS.
linalgowns 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.
What this is, in one minute
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.
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.
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.
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
Symbolic derivative
Result<T>
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.
symbolic library.
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 loadedNothing 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.
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.
tools/wasm/README.md.
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.
Core systems
Dense and sparse linear algebra with in-tree LU, QR, SVD, eigensolvers and Cholesky. Result<T> error handling throughout.
ODE, PDE, FEM, CFD
Time integration, finite elements and computational fluid dynamics, plus special functions and quadrature.
Statistics & ML
Distributions, inference, regression and the optimisation machinery underneath them.
Signal, image, control, finance
Transforms, filtering, image processing, control theory and quantitative finance primitives.
Computer algebra
A small symbolic CAS sitting alongside the numerics rather than bolted on top of them.
Graphs, geometry, topology, quantum
Number theory, graph algorithms, computational geometry, topology and quantum primitives.
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.
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.
| Gate | Setting |
|---|---|
| CTest suites | 816, 100% passed |
| Platform | Windows MSVC Release |
| CI matrix | MSVC + Linux GCC 13 |
| Coverage gate | 90% |
| Sanitizers | Enabled |
| Fuzzing | Enabled |
| Benchmark regressions | 28, 10% tolerance |
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.
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.
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.
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.
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.