Differential equations, mathematical equations that relate a function and its derivatives, are the cornerstone of many scientific and engineering disciplines. They provide a powerful tool for modeling and understanding complex systems, from the laws of physics to the dynamics of biological populations.
In physics, differential equations are used to describe the motion of objects, the flow of fluids, and the behavior of electromagnetic fields. In engineering, they are employed in designing structures, optimizing processes, and analyzing systems. In biology, they help model population growth, the spread of diseases, and the dynamics of neural networks.
Differential equations can be used to predict future behavior, analyze stability, and optimize performance. They are essential for understanding the underlying principles of various phenomena and for developing innovative solutions to real-world problems.
Enter Euler’s Method
Euler’s method is a numerical technique used to approximate the solution of a differential equation. It works by approximating the slope of the solution curve at a given point using the derivative at that point, and then using that slope to estimate the next point on the curve.
Given a differential equation:
- dy/dx = f(x, y)
- An initial condition: y(x₀) = y₀
Euler’s method formula:
- yₙ₊₁ = yₙ + h * f(xₙ, yₙ)
Where:
- yₙ is the approximate value of y at xₙ
- h is the step size (the distance between consecutive x values)
- f(xₙ, yₙ) is the value of the derivative at the point (xₙ, yₙ)
By iteratively applying this formula, we can approximate the solution curve over a desired interval.
Example 1
Take for example the function:
which can be otherwise written as:
It is quite apparent that solving this differential equation by hand is not trivial. Spreadsheets can help solve this with remarkable ease.
As stated above, we need an initial condition. Let us say, in this example:
We can choose a value of h = 0.01
Thus, according to Euler’s equation:
which can be rewritten as:
Plugging in the values in a spreadsheet, we can very quickly see that the function is easily derived. Below, we see an example of this done on google sheets.
One major problem with Euler’s method is that the further away we go from the initial condition, the more error-prone our solution is. We can keep making h smaller to reduce the error, but as one of my managers used to say at work, “close enough is good enough for engineers”.
To test out how the value of h affects our solution, let us solve a very basic differential equation, one whose value can easily be calculated by hand.
Example 2
In this example, let’s consider the function:
Thus, our differential equation is:
And we can say that our starting condition is:
We can choose two different values of h to test out: 0.01 and 0.005, and compare it with the real solution.
We can see that when h = 0.01, the error is too large beyond x = 0.5, but for h = 0.005, it is practically indistinguishable from the real solution at values up to 2.5.
Conclusion
Differential equations, as the foundation of many scientific and engineering disciplines, provide a powerful tool for modeling complex systems. Euler’s method, a numerical technique, offers a practical approach to approximating solutions to these equations. While it’s a valuable tool, its accuracy can be limited, especially for large step sizes or complex equations.
In the next post, we shall look at extending the Euler’s method to finite difference method.
Leave a Reply