May 4, 2014 at 10:33 AM
Edited May 4, 2014 at 10:34 AM

Hi everyone,
I have a project that allows describing in .NET the transformation rules for computer algebra systems. These rules transform syntax trees and may be used for differentitation, simplification and other such tasks. It was a part of my project (not related to
computer algebra), but it is discontinued. Now i'm trying to pass this solution to good hands, in case there is an interest for this.
As I learned from Math.NET code, differentiation and other such actions are performed with Visitor pattern. Although, defining it with rules is more natural and more convenient.
The definition of a rule is as follows:
Rule
// searches for a tuple (A,B,C) of an arbitrary node A and its children B and C
.Select(AnyA[ChildB, ChildC])
//reject tuples (A,B,C) where B is not a constant or A is not a product
.Where<ScalarProduct<double>, Constant<double>, INode>
//checks the B's value equals to zero
(z => z.B.Value.Equals(0d))
// cut A node and replace it with B, i.e. with 0
.Mod(z => z.A.Replace(z.B.Node));
If you are interested, please find more samples and the source code at
http://github.com/airlabs/CA


Coordinator
May 6, 2014 at 5:42 PM

That looks very interesting, thanks for sharing!
My latest stab at computer algebra,
Math.NET Symbolics, actually uses straight recursive F# pattern matching ( example: differentiation) which makes the code very compact and readable,
but as is is indeed not dynamically extensible, so a rule approach might come in handy (also e.g. once we move towards symbolic integration).
Thanks,
Christoph

