The Museum of HP Calculators

HP Forum Archive 18

[ Return to Index | Top of Index ]

HP 50g finding the nth derivative
Message #1 Posted by Jonathan Vogel on 8 Mar 2008, 4:05 p.m.

Is there a way I can find the nth derivative of a function using the hp 50g?

      
Re: HP 50g finding the nth derivative
Message #2 Posted by Mark W Paris on 10 Mar 2008, 10:56 a.m.,
in response to message #1 by Jonathan Vogel

Hi Jonathan -- I don't know if there's a key-sequence that'll do it for you, but I tend to doubt it. I checked the manual and didn't find any f^{(n)} function.

You can write a short program using matrix functions to do it.

Suppose you want the n-th derivative. The brute force way of doing this is to evaluate the function at n+1 points and take the finite differences dividing out (for n>0) some appropriate interval. Eg.

f^{(1)}(x) = \frac{f(h)-f(-h)}{2h} (LaTeX form - should be pretty obvious)

The error in this equation is O(h^2) since we've taken the symmetric diffrence.

Now if we truncate the Taylor expansion for a function f(x) about a point f(x_0) at order n

f(x)-f(x_0)=\sum_{m=1}^n f^{(m)}(x_0) x^m/m!

we can write a linear system of equations for the derivatives f^{(m)} for m>0 in terms of the differences of the function evaluated at x_0 and multiples of some small number h as

f^{(m)}(x_0) = \sum_{j=1}^n A^{-1}_{mj} [f_j-f(x_0)]

where f_j = f(x=j*h) and A^{-1} is the inverse of the matrix

A_{jm} = (j*h)^m/m!

The method is accurate to O(h^(n-j)) for the j-th derivative.

There are some tricks you can play to improve the accuracy of the algorithm, like taking symmetric intervals about x_0, ie. x=+/-h, x=+/-2h, x=+/-3h, ... but the idea is the same.

Of course, as always, you should check any math people tell you yourself.

            
Re: HP 50g finding the nth derivative
Message #3 Posted by Marcus von Cube, Germany on 10 Mar 2008, 12:34 p.m.,
in response to message #2 by Mark W Paris

Why not do it symbolically in RPL?

<< -> fn var n 
  <<
    fn
    1 n START
      var
      d
    NEXT
    EVAL
  >>
>>
'dN' STO
It can be used on the stack or algebraically like this:
'dN(X^4,X,3)'
EVAL
The latter leads to 24*X as a result.

Marcus

Edited: 10 Mar 2008, 4:13 p.m. after one or more responses were posted

                  
Re: HP 50g finding the nth derivative
Message #4 Posted by Mark W Paris on 10 Mar 2008, 12:46 p.m.,
in response to message #3 by Marcus von Cube, Germany

Much nicer. Guess I should learn RPL.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall