Numerical Methods for Differential Equations¶

Problem Statement¶

A certain cold soda initially at 38°F would warm up to 44°F in 24 minutes while sitting in a room of temperature 68°F.

Suppose a similar cold soda initially at 38°F is left outside on a couple ideal March days, when the high temperature of 60°F is reached at 6pm and the low temperature of 40°F is reached at 6am.

If the soda was left out at 4pm, how warm will the soda be the next day at 8pm?

Cooling Model¶

We'll model the change in temperature of our soda using Newton's law of cooling, which says that the change in temperature is proportional to the difference in temperature of the object and its surroundings.

If $T$ is the temperature in Fahrenheit after $t$ hours, then: $$\frac{dT}{dt} = k(T_{soda}-T_{surroundings})$$ where $k$ is a proportionality constant.

Since we have initial conditions for the first cold soda, we can use those to find $k$: $$\frac{dT}{dt} = k(T-68)$$ where $T$ is the teperature of the soda (and it's in a 68F room).

Solving for T and k¶

Since the ODE is separable, we can solve for $T$ by integrating: $$\int \frac{1}{T-68}dT = \int kdt$$ $$ln|T-68|+c = kt+c$$ Solving for T and absorbing the constants: $$T = ce^{kt}+68$$

The problem gives us two initial conditions: $T(0) = 38$ and $T(\frac{2}{5}) = 44$. Where did the $\frac{2}{5}$ come from? Shouldn't it be 24? Remember that we said $t$ is measured in hours and 24 minutes is $\frac{2}{5}$ of an hour.

$T(0) = 38$: $$38 = ce^{0k}+68 \implies c+30=0 \implies c=-30$$ $T(\frac{2}{5}) = 44$: $$ 44 = -30e^{\frac{2}{5}k}+68 $$ $$-24 = -30e^{\frac{2}{5}k}$$ $$ 4 = 5e^{\frac{2}{5}k} $$ $$ ln(\frac{4}{5}) = \frac{2}{5}k $$ $$ k = \frac{2ln\left(\frac{4}{5}\right)}{5} $$

Now that we have a proportionality constant, $k$, we can update our original model: $$\frac{dT}{dt} = \frac{2}{5}ln\left(\frac{4}{5}\right)(T_{soda}-T_{surroundings})$$

Modeling the change in outdoor temperature¶

Since we are outdoors, the surrounding temperature, $T_{surroundings}$, fluctuates. We can use a function of $t$ to model the outside temperature> Since we know the time and value of the extrema, we can use a smooth sine curve that oscillates between them. Specifically, we want a sine about 50F with an amplitude of 10F and a period of 24 hours. The soda was left outside at 4pm, so we'll set $t=0=$4pm, so that $t$ is the number of hours that have passed since the soda was left outside. $$ T_{surroundings}(t) = 10sin(\frac{\pi}{12}(t+4))+50 $$

Final Equation¶

$$\frac{dT}{dt} = \frac{2}{5}ln\left(\frac{4}{5}\right)\left[T-10sin(\frac{\pi}{12}(t+4))+50\right]$$

This is a first-order ordinary differential equation. It isn't separable, and the sine function makes it non-linear as well, so we're going to use numerical estimation methods for integration to solve it.