Sunday, 18 March 2007

Symbolic math

I got surprised the first time I saw Mathematica working with symbolic expressions, and since then I always wondered how was that done, so i just went ahead and tried to do a mini Mathematica

I created a system that can learn rules. The rules are read by a simple parser that understands mathematical expressions, and once this is done it can derive, simplify, isolate variables...

For example to teach the system how the number zero works I'd do it this way:

der.AddRule( "a*0", "0" )
der.AddRule( "a+0", "a" )

where 'a' represents any expression , another rule for workign with powers:

der.AddRule( "(a^b)*a", "a^(b+1)" )

and to compute the derivative:

der.AddRule( "der(a,a)", "1" )
der.AddRule( "der(cos(a),b)", "-sin(a)*der(a,b)" )
der.AddRule( "der((a/b),c)", "(der(a,c)*b-a*der(b,c))/(b^2)" )


So I teached the system a bunch of rules and then its is able simplify, derive and isolate variables (this last one only works on some silly situations)

So, here is the code---> SymbolicMath.zip