# What's the minimum step size that can be used in Euler's method before it becomes unreliable?

In particular, if Euler's method is implemented on a computer, what's the minimum step size that can be used before rounding errors cause the Euler approximations to become completely unreliable?

I presume it's when step size reaches the machine epsilon? E.g. if machine epsilon is e-16, then once step size is roughly e-16, the Euler approximations are unreliable.

• Crossposted (on recommendation) from math.stackexchange.com/q/3188019/115115, there with answers. – Lutz Lehmann Apr 15 '19 at 7:01
• It is possible to give a general qualitative answer which explains why $h = O(\sqrt{\epsilon})$ is optimal. This would be an extension of the answer Lutz provided you earlier. Under very general assumptions, it is possible to determine numerically if further reduction of the current stepsize is worthwhile. However, this would be a rather long answer. You can get a taste of the relevant material by reading this answer to a related question. – Carl Christian Apr 16 '19 at 21:47
• I'm voting to close this question cross post with this – Mauro Vanzetto Apr 19 '19 at 14:48

You can do this computationally for both one-sides (first order similar to Euler) and center (second order) differences easily using the code below. Basically the error due to floating point takes over much sooner than machine epsilon would suggest even for double precision. The case is even worse for single precision of course (you can change the below code by changing the delta_x line to delta_x = numpy.logspace(-17, 1.0, 100, dtype=numpy.float16).

import numpy
import matplotlib.pyplot as plt

delta_x = numpy.logspace(-17, 1.0, 100)
x = 1.0
f_hat_1 = (numpy.exp(x + delta_x) - numpy.exp(x)) / (delta_x)
f_hat_2 = (numpy.exp(x + delta_x) - numpy.exp(x - delta_x)) / (2.0 * delta_x)

fig = plt.figure()
axes = fig.add_subplot(1, 1, 1)
axes.loglog(delta_x, numpy.abs(f_hat_1 - numpy.exp(1)), 'o-', label="One-Sided")
axes.loglog(delta_x, numpy.abs(f_hat_2 - numpy.exp(1)), 's-', label="Centered")
axes.legend(loc=3)
axes.set_xlabel("$$\Delta x$$")
axes.set_ylabel("Absolute Error")
plt.show()