¿Qué es el método de Euler y cómo podemos usarlo para aproximar la solución a un problema de valor inicial?
¿Qué tan preciso es el método de Euler?
En Sección 7.2, vimos cómo un campo de pendientes puede ser usado para esbozar soluciones a una ecuación diferencial. En particular, el campo de pendientes es un gráfico de una gran colección de líneas tangentes a un gran número de soluciones de la ecuación diferencial, y esbozamos una sola solución simplemente siguiendo estas líneas tangentes. Con un poco más de reflexión, podemos usar esta misma idea para aproximar numéricamente las soluciones de una ecuación diferencial.
Usa la ecuación diferencial para encontrar la pendiente de la línea tangente a la solución \(y(t)\) en \(t=0\text{.}\) Luego usa el valor inicial dado para encontrar la ecuación de la línea tangente en \(t=0\text{.}\)
Dibuja la línea tangente en los ejes proporcionados en Figure 7.3.1 en el intervalo \(0\leq t\leq 2\) y úsala para aproximar \(y(2)\text{,}\) el valor de la solución en \(t=2\text{.}\)
Suponiendo que tu aproximación para \(y(2)\) es el valor real de \(y(2)\text{,}\) usa la ecuación diferencial para encontrar la pendiente de la línea tangente a \(y(t)\) en \(t=2\text{.}\) Luego, escribe la ecuación de la línea tangente en \(t=2\text{.}\)
Añade un dibujo de esta línea tangente en el intervalo \(2\leq t\leq 4\) a tu gráfico Figure 7.3.1; usa esta nueva línea tangente para aproximar \(y(4)\text{,}\) el valor de la solución en \(t=4\text{.}\)
Repite el mismo paso para encontrar una aproximación para \(y(6)\text{.}\)
“Euler” se pronuncia “Oy-ler.” Entre otras cosas, Euler es el matemático acreditado con el famoso número \(e\text{;}\) si pronuncias incorrectamente su nombre como “You-ler,” no aprecias su genio y legado.
, que genera una aproximación numérica a la solución de un problema de valor inicial. En este algoritmo, aproximaremos la solución tomando pasos horizontales de un tamaño fijo que denotamos por \(\Delta t\text{.}\)
Antes de explicar el algoritmo en detalle, recordemos cómo calculamos la pendiente de una línea: la pendiente es la razón del cambio vertical al cambio horizontal, como se muestra en Figura 7.3.2.
En otras palabras, \(m = \frac{\Delta y}{\Delta t}\text{.}\) Resolviendo para \(\Delta y\text{,}\) vemos que el cambio vertical es el producto de la pendiente y el cambio horizontal, o
\begin{equation*}
\Delta y = m\Delta t\text{.}
\end{equation*}
Ahora, supón que queremos resolver el problema de valor inicial
\begin{equation*}
\frac{dy}{dt} = t - y, \ y(0) = 1\text{.}
\end{equation*}
Hay un algoritmo mediante el cual podemos encontrar una fórmula algebraica para la solución de este problema de valor inicial, y podemos verificar que esta solución es \(y(t) = t -1 + 2e^{-t}\text{.}\) Pero en cambio estamos interesados en generar una solución aproximada creando una secuencia de puntos \((t_i, y_i)\text{,}\) donde \(y_i\approx y(t_i)\text{.}\) Para este primer ejemplo, elegimos \(\Delta t = 0.2\text{.}\)
Dado que sabemos que \(y(0) = 1\text{,}\) tomaremos el punto inicial como \((t_0,y_0) = (0,1)\) y nos moveremos horizontalmente por \(\Delta t = 0.2\) hasta el punto \((t_1,y_1)\text{.}\) Así, \(t_1=t_0+\Delta t = 0.2\text{.}\) Ahora, la ecuación diferencial nos dice que la pendiente de la línea tangente en este punto es
así que para movernos a lo largo de la línea tangente tomando un paso horizontal de tamaño \(\Delta t=0.2\text{,}\) también debemos movernos verticalmente por
\begin{equation*}
\Delta y = m\Delta t = -1\cdot 0.2 = -0.2\text{.}
\end{equation*}
Entonces tenemos la aproximación \(y(0.2) \approx y_1= y_0 + \Delta y = 1 - 0.2 = 0.8\text{.}\) En este punto, hemos ejecutado un paso del método de Euler, como se ve gráficamente en Figura 7.3.3.
Ahora repetimos este proceso: en \((t_1,y_1) = (0.2,0.8)\text{,}\) la ecuación diferencial nos dice que la pendiente es
Si avanzamos horizontalmente por \(\Delta t\) hasta \(t_2=t_1+\Delta = 0.4\text{,}\) debemos movernos verticalmente por
\begin{equation*}
\Delta y = -0.6\cdot0.2 = -0.12\text{.}
\end{equation*}
Consecuentemente llegamos a \(y_2=y_1+\Delta y = 0.8-0.12 = 0.68\text{,}\) lo que da \(y(0.2)\approx 0.68\text{.}\) Ahora hemos completado el segundo paso del método de Euler, como se muestra en Figura 7.3.4.
Si continuamos de esta manera, podemos generar los puntos \((t_i, y_i)\) mostrados en Figura 7.3.5. Debido a que podemos encontrar una fórmula para la solución real \(y(t)\) de esta ecuación diferencial, podemos graficar \(y(t)\) y compararla con los puntos generados por el método de Euler, como se muestra en Figura 7.3.6.
Debido a que necesitamos generar un gran número de puntos \((t_i,y_i)\text{,}\) es conveniente organizar la implementación del método de Euler en una tabla como se muestra. Comenzamos con los datos iniciales dados.
\(t_i\)
\(y_i\)
\(dy/dt\)
\(\Delta y\)
\(0.0000\)
\(1.0000\)
Desde aquí, calculamos la pendiente de la línea tangente \(m=dy/dt\) usando la fórmula para \(dy/dt\) de la ecuación diferencial, y luego encontramos \(\Delta y\text{,}\) el cambio en \(y\text{,}\) usando la regla \(\Delta y = m\Delta t\text{.}\)
\(t_i\)
\(y_i\)
\(dy/dt\)
\(\Delta y\)
\(0.0000\)
\(1.0000\)
\(-1.0000\)
\(-0.2000\)
Luego, aumentamos \(t_i\) por \(\Delta t\) y \(y_i\) por \(\Delta y\) para obtener
\(t_i\)
\(y_i\)
\(dy/dt\)
\(\Delta y\)
\(0.0000\)
\(1.0000\)
\(-1.0000\)
\(-0.2000\)
\(0.2000\)
\(0.8000\)
Continuamos el proceso por la cantidad de pasos que decidamos, eventualmente generando una tabla como Table 7.3.7.
Table7.3.7.Método de Euler para 6 pasos con \(\Delta t = 0.2\text{.}\)
Usa el método de Euler con \(\Delta t = 0.2\) para aproximar la solución en \(t_i = 0.2, 0.4, 0.6, 0.8\text{,}\) y \(1.0\text{.}\) Registra tu trabajo en la siguiente tabla, y dibuja los puntos \((t_i, y_i)\) en los ejes proporcionados.
\(t_i\)
\(y_i\)
\(dy/dt\)
\(\Delta y\)
\(0.0000\)
\(0.0000\)
\(0.2000\)
\(0.4000\)
\(0.6000\)
\(0.8000\)
\(1.0000\)
Table7.3.8.Tabla para registrar los resultados del método de Euler.
Encuentra la solución exacta al problema de valor inicial original y usa esta función para encontrar el error en tu aproximación en cada uno de los puntos \(t_i\text{.}\)
Explica por qué el valor \(y_5\) generado por el método de Euler para este problema de valor inicial produce el mismo valor que una suma de Riemann a la izquierda para la integral definida \(\int_0^1 (2t-1)~dt\text{.}\)
¿Cómo diferirían tus cálculos si el valor inicial fuera \(y(0) = 1\text{?}\) ¿Qué significa esto sobre las diferentes soluciones a esta ecuación diferencial?
Activity7.3.3.
Considera la ecuación diferencial \(\frac{dy}{dt} = 6y-y^2\text{.}\)
Dibuja el campo de pendientes para esta ecuación diferencial en los ejes proporcionados en Figura 7.3.10.
Identifica cualquier solución de equilibrio y determina si son estables o inestables.
¿Cuál es el comportamiento a largo plazo de la solución que satisface el valor inicial \(y(0) = 1\text{?}\)
Usando el valor inicial \(y(0) = 1\text{,}\) usa el método de Euler con \(\Delta t = 0.2\) para aproximar la solución en \(t_i = 0.2, 0.4, 0.6, 0.8\text{,}\) y \(1.0\text{.}\) Registra tus resultados en Tabla 7.3.11 y dibuja los puntos correspondientes \((t_i, y_i)\) en los ejes proporcionados en Figura 7.3.12. Nota la diferente escala horizontal en los ejes en Figura 7.3.12 comparado con Figura 7.3.10.
\(t_i\)
\(y_i\)
\(dy/dt\)
\(\Delta y\)
\(0.0\)
\(1.0000\)
\(0.2\)
\(0.4\)
\(0.6\)
\(0.8\)
\(1.0\)
Table7.3.11.Tabla para registrar los resultados del método de Euler con \(\Delta t = 0.2\text{.}\)
¿Qué pasa si aplicamos el método de Euler para aproximar la solución con \(y(0) = 6\text{?}\)
Subsection7.3.2El error en el método de Euler
Ya que estamos aproximando las soluciones a un problema de valor inicial usando líneas tangentes, deberíamos esperar que el error en la aproximación sea menor cuando el tamaño del paso es menor. Considera el problema de valor inicial
\begin{equation*}
\frac{dy}{dt} = y, \ y(0) = 1\text{,}
\end{equation*}
cuya solución podemos encontrar fácilmente.
La pregunta planteada por este problema de valor inicial es “¿qué función conocemos que sea igual a su propia derivada y tenga valor 1 cuando \(t=0\text{?}\)” No es difícil ver que la solución es \(y(t) = e^t\text{.}\) Ahora aplicamos el método de Euler para aproximar \(y(1) = e\) usando varios valores de \(\Delta t\text{.}\) Estas aproximaciones serán denotadas por \(E_{\Delta t}\text{,}\) y las usaremos para ver qué tan preciso es el Método de Euler.
Para comenzar, aplicamos el método de Euler con un tamaño de paso de \(\Delta t =
0.2\text{.}\) En ese caso, encontramos que \(y(1) \approx E_{0.2} = 2.4883\text{.}\) El error es por lo tanto
Reduciendo repetidamente a la mitad \(\Delta t\) obtenemos los siguientes resultados, expresados tanto en forma tabular como gráfica.
\(\Delta t\)
\(E_{\Delta t}\)
Error
\(0.200\)
\(2.4883\)
\(0.2300\)
\(0.100\)
\(2.5937\)
\(0.1245\)
\(0.050\)
\(2.6533\)
\(0.0650\)
\(0.025\)
\(2.6851\)
\(0.0332\)
Table7.3.13.Errores que corresponden a diferentes valores de \(\Delta t\text{.}\)
Nota, tanto numérica como gráficamente, que el error se reduce aproximadamente a la mitad cuando \(\Delta t\) se reduce a la mitad. Este ejemplo ilustra el siguiente principio general.
Si se usa el método de Euler para aproximar la solución a un problema de valor inicial en un punto \(\overline{t}\text{,}\) entonces el error es proporcional a \(\Delta t\text{.}\) Es decir,
\begin{equation*}
y(\overline{t}) - E_{\Delta t} \approx K\Delta t
\end{equation*}
para alguna constante de proporcionalidad \(K\text{.}\)
Subsection7.3.3Resumen
El método de Euler es un algoritmo para aproximar la solución a un problema de valor inicial siguiendo las líneas tangentes mientras tomamos pasos horizontales a lo largo del eje \(t\text{.}\)
Si deseamos aproximar \(y(\overline{t})\) para algún \(\overline{t}\) fijo tomando pasos horizontales de tamaño \(\Delta t\text{,}\) entonces el error en nuestra aproximación es proporcional a \(\Delta t\text{.}\)
Exercises7.3.4Exercises
1.A few steps of Euler’s method.
Consider the differential equation \(y'=-x-y\text{.}\)
Use Euler’s method with \(\Delta x=0.1\) to estimate \(y\) when \(x=1.4\) for the solution curve satisfying
Use Euler’s method with \(\Delta x=0.1\) to estimate \(y\) when \(x=2.4\) for the solution curve satisfying \(y(1) = 0\) : Euler’s approximation gives \(y(2.4)\approx\)
2.Using Euler’s method for a solution of \(y'=4y\).
Consider the solution of the differential equation \(y' = -2 y\) passing through \(y(0) = 1\text{.}\)
A. Sketch the slope field for this differential equation, and sketch the solution passing through the point (0,1).
B. Use Euler’s method with step size \(\Delta x=0.2\) to estimate the solution at \(x=0.2,0.4,\ldots,1\text{,}\) using these to fill in the following table. (Be sure not to round your answers at each step!)
\(x =\)
0
0.2
0.4
0.6
0.8
1.0
\(y\approx\)
1
C. Plot your estimated solution on your slope field. Compare the solution and the slope field. Is the estimated solution an over or under estimate for the actual solution?
over
under
D. Check that \(y = e^{-2 x}\) is a solution to \(y' = -2 y\) with \(y(0) = 1\text{.}\)
3.Using Euler’s method with different time steps.
Use Euler’s method to solve
\begin{equation*}
\frac{dB}{dt}= 0.05 B
\end{equation*}
with initial value \(B=800\) when \(t=0\) .
A.\(\Delta t = 1\) and 1 step: \(B(1) \approx\)
B.\(\Delta t = 0.5\) and 2 steps: \(B(1) \approx\)
C.\(\Delta t = 0.25\) and 4 steps: \(B(1) \approx\)
D. Suppose \(B\) is the balance in a bank account earning interest. Be sure that you can explain why the result of your calculation in part (a) is equivalent to compounding the interest once a year instead of continuously. Then interpret the result of your calculations in parts (b) and (c) in terms of compound interest.
4.
Newton’s Law of Cooling says that the rate at which an object, such as a cup of coffee, cools is proportional to the difference in the object’s temperature and room temperature. If \(T(t)\) is the object’s temperature and \(T_r\) is room temperature, this law is expressed at
where \(k\) is a constant of proportionality. In this problem, temperature is measured in degrees Fahrenheit and time in minutes.
Two calculus students, Alice and Bob, enter a 70\(^\circ\) classroom at the same time. Each has a cup of coffee that is 100\(^\circ\text{.}\) The differential equation for Alice has a constant of proportionality \(k=0.5\text{,}\) while the constant of proportionality for Bob is \(k=0.1\text{.}\) What is the initial rate of change for Alice’s coffee? What is the initial rate of change for Bob’s coffee?
What feature of Alice’s and Bob’s cups of coffee could explain this difference?
As the heating unit turns on and off in the room, the temperature in the room is
Implement Euler’s method with a step size of \(\Delta t = 0.1\) to approximate the temperature of Alice’s coffee over the time interval \(0\leq t\leq
50\text{.}\) This will most easily be performed using a spreadsheet such as Excel. Graph the temperature of her coffee and room temperature over this interval.
In the same way, implement Euler’s method to approximate the temperature of Bob’s coffee over the same time interval. Graph the temperature of his coffee and room temperature over the interval.
Explain the similarities and differences that you see in the behavior of Alice’s and Bob’s cups of coffee.
5.
We have seen that the error in approximating the solution to an initial value problem is proportional to \(\Delta t\text{.}\) That is, if \(E_{\Delta t}\) is the Euler’s method approximation to the solution to an initial value problem at \(\overline{t}\text{,}\) then
\begin{equation*}
y(\overline{t})-E_{\Delta t} \approx K\Delta t
\end{equation*}
for some constant of proportionality \(K\text{.}\)
In this problem, we will see how to use this fact to improve our estimates, using an idea called accelerated convergence.
We will create a new approximation by assuming the error is exactly proportional to \(\Delta t\text{,}\) according to the formula
This is a system of two linear equations in the unknowns \(y(1)\) and \(K\text{.}\) Solve this system to find a new approximation for \(y(1)\text{.}\) (You may remember that the exact value is \(y(1) = e =
2.71828\ldots\text{.}\))
Use the other data, \(E_{0.05} = 2.6533\) and \(E_{0.025} = 2.6851\) to do similar work as in (a) to obtain another approximation. Which gives the better approximation? Why do you think this is?
Approximate \(y(0.3)\) by applying Euler’s method to find approximations \(E_{0.1}\) and \(E_{0.05}\text{.}\) Now use the idea of accelerated convergence to obtain a better approximation. (For the sake of comparison, you want to note that the actual value is \(y(0.3) =
0.0408\text{.}\))
6.
In this problem, we’ll modify Euler’s method to obtain better approximations to solutions of initial value problems. This method is called the Improved Euler’s method.
In Euler’s method, we walk across an interval of width \(\Delta t\) using the slope obtained from the differential equation at the left endpoint of the interval. Of course, the slope of the solution will most likely change over this interval. We can improve our approximation by trying to incorporate the change in the slope over the interval.
Let’s again consider the initial value problem \(dy/dt = y\) and \(y(0) = 1\text{,}\) which we will approximate using steps of width \(\Delta t = 0.2\text{.}\) Our first interval is therefore \(0\leq t \leq 0.2\text{.}\) At \(t=0\text{,}\) the differential equation tells us that the slope is 1, and the approximation we obtain from Euler’s method is that \(y(0.2)\approx y_1= 1+ 1(0.2)= 1.2\text{.}\)
This gives us some idea for how the slope has changed over the interval \(0\leq t\leq 0.2\text{.}\) We know the slope at \(t=0\) is 1, while the slope at \(t=0.2\) is 1.2, trusting in the Euler’s method approximation. We will therefore refine our estimate of the initial slope to be the average of these two slopes; that is, we will estimate the slope to be \((1+1.2)/2 = 1.1\text{.}\) This gives the new approximation \(y(1) = y_1 = 1 + 1.1(0.2) = 1.22\text{.}\)
The first few steps look like what is found in Table 7.3.15.
Table7.3.15.The first several steps of the improved Euler’s method
\(t_i\)
\(y_i\)
Slope at \((t_{i+1},y_{i+1})\)
Average slope
\(0.0\)
\(1.0000\)
\(1.2000\)
\(1.1000\)
\(0.2\)
\(1.2200\)
\(1.4640\)
\(1.3420\)
\(0.4\)
\(1.4884\)
\(1.7861\)
\(1.6372\)
\(\vdots\)
\(\vdots\)
\(\vdots\)
\(\vdots\)
Continue with this method to obtain an approximation for \(y(1) = e\text{.}\)
Repeat this method with \(\Delta t = 0.1\) to obtain a better approximation for \(y(1)\text{.}\)
We saw that the error in Euler’s method is proportional to \(\Delta t\text{.}\) Using your results from parts (a) and (b), what power of \(\Delta t\) appears to be proportional to the error in the Improved Euler’s Method?