Skip to main content
Engineering LibreTexts

19.11: Exercise

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Before you go on, you might want to work on the following exercise.

    Exercise 9.1

    Suppose that you’re given an 8-ounce cup of coffee at 90 °C. You have learned from bitter experience that the hottest coffee you can drink comfortably is 60 °C.

    If the temperature of the coffee drops by 0.7 °C during the first minute, how long will you have to wait to drink your coffee?

    You can answer this question with Newton’s Law of Cooling (see \[\frac{dy}{dt}(t) = -k (y(t) - e)\notag\] where \(y(t)\) is the temperature of the coffee at time \(t\), \(e\) is the temperature of the environment, and \(k\) is a parameter that characterizes the rate of heat transfer from the coffee to the environment.

    Let’s assume that \(e\) is 20 °C and constant; that is, the coffee does not warm up the room.

    Let’s also assume \(k\) is constant. In that case, we can estimate it based on the information we have. If the temperature drops 0.7 °C during the first minute, when the coffee is 90 °C, we can write \[-0.7 = -k (90 - 20)\notag\]

    Solving this equation yields \(k = 0.01\).

    Here are some suggestions for getting started:

    1. Create a file named coffee.m and write a function called coffee that takes no input variables. Put a simple statement like x = 5 in the body of the function and invoke coffee from the Command Window.
    2. Add a helper function called rate_func that takes t and y and computes \(dy/dt\). In this case, rate_func does not actually depend on \(t\); nevertheless, your function has to take \(t\) as the first input variable in order to work with ode45.
    3. Test your function by adding a line like rate_func(0, 90) to coffee, then call coffee from the Command Window. Confirm that the initial rate is -0.7 °C/min.
    4. Once you get rate_func working, modify coffee to use ode45 to compute the temperature of the coffee for 60 minutes. Confirm that the coffee cools quickly at first, then cools more slowly, and reaches room temperature after about an hour.
    5. Plot the results and estimate the time when the temperature reaches 60 °C.

    This page titled 19.11: Exercise is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Allen B. Downey (Green Tea Press) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.