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 Tair,T_{\text{air}}, what equation can we infer for T(t), T(t), the object's temperature?

In all options, k k is a constant.

Our First Equation

                     

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

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


Hint: Think about different cases for the initial temperature T(0)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)T(t) from dTdt=k[T(t)Tair]? \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) T(t) always increase when T(0)<Tair T(0) < T_{\text{air}} and not cross over Tair? T_{\text{air}} ? The answer lies in the concavity, or "bendiness," of T(t). T(t).

If \(y=f(x),\) the sign of \(f''(x)\) determines if the best-fit parabola opens up/down.   If y=f(x),y=f(x), the sign of f(x)f''(x) determines if the best-fit parabola opens up/down.

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

The second derivative is T(t)=k2[T(t)Tair]T''(t) = k^2 \big[ T(t)-T_{\text{air}} \big] (see the solution for the details). What can we say about T(t)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)>TairT(0) > T_{\text{air}} (T(0)<Tair),\big(T(0) < T_{\text{air}}\big), the function T(t)T(t) is strictly decreasing (increasing) and its graph is always concave up (down).

So the graph of T(t) T(t) depends on the initial condition T(0),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 Tair, T_{\text{air}}, the other below.

Select the only option that displays correct graphs for T(t). T(t). The dashed line is Tair 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) T(t) explicitly.

Since T(t) T'(t) also gives us the slope of lines tangent to solution curves, we lay down a grid on the tTtT-plane and sketch a short arrow with slope T(tg)T'(t_{g}) at every grid point (tg,Tg). (t_{g}, T_{g}).

This results in a slope or direction field: starting at a point on the T T-axis, we follow the arrows to trace the shape of a solution with T(0)=T0.T(0) = T_{0}.

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

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

Our First Equation

                     

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

The Python code below computes T(nh) T(nh) for n=1,2,,10 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, h > 0, the initial temperature “To”, and the air temperature “Ta”. We set k=1.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 your initial temperature!

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, 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 TT by rewriting the estimate as T(t)Tair+[1+k(tn)h]n(T0Tair), 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.k<0.

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

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


Good to know: Euler's number is defined by e=limx(1+1x)x. 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

                     
×

Problem Loading...

Note Loading...

Set Loading...