Skip to content

Differential equations: a first look

Change and motion · level 8, lesson 7 of 7

A question to start

A cup of tea is poured at 90 °C in a room at 20 °C. Ten minutes later it has cooled to 60 °C.

When will it be down to 30 °C?

You might guess: it lost 30 degrees in 10 minutes, so another 30 degrees takes another 10 minutes. But a cup of tea does not cool at a steady rate. It cools fast when it is hot and slowly when it is nearly at room temperature. The real answer is about 35 minutes after pouring. To find it we need a law about the rate of cooling, and then we need to turn that law about rates into a formula for the temperature itself. A law about rates is a differential equation, and solving one is the first step beyond school calculus.

The idea

Equations whose unknown is a function

An ordinary equation like \(x^2 = 9\) has a number as its unknown. A differential equation has a function as its unknown, and it tells you something about that function's derivative. Its solution is a function that makes the equation true for every \(t\).

You have already solved some:

  • \(\frac{dy}{dt} = 3\): the rate is constant, so \(y = 3t + C\).
  • \(\frac{dy}{dt} = 2t\): \(y = t^2 + C\) (an antiderivative, lesson 6).
  • \(s''(t) = -9.8\): a thrown ball. Integrating twice gives \(s = s_0 + v_0 t - 4.9t^2\) (level 7, lesson 6).

There is always a constant \(C\) (or more than one), because many functions share a derivative. One extra fact, such as the value at \(t = 0\) (an initial condition), picks out the single solution you want.

Rate proportional to amount: \(\frac{dy}{dt} = ky\)

The most important differential equation of all says: the rate of change is proportional to the amount.

\[\frac{dy}{dt} = ky.\]

It describes anything whose growth feeds itself: bacteria (more bacteria, more divisions), money earning continuous interest (more money, more interest), and, with \(k\) negative, anything that decays by a fixed fraction, such as a radioactive substance (more atoms, more decays).

A solution. From lesson 2, \(\frac{d}{dt}e^{kt} = ke^{kt}\). So \(y = Ce^{kt}\) works for any constant \(C\): its derivative is \(Cke^{kt} = ky\). At \(t = 0\), \(y = Ce^0 = C\), so \(C\) is the starting amount \(y_0\):

\[y = y_0 e^{kt}.\]

The only solutions. Could some other, stranger function also satisfy \(y' = ky\)? No, and here is a short proof. Suppose \(y' = ky\). Let \(z = y e^{-kt}\). By the product rule,

\[z' = y' e^{-kt} - k y e^{-kt} = ky e^{-kt} - ky e^{-kt} = 0.\]

A function with derivative 0 everywhere is constant, so \(z = C\) and \(y = Ce^{kt}\). Every solution is an exponential.

That is why exponential growth and decay turn up everywhere in nature: they are what "rate proportional to amount" forces. If \(k > 0\) the amount grows, doubling every \(\frac{\ln 2}{k}\) time units. If \(k < 0\) it decays, halving every \(\frac{\ln 2}{|k|}\) (the half-life). (Doubling: \(e^{kt} = 2\) when \(kt = \ln 2\).)

Newton's law of cooling

Isaac Newton proposed that a hot object cools at a rate proportional to how much hotter it is than its surroundings. With room temperature \(R\):

\[\frac{dT}{dt} = -k(T - R), \qquad k > 0.\]

The minus sign makes \(T\) fall when \(T > R\). To solve it, let \(u = T - R\), the "excess" temperature. Since \(R\) is constant, \(\frac{du}{dt} = \frac{dT}{dt} = -ku\). That is the equation above, with \(-k\) in place of \(k\). So \(u = u_0 e^{-kt}\), and

\[T = R + (T_0 - R)e^{-kt}.\]

The excess temperature decays exponentially, and \(T\) creeps towards room temperature, getting closer and closer but never quite reaching it in this model. This is the "fast at first, then slower" curve you met in level 3, now with its formula explained.

Slope fields: seeing solutions without solving

A differential equation \(\frac{dy}{dt} = f(t, y)\) tells you the slope of the solution through every point. So you can draw it: at many points \((t, y)\) draw a short segment with slope \(f(t, y)\). The result is a slope field, and every solution curve follows the segments, like a leaf floating on a stream.

Here is the slope field for the tea, \(\frac{dT}{dt} = -0.1(T - 20)\), with three solution curves: starting at 90 °C, at 60 °C, and a cold drink starting at 5 °C.

1020304020406080t (min)T (°C)

You can read the whole story from the segments, without any formula. Above 20 they slope down, steeply when \(T\) is far above 20. Below 20 they slope up. Along \(T = 20\) they are flat: room-temperature tea stays at room temperature (an equilibrium). Every solution is drawn towards 20.

Euler's method: solving with tiny steps

Most differential equations cannot be solved with a formula. But a computer can follow the slope field step by step. Start at the initial point. Find the slope there from the equation. Walk a short step \(\Delta t\) along that slope. Repeat:

\[y_{\text{new}} = y_{\text{old}} + (\text{slope at the old point}) \times \Delta t.\]

This is Euler's method (after Leonhard Euler). Try it on \(\frac{dy}{dt} = y\) with \(y(0) = 1\), whose exact solution is \(e^t\). With step 0.25, each step multiplies \(y\) by \(1 + 0.25 = 1.25\) (because \(y_{\text{new}} = y + y \times 0.25\)). Four steps reach \(t = 1\):

\[y(1) \approx 1.25^4 \approx 2.441.\]

With step 0.1, ten steps give \(1.1^{10} \approx 2.594\). The exact value is \(e \approx 2.718\). Smaller steps get closer, and with \(n\) steps the estimate is \(\left(1 + \frac1n\right)^n\): exactly the compound-interest formula for \(e\). Euler's method and compound interest are the same idea.

Beyond this level

Two famous equations to look forward to:

  • Logistic growth, \(\frac{dP}{dt} = kP\left(1 - \frac{P}{K}\right)\): growth that slows as a population nears the most its environment can support, \(K\). Its solutions are the S-shaped curves of level 6.
  • Oscillation, \(s'' = -\omega^2 s\): a spring or pendulum, where the pull back is proportional to the distance out. Its solutions are \(\sin(\omega t)\) and \(\cos(\omega t)\), because differentiating sine twice gives minus sine.

Much of physics, biology and economics is written in differential equations. This is where calculus stops being a school subject and becomes the language of science.

Worked examples

1. Checking a solution. Show that \(y = 5e^{3t}\) solves \(\frac{dy}{dt} = 3y\) with \(y(0) = 5\).

\(\frac{dy}{dt} = 5 \cdot 3e^{3t} = 3 \cdot 5e^{3t} = 3y\) ✓, and \(y(0) = 5e^0 = 5\) ✓.

2. Bacteria. A culture of 1000 bacteria doubles every 3 hours. Find \(k\) and the population after 10 hours.

  1. Doubling time \(\frac{\ln 2}{k} = 3\), so \(k = \frac{\ln 2}{3} \approx 0.231\) per hour.
  2. \(P(10) = 1000e^{0.231 \times 10}\). More simply, 10 hours is \(\frac{10}{3}\) doublings: \(P = 1000 \times 2^{10/3} \approx 10\,080\).

3. Carbon dating. Carbon-14 has a half-life of about 5730 years. What fraction is left after 10 000 years?

\(\frac{10\,000}{5730} \approx 1.745\) half-lives, so the fraction is \(\left(\frac12\right)^{1.745} \approx 0.298\): about 30%. Measuring the fraction left in old wood or bone is how such materials are dated.

4. The tea. \(T = 20 + 70e^{-kt}\) (room 20 °C, start 90 °C, excess 70).

  1. At \(t = 10\), \(T = 60\): \(70e^{-10k} = 40\), so \(e^{-10k} = \frac47\) and \(k = \frac{\ln(7/4)}{10} \approx 0.0560\) per minute.
  2. Reaching 30 °C: \(70e^{-kt} = 10\), so \(e^{-kt} = \frac17\) and \(t = \frac{\ln 7}{k} \approx \frac{1.946}{0.0560} \approx 34.8\) minutes.

So about 35 minutes after pouring: the second 30 degrees take nearly 25 minutes, not 10. The excess temperature has to fall from 40 to 10, a factor of 4, while the first 10 minutes only shrank it by a factor of \(\frac{7}{4}\).

5. Euler by hand. Use Euler's method with step 0.5 on \(\frac{dy}{dt} = y\), \(y(0) = 1\), to estimate \(y(1)\).

Step 1: slope at \((0, 1)\) is 1; \(y = 1 + 1 \times 0.5 = 1.5\). Step 2: slope at \((0.5, 1.5)\) is 1.5; \(y = 1.5 + 1.5 \times 0.5 = 2.25\). Estimate 2.25, against the true \(e \approx 2.718\). Too low, because the true curve keeps getting steeper during each step, while Euler uses the slope from the start of the step.

Try it

  1. Solve \(\frac{dy}{dt} = 6t^2\) with \(y(0) = 4\).
  2. Check that \(y = 3e^{-2t}\) solves \(\frac{dy}{dt} = -2y\). What is \(y(0)\)?
  3. Solve \(\frac{dy}{dt} = 0.04y\) with \(y(0) = 500\), and find \(y(10)\).
  4. A substance decays with \(\frac{dm}{dt} = -0.1m\) (\(t\) in days). What is its half-life?
  5. Soup at 80 °C is left in a 20 °C room, with \(k = 0.05\) per minute in Newton's law. What is its temperature after 10 minutes?
  6. Use Euler's method with step 0.25 on \(\frac{dy}{dt} = y\), \(y(0) = 1\), writing down each of the four steps.
  7. In the slope field for \(\frac{dT}{dt} = -0.1(T - 20)\), where are the segments flat? What happens in the long run to a drink that starts at 5 °C?
  8. Use the proof in the lesson to show: if \(y' = ky\) and \(y(0) = 0\), then \(y(t) = 0\) for every \(t\).
Answers
  1. \(y = 2t^3 + C\), and \(y(0) = 4\) gives \(C = 4\): \(y = 2t^3 + 4\).
  2. \(\frac{dy}{dt} = 3 \times (-2)e^{-2t} = -2 \times 3e^{-2t} = -2y\) ✓. \(y(0) = 3\).
  3. \(y = 500e^{0.04t}\). \(y(10) = 500e^{0.4} \approx 745.9\).
  4. Half-life \(\frac{\ln 2}{0.1} \approx 6.93\) days.
  5. \(T = 20 + 60e^{-0.05t}\), so \(T(10) = 20 + 60e^{-0.5} \approx 20 + 36.4 = 56.4\) °C.
  6. Each step multiplies by 1.25: \(1 \to 1.25 \to 1.5625 \to 1.953125 \to 2.44140625\). So \(y(1) \approx 2.441\) (true value \(e \approx 2.718\)).
  7. Flat where the slope \(-0.1(T - 20)\) is 0: along \(T = 20\). The cold drink's curve slopes upwards, less and less steeply, and creeps up towards 20 °C: it warms to room temperature.
  8. Let \(z = ye^{-kt}\). As in the lesson, \(z' = 0\), so \(z\) is constant, and \(z(0) = y(0) \times 1 = 0\). So \(z = 0\) always, and \(y = ze^{kt} = 0\) always. (If nothing is there, nothing can grow.)

Common mistake

Treating a rate law as a formula for the amount. \(\frac{dT}{dt} = -0.1(T - 20)\) is not the temperature; it is how fast the temperature changes. To get \(T\) you must solve the equation. Plugging a time into the rate law does not give a temperature.

Assuming steady change. The opening guess (another 10 minutes) assumed a constant rate. Whenever the rate depends on the amount, the change is not steady, and straight-line thinking gives the wrong answer.

Where it leads