[comp.sys.handhelds] HP48: User-defined derivative problemes

d89-mlt@sm.luth.se (Morgan Lindqvist) (02/21/91)

Hello world!

We have some problems to define discrete Heaviside step function
U(t) and it's derivative Unit impulse SIGMA(t) in the same
directory, and after that use: 'dt(U(5*t))' EVAL.

We have defined U(t) like: \<< \-> t 'IFTE(t\>=0,1,0)' \>>
         and derU(t) like: \<< \-> t dt 'SIGMA(t)' \>>
        and SIGMA(t) like: \<< \-> t 'IFTE(t==0,1,0)' \>>

Now, if we try to derivative 'U(a*5)' the HP48 will say
following:
           der Error
           Undefined Local Name
           4:
           3:
           2:         'U(a*5)'
           1:              'a'

Can someone help us solving this problem.
================================================================
|Mattias Dahl                 &            Morgan Lindvqist    |
|d89-mdl@sm.luht.se                        d89-mlt@sm.luth.se  |
|                                                              |
|                 University of Lulea, SWEDEN                  |
================================================================

john%solvint@orstcs.UUCP (02/23/91)

> 
> Relay-Version: VMS News - V6.0-1 14/11/90 VAX/VMS V5.4; site gacvx2.gac.edu
> Path: gacvx2.gac.edu!noc.MR.NET!uc!shamash!timbuk!uunet!bellcore!att!news.cs.indiana.edu!samsung!
>  think.com!mintaka!bloom-beacon!eru!hagbard!lunic!my!luth!d89-mlt
> Newsgroups: comp.sys.handhelds
> Subject: HP48: User-defined derivative problemes
> Message-ID: <1477@tau.sm.luth.se>
> From: d89-mlt@sm.luth.se (Morgan Lindqvist)
> Date: 20 Feb 91 20:12:05 GMT
> Distribution: comp
> Organization: University of Lulea, Sweden
> Lines: 27
> 
> 
> Hello world!
> 
> We have some problems to define discrete Heaviside step function
> U(t) and it's derivative Unit impulse SIGMA(t) in the same
> directory, and after that use: 'dt(U(5*t))' EVAL.
> 
> We have defined U(t) like: \<< \-> t 'IFTE(t\>=0,1,0)' \>>
>          and derU(t) like: \<< \-> t dt 'SIGMA(t)' \>>
>         and SIGMA(t) like: \<< \-> t 'IFTE(t==0,1,0)' \>>
> 
> Now, if we try to derivative 'U(a*5)' the HP48 will say
> following:
>            der Error
>            Undefined Local Name
>            4:
>            3:
>            2:         'U(a*5)'
>            1:              'a'
> 
> Can someone help us solving this problem.
> ================================================================
> |Mattias Dahl                 &            Morgan Lindvqist    |
> |d89-mdl@sm.luht.se                        d89-mlt@sm.luth.se  |
> |                                                              |
> |                 University of Lulea, SWEDEN                  |
> ================================================================
> 
> 

The following was ascertained from empirical trial:

First off, one defines ``user-defined derivatives'' when a function has no
built-in derivative.  Function 'U' is differentiable (to a degree) as far as the
48 is concerned.

Consider, put 'U(a*5)' on the stack and EVAL'uate it.  You get:

'IFTE(a*5\>=0,1,0)'

Differentiate this with respect to 'a' and get:

'IFTE(a*5\>=0,\.da(1),\.da(0))'

This is, I think, correct.  The critical point is still at a*5 and the result is
either the differential of 1 or 0 with respect to a.  But the 48 won't evaluate
this any further because of the undefined a in the condition.  It is a perfectly
valid function that can be put into the SOLVE'r or PLOT'ter, and returns 0 for
all points.  It doesn't reflect the discontinuity between 0 and 0+, however,
which is probably something you want.

The original attempt at differentiating failed probably because the 48 tried to
force evaluation of the condition and hit the undefined name (why it reported it
as a LOCAL name I don't know).

If you REALLY want to use a user-defined derivative, simply undefine (PURGE) the
function U before differentiating.  The derivative of U with respect to a is
then indeed unknown, so the 48 looks for and uses derU in its solution.  Using
your derU and SIGMA, the result is:

'IFTE(a*5==0,1,0)'

No evaluation needed before differentiating.  This is similar to the previous
result but defines the discontinuity at 0 and returns a slope of 1 at that
point.  (You could, by the way, replace derU with 'NOT t' and get the same
result.)

Finally, to accurately describe the discontinuity, you probably want a three-way
conditional for U, something like:

'IFTE(t>0,1,IFTE(t<0,0,0/0))'

This doesn't give a pretty symbollic derivative, but it does return an undefined
result error at t==0.


For what it's worth (I've been known to be wrong before), I hope I've helped.

--
John W. Loux                    | Solve and Integrate Corp
solvint!john@orstcs.cs.orst.edu | PO Box 1928
john@solvint.uucp               | Corvallis, OR 97339-1928
                                | (503) 754-1207