If an initial value problem
can’t be solved analytically, it’s necessary to resort to numerical methods to obtain useful approximations to a solution of (3.1.1). We’ll consider such methods in this chapter.
We’re interested in computing approximate values of the solution of (3.1.1) at equally spaced points \(x_0\), \(x_1\), …, \(x_n=b\) in an interval \([x_0,b]\). Thus,
where
We’ll denote the approximate values of the solution at these points by \(y_0\), \(y_1\), …, \(y_n\); thus, \(y_i\) is an approximation to \(y(x_i)\). We’ll call
the error at the \(i\)th step. Because of the initial condition \(y(x_0)=y_0\), we’ll always have \(e_0=0\). However, in general \(e_i\ne0\) if \(i>0\).
We encounter two sources of error in applying a numerical method to solve an initial value problem:
The formulas defining the method are based on some sort of approximation. Errors due to the inaccuracy of the approximation are called truncation errors.
Computers do arithmetic with a fixed number of digits, and therefore make errors in evaluating the formulas defining the numerical methods. Errors due to the computer’s inability to do exact arithmetic are called roundoff errors.
Since a careful analysis of roundoff error is beyond the scope of this book, we’ll consider only truncation errors.
Euler’s Method
The simplest numerical method for solving (3.1.1) is Euler’s method. This method is so crude that it is seldom used in practice; however, its simplicity makes it useful for illustrative purposes.
Euler’s method is based on the assumption that the tangent line to the integral curve of (3.1.1) at \((x_i,y(x_i))\) approximates the integral curve over the interval \([x_i,x_{i+1}]\). Since the slope of the integral curve of (3.1.1) at \((x_i,y(x_i))\) is \(y'(x_i)=f(x_i,y(x_i))\), the equation of the tangent line to the integral curve at \((x_i,y(x_i))\) is
Setting \(x=x_{i+1}=x_i+h\) in (3.1.2) yields
as an approximation to \(y(x_{i+1})\). Since \(y(x_0)=y_0\) is known, we can use (3.1.3) with \(i=0\) to compute
However, setting \(i=1\) in (3.1.3) yields
which isn’t useful, since we don’t know \(y(x_1)\). Therefore we replace \(y(x_1)\) by its approximate value \(y_1\) and redefine
Having computed \(y_2\), we can compute
In general, Euler’s method starts with the known value \(y(x_0)=y_0\) and computes \(y_1\), \(y_2\), …, \(y_n\) successively by with the formula
The next example illustrates the computational procedure indicated in Euler’s method.
Example 3.1.1
Use Euler’s method with \(h=0.1\) to find approximate values for the solution of the initial value problem
at \(x=0.1,0.2,0.3\).
Solution We rewrite (3.1.5) as
which is of the form (3.1.1), with
Euler’s method yields
We’ve written the details of these computations to ensure that you understand the procedure. However, in the rest of the examples as well as the exercises in this chapter, we’ll assume that you can use a programmable calculator or a computer to carry out the necessary computations.
Examples Illustrating The Error in Euler’s Method
Example 3.1.2
Use Euler’s method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of the initial value problem
at \(x=0\), \(0.1\), \(0.2\), \(0.3\), …, \(1.0\). Compare these approximate values with the values of the exact solution
which can be obtained by the method of Section 2.1. (Verify.)
Solution Table 3.1.1 shows the values of the exact solution (3.1.6) at the specified points, and the approximate values of the solution at these points obtained by Euler’s method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\). In examining this table, keep in mind that the approximate values in the column corresponding to \(h=.05\) are actually the results of 20 steps with Euler’s method. We haven’t listed the estimates of the solution obtained for \(x=0.05\), \(0.15\), …, since there’s nothing to compare them with in the column corresponding to \(h=0.1\). Similarly, the approximate values in the column corresponding to \(h=0.025\) are actually the results of 40 steps with Euler’s method.
| \(x\) | \(h=0.1\) | \(h=0.05\) | \(h=0.025\) | Exact |
| 0.0 | 1.000000000 | 1.000000000 | 1.000000000 | 1.000000000 |
| 0.1 | 0.800000000 | 0.810005655 | 0.814518349 | 0.818751221 |
| 0.2 | 0.640081873 | 0.656266437 | 0.663635953 | 0.670588174 |
| 0.3 | 0.512601754 | 0.532290981 | 0.541339495 | 0.549922980 |
| 0.4 | 0.411563195 | 0.432887056 | 0.442774766 | 0.452204669 |
| 0.5 | 0.332126261 | 0.353785015 | 0.363915597 | 0.373627557 |
| 0.6 | 0.270299502 | 0.291404256 | 0.301359885 | 0.310952904 |
| 0.7 | 0.222745397 | 0.242707257 | 0.252202935 | 0.261398947 |
| 0.8 | 0.186654593 | 0.205105754 | 0.213956311 | 0.222570721 |
| 0.9 | 0.159660776 | 0.176396883 | 0.184492463 | 0.192412038 |
| 1.0 | 0.139778910 | 0.154715925 | 0.162003293 | 0.169169104 |
You can see from Table 3.1.1 that decreasing the step size improves the accuracy of Euler’s method. For example,
Based on this scanty evidence, you might guess that the error in approximating the exact solution at a fixed value of \(x\) by Euler’s method is roughly halved when the step size is halved. You can find more evidence to support this conjecture by examining Table 3.1.2, which lists the approximate values of \(y_{\mbox{\tiny exact}}-y_{\mbox{\tiny approx}}\) at \(x=0.1\), \(0.2\), …, \(1.0\).
| \(x\) | \(h=0.1\) | \(h=0.05\) | \(h=0.025\) |
| 0.1 | 0.0187 | 0.0087 | 0.0042 |
| 0.2 | 0.0305 | 0.0143 | 0.0069 |
| 0.3 | 0.0373 | 0.0176 | 0.0085 |
| 0.4 | 0.0406 | 0.0193 | 0.0094 |
| 0.5 | 0.0415 | 0.0198 | 0.0097 |
| 0.6 | 0.0406 | 0.0195 | 0.0095 |
| 0.7 | 0.0386 | 0.0186 | 0.0091 |
| 0.8 | 0.0359 | 0.0174 | 0.0086 |
| 0.9 | 0.0327 | 0.0160 | 0.0079 |
| 1.0 | 0.0293 | 0.0144 | 0.0071 |
Example 3.1.3
Tables 3.1.3 and 3.1.4 show analogous results for the nonlinear initial value problem
except in this case we can’t solve (3.1.7) exactly. The results in the “Exact” column were obtained by using a more accurate numerical method known as the Runge-Kutta method with a small step size. They are exact to eight decimal places.∎
Since we think it’s important in evaluating the accuracy of the numerical methods that we’ll be studying in this chapter, we often include a column listing values of the exact solution of the initial value problem, even if the directions in the example or exercise don’t specifically call for it. If quotation marks are included in the heading, the values were obtained by applying the Runge-Kutta method in a way that’s explained in Section 3.3. If quotation marks are not included, the values were obtained from a known formula for the solution. In either case, the values are exact to eight places to the right of the decimal point.
| \(x\) | \(h=0.1\) | \(h=0.05\) | \(h=0.025\) | “Exact” |
| 0.0 | 1.000000000 | 1.000000000 | 1.000000000 | 1.000000000 |
| 0.1 | 0.800000000 | 0.821375000 | 0.829977007 | 0.837584494 |
| 0.2 | 0.681000000 | 0.707795377 | 0.719226253 | 0.729641890 |
| 0.3 | 0.605867800 | 0.633776590 | 0.646115227 | 0.657580377 |
| 0.4 | 0.559628676 | 0.587454526 | 0.600045701 | 0.611901791 |
| 0.5 | 0.535376972 | 0.562906169 | 0.575556391 | 0.587575491 |
| 0.6 | 0.529820120 | 0.557143535 | 0.569824171 | 0.581942225 |
| 0.7 | 0.541467455 | 0.568716935 | 0.581435423 | 0.593629526 |
| 0.8 | 0.569732776 | 0.596951988 | 0.609684903 | 0.621907458 |
| 0.9 | 0.614392311 | 0.641457729 | 0.654110862 | 0.666250842 |
| 1.0 | 0.675192037 | 0.701764495 | 0.714151626 | 0.726015790 |
| \(x\) | \(h=0.1\) | \(h=0.05\) | \(h=0.025\) |
| 0.1 | 0.0376 | 0.0162 | 0.0076 |
| 0.2 | 0.0486 | 0.0218 | 0.0104 |
| 0.3 | 0.0517 | 0.0238 | 0.0115 |
| 0.4 | 0.0523 | 0.0244 | 0.0119 |
| 0.5 | 0.0522 | 0.0247 | 0.0121 |
| 0.6 | 0.0521 | 0.0248 | 0.0121 |
| 0.7 | 0.0522 | 0.0249 | 0.0122 |
| 0.8 | 0.0522 | 0.0250 | 0.0122 |
| 0.9 | 0.0519 | 0.0248 | 0.0121 |
| 1.0 | 0.0508 | 0.0243 | 0.0119 |
Truncation Error in Euler’s Method
Consistent with the results indicated in Tables 3.1.1–3.1.4, we’ll now show that under reasonable assumptions on \(f\) there’s a constant \(K\) such that the error in approximating the solution of the initial value problem
at a given point \(b>x_0\) by Euler’s method with step size \(h=(b-x_0)/n\) satisfies the inequality
where \(K\) is a constant independent of \(n\).
There are two sources of error (not counting roundoff) in Euler’s method:
The error committed in approximating the integral curve by the tangent line (3.1.2) over the interval \([x_i,x_{i+1}]\).
The error committed in replacing \(y(x_i)\) by \(y_i\) in (3.1.2) and using (3.1.4) rather than (3.1.2) to compute \(y_{i+1}\).
Euler’s method assumes that \(y_{i+1}\) defined in (3.1.2) is an approximation to \(y(x_{i+1})\). We call the error in this approximation the local truncation error at the \(i\)th step, and denote it by \(T_i\); thus,
We’ll now use Taylor’s theorem to estimate \(T_i\), assuming for simplicity that \(f\), \(f_x\), and \(f_y\) are continuous and bounded for all \((x,y)\). Then \(y''\) exists and is bounded on \([x_0,b]\). To see this, we differentiate
to obtain
Since we assumed that \(f\), \(f_x\) and \(f_y\) are bounded, there’s a constant \(M\) such that
which implies that
Since \(x_{i+1}=x_i+h\), Taylor’s theorem implies that
where \(\tilde x_i\) is some number between \(x_i\) and \(x_{i+1}\). Since \(y'(x_i)=f(x_i,y(x_i))\) this can be written as
or, equivalently,
Comparing this with (3.1.8) shows that
Recalling (3.1.9), we can establish the bound
Although it may be difficult to determine the constant \(M\), what is important is that there’s an \(M\) such that (3.1.10) holds. We say that the local truncation error of Euler’s method is of order \(h^2\), which we write as \(O(h^2)\).
Note that the magnitude of the local truncation error in Euler’s method is determined by the second derivative \(y''\) of the solution of the initial value problem. Therefore the local truncation error will be larger where \(|y''|\) is large, or smaller where \(|y''|\) is small.
Since the local truncation error for Euler’s method is \(O(h^2)\), it’s reasonable to expect that halving \(h\) reduces the local truncation error by a factor of 4. This is true, but halving the step size also requires twice as many steps to approximate the solution at a given point. To analyze the overall effect of truncation error in Euler’s method, it’s useful to derive an equation relating the errors
To this end, recall that
and
Subtracting (3.1.12) from (3.1.11) yields
The last term on the right is the local truncation error at the \(i\)th step. The other terms reflect the way errors made at previous steps affect \(e_{i+1}\). Since \(|T_i|\le Mh^2/2\), we see from (3.1.13) that
Since we assumed that \(f_y\) is continuous and bounded, the mean value theorem implies that
where \(y_i^*\) is between \(y_i\) and \(y(x_i)\). Therefore
for some constant \(R\). From this and (3.1.14),
For convenience, let \(C=1+Rh\). Since \(e_0=y(x_0)-y_0=0\), applying (3.1.15) repeatedly yields
Recalling the formula for the sum of a geometric series, we see that
(since \(C=1+Rh\)). From this and (3.1.16),
Since Taylor’s theorem implies that
(verify),
This and (3.1.17) imply that
with
Because of (3.1.18) we say that the global truncation error of Euler’s method is of order \(h\), which we write as \(O(h)\).
Semilinear Equations and Variation of Parameters
An equation that can be written in the form
with \(p\not\equiv0\) is said to be semilinear. (Of course, (3.1.19) is linear if \(h\) is independent of \(y\).) One way to apply Euler’s method to an initial value problem
for (3.1.19) is to think of it as
where
However, we can also start by applying variation of parameters to (3.1.20), as in Sections 2.1 and 2.4; thus, we write the solution of (3.1.20) as \(y=uy_1\), where \(y_1\) is a nontrivial solution of the complementary equation \(y'+p(x)y=0\). Then \(y=uy_1\) is a solution of (3.1.20) if and only if \(u\) is a solution of the initial value problem
We can apply Euler’s method to obtain approximate values \(u_0\), \(u_1\), …, \(u_n\) of this initial value problem, and then take
as approximate values of the solution of (3.1.20). We’ll call this procedure the Euler semilinear method.
The next two examples show that the Euler and Euler semilinear methods may yield drastically different results.
Example 3.1.4
In Example 2.1.7 we had to leave the solution of the initial value problem
in the form
because it was impossible to evaluate this integral exactly in terms of elementary functions. Use step sizes \(h=0.2\), \(h=0.1\), and \(h=0.05\) to find approximate values of the solution of (3.1.22) at \(x=0\), \(0.2\), \(0.4\), \(0.6\), …, \(2.0\) by (a) Euler’s method; (b) the Euler semilinear method.
Solution (a) Rewriting (3.1.22) as
and applying Euler’s method with \(f(x,y)=1+2xy\) yields the results shown in Table 3.1.5. Because of the large differences between the estimates obtained for the three values of \(h\), it would be clear that these results are useless even if the “exact” values were not included in the table.
| \(x\) | \(h=0.2\) | \(h=0.1\) | \(h=0.05\) | “Exact” |
| 0.0 | 3.000000000 | 3.000000000 | 3.000000000 | 3.000000000 |
| 0.2 | 3.200000000 | 3.262000000 | 3.294348537 | 3.327851973 |
| 0.4 | 3.656000000 | 3.802028800 | 3.881421103 | 3.966059348 |
| 0.6 | 4.440960000 | 4.726810214 | 4.888870783 | 5.067039535 |
| 0.8 | 5.706790400 | 6.249191282 | 6.570796235 | 6.936700945 |
| 1.0 | 7.732963328 | 8.771893026 | 9.419105620 | 10.184923955 |
| 1.2 | 11.026148659 | 13.064051391 | 14.405772067 | 16.067111677 |
| 1.4 | 16.518700016 | 20.637273893 | 23.522935872 | 27.289392347 |
| 1.6 | 25.969172024 | 34.570423758 | 41.033441257 | 50.000377775 |
| 1.8 | 42.789442120 | 61.382165543 | 76.491018246 | 98.982969504 |
| 2.0 | 73.797840446 | 115.440048291 | 152.363866569 | 211.954462214 |
It’s easy to see why Euler’s method yields such poor results. Recall that the constant \(M\) in (3.1.10) – which plays an important role in determining the local truncation error in Euler’s method – must be an upper bound for the values of the second derivative \(y''\) of the solution of the initial value problem (3.1.22) on \((0,2)\). The problem is that \(y''\) assumes very large values on this interval. To see this, we differentiate (3.1.24) to obtain
where the second equality follows again from (3.1.24). Since (3.1.23) implies that \(y(x)>3e^{x^2}\) if \(x>0\),
For example, letting \(x=2\) shows that \(y''(2)>2952\).
Solution (b) Since \(y_1=e^{x^2}\) is a solution of the complementary equation \(y'-2xy=0\), we can apply the Euler semilinear method to (3.1.22), with
The results listed in Table 3.1.6 are clearly better than those obtained by Euler’s method.
| \(x\) | \(h=0.2\) | \(h=0.1\) | \(h=0.05\) | “Exact” |
| 0.0 | 3.000000000 | 3.000000000 | 3.000000000 | 3.000000000 |
| 0.2 | 3.330594477 | 3.329558853 | 3.328788889 | 3.327851973 |
| 0.4 | 3.980734157 | 3.974067628 | 3.970230415 | 3.966059348 |
| 0.6 | 5.106360231 | 5.087705244 | 5.077622723 | 5.067039535 |
| 0.8 | 7.021003417 | 6.980190891 | 6.958779586 | 6.936700945 |
| 1.0 | 10.350076600 | 10.269170824 | 10.227464299 | 10.184923955 |
| 1.2 | 16.381180092 | 16.226146390 | 16.147129067 | 16.067111677 |
| 1.4 | 27.890003380 | 27.592026085 | 27.441292235 | 27.289392347 |
| 1.6 | 51.183323262 | 50.594503863 | 50.298106659 | 50.000377775 |
| 1.8 | 101.424397595 | 100.206659076 | 99.595562766 | 98.982969504 |
| 2.0 | 217.301032800 | 214.631041938 | 213.293582978 | 211.954462214 |
We can’t give a general procedure for determining in advance whether Euler’s method or the semilinear Euler method will produce better results for a given semilinear initial value problem (3.1.19). As a rule of thumb, the Euler semilinear method will yield better results than Euler’s method if \(|u''|\) is small on \([x_0,b]\), while Euler’s method yields better results if \(|u''|\) is large on \([x_0,b]\). In many cases the results obtained by the two methods don’t differ appreciably. However, we propose the an intuitive way to decide which is the better method: Try both methods with multiple step sizes, as we did in Example 3.1.4, and accept the results obtained by the method for which the approximations change less as the step size decreases.
Example 3.1.5
Applying Euler’s method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to the initial value problem
on \([1,2]\) yields the results in Table 3.1.7. Applying the Euler semilinear method with
yields the results in Table 3.1.8. Since the latter are clearly less dependent on step size than the former, we conclude that the Euler semilinear method is better than Euler’s method for (3.1.25). This conclusion is supported by comparing the approximate results obtained by the two methods with the “exact” values of the solution.
| \(x\) | \(h=0.1\) | \(h=0.05\) | \(h=0.025\) | “Exact” |
| 1.0 | 7.000000000 | 7.000000000 | 7.000000000 | 7.000000000 |
| 1.1 | 8.402000000 | 8.471970569 | 8.510493955 | 8.551744786 |
| 1.2 | 10.083936450 | 10.252570169 | 10.346014101 | 10.446546230 |
| 1.3 | 12.101892354 | 12.406719381 | 12.576720827 | 12.760480158 |
| 1.4 | 14.523152445 | 15.012952416 | 15.287872104 | 15.586440425 |
| 1.5 | 17.428443554 | 18.166277405 | 18.583079406 | 19.037865752 |
| 1.6 | 20.914624471 | 21.981638487 | 22.588266217 | 23.253292359 |
| 1.7 | 25.097914310 | 26.598105180 | 27.456479695 | 28.401914416 |
| 1.8 | 30.117766627 | 32.183941340 | 33.373738944 | 34.690375086 |
| 1.9 | 36.141518172 | 38.942738252 | 40.566143158 | 42.371060528 |
| 2.0 | 43.369967155 | 47.120835251 | 49.308511126 | 51.752229656 |
| \(x\) | \(h=0.1\) | \(h=0.05\) | \(h=0.025\) | “Exact” |
| 1.0 | 7.000000000 | 7.000000000 | 7.000000000 | 7.000000000 |
| 1.1 | 8.552262113 | 8.551993978 | 8.551867007 | 8.551744786 |
| 1.2 | 10.447568674 | 10.447038547 | 10.446787646 | 10.446546230 |
| 1.3 | 12.762019799 | 12.761221313 | 12.760843543 | 12.760480158 |
| 1.4 | 15.588535141 | 15.587448600 | 15.586934680 | 15.586440425 |
| 1.5 | 19.040580614 | 19.039172241 | 19.038506211 | 19.037865752 |
| 1.6 | 23.256721636 | 23.254942517 | 23.254101253 | 23.253292359 |
| 1.7 | 28.406184597 | 28.403969107 | 28.402921581 | 28.401914416 |
| 1.8 | 34.695649222 | 34.692912768 | 34.691618979 | 34.690375086 |
| 1.9 | 42.377544138 | 42.374180090 | 42.372589624 | 42.371060528 |
| 2.0 | 51.760178446 | 51.756054133 | 51.754104262 | 51.752229656 |
Example 3.1.6
Applying Euler’s method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to the initial value problem
on \([2,3]\) yields the results in Table 3.1.9. Applying the Euler semilinear method with
yields the results in Table 3.1.10. Noting the close agreement among the three columns of Table 3.1.9 (at least for larger values of \(x\)) and the lack of any such agreement among the columns of Table 3.1.10, we conclude that Euler’s method is better than the Euler semilinear method for (3.1.26). Comparing the results with the exact values supports this conclusion.
| \(x\) | \(h=0.1\) | \(h=0.05\) | \(h=0.025\) | “Exact” |
| 2.0 | 2.000000000 | 2.000000000 | 2.000000000 | 2.000000000 |
| 2.1 | 0.100000000 | 0.493231250 | 0.609611171 | 0.701162906 |
| 2.2 | 0.068700000 | 0.122879586 | 0.180113445 | 0.236986800 |
| 2.3 | 0.069419569 | 0.070670890 | 0.083934459 | 0.103815729 |
| 2.4 | 0.059732621 | 0.061338956 | 0.063337561 | 0.068390786 |
| 2.5 | 0.056871451 | 0.056002363 | 0.056249670 | 0.057281091 |
| 2.6 | 0.050560917 | 0.051465256 | 0.051517501 | 0.051711676 |
| 2.7 | 0.048279018 | 0.047484716 | 0.047514202 | 0.047564141 |
| 2.8 | 0.042925892 | 0.043967002 | 0.043989239 | 0.044014438 |
| 2.9 | 0.042148458 | 0.040839683 | 0.040857109 | 0.040875333 |
| 3.0 | 0.035985548 | 0.038044692 | 0.038058536 | 0.038072838 |
| \(x\) | \(h=0.1\) | \(h=0.05\) | \(h=0.025\) | “Exact” |
| \(x\) | \(h=0.1\) | \(h=0.05\) | \(h=0.025\) | \(h=.0125\) |
| 2.0 | 2.000000000 | 2.000000000 | 2.000000000 | 2.000000000 |
| 2.1 | 0.708426286 | 0.702568171 | 0.701214274 | 0.701162906 |
| 2.2 | 0.214501852 | 0.222599468 | 0.228942240 | 0.236986800 |
| 2.3 | 0.069861436 | 0.083620494 | 0.092852806 | 0.103815729 |
| 2.4 | 0.032487396 | 0.047079261 | 0.056825805 | 0.068390786 |
| 2.5 | 0.021895559 | 0.036030018 | 0.045683801 | 0.057281091 |
| 2.6 | 0.017332058 | 0.030750181 | 0.040189920 | 0.051711676 |
| 2.7 | 0.014271492 | 0.026931911 | 0.036134674 | 0.047564141 |
| 2.8 | 0.011819555 | 0.023720670 | 0.032679767 | 0.044014438 |
| 2.9 | 0.009776792 | 0.020925522 | 0.029636506 | 0.040875333 |
| 3.0 | 0.008065020 | 0.018472302 | 0.026931099 | 0.038072838 |
In the next two sections we’ll study other numerical methods for solving initial value problems, called the improved Euler method, the midpoint method, Heun’s method and the Runge-Kutta method. If the initial value problem is semilinear as in (3.1.19), we also have the option of using variation of parameters and then applying the given numerical method to the initial value problem (3.1.21) for \(u\). By analogy with the terminology used here, we’ll call the resulting procedure the improved Euler semilinear method, the midpoint semilinear method, Heun’s semilinear method or the Runge-Kutta semilinear method, as the case may be.
3.1 Exercises
You may want to save the results of these exercises, sincewe’ll revisit in the next two sections. In Exercises 1–5 use Euler’s method to find approximate values of the solution of the given initial value problem at the points \(x_i=x_0+ih\), where \(x_0\) is the point wher the initial condition is imposed and \(i=1\), \(2\), \(3\). The purpose of these exercises is to familiarize you with the computational procedure of Euler’s method.
-
C \(y'=2x^2+3y^2-2,\quad y(2)=1;\quad h=0.05\)
Show answer
\(y_1=1.450000000,\; y_2=2.085625000,\; y_3= 3.079099746\)
-
C \(y'=y+\sqrt{x^2+y^2},\quad y(0)=1;\quad h=0.1\)
Show answer
\(y_1=1.200000000,\; y_2=1.440415946,\; y_3=1.729880994\)
-
C \(y'+3y=x^2-3xy+y^2,\quad y(0)=2;\quad h=0.05\)
Show answer
\(y_1=1.900000000,\; y_2=1.781375000,\; y_3=1.646612970\)
-
C \(y'=\dst{1+x\over1-y^2},\quad y(2)=3;\quad h=0.1\)
Show answer
\(y_1=2.962500000,\; y_2=2.922635828,\; y_3=2.880205639\)
-
C \(y'+x^2y=\sin xy,\quad y(1)=\pi;\quad h=0.2\)
Show answer
\(y_1=2.513274123,\; y_2=1.814517822,\; y_3=1.216364496\)
-
C Use Euler’s method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of the initial value problem
\[ y'+3y=7e^{4x},\quad y(0)=2 \]at \(x=0\), \(0.1\), \(0.2\), \(0.3\), …, \(1.0\). Compare these approximate values with the values of the exact solution \(y=e^{4x}+e^{-3x}\), which can be obtained by the method of Section 2.1. Present your results in a table like Table 3.1.1.
Show answer
\(x\) \(h=0.1\) \(h=0.05\) \(h=0.025\) Exact 1.0 48.298147362 51.492825643 53.076673685 54.647937102 -
C Use Euler’s method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of the initial value problem
\[ y'+{2\over x}y={3\over x^3}+1,\quad y(1)=1 \]at \(x=1.0\), \(1.1\), \(1.2\), \(1.3\), …, \(2.0\). Compare these approximate values with the values of the exact solution
\[ y={1\over3x^2}(9\ln x+x^3+2), \]which can be obtained by the method of Section 2.1. Present your results in a table like Table 3.1.1.
Show answer
\(x\) \(h=0.1\) \(h=0.05\) \(h=0.025\) Exact 2.0 1.390242009 1.370996758 1.361921132 1.353193719 -
C Use Euler’s method with step sizes \(h=0.05\), \(h=0.025\), and \(h=0.0125\) to find approximate values of the solution of the initial value problem
\[ y'={y^2+xy-x^2\over x^2},\quad y(1)=2 \]at \(x=1.0\), \(1.05\), \(1.10\), \(1.15\), …, \(1.5\). Compare these approximate values with the values of the exact solution
\[ y={x(1+x^2/3)\over1-x^2/3} \]obtained in Example 2.4.3. Present your results in a table like Table 3.1.1.
Show answer
\(x\) \(h=0.05\) \(h=0.025\) \(h=0.0125\) Exact 1.50 7.886170437 8.852463793 9.548039907 10.500000000 -
C In Example 2.2.3 it was shown that
\[ y^5+y=x^2+x-4 \]is an implicit solution of the initial value problem
\[ y'={2x+1\over5y^4+1},\quad y(2)=1. \tag*{\rm(A)} \]Use Euler’s method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of (A) at \(x=2.0\), \(2.1\), \(2.2\), \(2.3\), …, \(3.0\). Present your results in tabular form. To check the error in these approximate values, construct another table of values of the residual
\[ R(x,y)=y^5+y-x^2-x+4 \]for each value of \((x,y)\) appearing in the first table.
Show answer
\(x\) \(h=0.1\) \(h=0.05\) \(h=0.025\) \(h=0.1\) \(h=0.05\) \(h=0.025\) 3.0 1.469458241 1.462514486 1.459217010 0.3210 0.1537 0.0753 Approximate Solutions Residuals -
C You can see from Example 2.5.1 that
\[ x^4y^3+x^2y^5+2xy=4 \]is an implicit solution of the initial value problem
\[ y'=-{4x^3y^3+2xy^5+2y\over3x^4y^2+5x^2y^4+2x},\quad y(1)=1. \tag*{\rm(A)} \]Use Euler’s method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of (A) at \(x=1.0\), \(1.1\), \(1.2\), \(1.3\), …, \(2.0\). Present your results in tabular form. To check the error in these approximate values, construct another table of values of the residual
\[ R(x,y)=x^4y^3+x^2y^5+2xy-4 \]for each value of \((x,y)\) appearing in the first table.
Show answer
\(x\) \(h=0.1\) \(h=0.05\) \(h=0.025\) \(h=0.1\) \(h=0.05\) \(h=0.025\) 2.0 0.473456737 0.483227470 0.487986391 -0.3129 -0.1563 -0.0781 Approximate Solutions Residuals -
C Use Euler’s method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of the initial value problem
\[ (3y^2+4y)y'+2x+\cos x=0, \quad y(0)=1; \mbox{\; (Exercise~2.2.~\hspace*{-3pt}\ref{exer:2.2.13})} \]at \(x=0\), \(0.1\), \(0.2\), \(0.3\), …, \(1.0\).
Show answer
\(x\) \(h=0.1\) \(h=0.05\) \(h=0.025\) “Exact” 1.0 0.691066797 0.676269516 0.668327471 0.659957689 -
C Use Euler’s method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of the initial value problem
\[ y'+{(y+1)(y-1)(y-2)\over x+1}=0, \quad y(1)=0 \mbox{\; (Exercise~2.2.~\hspace*{-3pt}\ref{exer:2.2.14})} \]at \(x=1.0\), \(1.1\), \(1.2\), \(1.3\), …, \(2.0\).
Show answer
\(x\) \(h=0.1\) \(h=0.05\) \(h=0.025\) “Exact” 2.0 -0.772381768 -0.761510960 -0.756179726 -0.750912371 -
C Use Euler’s method and the Euler semilinear method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of the initial value problem
\[ y'+3y=7e^{-3x},\quad y(0)=6 \]at \(x=0\), \(0.1\), \(0.2\), \(0.3\), …, \(1.0\). Compare these approximate values with the values of the exact solution \(y=e^{-3x}(7x+6)\), which can be obtained by the method of Section 2.1. Do you notice anything special about the results? Explain.
Show answer
Euler’s method \(x\) \(h=0.1\) \(h=0.05\) \(h=0.025\) Exact 1.0 0.538871178 0.593002325 0.620131525 0.647231889 Euler semilinear method \(x\) \(h=0.1\) \(h=0.05\) \(h=0.025\) Exact 1.0 0.647231889 0.647231889 0.647231889 0.647231889 Applying variation of parameters to the given initial value problem yields
\(y=ue^{-3x}\), where (A) \(u'=7,\quad u(0)=6\). Since \(u''=0\), Euler’s method yields the exact solution of (A). Therefore the Euler semilinear method produces the exact solution of the given problem
.
The linear initial value problems in Exercises 14–19 can’t be solved exactly in terms of known elementary functions. In each exercise, use Euler’s method and the Euler semilinear methods with the indicated step sizes to find approximate values of the solution of the given initial value problem at 11 equally spaced points (including the endpoints) in the interval.
-
C \(y'-2y=\dst{1\over1+x^2},\quad y(2)=2\); \(h=0.1,0.05,0.025\) on \([2,3]\)
Show answer
Euler’s method \(x\) \(h=0.1\) \(h=0.05\) \(h=0.025\) “Exact” 3.0 12.804226135 13.912944662 14.559623055 15.282004826 Euler semilinear method \(x\) \(h=0.1\) \(h=0.05\) \(h=0.025\) “Exact” 3.0 15.354122287 15.317257705 15.299429421 15.282004826 -
C \(y'+2xy=x^2,\quad y(0)=3\) (Exercise 2.1. 38); \(h=0.2,0.1,0.05\) on \([0,2]\)
Show answer
Euler’s method \(x\) \(h=0.2\) \(h=0.1\) \(h=0.05\) “Exact” 2.0 0.867565004 0.885719263 0.895024772 0.904276722 Euler semilinear method \(x\) \(h=0.2\) \(h=0.1\) \(h=0.05\) “Exact” 2.0 0.569670789 0.720861858 0.808438261 0.904276722 -
C \(\dst{y'+{1\over x}y={\sin x\over x^2},\quad y(1)=2}\); (Exercise 2.1. 39); \(h=0.2,0.1,0.05\) on \([1,3]\)
Show answer
Euler’s method \(x\) \(h=0.2\) \(h=0.1\) \(h=0.05\) “Exact” 3.0 0.922094379 0.945604800 0.956752868 0.967523153 Euler semilinear method \(x\) \(h=0.2\) \(h=0.1\) \(h=0.05\) “Exact” 3.0 0.993954754 0.980751307 0.974140320 0.967523153 -
C \(\dst{y'+y={e^{-x}\tan x\over x},\quad y(1)=0}\); (Exercise 2.1. 40); \(h=0.05,0.025,0.0125\) on \([1,1.5]\)
Show answer
Euler’s method \(x\) \(h=0.0500\) \(h=0.0250\) \(h=0.0125\) “Exact” 1.50 0.319892131 0.330797109 0.337020123 0.343780513 Euler semilinear method \(x\) \(h=0.0500\) \(h=0.0250\) \(h=0.0125\) “Exact” 1.50 0.305596953 0.323340268 0.333204519 0.343780513 -
C \(\dst{y'+{2x\over 1+x^2}y={e^x\over (1+x^2)^2}, \quad y(0)=1}\); (Exercise 2.1. 41); \(h=0.2,0.1,0.05\) on \([0,2]\)
Show answer
Euler’s method \(x\) \(h=0.2\) \(h=0.1\) \(h=0.05\) “Exact” 2.0 0.754572560 0.743869878 0.738303914 0.732638628 Euler semilinear method \(x\) \(h=0.2\) \(h=0.1\) \(h=0.05\) “Exact” 2.0 0.722610454 0.727742966 0.730220211 0.732638628 -
C \(xy'+(x+1)y=e^{x^2},\quad y(1)=2\); (Exercise 2.1. 42); \(h=0.05,0.025,0.0125\) on \([1,1.5]\)
Show answer
Euler’s method \(x\) \(h=0.0500\) \(h=0.0250\) \(h=0.0125\) “Exact” 1.50 2.175959970 2.210259554 2.227207500 2.244023982 Euler semilinear method \(x\) \(h=0.0500\) \(h=0.0250\) \(h=0.0125\) “Exact” 1.50 2.117953342 2.179844585 2.211647904 2.244023982
In Exercises 20–22, use Euler’s method and the Euler semilinear method with the indicated step sizes to find approximate values of the solution of the given initial value problem at 11 equally spaced points (including the endpoints) in the interval.
-
C \(y'+3y=xy^2(y+1),\quad y(0)=1\); \(h=0.1,0.05,0.025\) on \([0,1]\)
Show answer
Euler’s method \(x\) \(h=0.1\) \(h=0.05\) \(h=0.025\) “Exact” 1.0 0.032105117 0.043997045 0.050159310 0.056415515 Euler semilinear method \(x\) \(h=0.1\) \(h=0.05\) \(h=0.025\) “Exact” 1.0 0.056020154 0.056243980 0.056336491 0.056415515 -
C \(\dst{y'-4y={x\over y^2(y+1)},\quad y(0)=1}\); \(h=0.1,0.05,0.025\) on \([0,1]\)
Show answer
Euler’s method \(x\) \(h=0.1\) \(h=0.05\) \(h=0.025\) “Exact” 1.0 28.987816656 38.426957516 45.367269688 54.729594761 Euler semilinear method \(x\) \(h=0.1\) \(h=0.05\) \(h=0.025\) “Exact” 1.0 54.709134946 54.724150485 54.728228015 54.729594761 -
C \(\dst{y'+2y={x^2\over1+y^2},\quad y(2)=1}\); \(h=0.1,0.05,0.025\) on \([2,3]\)
Show answer
Euler’s method \(x\) \(h=0.1\) \(h=0.05\) \(h=0.025\) “Exact” 3.0 1.361427907 1.361320824 1.361332589 1.361383810 Euler semilinear method \(x\) \(h=0.1\) \(h=0.05\) \(h=0.025\) “Exact” 3.0 1.291345518 1.326535737 1.344004102 1.361383810 -
Numerical Quadrature. The fundamental theorem of calculus says that if \(f\) is continuous on a closed interval \([a,b]\) then it has an antiderivative \(F\) such that \(F'(x)=f(x)\) on \([a,b]\) and
\[ \int_a^bf(x)\,dx=F(b)-F(a). \tag*{\rm(A)} \]This solves the problem of evaluating a definite integral if the integrand \(f\) has an antiderivative that can be found and evaluated easily. However, if \(f\) doesn’t have this property, (A) doesn’t provide a useful way to evaluate the definite integral. In this case we must resort to approximate methods. There’s a class of such methods called numerical quadrature, where the approximation takes the form
\[ \int_a^bf(x)\,dx\approx \sum_{i=0}^n c_if(x_i), \tag*{\rm(B)} \]where \(a=x_0<x_1<\cdots<x_n=b\) are suitably chosen points and \(c_0\), \(c_1\), …, \(c_n\) are suitably chosen constants. We call (B) a quadrature formula.
Derive the quadrature formula
\[ \int_a^bf(x)\,dx\approx h\sum_{i=0}^{n-1}f(a+ih)\mbox{\quad(where $h=(b-a)/n)$} \tag*{\rm(C)} \]by applying Euler’s method to the initial value problem
\[ y'=f(x),\quad y(a)=0. \]The quadrature formula (C) is sometimes called the left rectangle rule. Draw a figure that justifies this terminology.
L For several choices of \(a\), \(b\), and \(A\), apply (C) to \(f(x)=A\) with \(n = 10,20,40,80,160,320\). Compare your results with the exact answers and explain what you find.
L For several choices of \(a\), \(b\), \(A\), and \(B\), apply (C) to \(f(x)=A+Bx\) with \(n=10\), \(20\), \(40\), \(80\), \(160\), \(320\). Compare your results with the exact answers and explain what you find.