Symbolic Differentiation Implementation in Prolog

Wojtek Jurczyk, Warsaw University of Technology

sym-diff-prolog

About
Sym-diff-prolog is an implementation of symbolic differentiation using Prolog. It is a bit optimized (it has arithmetic operations optimised; see the source code) but the implementation is still very simple. I hope you will find it useful for learning Prolog. Enjoy!

Functionality
It is capable of calculating derivatives of:* basic functions* sum of functions* subtraction of functions* multiplication of functions* division of functions* powers (thus, square root)* logarithmic and exponential functions* some trigonometric functions.
Any other functions can be easily added to the code :)

Example:
Let's ask about some derivative:
| ?- diff(x^(x*log(cos(x))), x, N).

The answer we get is:
N = x^(x*log(cos(x))-1)*(x*log(cos(x))+(log(cos(x))+x*(-sin(x)/cos(x)))*x*log(x)) 
The answer is correct and you can check it