Post Reply 
Second derivative with complex numbers
02-09-2021, 03:45 PM
Post: #2
RE: Second derivative with complex numbers
Here is another way to obtain the derivative formulas

\(\displaystyle f'(x) ≈ {f(x+ih) - f(x) \over ih}\)

\(\displaystyle f''(x) ≈ {f'(x) - f'(x-ih) \over ih}
≈ \frac{{{f(x+ih) - f(x) \over ih}} - {{f(x) - f(x-ih) \over ih}}}{ih}
= {f(x+ih) - 2 f(x) + f(x-ih) \over -h^2} \)

Weierstrass approximation theorem: we can assume f(x) is polynomial.
Conjugate of polynomial is polynomial of conjugate: f(x-hi) = conj(f(x+hi))

If f(x) is smooth and real, so does its derivatives → RHS must be real.

\(\displaystyle f'(x) ≈ {\Im(f(x+ih)) \over h} \)

\(\displaystyle f''(x) ≈ {\Re(f(x+ih) - f(x)) \over -h^2/2} \)

---

Using central difference derivative formula, we also get the same f'(x) formula.
Note: below does not assume real f'(x), RHS imaginary parts really cancelled out.

\(\displaystyle f'(x)
≈ {f(x+ih) - f(x-ih) \over 2ih}
= {\Im(f(x+ih)) - \Im(f(x-ih)) \over 2h}
= {\Im(f(x+ih)) \over h} \)

→ both derivative formulas should give accuracy similar to central difference formulas.

XCas> f(x) := x*(x^3+5*x^2-21*x)                    // example from here

XCas> f'(4)                                                         → 328
XCas> (f(x+h) - f(x-h)) / (2h) | x=4, h=1e-3        → 328.000021
XCas> im(f(x+h*i)) / h           | x=4, h=1e-3        → 327.999979

XCas> f''(4)                                                         → 270
XCas> (f(x+h)-2*f(x)+f(x-h))/h^2 | x=4, h=1e-3  → 270.000002132
XCas> re(f(x+h*i)-f(x)) / (-h^2/2) | x=4, h=1e-3  → 269.999998125
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Second derivative with complex numbers - Albert Chan - 02-09-2021 03:45 PM



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