Reputation: 4869
I'm reading up on prolog simplifcation of algebraic expressions and there are some parts I dont understand.
So these are the basic simplications
x+0, x-0, 0+x, 0-x --> x.
x*1, x/1, 1*x --> x.
-1*x, x*(-1), x/(-1) --> –x.
x+(-x) --> x–x.
so given an expression
(x+4)*(2-x)
how do I make the derivation
(1+0)*(2-x)+(x+4)*(0-1)
?
I dont understand how the derivation came about. Help is much appreciated.
Upvotes: 1
Views: 1331
Reputation:
I guess by derivation you mean the mathematical derivative of the function f(x) = (x+4)*(2-x). This is a very famous old and not so hard computer algebra problem, solutions have been initially written for example in lisp.
A Prolog version is straight forward. You implement derivation rules such as:
d/dx (f + g) = d/dx f + d/dx g
d/dx (f * g) = d/dx f * g + d/dx g * f
etc..
I suggest you give it first a try by yourself bevor you check for example deriv.p. A computer algebra based autodiff is here deriv.p.
Bye
Upvotes: 2