In the exercises, feel free to leave answer as a definite integral if a closed form solution cannot be found. If you can find a closed form solution, you should give that.
Exercise \(\PageIndex{1.4.1}\)
Solve \( y' + xy = x\).
Exercise \(\PageIndex{1.4.2}\)
Solve \( y' + 6y = e^x\).
Exercise \(\PageIndex{1.4.3}\)
Solve \(y' +3x^2y = \sin(x)\,e^{-x^3}\) with \( y(0)=1\).
Exercise \(\PageIndex{1.4.4}\)
Solve \(y' + \cos(x)\,y =\cos(x) \).
Exercise \(\PageIndex{1.4.5}\)
Solve \( \frac{1}{x^2+1}y'+xy = 3\) with \( y(0)=0\).
Exercise \(\PageIndex{1.4.6}\)
Suppose there are two lakes located on a stream. Clean water flows into the first lake, then the water from the first lake flows into the second lake, and then water from the second lake flows further downstream. The in and out flow from each lake is \(500\) liters per hour. The first lake contains \(100\) thousand liters of water and the second lake contains \(200\) thousand liters of water. A truck with \(500\) kg of toxic substance crashes into the first lake. Assume that the water is being continually mixed perfectly by the stream.
- Find the concentration of toxic substance as a function of time in both lakes.
- When will the concentration in the first lake be below \(0.001\text{ kg}\) per liter?
- When will the concentration in the second lake be maximal?
Exercise \(\PageIndex{1.4.7}\)
Newton’s law of cooling states that \(\frac{dx}{dt} = -k(x-A)\) where \(x\) is the temperature, \(t\) is time, \(A\) is the ambient temperature, and \(k>0\) is a constant. Suppose that \(A=A_0 \cos(\omega t)\) for some constants \(A_0\) and \(\omega\). That is, the ambient temperature oscillates (for example night and day temperatures).
- Find the general solution.
- In the long term, will the initial conditions make much of a difference? Why or why not?
Exercise \(\PageIndex{1.4.8}\)
Initially \(5\) grams of salt are dissolved in \(20\) liters of water. Brine with concentration of salt \(2\) grams of salt per liter is added at a rate of \(3\) liters a minute. The tank is mixed well and is drained at \(3\) liters a minute. How long does the process have to continue until there are \(20\) grams of salt in the tank?
Exercise \(\PageIndex{1.4.9}\)
Initially a tank contains \(10\) liters of pure water. Brine of unknown (but constant) concentration of salt is flowing in at \(1\) liter per minute. The water is mixed well and drained at \(1\) liter per minute. In \(20\) minutes there are \(15\) grams of salt in the tank. What is the concentration of salt in the incoming brine?
Exercise \(\PageIndex{1.4.10}\)
Solve \(y' + 3x^2y + x^2\).
- Answer
-
\(y=Ce^{-x^{3}}+\frac{1}{3}\)
Exercise \(\PageIndex{1.4.11}\)
Solve \(y' + 2\sin(2x)y=2\sin(2x)\) with \(y(\pi/2)=3\).
- Answer
-
\(y=2e^{\cos (2x)+1}+1\)
Exercise \(\PageIndex{1.4.12}\)
Suppose a water tank is being pumped out at \(3\:\frac{\text{L}}{\text{min}}\). The water tank starts at \(10\text{ L}\) of clean water. Water with toxic substance is flowing into the tank at \(2\:\frac{\text{L}}{\text{min}}\), with concentration \(20t\:\frac{\text{g}}{\text{L}}\) at time \(t\). When the tank is half empty, how many grams of toxic substance are in the tank (assuming perfect mixing)?
- Answer
-
\(250\) grams
Exercise \(\PageIndex{1.4.13}\)
Suppose we have bacteria on a plate and suppose that we are slowly adding a toxic substance such that the rate of growth is slowing down. That is, suppose that \(\frac{dP}{dt}=(2-0.1\, t)P\). If \(P(0)=1000\), find the population at \(t=5\).
- Answer
-
\(P(5)=1000e^{2\times 5-0.05\times 5^{2}}=1000e^{8.75}\approx 6.31\times 10^{6}\)
Exercise \(\PageIndex{1.4.14}\)
A cylindrical water tank has water flowing in at \(I\) cubic meters per second. Let \(A\) be the area of the cross section of the tank in meters. Suppose water is flowing from the bottom of the tank at a rate proportional to the height of the water level. Set up the differential equation for \(h\), the height of the water, introducing and naming constants that you need. You should also give the units for your constants.
- Answer
-
\(Ah'=I-kh\), where \(k\) is a constant with units \(\frac{\text{m}^{2}}{\text{s}}\).
Exercise \(\PageIndex{1.7.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)\).
Exercise \(\PageIndex{1.7.2}\)
Consider \(\frac{dx}{dt} = t -x \), \(x(0) = 1\).
- Use Euler’s method with step sizes \(h = 1, \frac{1}{2}, \frac{1}{4}, \frac{1}{8}\) to approximate \(x(1)\).
- Solve the equation exactly.
- 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.
Exercise \(\PageIndex{1.7.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\).
Exercise \(\PageIndex{1.7.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{1.7.5}\)
Consider \(\frac{dy}{dx} = yx^2\), \(y(0) = 1\).
- Use Runge-Kutta (see above) with step sizes \(h = 1\) and \(h = \frac{1}{2}\) to approximate \(y(1)\).
- Use Euler’s method with \(h = 1\) and \(h = \frac{1}{2}\).
- Solve exactly, find the exact value of \(y(1)\), and compare.
Exercise \(\PageIndex{1.7.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{1.7.7}\)
Let \(x' = 2t\), and \(x(0) = 0\).
- Approximate \(x(4)\) using Euler’s method with step sizes \(4\), \(2\), and \(1\).
- Solve exactly, and compute the errors.
- Compute the factor by which the errors changed.
- Answer
-
- \(0,\: 8,\: 12\)
- \(x(4) = 16,\) so errors are: \(16,\: 8,\: 4\).
- Factors are \(0.5,\: 0.5,\: 0.5\).
Exercise \(\PageIndex{1.7.8}\)
Let \(x' = xe^{xt+1}\), and \(x(0) = 0\).
- Approximate \(x(4)\) using Euler’s method with step sizes \(4\), \(2\), and \(1\).
- Guess an exact solution based on part a) and compute the errors.
- Answer
-
- \(0,\: 0,\: 0\)
- \(x=0\) is a solution so errors are: \(0,\: 0,\: 0\).
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{1.7.9}\)
Consider \(\dfrac{dy}{dx} = x+y\), \(y(0)=1\).
- Use the improved Euler’s method (see above) with step sizes \(h=\frac{1}{4}\) and \(h=\frac{1}{8}\) to approximate \(y(1)\).
- Use Euler’s method with \(h=\frac{1}{4}\) and \(h=\frac{1}{8}\).
- Solve exactly, find the exact value of \(y(1)\).
- Compute the errors, and the factors by which the errors changed.
- Answer
-
- Improved Euler: \(y(1)\approx 3.3897\) for \(h=1/4\), \(y(1)\approx 3.4237\) for \(h=1/8\),
- Standard Euler: \(y(1)\approx 2.8828\) for \(h=1/4\), \(y(1)\approx 3.1316\) for \(h=1/8\),
- \(y=2e^{x}-x-1\), so \(y(2)\) is approximately \(3.4366\).
- 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.