Project Two. Outline. James K. Peterson. March 27, Cooling Models. Estimating the Cooling Rate k. Typical Cooling Project Matlab Session

Similar documents
Project Two. James K. Peterson. March 26, Department of Biological Sciences and Department of Mathematical Sciences Clemson University

Newton s Cooling Model in Matlab and the Cooling Project!

The First Derivative and Second Derivative Test

The First Derivative and Second Derivative Test

MatLab Code for Simple Convex Minimization

A population is modeled by the differential equation

Project One: C Bump functions

Riemann Sums. Outline. James K. Peterson. September 15, Riemann Sums. Riemann Sums In MatLab

Solving systems of ODEs with Matlab

One common method of shaping

Predator - Prey Model Trajectories and the nonlinear conservation law

Riemann Integration. Outline. James K. Peterson. February 2, Riemann Sums. Riemann Sums In MatLab. Graphing Riemann Sums

Using Recursion in Models and Decision Making: Recursion Using Rate of Change IV.C Student Activity Sheet 5: Newton s Law of Cooling

Riemann Integration. James K. Peterson. February 2, Department of Biological Sciences and Department of Mathematical Sciences Clemson University

Taylor Polynomials. James K. Peterson. Department of Biological Sciences and Department of Mathematical Sciences Clemson University

More Protein Synthesis and a Model for Protein Transcription Error Rates

The Derivative of a Function

Defining Exponential Functions and Exponential Derivatives and Integrals

The SIR Disease Model Trajectories and MatLab

Computer simulation of radioactive decay

Extreme Values and Positive/ Negative Definite Matrix Conditions

2. (12 points) Find an equation for the line tangent to the graph of f(x) =

Regression and Covariance

Integration by Parts Logarithms and More Riemann Sums!

More On Exponential Functions, Inverse Functions and Derivative Consequences

Matrices and Vectors

Uniform Convergence Examples

Mathematical Induction

Chill Out: How Hot Objects Cool

A Library of Functions

Algebra 2 and Trigonometry Honors

Sin, Cos and All That

Math-3 Lesson 8-7. b) ph problems c) Sound Intensity Problems d) Money Problems e) Radioactive Decay Problems. a) Cooling problems

Linear Systems of ODE: Nullclines, Eigenvector lines and trajectories

Mathematics 256 a course in differential equations for engineering students

Geometric Series and the Ratio and Root Test

Linear Systems of ODE: Nullclines, Eigenvector lines and trajectories

Mathematics 132 Calculus for Physical and Life Sciences 2 Exam 3 Review Sheet April 15, 2008

Uniform Convergence Examples

HW#1. Unit 4B Logarithmic Functions HW #1. 1) Which of the following is equivalent to y=log7 x? (1) y =x 7 (3) x = 7 y (2) x =y 7 (4) y =x 1/7

Solving Linear Systems of ODEs with Matlab

Advanced Protein Models

Sin, Cos and All That

An Introduction to Matlab

ACCESS TO SCIENCE, ENGINEERING AND AGRICULTURE: MATHEMATICS 1 MATH00030 SEMESTER / Lines and Their Equations

Fault Tolerant Computing CS 530DL

Exponential Growth (Doubling Time)

Math 1320, Section 10 Quiz IV Solutions 20 Points

Class President: A Network Approach to Popularity. Due July 18, 2014

Lecture 5b: Starting Matlab

dq = λa T Direction of heat flow dq = λa T h T c

Advanced Protein Models

Section 6.8 Exponential Models; Newton's Law of Cooling; Logistic Models

Civil Engineering Computation. Initial Meeting and Class Setup EXCEL Review Problems

Math , Spring 2010: Exam 2 Solutions 1. #1.) /5 #2.) /15 #3.) /20 #4.) /10 #5.) /10 #6.) /20 #7.) /20 Total: /100

An equation of the form y = ab x where a 0 and the base b is a positive. x-axis (equation: y = 0) set of all real numbers

Ideal Gas and Latent Heat

Linear Motion with Constant Acceleration

Derivatives and the Product Rule

AP CHEMISTRY LAB RATES OF CHEMICAL REACTIONS (II)

MA 0090 Section 21 - Slope-Intercept Wednesday, October 31, Objectives: Review the slope of the graph of an equation in slope-intercept form.

MATH 408N PRACTICE MIDTERM 1

Experiment Flow Analysis

Introduction to Determining Power Law Relationships

Hölder s and Minkowski s Inequality

MAPLE Worksheet Number 7 Derivatives in Calculus

Review for Final Exam, MATH , Fall 2010

1 Implicit Differentiation

Systems of Linear ODEs

6.5 Separable Differential Equations and Exponential Growth

Math 2300 Calculus II University of Colorado Final exam review problems

Outline. Additional Nonlinear Systems. Abstract. Finding Equilibrium Points Numerically. Newton s Method

7.2 Logarithmic Functions Name: 1

3.1 Derivative Formulas for Powers and Polynomials

REVIEW PROBLEMS FOR MIDTERM I MATH 2373, FALL 2016 ANSWER KEY

Mathematical Induction Again

PHYSICS 211 LAB #8: Periodic Motion

Convergence of Sequences

Solve by equating exponents

Some Basic Modeling with Differential Equations

Example 1: What do you know about the graph of the function

DIFFERENTIATION RULES

Mathematical Induction Again

22: Applications of Differential Calculus

Geometric Series and the Ratio and Root Test

Math 229 Mock Final Exam Solution

Consequences of Continuity

Appendix A. Common Mathematical Operations in Chemistry

4.1 Solutions to Exercises

Modeling Via Differential Equations

Homework Solutions:

The Basics of Physics with Calculus Part II. AP Physics C

UTILIZING NEWTON S LAW OF COOLING TO CORROBORATE THE MPEMBA EFFECT

DON T PANIC! If you get stuck, take a deep breath and go on to the next question. Come back to the question you left if you have time at the end.

ISP 207L Supplementary Information

Alg2H Ch6: Investigating Exponential and Logarithmic Functions WK#14 Date:

Lecture 19: Introduction to Kinetics First a CH 302 Kinetics Study Guide (Memorize these first three pages, they are all the background you need)

Regression I - the least squares line

Math 160 Final Exam Info and Review Exercises

Convergence of Fourier Series

Transcription:

Project Two James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University March 27, 2018 Outline Cooling Models Estimating the Cooling Rate k Typical Cooling Project Matlab Session

Newton formulated a law of cooling by observing how the temperature of a hot object cooled. As you might expect, this is called Newton s Law Of Cooling. If we let T (t) represent the temperature of the liquid in some container and A denote the ambient temperature of the air around the container, then Newton observed that T (t) (T (t) A). We will assume that the temperature outside the container, A, is smaller than the initial temperature of the hot liquid inside. So we expect the temperature of the liquid to go down with time. Let the constant of proportionality be k. Next, we solve T (t) = k (T (t) A), T (0) = T0 where T0 is the initial temperature of the liquid. For example, we might want to solve T (t) = k(t (t) 70), T (0) = 210 where all of our temperatures are measured in degrees Fahrenheit. We use our usual solution methods to solve this. Divide both sides dt by T 70 to get T 70 = k dt. Then integrate both sides to get ln T (t) 70 = kt + C. Then, exponentiate: T (t) 70 = Be kt. Now, since we start at 210 degrees and the ambient temperature is 70 degrees, we know the temperature of our liquid will go down with time. Thus, we have T (t) 70 = Be kt.

Solving, we find T (t) = 70 + Be kt. Since the initial condition is T (0) = 210, we find T (0) = 210 = 70 + Be 0 = 70 + B, and so B = 140. Putting all of this together, we see the solution to the model is T (t) = 70 + 140e kt. Now since the temperature of our liquid is going down, it is apparent that the proportionality constant k must be negative. In fact, our common sense tells us that as time increases, the temperature of the liquid approaches the ambient temperature 70 asymptotically from above. Example Solve T (t) = k(t (t) 70) with T (0) = 210 and then use the conditions T (10) = 140 to find k. Here time is measured in minutes. Solution First, we solve as usual to find T (t) = 70 + 140e kt. Next, we know T (10) = 140, so we must have T (10) = 140 = 70 + 140e 10k. Thus 70 = 140e 10k 1 2 = e10k ln(2) = 10k. and so k = ln(2)/10 =.0693.

We now know the general cooling model is which has solution T (t) = k(t (t) A), T (0) = T 0. T (t) = A + Be kt. Applying the initial condition, we get T 0 = A + B. or B = T 0 A. Hence, the solution is T (t) = A + (T 0 A)e kt. The one parameter we don t know is the constant of proportionality, k. However, let s assume we have collected some data in the form {t i, T i} for 1 i N for some finite integer N. Rewrite the solution as T (t) A T 0 A = e kt. Now take the logarithm of both sides to get ( ) T (t) A ln = kt. (1) T 0 A This tell us how to estimate the value of k. Let the variable U(t) be defined to be ( ) T (t) A U(t) = ln T 0 A Then, Equation 1 can be written as U(t) = kt. Thus, the variable U is linear in t; i.e. if we graph U versus t we should see a straight line with slope k.

Our collected data consists of pairs of the form (time, temperature). Suppose we collected N such pairs. Label them as (t i, T i) for 1 i N. Compute the corresponding U(t i) U i points ( ) Ti A U i = ln T 0 A and plot them as a scatter plot in MatLab. Note the first value, U 1 = ln T0 A T0 A = ln(1) = 0. So our line has U intercept 0. Hence, our line is of the form y = mt and we have to find a good candidate for the slope m. This slope will then be used in our cooling model. From your data, you now have a collection of pairs (t i, U i) for 1 i N. We can find a line which comes close in an optimal way to all of this data (although the line does not have to include all the data!) by using a bit of calculus. At each time, the line has the value mt i. The discrepancy or error between the actual U value and the line value is then U i mt i. We want the cumulative error between our line and the data, so we don t want errors to cancel. Hence, we could choose an error term like U i mt i or (U i mt i) 2. Both of these are fine, but the squared one is differentiable which will allow us to use calculus methods. Define the energy function E(m) where m is the slope to be E(m) = N (U i mt i) 2. This is a nice function and so let s find where this function has a minimum by setting its derivative is zero.

Setting the derivative to zero, we find de N dm = 2 (U i mt i) ( t i) = 0. Simplifying a bit, we have N ( U it i = m ti 2 Solving for the critical point m, we find ). m = Uiti t2 i Finally, it is easy to see d 2 E dm 2 = 2 N ti 2 > 0. for all choices of m. Hence, the value m which is the critical point must be the global minimum Hence, the optimal slope is m = Uiti t2 i Then we can see how good our model is by plotting the model solution T (t) = T (t) = A + (T 0 A)e m t on the same plot as the actual data.

Let s see how we can manage some experimental data. Save your experimental data in a file with two columns. Column one is for time and column two is for the temperature of your liquid. Create a new file in Matlab and call it Newton.dat or some other name. Place it in your class folder. For a typical liquid (orange juice, water, tomato juice etc), we might collect the data here 0. 0 205 0. 5 201 2. 0 201 5. 0 190 8. 0 178 1 0. 0 175 1 3. 0 167 1 5. 0 161 2 5. 0 141 3 0. 0 135 4 0. 0 127 5 0. 0 117 6 5. 0 108 8 0. 0 100 9 5. 0 95 1 1 0. 0 89 1 3 0. 0 83 1 6 5. 0 80 We have the ambient or room temperature is 76 degrees for our experiment. load the data and generate the plot of the data % l o a d i n t h e e x p e r i m e n t a l data from t h e % f i l e Newton. dat as two columns >> Data = l o a d ( Newton. dat ) ; % use t h e f i r s t column as time >> time = Data ( :, 1 ) ; % use t h e second column a s t e m p e r a t u r e >> Temperature = Data ( :, 2 ) ; % g e n e r a t e a p l o t o f t h e e x p e r i m e n t a l data >> p l o t ( time, Temperature, o ) ; % s e t x l a b e l >> x l a b e l ( Time in Minutes ) ; % s e t y l a b e l >> y l a b e l ( Temperature in Fahrenheit ) ; % s e t t i t l e >> t i t l e ( Newton Law Of Cooling Experimental Data ) ;

We see the plot of the measured data here: From the theory we have discussed, ( we ) know we should graph the T A transformed data given by log T0 A where A is the room temperature, T and T0 are the temperature and initial temperature of the liquid, respectively. Here A = 76 and T0 = 205. Thus, T0 A = 129. Here is how we do this in Matlab: % for t h i s data, T 0 A = 205 76 = 129 >> A = 7 6 ; >> LogTemperature = l o g ( ( Temperature A) / ( 129. 0 ) ) ; >> p l o t ( time, LogTemperature, o ) ; >> x l a b e l ( Time in Minutes ) ; >> y l a b e l ( Transformed V a r i a b l e l n ( (T A) /( T 0 A) ) ) ; >> t i t l e ( Transformed Data Versus Time ) ;

You can see this transformed data here: Then, look for the best straight line through the plot making sure you have the line go through the point (0, 0) at the top. The optimal slope is then m = Uiti N. t2 i In MatLab, we can add up all the entries in the variable U and time using the sum command. The optimal slope calculation in MatLab is then >> mstar = sum ( LogTemperature. time ) /sum ( time. time ) mstar = 0.0215 where the variable LogTemperature plays the role of U. Note time and LogTemperature are vectors so we use.* to do component wise multiplications!

The syntax LogTemperature.*time means to multiply each component of LogTemperature and time separately to create the new column of values LogTemperature(1) time (1) LogTemperature(N). time (N) The command sum applied to this column then creates the sum Uiti like we need. A similar thing is happening with the term sum(time.*time). The model is thus u(t) = 76.0 + 129 e 0.0215t which we enter in MatLab as % compute t h e model >> u2 = 7 6.0 + 129.0 exp ( mstar time ) ; Then we plot both the experimental data and the model on the same plot, % p l o t t h e model and t h e measure data on t h e same p l o t >> p l o t ( time, u2, r, time, Temperature, o ) ; >> x l a b e l ( Time In Minutes ) ; >> y l a b e l ( Temperature in Fahrenheit ) ; >> t i t l e ( F i t o f Newton Law o f C o o l i n g Model To Data : Data = o ) ; Looks pretty good! We could also have added a legend like legend( Model, Data, Location, BestOutside ); but we didn t show that. You should do that though in your report so it is really easy to see what is going on.

Our final plot! Here is all the code without comments! >> Data = l o a d ( Newton. dat ) ; >> time = Data ( :, 1 ) ; >> Temperature = Data ( :, 2 ) ; >> p l o t ( time, Temperature, o ) ; >> x l a b e l ( Time in Minutes ) ; >> y l a b e l ( Temperature in Fahrenheit ) ; >> t i t l e ( Newton Law Of Cooling Experimental Data ) ; % for t h i s data, T 0 A = 205 76 = 129 >> A = 7 6 ; >> LogTemperature = l o g ( ( Temperature A) / ( 129. 0 ) ) ; >> p l o t ( time, LogTemperature, o ) ; >> x l a b e l ( Time in Minutes ) ; >> y l a b e l ( Transformed V a r i a b l e l n ( (T A) /( T 0 A) ) ) ; >> t i t l e ( Transformed Data Versus Time ) ; >> mstar = sum ( LogTemperature. time ) /sum ( time. time ) ; >> u2 = 7 6.0 + 129.0 exp ( mstar time ) ; >> p l o t ( time, u2, r, time, Temperature, o ) ; >> x l a b e l ( Time In Minutes ) ; >> y l a b e l ( Temperature in Fahrenheit ) ; >> t i t l e ( F i t o f Newton Law o f C o o l i n g Model To Data : Data = o ) ;

Due Date: Friday December 8, 2017. We will use the following time and temperature data: This data gives you a set of 18 {ti, Yi} data pairs. The ambient temperture is 68 degrees. 0. 0 209 0. 5 202 2. 0 196 5. 0 188 9. 0 177 1 1. 0 162 1 3. 0 155 1 5. 0 145 2 5. 0 131 3 0. 0 120 4 0. 0 111 5 0. 0 103 6 5. 0 94 8 0. 0 83 9 5. 0 78 1 2 0. 0 74 1 3 0. 0 73 1 6 5. 0 71 Let E(m) = 18 18 (Ui mti) 2 and F (m) = Ui mti Your project is this: Find the value of m that optimizes E using our calculus tools for finding extremal values. Prove this value gives a minimum. Find the values of m that optimize F using our subdifferential tools for finding extremal values. Prove this value gives a minimum. For the differentiable case, show all the MatLab code and the three appropriate graphs: the data, the transformed data, the model and data on the same graph. For the nondifferentiable case, all the work is done by hand as we have done in smaller problems for homework. Graph your model and the data on the same graph for this one too. Comment on the difference in these two optimal cooling parameter solutions.