https://github.com/peter-juhasz/science.mathematics.algebra
Algebra system using Roslyn as a model.
https://github.com/peter-juhasz/science.mathematics.algebra
algebra computer-algebra-system dotnet mathematics science
Last synced: 11 months ago
JSON representation
Algebra system using Roslyn as a model.
- Host: GitHub
- URL: https://github.com/peter-juhasz/science.mathematics.algebra
- Owner: Peter-Juhasz
- License: mit
- Created: 2015-01-16T22:41:40.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2022-05-08T09:59:03.000Z (about 4 years ago)
- Last Synced: 2025-04-07T19:21:10.385Z (about 1 year ago)
- Topics: algebra, computer-algebra-system, dotnet, mathematics, science
- Language: C#
- Homepage:
- Size: 185 KB
- Stars: 5
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Science.Mathematics.Algebra
Computer Algebra System (CAS) implemented in **.NET Standard 1.6** using Roslyn as a model.
You can create algebra expressions using `ExpressionFactory`, by implicit conversions (numbers and symbols) and by combining them using the basic operators.
```C#
using static ExpressionFactory;
```
Let's do some symbolic computation:
```C#
var x = Symbol('x');
```
You can perform basic operations to build new expressions using the built-in operators:
```C#
var expression = (x ^ 2) + 3 * x + 5;
```
Differentiate the expression above by `x`:
```C#
var differentiated = expression.Differentiate(x); // d/dx (x ^ 2) + 3 * x + 5
```
This gives you a new kind of expression not the result yet. If you want to evaluate it, call `Simplify` which is going to return the most simple form (eliminating the zero constant from the end):
```C#
var result = differentiated.Simplify(); // 2 * x + 3
```
Or you can also convert the differentiation expression to a limit:
```C#
var limit = differentiated.ToLimit();
```
## Extensibility for simplification logic
An example for a simplifier which denotes that power expressions like `x ^ 1` can be simplified to `x`:
```C#
public sealed class ExponentOneSimplifier : ISimplifier
{
public AlgebraExpression Simplify(PowerExpression expression, CancellationToken cancellationToken)
{
if (expression.Exponent.GetConstantValue(cancellationToken) == 1)
return expression.Base;
return expression;
}
}
```