MarcusMedina.Maths.Algebra 0.3.2

dotnet add package MarcusMedina.Maths.Algebra --version 0.3.2
                    
NuGet\Install-Package MarcusMedina.Maths.Algebra -Version 0.3.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MarcusMedina.Maths.Algebra" Version="0.3.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MarcusMedina.Maths.Algebra" Version="0.3.2" />
                    
Directory.Packages.props
<PackageReference Include="MarcusMedina.Maths.Algebra" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MarcusMedina.Maths.Algebra --version 0.3.2
                    
#r "nuget: MarcusMedina.Maths.Algebra, 0.3.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MarcusMedina.Maths.Algebra@0.3.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MarcusMedina.Maths.Algebra&version=0.3.2
                    
Install as a Cake Addin
#tool nuget:?package=MarcusMedina.Maths.Algebra&version=0.3.2
                    
Install as a Cake Tool

MarcusMedina.Maths.Algebra

NuGet NuGet Downloads C# .NET License: MIT Open Source Build Signed Wiki

Fluent API for algebraic expressions, symbolic mathematics, and equation manipulation in C#

Build expression trees, evaluate symbolic math, and export to LaTeX - all with a clean, fluent interface designed for both education and production use.

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.


๐Ÿš€ Features

  • โœ… Expression Trees - Build complex algebraic expressions programmatically
  • โœ… Symbolic Math - Work with variables and expressions without immediate evaluation
  • โœ… Fluent API - Chain operations naturally: Algebra.X.Add(5).Square()
  • โœ… Variable Substitution - Replace variables with values or other expressions
  • โœ… Simplification - Automatic constant folding and identity rule application
  • โœ… LaTeX Export - Generate publication-ready mathematical notation
  • โœ… Type-Safe - Full type safety with expression validation
  • โœ… Extensible - Easy to add custom functions and operators
  • ๐Ÿ”œ Expression Parser - Parse strings like "3*(x+2)^2" (coming soon)
  • ๐Ÿ”œ Symbolic Differentiation - Automatic derivative calculation (coming soon)
  • ๐Ÿ”œ Matrix Operations - Fluent matrix algebra (coming soon)

๐Ÿ“ฆ Installation

dotnet add package MarcusMedina.Maths.Algebra

Or via Package Manager Console:

Install-Package MarcusMedina.Maths.Algebra

Requirements:

  • .NET 10.0 or later
  • C# 14.0 or later

๐ŸŽ“ Quick Start

Basic Usage

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

// Create expression: (x + 2)^2 / 3
var expr = Algebra.X
    .Add(2)
    .Square()
    .Divide(3);

// Evaluate with x = 4
double result = expr.Evaluate("x", 4);  // (4 + 2)^2 / 3 = 12

// Export to LaTeX
string latex = expr.ToLaTeX();  // \frac{(x + 2)^{2}}{3}

Variable Substitution

// Work with multiple variables
var expr = Algebra.X.Multiply(2).Add(Algebra.Y);

// Substitute and evaluate
var vars = new Dictionary<string, double> { ["x"] = 3, ["y"] = 5 };
double result = expr.Evaluate(vars);  // 2*3 + 5 = 11

๐Ÿ“– Documentation


๐Ÿ”ง Use Cases

This library solves real-world problems in mathematics and education:

  1. Equation Solver - Programmatically build and solve algebraic equations
  2. LaTeX Generator - Convert mathematical expressions to publication-ready notation
  3. Symbolic Calculator - Interactive symbolic mathematics with variable substitution

Each use case includes a working example and demonstrates how to integrate this library.


๐Ÿ’ก Examples

Creating Complex Expressions

// (2x^2 + 3x + 1) / (x - 1)
var numerator = Algebra.X
    .Square()
    .Multiply(2)
    .Add(Algebra.X.Multiply(3))
    .Add(1);

var denominator = Algebra.X.Subtract(1);

var fraction = numerator.Divide(denominator);
var simplified = fraction.Simplify();

Generating Mathematical Notation

var expr = Algebra.X
    .Add(5)
    .Multiply(Algebra.X.Subtract(3));

var latex = expr.ToLaTeX();
// Output: (x + 5)(x - 3)

var text = expr.ToString();
// Output: (x + 5) * (x - 3)

๐Ÿงช Testing

Run the test suite:

cd csharp
dotnet test --configuration Release

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ” Package Integrity

All releases are signed with cosign (Sigstore keyless signing).

To verify a downloaded package:

cosign verify-blob <package.nupkg> \
  --bundle <package.nupkg.sigstore.json> \
  --certificate-identity-regexp "https://github.com/MarcusMedinaPro/.*/release.yml" \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com

The .sigstore.json bundle is available in each GitHub Release.


๐Ÿค Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“ž Support


Built with Human + AI Collaboration

This library was written by Marcus Medina together with Claude Code (Anthropic) โ€” not through "vibe coding" where you just describe and accept, but through genuine collaboration: planning together, reviewing each other's decisions, pushing back when something felt wrong, and iterating until the result felt right.

The goal was always to write code worth reading and code worth using โ€” the kind a student can open, understand, and learn from, and the kind any programmer can drop into real, professional work without wanting to rewrite it from scratch. AI was a partner in that process, not a shortcut around it.

If you're curious about this way of working, the source code and git history are open. Every decision has a reason behind it.

Made for Curious Minds

This library was built with students in mind โ€” not as a black box to copy and paste, but as a real-world example of how clean, purposeful code is written and shared. At the same time, it's built to be genuinely useful in professional projects too โ€” for any developer who's tired of writing the same code over and over.

Whether you're discovering C# for the first time, need a reliable helper for your school project, want a dependable building block for production work, or are simply trying to fall in love with writing code โ€” you're exactly who this was made for.

The source is open. Read it, fork it, break it, improve it. That's the whole point.


Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.2 161 7/3/2026
0.3.1 153 6/29/2026