Post Reply 
Namir, Byte and REXX
09-10-2018, 04:00 PM
Post: #10
RE: Namir, Byte and REXX
We can use the Complex-Step Derivative Approximation mentioned in Derivatives on HP 42S to calculate with a single subroutine call both \(f(x)\) and \(f'(x)\) in Newton's method:

\(x_{n+1}=x_{n}-{\frac {f(x_{n})}{f'(x_{n})}}\)

Code:
00 { 34-Byte Prgm }
01▸LBL "NEWTON"
02 STO "x"
03 RCL "h"
04 COMPLEX
05 XEQ "FF"
06 COMPLEX
07 RCL÷ "h"
08 ÷
09 STO- "x"
10 RCL "x"
11 END

For the equation \(2x^2+3x-12=0\) of the given example this program can be used:
Code:
00 { 19-Byte Prgm }
01▸LBL "FF"
02 2
03 RCL× ST Y
04 3
05 +
06 ×
07 12
08 –
09 END

Initialisation

1E-8
STO "h"


Iteration

5
XEQ "NEWTON"

y: 2.30434782609
x: 2.69565217391

R/S
y: 0.77053902071
x: 1.92511315320

R/S
y: 1.10972947392E-1
x: 1.81414020581

R/S
y: 2.40138878229E-3
x: 1.81173881703

R/S
y: 1.12553786619E-6
x: 1.81173769149

R/S
y: 2.47260969077E-13
x: 1.81173769149


Cheers
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Namir, Byte and REXX - Massimo Gnerucci - 09-07-2018, 11:32 AM
RE: Namir, Byte and REXX - Zaphod - 09-08-2018, 06:34 PM
RE: Namir, Byte and REXX - Geoff - 09-10-2018, 03:07 PM
RE: Namir, Byte and REXX - Duane Hess - 09-09-2018, 05:36 AM
RE: Namir, Byte and REXX - toml_12953 - 09-10-2018, 12:11 PM
RE: Namir, Byte and REXX - toml_12953 - 09-10-2018, 12:14 PM
RE: Namir, Byte and REXX - Thomas Klemm - 09-10-2018, 12:52 PM
RE: Namir, Byte and REXX - toml_12953 - 09-11-2018, 12:35 PM
RE: Namir, Byte and REXX - Thomas Klemm - 09-10-2018 04:00 PM



User(s) browsing this thread: 1 Guest(s)