Vincze, my friend,

recently you asked how to do symbolic differentiation on the HP35S. I though this was easy, but it actually is harder than I thought. I know symbolic differentiation is pressty easy once you have your algebraic expression assembled as a tree, e.g. for

x + sin (x*x)

which would look like

+

x sin

*

x x

and where the rules are:

1. x -> 1

2. + -> diff (left branch) + diff (right branch)

3. sin -> diff (below branch) * cos (branch)

4. * -> diff (left) * right + left * diff (right)

resulting in

+

1 *

+ cos

* * *

1 x x 1 x x

by applying the above recursively. I thought this would be easy to convert from the tree notation to RPN, but it was not so easy.

Storage of the expression on the 35S however seems pretty straightforward, by using the indirect registers and representing the operands as negative numbers (so you can e.g. solve for x by storing -24 in I), and representing the operators as positive numbers, +=1, -=2, *=3 ... sin=21, cos=22, ... or whatever.

x x x * sin +

would thus become

I 1 2 3 4 5 6

(I) -24 -24 -24 3 21 1

This way you could write a routine which evaluates the indirect variables and leaves the result in the X register.

The trouble is now that when you're working your way through from right to left, you don't know yet where the operands finish yet (unlike in the case of the tree).

Therefore I did not succeed in providing the symbolic differentiation on the 35S.

Cheers, Peter.

*Edited: 7 Sept 2007, 11:29 a.m. *