I have been having trouble coming up with an approximation formula for numerical differentiation (2nd derivative) of a function based on the truncation of its Taylor Series. I am not sure if the error is an algebraic one or otherwise.
I start of with the truncated Taylor series expanded about an arbitrary point a, which is derived from Taylor's theorem:
$f(a+h) = f(a) + h \cdot f'(a) + \frac { h^2 \cdot f''(a)}{2}$
The unknown is $f''(a)$, so let's switch the equation around:
$\frac{ h^2 \cdot f''(a) }{2} + h \cdot f'(a) + f(a) = f(a+h)$
Substracting $h \cdot f'(a) + f(a)$ from both sides, I get:
$\frac{f''(a)}{h^2}= f(a+h) - f(a) - h \cdot f'(a) $
Since h is small, I then substitute $f'(a)$ by the secant $\frac{( f(a+h) - f(a) )}{h}$ :
$ \frac { h^2 \cdot f'(a)}{2} = f(a+h) - f(a) - h \cdot \frac{( f(a+h) - f(a) )}{h} $
$ \frac { h^2 \cdot f'(a)}{2}$ = $f(a+h) - f(a)$ $-$ $f(a+h) + f(a)$ = 0
I thus end up with the confusing result that f''(a) = 0 for arbitrary values of a. Can anybody tell me what went wrong?
Your substitution of $f'(a)$ by the approximation $(f(a+h) - f(a) )/h$ is exact when when $f'(x)$ is constant for all $x \in [a,a+h]$, i.e. when $f''(x)=0$ on that interval. So it is unsuitable when trying to approximate $f''(a)$
Instead you could take your
$$\frac12 h^2 f''(a)\approx f(a+h) - f(a) - hf'(a)$$ and rewrite it to say $$f''(a)\approx \frac{2}{h^2}( f(a+h) - f(a) - hf'(a))$$