1.10E: Exercises for Section 1.10

Introductory Differential Equations · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    From LibreTexts, under CC BY-NC-SA 3.0, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    1.10E: Exercises for Section 1.10

    Exercises 1-9

    Use numerical methods, including Euler’s method, Improved Euler’s method, or Runge-Kutta method, to approximate or solve the given differential equations.

    Exercise \(\PageIndex{1}\)

    Consider \(\frac{dx}{dt} = (2t - x)^2\), \(x(0) = 2\). Use Euler’s method with step size \(h = 0.5\) to approximate \(x(1)\).

    Answer

    \( x(1) \approx 8.5 \)

    Exercise \(\PageIndex{2}\)

    Consider \(\frac{dx}{dt} = t -x \), \(x(0) = 1\).

    1. Use Euler’s method with step sizes \(h = 1, \frac{1}{2}, \frac{1}{4}, \frac{1}{8}\) to approximate \(x(1)\).
    2. Solve the equation exactly.
    3. Describe what happens to the errors for each \(h\) you used. That is, find the factor by which the error changed each time you halved the interval.

    Hint: 

    Euler update formula: \( x_{n+1} = x_n + h(t_n - x_n) \)

    Runge–Kutta Method (RK4) formula: \( 
    k_1 = f(x_n, y_n), \quad k_2 = f(x_n + h/2, y_n + hk_1/2),\\
    k_3 = f(x_n + h/2, y_n + hk_2/2), \quad k_4 = f(x_n + h, y_n + hk_3)\\
    y_{n+1} = y_n + \frac{h}{6}(k_1 + 2k_2 + 2k_3 + k_4) \)

    Answer
    1.  Approximations of  \(x(1)\):
      \( \begin{array}{c|c}
      h & x(1)\ \text{(Euler Approximation)} \\ \hline
      1 & 0 \\
      \frac{1}{2} & 0.5 \\
      \frac{1}{4} & 0.578125 \\
      \frac{1}{8} & 0.6478
      \end{array}
      \)
    2. \( x(1) = \frac{2}{e} \approx 0.73576 \)
    3. \( \begin{array}{c|c|c}
      h & \text{Approximation} & \text{Error} & \textbf{ Error Reduction}\\ \hline
      1 & 0 & 0.73576 \\
      \frac{1}{2} & 0.5 & 0.23576 & \frac{E_{1/2}}{E_1} \approx 0.32\\
      \frac{1}{4} & 0.578125 & 0.15763 & \frac{E_{1/4}}{E_{1/2}} \approx 0.67 \\
      \frac{1}{8} & 0.6478 & 0.08796 & \frac{E_{1/8}}{E_{1/4}} \approx 0.56
      \end{array} \) 
    Exercise \(\PageIndex{3}\)

    Approximate the value of \(e\) by looking at the initial value problem \(y' = y\) with \(y(0) = 1\) and approximating \(y(1)\) using Euler’s method with a step size of \(0.2\).

    Answer

     \(  e \approx 2.48832  \)

    Exercise \(\PageIndex{4}\)

    Example of numerical instability: Take \(y' = -5y\), \(y(0) = 1\). We know that the solution should decay to zero as \(x\) grows. Using Euler’s method, start with \(h =1\) and compute \(y_1, y_2, y_3, y_4\) to try to approximate \(y(4)\). What happened? Now halve the interval. Keep halving the interval and approximating \(y(4)\) until the numbers you are getting start to stabilize (that is, until they start going towards zero). Note: You might want to use a calculator.

    The simplest method used in practice is the Runge-Kutta method. Consider \(\frac{dy}{dx} = f(x, y)\), \(y(x_0) = y_0\) and a step size \(h\). Everything is the same as in Euler’s method, except the computation of \(y_{i+1}\) and \(x_{i+1}\).

    \[\begin{align}\begin{aligned} k_1 &= f(x_i, y_i), \\ k_2 &= f(x_i + \frac{h}{2}, y_i +k_1 \frac{h}{2}) & x_{i+1} = x_i + h, \\ k_3 &= f(x_i + \frac{h}{2}, y_i +k_2 \frac{h}{2}) & y_{i+1} = y_i + \dfrac{k_1 + 2k_2 + 2k_3 + k_4}{6}h, \\ k_4 &= f(x_i + h, y_i +k_3h).\end{aligned}\end{align}\]

    Exercise \(\PageIndex{5}\)

    Consider \(\frac{dy}{dx} = yx^2\), \(y(0) = 1\).

    1. Use Runge-Kutta (see Exercise 1.10E.4) with step sizes \(h = 1\) and \(h = \frac{1}{2}\) to approximate \(y(1)\).
    2. Use Euler’s method with \(h = 1\) and \(h = \frac{1}{2}\).
    3. Solve exactly, find the exact value of \(y(1)\), and compare.
    Answer
    1. \(  h = 1: y(1) \approx 1.3906,  \), \(  h = \frac{1}{2}: y(1) \approx 1.3967 \)
    2. \( y(1) \approx 1, y(1) \approx 1.125 \)
    3. \( y(1) = e^{1/3} \approx 1.3956 \)
    Exercise \(\PageIndex{6}\)

    Let \(x' = \sin (xt)\), and \(x(0) = 1\). Approximate \(x(1)\) using Euler’s method with step sizes \(1\), \(0.5\), \(0.25\). Use a calculator and compute up to \(4\) decimal digits.

    Answer

    Approximately: \(1.0000,\: 1.2397,\: 1.382\)

    Exercise \(\PageIndex{7}\)

    Let \(x' = 2t\), and \(x(0) = 0\).

    1. Approximate \(x(4)\) using Euler’s method with step sizes \(4\), \(2\), and \(1\).
    2. Solve exactly, and compute the errors.
    3. Compute the factor by which the errors changed.
    Answer
    1. \(0,\: 8,\: 12\)
    2. \(x(4) = 16,\) so errors are: \(16,\: 8,\: 4\).
    3. Factors are \(0.5,\: 0.5,\: 0.5\).
    Exercise \(\PageIndex{8}\)

    Let \(x' = xe^{xt+1}\), and \(x(0) = 0\).

    1. Approximate \(x(4)\) using Euler’s method with step sizes \(4\), \(2\), and \(1\).
    2. Guess an exact solution based on part (a) and compute the errors.
    Answer
    1. \(0,\: 0,\: 0\)
    2. \(x=0\) is a solution so errors are: \(0,\: 0,\: 0\).
    Note: The Improved Euler's Method

    There is a simple way to improve Euler’s method to make it a second order method by doing just one extra step. Consider \(\frac{dy}{dx}=f(x,y)\), \(y(x_0) = y_0\), and a step size \(h\). What we do is to pretend we compute the next step as in Euler, that is, we start with \((x_i,y_i)\), we compute a slope \(k_1 = f(x_i,y_i)\), and then look at the point \((x_i+h,y_i + k_1h)\). Instead of letting our new point be \((x_i+h,y_i + k_1h)\), we compute the slope at that point, call it \(k_2\), and then take the average of \(k_1\) and \(k_2\), hoping that the average is going to be closer to the actual slope on the interval from \(x_i\) to \(x_i+h\). And we are correct, if we halve the step, the error should go down by a factor of \(2^2 = 4\). To summarize, the setup is the same as for regular Euler, except the computation of \(y_{i+1}\) and \(x_{i+1}\).

    \[\begin{align}\begin{aligned} & k_1 = f(x_i,y_i) , & & x_{i+1} = x_i + h , \\ & k_2 = f(x_i + h,y_i + k_1h) , & & y_{i+1} = y_i + \frac{k_1+k_2}{2}\,h .\end{aligned}\end{align}\]

    Exercise \(\PageIndex{9}\)

    Consider \(\dfrac{dy}{dx} = x+y\), \(y(0)=1\).

    1. Use the improved Euler’s method with step sizes \(h=\frac{1}{4}\) and \(h=\frac{1}{8}\) to approximate \(y(1)\).
    2. Use Euler’s method with \(h=\frac{1}{4}\) and \(h=\frac{1}{8}\).
    3. Solve exactly, find the exact value of \(y(1)\).
    4. Compute the errors, and the factors by which the errors changed.
    Answer
    1. Improved Euler: \(y(1)\approx 3.3897\) for \(h=1/4\), \(y(1)\approx 3.4237\) for \(h=1/8\),
    2. Standard Euler: \(y(1)\approx 2.8828\) for \(h=1/4\), \(y(1)\approx 3.1316\) for \(h=1/8\),
    3. \(y=2e^{x}-x-1\), so \(y(2)\) is approximately \(3.4366\).
    4. Approximate errors for improved Euler: \(0.046852\) for \(h=1/4\), and \(0.012881\) for \(h=1/8\). For standard Euler: \(0.55375\) for \(h=1/4\), and \(0.30499\) for \(h=1/8\). Factor is approximately \(0.27\) for improved Euler, and \(0.55\) for standard Euler.
    Exercise \(\PageIndex{10}\)

    Consider the initial value problem: \( \frac{dy}{dt} = t + y, \qquad y(0) = 1 \)

    1. Use Euler’s method with step sizes \(h = 0.1\) and \(h = 0.05\) to approximate \(y(0.2)\).
    2. Solve the differential equation exactly.
    3. Compare your Euler approximations with the exact value of \(y(0.2)\) and discuss how the error changes with step size.
    Answer
    1. \( \begin{cases} &h = 0.1: && y(0.2) \approx 1.22 \\ &h = 0.05: && y(0.2) \approx 1.2310 \end{cases}\)
    2. Exact Solution: \( y(t) = -t - 1 + 2 e^t \), \( y(0.2) = -0.2 - 1 + 2 e^{0.2} \approx 1.2428 \)
    3. Comparison and Errors: \( \begin{array}{c|c|c|c}
      \text{Method} & h & y(0.2) & \text{Error} \\ \hline
      \text{Euler} & 0.1 & 1.22 & 0.0228 \\
      \text{Euler} & 0.05 & 1.2310 & 0.0118 \\
      \text{Exact} & - & 1.2428 & 0
      \end{array} \)

    Observation: Halving the step size roughly halves the error, consistent with Euler's first-order accuracy.

     


    This page titled 1.10E: Exercises for Section 1.10 was last modified on Wed, 11 Mar 2026 03:31:05 GMT and is shared under a CC BY-NC-SA 3.0 license and was authored, remixed, and/or curated by Vinh Kha Nguyen, Neelam R. Shukla, and Fatemeh Yarahmadi.