I like Serena
That doesn't seem to work for all functions. Let f(x)=tan x. Then using that formula, we will get the tangent of pi/2 to be something like 3.8264459099620716 ( here )
The precondition is that the function is differentiable in the entire interval that is used.
In your example the function is not differentiable in pi/2.