The value h is an initial step size. It should not be too small, in fact, it should be an interval over which
the function changes substantially. I discuss this more in the section below, More comments on nder1()
and Ridders' method.
To use nder1() and return just the derivative estimate, use
nder1(f,x,h)[1]
where [1] specifies the first element of the returned list.
If nder1() returns a very large error, then the starting interval h is probably the wrong value. For
example,
nder1("tan",1.5707,"auto")returns {-1.038873452988 E7, 3.42735731968 E8}
Note that the error is quite large, on the order of 3.43E8. We can manually set the starting interval to
see if we can get a better estimate. First, using nder1p() (see below), we find that the starting interval
with the "auto" setting is about 1.108E-4. If we try nder1() with a starting interval of about 1/10 of this
value, we get
nder1("tan",1.5707,1E-5) = {1.07771 965667E8, 1.62341}
Since the error estimate is much smaller, we can trust the derivative estimate.
Execution time will depend on the execution time of the function for which the derivative is being found.
For simple functions, execution times of 5-20 seconds are not uncommon.
It can be convenient to have a user interface for nder1(). This program provides an interface:
nderui()
Prgm
© User interface for nder1()
© 3jan00/dburkett@infinet.com
© Result also saved in nderout
local fn1,xx,steps,smode,reslist,ssz
1→xx
.1→steps
lbl lp
string(xx)→xx
string(steps)→steps
dialog
title "NDER1 INPUT"
request "Function name",fn1
request "Eval point",xx
dropdown "Step size mode",{"auto","manual"},smode
request "Manual step size",steps
enddlog
if ok=0:return
expr(xx)→xx
expr(steps)→steps
when(smode=2,steps,"auto")→ssz
nder\nder1(fn1,xx,ssz)→reslist
6 - 31