Skip to content
Marcus Ackre Medina edited this page Sep 13, 2026 · 4 revisions

MarcusMedina.Maths.Algebra

Fluent API for symbolic algebra in C# — build, evaluate, differentiate and parse mathematical expressions.

Think of it as LINQ for mathematics: instead of chaining operations on collections, you chain them on algebraic expressions.

dotnet add package MarcusMedina.Maths.Algebra

Why this exists

In 2016, working as a study supervisor for upper-secondary (gymnasium) students, I had to explain the thinking behind their algebra assignments — or break the problems down into small enough pieces that they'd click. It was more than a little dismaying how much I'd forgotten since my own gymnasium days, and it got me thinking about how you'd actually explain algebra step by step as code. It took until 2022 for that thought to turn into action: I was hunting through an old gymnasium textbook for simple calculation exercises to use in a first C# course, and that's where the idea of algebra-as-code finally clicked.

In this case, I wanted the code itself to read like the explanation I'd give a student out loud, step by step, not just spit out a final answer.

Who this is for

  • New to algebra-as-code? Chain operations on expressions the same way you'd chain LINQ on a collection — build, differentiate, evaluate, and print ToLaTeX() step by step, watching each transformation.
  • Professional? A small symbolic-computation engine for formula/calculator tools, educational software, or domain-specific apps that need expression building and differentiation without a full CAS dependency.

Pages

Quick Example

using MarcusMedina.Maths.Algebra.Builders;
using MarcusMedina.Maths.Algebra.Extensions;
using MarcusMedina.Maths.Algebra.Evaluators;

var expr = Algebra.X.Square().Add(Algebra.X.Multiply(3)).Subtract(7);
Console.WriteLine(expr);                   // (x^2 + 3*x) - 7
Console.WriteLine(expr.Evaluate("x", 2)); // -5
Console.WriteLine(expr.ToLaTeX());        // (x^{2} + 3 \cdot x) - 7

Links

Clone this wiki locally