Another example: compare the two algorithms, that are actually pure-mathematically equal:
def fc(x): return sqrt(x+1) - sqrt(x) def fd(x): return 1/(sqrt(x+1) + sqrt(x))
xs = np.linspace(10\*14,10\*16,10000) plt.figure(figsize=(8, 6), dpi=120) plt.plot(xs,[fc(x) for x in xs]) plt.plot(xs,[fd(x) for x in xs])
Another example: compare the two algorithms, that are actually pure-mathematically equal:
For large values of x (1e16 for example) plot the results and see the difference.