; ************************************************************
; Derivative Approximation 1
; ************************************************************
; Sourcebook for Programmable Calculators, Pgs. 3-6 - 3-9
;  Numerical Approximation of Derivatives

#EMULATOR c:\ti-59\prg2\deriv1\deriv1.t59
#LISTING c:\ti-59\prg2\deriv1\deriv1.lst
#POCKETPC c:\ti-59\prg2\deriv1\deriv1.ti

; Stores values of x.
; -------------------
lbl a
sto 1 sto 2 r/s

; Calculates h, based on magnitude of x.  If IxI<=.01, transfers
; to C.  If IxI>.01, calculates h as .001 IxI.
; --------------------------------------------------------------
abs x%t . 0 1 ge c . 0 0 1
* rcl 1 abs = gto b

; Enters .00001 as h.
; -------------------
lbl c
. 0 0 0 0 1

; Stores h.
; ---------
lbl b
sto 3

; Calculates f(x+h), f(x-h), and f(x+h)-f(x-h)/2h to find f'(x).
; --------------------------------------------------------------
sum 1 e sto 4 rcl 2 - rcl 3
= sto 1 e +/- + rcl 4 = / (
2 * rcl 3 = prt r/s

; Labels subroutine for f(x)
; --------------------------
lbl e
; Insert instructions for f(x) here:

rtn
 
#end
 