MarcusMedina.Fluent.Maths.Algebra
0.5.0
better code
dotnet add package MarcusMedina.Fluent.Maths.Algebra --version 0.5.0
NuGet\Install-Package MarcusMedina.Fluent.Maths.Algebra -Version 0.5.0
<PackageReference Include="MarcusMedina.Fluent.Maths.Algebra" Version="0.5.0" />
<PackageVersion Include="MarcusMedina.Fluent.Maths.Algebra" Version="0.5.0" />
<PackageReference Include="MarcusMedina.Fluent.Maths.Algebra" />
paket add MarcusMedina.Fluent.Maths.Algebra --version 0.5.0
#r "nuget: MarcusMedina.Fluent.Maths.Algebra, 0.5.0"
#:package MarcusMedina.Fluent.Maths.Algebra@0.5.0
#addin nuget:?package=MarcusMedina.Fluent.Maths.Algebra&version=0.5.0
#tool nuget:?package=MarcusMedina.Fluent.Maths.Algebra&version=0.5.0
FluentBuilders.Algebra
Fluent API for algebraic expressions, symbolic mathematics, and equation manipulation in C#
Think of it as LINQ for mathematics โ the same idea of chaining readable operations, but instead of transforming collections, you transform algebraic expressions:
// LINQ transforms data:
numbers.Where(x => x > 0)
.Select(x => x * 2)
.Sum();
// Algebra transforms expressions:
Algebra.X.Square()
.Add(Algebra.X.Multiply(3))
.Subtract(7)
.Differentiate("x"); // โ 2x + 3
Just like LINQ hides iterators and lazy evaluation behind a clean API, this library hides expression trees behind readable math. You see what the code means, not how it works internally.
๐ Features
- โ Expression Trees โ Build complex expressions programmatically
- โ Symbolic Math โ Work with variables without immediate evaluation
- โ
Fluent API โ Chain operations naturally:
Algebra.X.Add(5).Square() - โ
Expression Parser โ Parse strings like
"3*(x+2)^2"directly - โ
Symbolic Differentiation โ
expr.Differentiate("x")with full chain/product/quotient rules - โ Equation Solver โ Linear, quadratic, bisection, Newton-Raphson
- โ Matrix Operations โ Add, multiply, transpose, determinant
- โ Variable Substitution โ Replace variables with values or other expressions
- โ Simplification โ Constant folding and identity rules
- โ LaTeX Export โ Generate publication-ready mathematical notation
- โ
Constants โ
Algebra.Pi,Algebra.Ebuilt in
๐ฆ Installation
dotnet add package MarcusMedina.Fluent.Maths.Algebra
Or via Package Manager Console:
Install-Package MarcusMedina.Fluent.Maths.Algebra
Requirements:
- .NET 10.0 or later
- C# 14.0 or later
๐ Quick Start
Basic Usage
using MarcusMedina.Fluent.Maths.Algebra.Builders;
using MarcusMedina.Fluent.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
- Getting Started - Installation and setup guide
- Manual - Comprehensive documentation
- Examples - Detailed usage examples
- API Reference - Complete API documentation
๐ง Use Cases
This library solves real-world problems in mathematics and education:
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.
๐ค Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
๐ Related Projects
- FluentBuilders.Units.Math - Unit-aware mathematical operations
- FluentBuilders.Maths.Calculus - Symbolic calculus (coming soon)
Package integrity
All releases are signed with cosign (Sigstore keyless signing).
To verify a downloaded package, download both the .nupkg and its .sigstore.json bundle from the GitHub Release, then run:
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
Expected output: Verified OK
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 โ the kind a student can open, understand, and learn from. 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.
Whether you're discovering C# for the first time, need a reliable helper for your school project, 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.
And if this library saved you an afternoon, or made something click that didn't before โ that's everything.
Non-students are equally welcome. Good code doesn't care about your diploma.
โญ If this helped you, consider starring the project on GitHub โ it helps other students find it too.
๐ฌ Have an idea, a feature request, or just want to say hi? Open an issue on GitHub โ I'd love to hear from you.
| Product | Versions 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. |
-
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 |
|---|