Minimize compounded error in forward difference formula

43 Views Asked by At

I am trying to write some code to do a Taylor approximation for a given function, and, as actually using differentiation strategies is very complicated for a computer program, I have used the forward difference formula. When I tested just the differentiation function, everything worked pretty well to start. Then, I tried making a Taylor approximation for the polynomial ($x^2$), to see if I got roughly the same function back. The first few terms were fine, but, after about the fifth term, my coefficients were way off (using $\Delta x$ of 0.0001). After testing the differentiation function, I realized that small errors in the forward difference formula were building up and causing results to be way off on higher derivatives. What can I do to minimize this error? I have tried smaller $\Delta x$ values, but they cause issues with both memory usage and estimation of lower derivatives.