JustToThePoint English Website Version
JustToThePoint en español

Maximize your online presence with our exclusive offer: Get a stunning hero banner, the hero you need and deserve, at an unbeatable price! Bew, 689282782, bupparchard@gmail.com

Numerical Solutions

Pure mathematics is, in its way, the poetry of logical ideas. Do not worry about your difficulties in mathematics, I assure you that mine are still greater, Albert Einstein

Mathematics is not a careful march down a well-cleared highway, but a journey into a strange wilderness, where the explorers often get lost, W.S. Anglin.

Recall

Definition. A differential equation is an equation that involves one or more dependent variables, their derivatives with respect to one or more independent variables, and the independent variables themselves, e.g., $\frac{dy}{dx} = 3x +5y, y’ + y = 4xcos(2x), \frac{dy}{dx} = x^2y+y, etc.$

It involves (e.g., $\frac{dy}{dx} = 3x +5y$):

Solving differential equations

To solve ordinary differential equations (ODEs), several methods can be employed, each suited to different types of equations. Here are some of the key methods:

Solving differential equations

Euler’s Numerical Method

Euler’s method is a fundamental numerical technique used to approximate the solution of a first-order differential equation (ODE) of the form y’ = f(x, y) with a given initial condition y(x0) = y0. Unlike analytical methods that seek an explicit formula for y(x), Euler’s method generates an approximation by creating a sequence of points (xk, yk) that estimate the true solution at discrete points. More precisely, each yk estimates the value of the true solution y(xk).

Euler's method approximates the solution curve by creating a sequence of tangent lines at successive points. Each point is determined by the slope of the tangent line at the previous point (Refer to Figure 1 for a visual representation and aid in understanding it). The slope at any point (xk, yk) is determined by the given differential equation y′ = f(x, y). The method progresses from one point to the next by taking small steps of size h (also known as the step size).

EDO

Method Outline

Given the differential equation of the form: y’ = f(x, y) and an initial condition y(x0) = y0, Euler’s method approximates y at points x1, x2, ···, xN. The basic idea is to use the slope at (xn, yn) to estimate y at the next point xn+1 of the sequence using the following steps:

  1. Start with the initial point (x0, y0) where y0 is the known initial value of the solution at x0.
  2. Choose a Step Size h: The value of h determines the interval between successive points. A smaller h generally leads to better accuracy but obviously requires more computations effort (which is less of a concern with modern computers, they have evolved tremendously over the years, becoming incredibly powerful).
  3. Compute the Slope: At each step n, compute the slope An of the tangent line at (xn, yn) using the differential equation: An = f(xn, yn).
  4. Update the Values: The next y-value, yn+1 is calculated using the slope at (xn, yn): yn+1-yn = hAn or equivalently yn+1 = yn + hAn. Similarly, the next x-value is: xn+1 = xn + h.
  5. Repeat the Process: Continue this process to compute the sequence of points (x1, y1), (x2, y2), ··· (xn, yn), ···, generating a numerical approximation of the solution (Refer to Figure B for a visual representation and aid in understanding it).

EDO

The Euler equations or formulas are: xn+1 = xn + h, yn+1 = yn + hAn, An = f(xn, yn).

Solved examples

We will compute or approximate y at x = 0.1, 0.2, and 0.3.

Step-by-step table of calculations:

n xn yn An=xn2-yn2 hAn
0 0 1 0-12=-1 -0.1
1 0.1 1-0.1 = 0.9 0.12-0.92=-0.8 -0.08
2 0.2 0.9-0.08 = 0.82 0.22-0.822=-0.6324 -0.06324
3 0.3 0.82−0.06324 = 0.75676 0.3²-0.75676²=−0.48268 −0.048268

The approximated value at x = 0.3 is y3 ≈ y2 + hA2 ≈ 0.82-0.06324 ≈ 0.75676. Similarly, the approximated value at x = 0.4 is y4 ≈ y3 + hA3 ≈ 0.75676 −0.04907 = 0.70849.

Discussion of the Results

Euler’s method provides a straightforward approach to approximating solutions of first-order ODEs. While simple and easy to implement, its accuracy depends on the size of the step h and the behavior of the true solution.

If the true solution is convex in the interval of interest (i.e., the second derivative y′′ is positive), Euler’s approximation tends to underestimate the true value. If the solution is concave (i.e., the second derivative y′′ is negative), Euler’s approximation tends to overestimate the true value (Refer to Figure C for a visual representation and aid in understanding it).

EDO

In our example, to determine the convexity, we calculate the second derivative using the Chain Rule: $y’’ = \frac{d}{dx}(y’) = \frac{d}{dx}(x^2-y^2) = 2x -2yy’.$

At (x0 = 0, y0 = 1): y(0) = 1 (Initial condition), y’(0) = A0 = -1, y’’(0) =[y’’ = 2x -2yy’] 2·0 -2·1·(-1) = 2. Since y′′(0) = 2 > 0, the solution is convex near x = 0, and Euler’s method will underestimate the true solution in the initial steps.

Error Analysis

Euler’s method approximates the solution curve by constructing a series of tangent line segments, moving from one point to the next based on the local slope of the solution at the current point.

Each tangent line is a linear approximation, and as such, the error introduced at each step depends on how much the true solution deviates from linearity over that interval. Therefore, its accuracy can vary depending on the step size and the nature of the solution curve. For smoother (slowly changing) functions, Euler’s method performs better, while for more complex functions, smaller steps (halve the step side, halve the error, refer to Figure D) or more advanced numerical methods may be needed for improved accuracy and stability.

EDO

Euler’s method is a fundamental numerical technique used to approximate solutions to ordinary differential equations (ODEs) when an analytical solution is difficult, costly or impossible to obtain.

Step-by-step table of calculations:

n xn yn An=xn+2yn hAn=0.1An
0 0 0 0+2*0=0 0
1 0.1 0+0.1·0 = 0 0.1+2·0 = 0.1 0.01
2 0.2 0 + 0.01 = 0.01 0.2+2·001 = 0.22 0.022
3 0.3 0.01 + 0.022 = 0.032 0.3 + 2·0.032=0.364 0.0364
4 0.4 0.032 + 0.0364 = 0.0684 0.4 + 2·0.0684=0.5368 0.05368

After four steps, the approximated value at x = 0.4 is y4 ≈ 0.032 + 0.0364 = 0.0684.

Verification with the Exact Solution

Solving the Differential Equation Analytically.

  1. Rewrite the equation in standard linear form: y’ -2y = x.
  2. Compute the integrating factor μ(x) = $e^{\int -2dx} = e^{-2x}$
  3. Multiply both sides by μ(x): $e^{-2x}y’-2e^{-2x}y = e^{-2x}x↭ \frac{d}{dx}(e^{-2x}y)= e^{-2x}x$
  4. Integrate Both Sides: $e^{-2x}y = \int e^{-2x}xdx = $[Integration by parts. u = x⇒du = dx, $dv = e^{-2x}dx, v = \frac{-1}{2}e^{-2x}$] = $\frac{-1}{2}xe^{-2x} -\int \frac{-1}{2}e^{-2x}dx = \frac{-1}{2}xe^{-2x} +\frac{1}{4}e^{-2x} + C ↭ e^{-2x}y = \frac{-1}{2}xe^{-2x} +\frac{1}{4}e^{-2x} + C$
  5. Solve for y: $y = \frac{-1}{2}x +\frac{1}{4} + Ce^{2x}$
  6. Apply Initial Conditions y(0) = 0, $0 = \frac{-1}{2}0 +\frac{1}{4} + Ce^{2·0}⇒ 0 = \frac{1}{4} + C⇒\text{Solve for C: } C = \frac{-1}{4}.$ Final Solution = $y = \frac{-1}{2}x +\frac{1}{4} + \frac{-1}{4}e^{2x}$
  7. Compute y(0.4): $y(0.4) = \frac{-1}{2}0.4 +\frac{1}{4} + \frac{-1}{4}e^{2·0.4} = -0.2 + 0.25 + \frac{-1}{4}e^{0.8} ≈ -0.2 + 0.25 \frac{-1}{4}·2.22554 = 0.05−0.55639 ≈−0.50639.$

Conclusion: Our Euler's method approximation is y(0.4) ≈ 0.0684, whereas the exact value is approximately −0.50639. The discrepancy indicates that Euler's method with h = 0.1 is not very accurate for this problem over this interval.

Why? The exact solution involves an exponential term e2x, with grows rapidly. Euler's method with a relatively large step size h = 0.1 struggles to capture this rapid change. The error accumulates at each step, leading to significant deviation from the exact solution.

$y’’ = \frac{d}{dx}(y’) = \frac{d}{dx}(x+2y) = 1 > 0$ ⇒ The solution is convex near x = 0, and Euler’s method will underestimate the true solution.

Improving the Approximation

  1. Smaller Step Size. Using a smaller h would improve the accuracy. For instance, using h = 0.05 or h = 0.01 would improve accuracy, but the computational effort increases as h decreases.
  2. Higher-Order Methods: Employing methods like the Improved Euler’s Method (also known as Heun’s Method) or the Runge-Kutta methods would yield better approximations. These methods account for the curvature of the solution between steps, reducing the error.

Improved Euler’s method or RK2

The Improved Euler’s Method, also known as the second-order Runge-Kutta method (RK2), provides a more accurate approximation of the solution to ordinary differential equations (ODEs) than the basic Euler’s method. The key idea behind this method is to use two estimates of the slope at each step: one at the beginning of the interval and one at the end of the interval. These two slopes are then averaged to get a more accurate approximation of the solution (Refer to Figure E for a visual representation and aid in understanding it).

EDO

Method Outline

The steps for Improved Euler’s method are as follows:

  1. Initial Setup. Start with the initial point (xn, yn) and compute the slope at this point, An = f(xn, yn).
  2. Predictor Step. Use the slope An to predict the value of y at xn+1 = xn + h: $\widetilde{\mathbf{y_{n+1}}}=y_n+hA_n$. This is the first approximation of yn+1, similar to what is done in the basic Euler method.
  3. Corrector Step. Compute the slope Bn at the predicted point $(x_{n+1}, \widetilde{\mathbf{y_{n+1}}}), B_n = f(x_{n+1}, \widetilde{\mathbf{y_{n+1}}})$
  4. Update Step. Update the value of yn+1 using the average of the two previously calculated slopes An and Bn, $y_{n+1} = y_n + h(\frac{A_n+B_n}{2})$
  5. Advance to the next step. Update xn by increasing it by the step size h, xn+1 = xn + h.

Repeat steps 1–5 for each subsequent interval to approximate the solution over the desired range.

Euler’s method is a first-order method, meaning that the error e in the solution is proportional to the step size h, i.e., e ≈ c·h, where c is some constant. This means that if you halve the step size, the error roughly halves as well.

Improved Euler's method is a second-order method, meaning the error decreases quadratically with the step size, i.e., e ≈ c·h2. This quadratic dependence means that halving the step size will reduce the error by a factor of four. However, this increase in accuracy comes at the cost of more computations, as the method requires two function evaluations at each step - my dear reader, nothing comes for free! 😢

Example

Consider the differential equation y’ = x2 -y2 with the initial condition y(0) = 1 and step size h = 0.1. Let’s walk through the first step of the Improved Euler’s Method.

First Iteration

  1. Initial Values. x0 = 0, y0 = 1, and compute the initial slope A0 = f(x0, y0) = f(0, 1) = 02 -12 = -1.
  2. Predictor Step. Calculate the preliminary estimate of $\widetilde{\mathbf{y_{1}}}=y_0+hA_0 = 1 + 0.1·(-1) = 0.9$.
  3. Corrector Step. Compute the slope at the predicted point $B_0 = f(x_{1}, \widetilde{\mathbf{y_{1}}}) = f(0.1, 0.9) = 0.1^2-0.9^2 = 0.01−0.81 = -0.8$.
  4. Update Step. Update y1 using the average of A0 and B0: $y_{1} = y_0 + h(\frac{A_0+B_0}{2}) = 1 + 0.1·\frac{-1+(-0.8)}{2} = 1 + 0.1·(-0.9) = 1 -0.09 = 0.91$.
  5. Advance to the Next Step: x1 = x0 + h = 0 + 0.1 = 0.1.

After the first step, the Improved Euler method gives y1 ≈ 0.91, which is a more accurate approximation than the basic Euler method.

Second iteration

  1. Initial Values. x1 = 0.1, y1 = 0.91. Compute the slope A1 = f(x1, y1) = f(0.1, 0.91) = 0.12 -0.912 = −0.8181.
  2. Predictor Step. Calculate the preliminary estimate of $\widetilde{\mathbf{y_{2}}}=y_1+hA_1 = 0.91 + 0.1·(−0.8181)= 0.91−0.08181 = 0.82819.$
  3. Corrector Step. Compute the slope at the predicted point $B_1 = f(x_{2}, \widetilde{\mathbf{y_{2}}}) = f(0.2, 0.82819) = 0.2^2-0.82819^2 = 0.04−0.6859 = −0.64591$.
  4. Update Step. Update y2 using the average of A1 and B1: $y_{2} = y_1 + h(\frac{A_1+B_1}{2}) = 0.91 + 0.1·\frac{−0.8181+(−0.64591)}{2} = 0.91 + 0.1·(−0.73201) = 0.83680$.
  5. Advance to the Next Step: x2 = x1 + h = 0.2.

Now, after two steps, we have y2 ≈ 0.83680 at x = 0.2.

The improved Euler's method takes into account the change in slope over the interval by averaging the slopes at the beginning and end. By considering both the initial and predicted slopes, the Improved Euler’s method provides a better approximation of the area under the curve, similar to the trapezoidal rule in numerical integration.

It is a second-order accurate method, significantly improving the approximation compared to the first-order Euler’s method, but each step requires two evaluations of f(x, y) instead of one, increasing the computational effort (cost).

Pitfalls: Singularity in Solutions

Consider the differential equation y’ = y2. This is a separable differential equation and we can solve it analytically as follows:

  1. Separation of Variables: $\frac{dy}{dx}=y^2↭ \frac{dy}{y^2}=dx$.
  2. Integrate both sides: $\int y^{-2}dy = \int dx ↭ \frac{-1}{y} + C = x$
  3. Solving for y: $\frac{-1}{y} = x - C ↭ y = \frac{-1}{x-C} = \frac{1}{C-x}$ where C is a constant determined by the initial condition.
  4. Applying the initial condition y(0) = 1, we find C as follows: $y(0)=1=\frac{1}{C-0} = \frac{1}{C}⇒ C = 1$.
  5. Therefore, the specific solution is y(x) = $\frac{1}{1-x}$ (Refer to Figure A for a visual representation and aid in understanding it).

Numerical Solutions

This solution has a singularity at x = 1, meaning the solution becomes undefined (blows up) as x approaches 1. The solution curve has a vertical asymptote at x = 1.

In general, the solution to y’ = y2 has a singularity at x = C, where C is determined by the initial condition.

As the solution approaches the singularity at x = 1, the slope f(x, y) becomes extremely large and numerical methods fail to approximate the solution. The methods become unstable near such points because the rapidly increasing slope requires an impractically small step size h to maintain accuracy.

Implications for Numerical Methods

When dealing with ODEs that have singularities within the interval of integration, special care must be taken:

To sum up, the Improved Euler's method offers a significant improvement in accuracy over the basic Euler's method by averaging the slopes at the beginning and end of each interval. However, it is important to be aware of potential pitfalls, such as singularities in the solution, which can render numerical methods quite ineffective without appropriate adjustments.

Bibliography

This content is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License and is based on MIT OpenCourseWare [18.01 Single Variable Calculus, Fall 2007].
  1. NPTEL-NOC IITM, Introduction to Galois Theory.
  2. Algebra, Second Edition, by Michael Artin.
  3. LibreTexts, Calculus and Calculus 3e (Apex). Abstract and Geometric Algebra, Abstract Algebra: Theory and Applications (Judson).
  4. Field and Galois Theory, by Patrick Morandi. Springer.
  5. Michael Penn, and MathMajor.
  6. Contemporary Abstract Algebra, Joseph, A. Gallian.
  7. YouTube’s Andrew Misseldine: Calculus. College Algebra and Abstract Algebra.
  8. MIT OpenCourseWare [18.03 Differential Equations, Spring 2006], YouTube by MIT OpenCourseWare.
  9. Calculus Early Transcendentals: Differential & Multi-Variable Calculus for Social Sciences.
Bitcoin donation

JustToThePoint Copyright © 2011 - 2024 Anawim. ALL RIGHTS RESERVED. Bilingual e-books, articles, and videos to help your child and your entire family succeed, develop a healthy lifestyle, and have a lot of fun. Social Issues, Join us.

This website uses cookies to improve your navigation experience.
By continuing, you are consenting to our use of cookies, in accordance with our Cookies Policy and Website Terms and Conditions of use.