Post Reply 
Second derivative with complex numbers
02-11-2021, 07:01 PM (This post was last modified: 02-12-2021 01:43 PM by Werner.)
Post: #7
RE: Second derivative with complex numbers
A Free42 program for both first and second derivative.
I took h=sqrt(i), that seems to work as well, and then the division by h^2 for the second derivative is no longer necessary ;-)
Update: whenever I think I'm being smart, it turns out I make things worse. So the program below uses h = sqrt(i)/1e3..
Update 2 : shorter

Instructions: put the name of the function to derive in the ALPHA reg, X-value in X, press either F' or F" for first and second derivative, respectively.

Code:
00 { 86-Byte Prgm }
01▸LBL 02
02 RCL+ "X"
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ᴇ-12
13 SQRT
14 SQRT
15 LSTO "h"
16 XEQ 02
17 LSTO "."
18 RCL "h"
19 +/-
20 XEQ 02
21 FC? 48
22 GTO 00
23 STO+ "."
24 CLX
25 XEQ 02
26 STO+ ST X
27▸LBL 00
28 +/-
29 RCL+ "."
30 RCL "h"
31 FC? 48
32 STO+ ST X
33 FS? 48
34 X^2
35 ÷
36 COMPLEX
37 R↓
38 AOFF
39 END

With the polynomial above:

Code:
00 { 19-Byte Prgm }
01▸LBL "FX"
02 ENTER
03 ENTER
04 ENTER
05 5
06 +
07 ×
08 21
09 -
10 ×
11 ×
12 END

"FX"
4 XEQ "F'" -> 328 (-2.91e-29)
4 XEQ "F"" -> 270 (+2e-28)

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-11-2021 07:01 PM



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