Math you can run.

A small lab for simulation and modeling. The work is written in Rustlab, a fast language in the spirit of MATLAB, and checked by running it.

Rustlab

Rustlab is a matrix algebra and DSP toolkit written in Rust. It is built to be fast and lean: scripts, a REPL, and a library you can embed. The syntax stays close to MATLAB, with ranges, elementwise operators, and plots, so a model reads like the math.

It is meant to be used with AI tools. Ask for an explanation of a hard problem and get a program you can run, plot, and correct, instead of a paragraph you have to trust.

a = 1:5
b = a .* a
print(b)

Notebooks

A new worked example, about once a week, written for electrical engineers and scientists. Each page is a Rustlab notebook: the code ran, and the plots and the numbers are the output.

This week — FIR filter quantization

A 63-tap lowpass at 48 kHz, designed in floating point with firpm, then cut to 10-bit coefficients. Rounding the taps raises passband ripple and lifts the stopband. firpmq re-optimizes in the integer domain and recovers about 7 dB of stopband rejection. The plots use the dark theme.

Rustlab LLM

Rustlab LLM is a tutorial that builds a language model from the ground up in Rustlab. Each lesson pairs the mathematics with a script and a plot, from tokens and probability through a GPT-style decoder. Nothing is left as a black box.

Lessons 00 through 26 are on this site: the code, the numbers, and the figures, from tokens through a GPT-style model.

Rustlab EM

Rustlab EM is a course in classical electromagnetics. It starts from vector calculus and Coulomb’s law and works through Gauss’s law, magnetostatics, Maxwell’s equations, and wave simulation. Each lesson pairs the mathematics with a Rustlab script that computes the fields.

The rendered lessons, with output and figures, can be read on GitHub without installing anything.

Quantum computing

The same approach is being used for quantum computing. States, gates, and small algorithms are written as linear algebra in Rustlab, so the calculation is visible and can be rerun. The point is to see how a quantum step works, not to hide it behind a framework.