### Differential Equations I

On a cold day, it doesn't take long for a cup of coffee to become tepid; if our refrigerator breaks, our frozen items tend to warm up.

These day-to-day experiences result from heat moving about, a topic that greatly interested Sir Isaac Newton. Newton is famous for inventing calculus and rules of motion, but he also discovered a law for cooling:

An object's temperature changes at a rate proportional to the difference between it and the surrounding temperature.

This will be our starting point for a quick pass through the essential ideas of differential equations. No experience with physics is required; just a little single-variable calculus and a dash of vector arithmetic will do. # Our First Equation

Let's cook up a differential equation based on Newton's Cooling Law:

“An object's temperature changes at a rate proportional to the difference between it and the surrounding temperature.”

If the surrounding air has constant temperature $T_{\text{air}},$ what equation can we infer for $T(t),$ the object's temperature?

In all options, $k$ is a constant.

# Our First Equation

So Newton's Cooling Law leads us to the following differential equation: $\frac{dT}{dt} = k \big[ T(t) - T_{\text{air}} \big].$ Right now we don't know anything about $k$ other than it's constant. For the wrong choice of $k,$ our equation could predict something weird.

For what values of $k$ does the differential equation match our intuition about the real world?

Hint: Think about different cases for the initial temperature $T(0)$ and what the equation implies about these scenarios.

# Our First Equation

We'll learn many techniques for solving differential equations, but it sometimes happens that an equation is just too difficult to solve.

That doesn't mean we give up and go home; we do what we can to glean as much information as possible from the equation itself.

To see how this works, let's start with a fact that's true for all equations in our course: solution curves never cross! Taking this for granted, what can we say about $T(t)$ from $\frac{dT}{dt} = k \big[ T(t) - T_{\text{air}} \big]?$ More than one option may be true!

# Our First Equation

Select one or more

But how can $T(t)$ always increase when $T(0) < T_{\text{air}}$ and not cross over $T_{\text{air}} ?$ The answer lies in the concavity, or "bendiness," of $T(t).$ If $y=f(x),$ the sign of $f''(x)$ determines if the best-fit parabola opens up/down.

From the figure above, we see that if $T''(t) > 0,$ the graph is concave up, while $T''(t) < 0$ means it's concave down.

The second derivative is $T''(t) = k^2 \big[ T(t)-T_{\text{air}} \big]$ (see the solution for the details). What can we say about $T(t)$'s concavity from this?

# Our First Equation

Select one or more

Let's summarize what we've found without solving the equation:

If $T(0) > T_{\text{air}}$ $\big(T(0) < T_{\text{air}}\big),$ the function $T(t)$ is strictly decreasing (increasing) and its graph is always concave up (down).

So the graph of $T(t)$ depends on the initial condition $T(0),$ which isn't surprising given what we uncovered in the last quiz.

Each of the four plots below shows two graphs that could be potential solution curves, one with initial condition above $T_{\text{air}},$ the other below.

Select the only option that displays correct graphs for $T(t).$ The dashed line is $T_{\text{air}}$ in all plots. # Our First Equation

There's another way of getting a quick sketch of the solution curves without finding $T(t)$ explicitly.

Since $T'(t)$ also gives us the slope of lines tangent to solution curves, we lay down a grid on the $tT$-plane and sketch a short arrow with slope $T'(t_{g})$ at every grid point $(t_{g}, T_{g}).$ This results in a slope or direction field: starting at a point on the $T$-axis, we follow the arrows to trace the shape of a solution with $T(0) = T_{0}.$

The interactive below shows the direction field for our equation with adjustable $T_{\text{air}}$ and $T(0) = T_{0}$ sliders. It also displays the solution.

Notice how the curve follows the arrows for all choices of $T_{0}.$

# Our First Equation

By following the direction field, we find an estimate for the solution: $T(nh) \approx T_{\text{air}} + [1+ k h ]^{n} \big(T(0)-T_{\text{air}}\big).$ Here, $h > 0$ measures how far we follow any arrow in the field.

The Python code below computes $T(nh)$ for $n = 1, 2, \dots, 10$ and compares the results to the exact answer we'll find soon.

You can set the hop size $h > 0,$ the initial temperature “To”, and the air temperature “Ta”. We set $k=-1.$

The larger the relative error, the worse the approximation; the smaller the relative error, the better! Play around with different values for the constants and then select the correct option.

from math import exp

h = 10 # Hop size
To = 0.5 # Initial temperature
Ta= 1 # Air temperature

n = 1
while n <= 10:
difference = To - Ta
exponential_h = exp(-n * abs(h) )

numerator_c = abs (Ta+(difference) * ((1- abs(h)) ** n) - (Ta+difference) * exponential_h)
denominator_c= abs( Ta + (difference)* exponential_h)

c = numerator_c / denominator_c

print(c)

n += 1 # Increase n by 1

Choose the size of your hop!

Set the ambient temperature!

This is our counter; please don't change it!

This measures the percent error of our approximation.

You need to be connected to run code

# Our First Equation The method we just used is attributed to Euler, but beyond this brief shoutout, we won't have very much to say about numerical methods in differential equations. That's a course unto itself!

The main takeaway of the last problem is this: the smaller the value of $h > 0,$ the better the approximation tends to be!

The figure shows the first three approximations we get by following the direction field arrows (green) starting from a point (red) on a solution curve (blue) with small hop lengths.

The green points are pretty close to the curve, so this scheme works pretty well. In fact, this process of hopping along direction field arrows is one of the simplest ways of solving a differential equation with a computer, which can be programmed to do the tedious algebra.

# Our First Equation

Challenge Problem:

To finish, let's find the actual solution for $T$ by rewriting the estimate as $T(t) \approx T_{\text{air}} + \bigg[1+ k \underbrace{ \left(\frac{t}{n} \right)}_{ h} \bigg]^{n} (T_{0}-T_{\text{air}}),$

where $k<0.$

According to the last page, this becomes exact if we take the limit as $h \to 0,$ which is equivalent to taking $n \to \infty.$

What is the result of this limit and therefore the exact value of $T(t) ?$

Good to know: Euler's number is defined by $e = \lim\limits_{x \to \infty} \left( 1+ \frac{1}{x} \right)^{x}.$

# Our First Equation

This quiz gives the gist of differential equations, but the topic is vast, and we have a long road ahead of us.

While we aim to be as self-contained as possible, some parts of our course rely heavily on results and techniques in other areas.

Below is a guide to some of the more important supporting topics and where they pop up in our course:

# Our First Equation

×