To find centered difference approximation for \(f^{\prime }\left ( x\right ) \), we can processed as follows.
Since\[ f\left ( x_{o}+h\right ) =f\left ( x_{o}\right ) +hf^{\prime }\left ( x_{o}\right ) +O\left ( h\right ) \] Then\begin{equation} f^{\prime }\left ( x_{o}\right ) \approx \frac{1}{h}\left [ f\left ( x_{o}+h\right ) -f\left ( x_{o}\right ) \right ] \tag{1} \end{equation} But we also know that\[ f\left ( x_{o}-h\right ) =f\left ( x_{o}\right ) -hf^{\prime }\left ( x_{o}\right ) +O\left ( h\right ) \] The trick is to find \(f\left ( x_{o}\right ) \) from the above and plug it in (1). From the above we find\[ f\left ( x_{o}\right ) \approx f\left ( x_{o}-h\right ) +hf^{\prime }\left ( x_{o}\right ) \] substituting the above in (1) gives\begin{align*} f^{\prime }\left ( x_{o}\right ) & \approx \frac{1}{h}\left [ f\left ( x_{o}+h\right ) -\left ( f\left ( x_{o}-h\right ) +hf^{\prime }\left ( x_{o}\right ) \right ) \right ] \\ & \approx \frac{f\left ( x_{o}+h\right ) -f\left ( x_{o}-h\right ) }{h}-f^{\prime }\left ( x_{o}\right ) \end{align*}
Hence\[ f^{\prime }\left ( x_{o}\right ) \approx \frac{f\left ( x_{o}+h\right ) -f\left ( x_{o}-h\right ) }{2h}\]
We can do the same trick to find centered difference approximation for \(f^{\prime \prime }\left ( x_{o}\right ) \). Since\[ f\left ( x_{o}+h\right ) =f\left ( x_{o}\right ) +hf^{\prime }\left ( x_{o}\right ) +\frac{h^{2}}{2}f^{^{\prime \prime }}\left ( x_{o}\right ) +O\left ( h^{2}\right ) \] Then\begin{equation} f^{^{\prime \prime }}\left ( x_{o}\right ) \approx \frac{2}{h^{2}}\left ( f\left ( x_{o}+h\right ) -f\left ( x_{o}\right ) -hf^{\prime }\left ( x_{o}\right ) \right ) \tag{2} \end{equation} But we also know that\begin{align*} f\left ( x_{o}-h\right ) & =f\left ( x_{o}\right ) -hf^{\prime }\left ( x_{o}\right ) +\frac{h^{2}}{2}f^{^{\prime \prime }}\left ( x_{o}\right ) +O\left ( h^{2}\right ) \\ hf^{\prime }\left ( x_{o}\right ) & \approx -f\left ( x_{o}-h\right ) +f\left ( x_{o}\right ) +\frac{h^{2}}{2}f^{^{\prime \prime }}\left ( x_{o}\right ) \\ f^{\prime }\left ( x_{o}\right ) & \approx \frac{f\left ( x_{o}\right ) -f\left ( x_{o}-h\right ) }{h}+\frac{h}{2}f^{^{\prime \prime }}\left ( x_{o}\right ) \end{align*}
Sustituting the above into (2), we find\begin{align*} f^{^{\prime \prime }}\left ( x_{o}\right ) & \approx \frac{2}{h^{2}}\left [ f\left ( x_{o}+h\right ) -f\left ( x_{o}\right ) -h\left ( \frac{f\left ( x_{o}\right ) -f\left ( x_{o}-h\right ) }{h}+\frac{h}{2}f^{^{\prime \prime }}\left ( x_{o}\right ) \right ) \right ] \\ & \approx \frac{2}{h^{2}}\left [ f\left ( x_{o}+h\right ) -f\left ( x_{o}\right ) -\left ( f\left ( x_{o}\right ) -f\left ( x_{o}-h\right ) +\frac{h^{2}}{2}f^{^{\prime \prime }}\left ( x_{o}\right ) \right ) \right ] \\ & \approx \frac{2}{h^{2}}\left [ f\left ( x_{o}+h\right ) -2f\left ( x_{o}\right ) +f\left ( x_{o}-h\right ) -\frac{h^{2}}{2}f^{^{\prime \prime }}\left ( x_{o}\right ) \right ] \\ & \approx \frac{2}{h^{2}}\left ( f\left ( x_{o}+h\right ) -2f\left ( x_{o}\right ) +f\left ( x_{o}-h\right ) \right ) -f^{^{\prime \prime }}\left ( x_{o}\right ) \\ 2f^{^{\prime \prime }}\left ( x_{o}\right ) & \approx \frac{2}{h^{2}}\left ( f\left ( x_{o}+h\right ) -2f\left ( x_{o}\right ) +f\left ( x_{o}-h\right ) \right ) \end{align*}
Solving for \(f^{\prime \prime }\left ( x_{0}\right ) \) from the above gives\[ f^{^{\prime \prime }}\left ( x_{o}\right ) \approx \frac{f\left ( x_{o}+h\right ) -2f\left ( x_{o}\right ) +f\left ( x_{o}-h\right ) }{h^{2}}\] This method can be used to find approximations for higher derivatives.