Post Reply 
Second derivative with complex numbers
02-13-2021, 02:50 PM (This post was last modified: 02-13-2021 03:15 PM by Werner.)
Post: #11
RE: Second derivative with complex numbers
That calls for a new rewrite, simpler again.
Another attempt at improvement, I take h = ε*√(2*i) = (ε,ε) - then both h and h^2 are exact (in a decimal calculator. This is the hpmuseum, after all)

Code:
00 { 71-Byte Prgm }
01▸LBL 02
02 +
03 ASTO ST L
04 GTO IND ST L
05▸LBL "F'"
06 AOFF
07 GTO 00
08▸LBL "F""
09 AON
10▸LBL 00
11 LSTO "X"
12 1ᴇ-3
13 ENTER
14 COMPLEX
15 LSTO "h"
16 XEQ 02
17 X<> "X"
18 RCL "h"
19 +/-
20 XEQ 02
21 FC? 48
22 +/-
23 RCL+ "."
24 RCL "h"
25 FC? 48
26 STO+ ST X
27 FS? 48
28 X^2
29 ÷
30 COMPLEX
31 R↓
32 AOFF
33 END

Still, for F', I favour the f'(x) = Im(f(x+ih))/h formula, as it needs only one function evaluation.
Then the routines become:

Code:
00 { 77-Byte Prgm }
01▸LBL 02
02 +
03 ASTO ST L
04 GTO IND ST L
05▸LBL "F""
06 LSTO "X"
07 1ᴇ-3
08 ENTER
09 COMPLEX
10 LSTO "h"
11 XEQ 02
12 X<> "X"
13 RCL "h"
14 +/-
15 XEQ 02
16 RCL+ "X"
17 RCL "h"
18 X^2
19 ÷
20 COMPLEX
21 R↓
22 RTN
23▸LBL "F'"
24 1ᴇ-99
25 COMPLEX
26 ASTO ST L
27 XEQ IND ST L
28 COMPLEX
29 1ᴇ99
30 ×
31 END

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Second derivative with complex numbers - Werner - 02-13-2021 02:50 PM



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