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:
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/air-labs/CA