HP Forums
(20S) and (21S) Numerical Derivative - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (20S) and (21S) Numerical Derivative (/thread-13000.html)



(20S) and (21S) Numerical Derivative - Eddie W. Shore - 05-20-2019 12:58 PM

Numerical Derivative

f'(x0) ≈ ( f(x0 + h) - f(x0 - h) ) / ( 2*h )

x = point
h = small change of x, example h = 0.0001

LBL A: Main Progam
LBL F: f(X), where R0 acts as X

Input variables:
R1 = h
R2 = point x0

Used variables:
R0 = x (use R0 for f(x), LBL F)

Calculated Variables:
R3 = f'(x)

Radians mode will be set.

Program:
Code:

01  LBL A:  61,41A
02  RAD:  61,24
03  RCL 2:  22,2
04  +:  75
05  RCL 1:  22, 1
06  =:  74
07  STO 0:  21,0
08 XEQ F:  41,F
09  STO 3:  21, 3
10  RCL 2: 22,2
11 -:  65
12 RCL 1: 22,1
13 =:  74
14 STO 0: 21,0
15 XEQ F:  41,F
16 STO - 3:  21,65,3
17 2:  2
18 STO ÷ 3:  21,45,3
19  RCL 1:  22,1
20 STO ÷ 3: 21,45,3
21  RCL 3:  22,3
22 R/S:  26
23 LBL F:  61,41,F
...
xx  RTN:  61,26  (end f(X) with RTN)

Example: e^x * sin x

LBL F
RCL 0
e^x
*
RCL 0
SIN
=
RTN

R1 = 0.0001
R2 = x0 = 0.03
Result: 1.060899867

R1 = 0.0001
R2 = x0 = 1.47
Result: 4.7648049