import numpy as np import matplotlib.pyplot as plt a = 0.5 riktig = np.cos(a) hL = [] dL = [] print(np.sin(a)/2) for h in 10.**(-np.arange(1,17)): d = (np.sin(a+h)-np.sin(a))/h hL.append(h) dL.append(d-riktig) print(f"{h:10e} {d:10e} {(d-riktig):10e}") #plt.plot(np.log(hL),np.log(np.abs(dL)),'o') plt.loglog(hL,np.abs(dL),'o') plt.show()