qkmaxware / CsCas

c# computer algebra system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

C# CAS

Simple computer algebra system in C# using a DSL (domain specific language) to construct mathematical expression trees which can be manipulated, transformed, and evaluated.

Build Status

Getting Started

The library is available as a NuGet package for any .Net implementation that supports the .Net Standard 2.0. Visit the Packages page for downloads.

Examples

Creating expressions

var x = Symbol("x");
var y = Symbol("y");

var expression = y <= (x^2) + 6; 

Evaluating expressions

var x = Symbol("x");
var y = Symbol("y");

var expression = y <= (x^2) + 6; 
var y6 = expression.Where(x == 6).Value;

Algebraic rearrangement

var x = Symbol("x");
var y = Symbol("y");

var expression = y <= (x^2) + 6; 
var expression_for_x = expression.SolveFor(x);

Differentiation

Symbol y = new Symbol("y");
Symbol x = new Symbol("x");

var expr = y <= (x^2);
var ddx = expr.Differentiate(x).Simplify();

Functions for Expression Trees

var x = new Symbol("x");
var y = new Symbol("y");

var equation = y <= Trig.Sin(x);

Several common functions have already been created, such as the trigonometric functions which can be accessed using static methods like seen above. For adding custom functions, extend the Function class. In order for custom functions to work with algebraic rearrangement, additionally implement the IInvertable interface. In order for custom functions to work with the derivative calculator, additionally implement the IDifferentiable interface.

Made With

License

See License for license details.

About

c# computer algebra system

License:MIT License


Languages

Language:C# 100.0%