In this we are going to understand the difference in the values obtained by analytical and numerical derivative.
The function is
We are also going to see how the error minimizes when we decrease the value of dx.
I used both first order and second order approximation, the results show us that second order approximation has less error than first order for the same value of dx.
Output
analytical derivative is -1.725
forward differencing method gives -1.5464
central differencing method gives -1.7448