Symbolic differentiation

next up previous contents
Next: A note on the quantification of variables
Up: Introduction to Prolog for Mathematicians
Previous: Operators

Symbolic differentiation

Using operators allows us to write very readable programs. Example: symbolic differentiation.

d( X, X, 1 ).

d( U+V, X, A+B ) :-
   d( U, X, A ),
   d( V, X, B ).

d( U*V, X, B*U+A*V ) :-
   d( U, X, A ),
   d( V, X, B ).

Read the second clause as

The differential of U+V with respect
to X is A+B if
    the differential of U with respect
    to X is A,
    and the differential of V with
    respect to X is B.

How much nicer this is than coding the structures in C or Pascal!

Jocelyn Ireson-Ireson-Paine
Mon Jul 17 22:27:41 BST 1995