Derivatives on HP 42S

08262018, 04:47 PM
Post: #21




RE: Derivatives on HP 42S
Hi Thomas,
The solver for dx=0 of some function fx, and then the running of fx to find f(x) of the extremum found by dx is quite successful. When I run dx for, say, pi/4 (let's be simple and use fx=sin x), I get ~0 instead of ~.707 Why is dx successful in solve, but not as a means to find dx of a specific x value? 

08262018, 08:00 PM
Post: #22




RE: Derivatives on HP 42S
(08262018 04:47 PM)lrdheat Wrote: Why is dx successful in solve, but not as a means to find dx of a specific x value? (08212018 12:34 AM)Thomas Klemm Wrote: For a small discrete h, this can be approximated by To return an approximation for the derivative we have to divide \(\Im[f(x + ih)]\) by \(h\): Code: LBL "dF" With your example: Code: LBL "Fx" We can calculate the value of \(\frac{d}{dx}\sin(x)\) at \(x=1\): 1E6 STO "h" 1 STO "x" XEQ "dF" x: 5.40302305868e1 Compare this with \(\cos(1)\): 1 COS x: 5.40302305868e1 Best regards Thomas 

08262018, 08:39 PM
Post: #23




RE: Derivatives on HP 42S
(08262018 04:47 PM)lrdheat Wrote: When I run dx for, say, pi/4 (let's be simple and use fx=sin x), I get ~0 instead of ~.707 my guess is you forget to divide by h: df(x) ~ Im((f(x + i*h)) / h Code: >>> from cmath import * 

08292018, 01:52 PM
(This post was last modified: 08272019 10:07 PM by Albert Chan.)
Post: #24




RE: Derivatives on HP 42S
A blog from the inventor of Complex Step Differentiation Algorithm.
It had a fully worked out example, showing very stable and accurate estimates: https://blogs.mathworks.com/cleve/2013/1...entiation/ Real part of f(x + h*I) is also useful, for getting second derivative (involve subtraction): http://ancs.eng.buffalo.edu/pdf/ancs_pap..._gnc06.pdf Since we already have the value of y = f(x + h*I) of approximate extremum x, we can improve it: Code: from cmath import * 2nd order x = 14.137167 3rd order x = 14.1371669412 Actual x = 14.137166942003920 ... 

« Next Oldest  Next Newest »

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