Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Numerical Methods Homework

Views: 706
Kernel: SageMath 8.2
import numpy as np def func(x): return sin(x) - cos(x) plot(func(x),(x,-2*pi,2*pi)) h = [.1,.01,.001,.0001,.00001,.000001,.00000001,.000000001,.000000001,.00000000001,.000000000001,.00000000001,.0000000000001] np.set_printoptions(precision=2) x =0 for width in h: print((f(x+width)-f(x))/(2*width))
0.524146256844011 0.502491645875069 0.500249916645823 0.500024999166571 0.500002499992380 0.500000250036603 0.500000002512380 0.499999985859034 0.499999985859034 0.500000041370185 0.499988939139939 0.500000041370185 0.500155472593633
# The error decreases to a point, but then begins to increase due to the periodic nature of the function