Joseph M. Mahaffy SDSU
Math 124: Calculus for the Life Sciences Fall 2016
 |  Course Index  |  Lectures  |  HW Assign  |  Computer Lab  |  WeBWorK  |  Syllabus  |  Miscellaneous  ||  Home
 

Computer Lab Help 7


This page is designed to provide helpful information about the laboratory questions. You will find more details in the Lab Manual that accompanies this course. Begin this lab and every lab by introducing yourself to your partner. Determine the times when you can meet together during the week before the lab is due at your next Lab session. You should start this lab and each lab by typing the name of each team member and your computer number on the Lab Cover Page (or a copy of it).

The first WeBWorK problem asks questions about this help page and appropriate lecture material. This should help you work through the Lab more smoothly. The first problem of the lab considers two models for the temperature change of a woman over the period of her menstrual cycle. Data are fit with a cubic polynomial and a trigonometric model, then differentiation techniques are used to help find minima, maxima, and points of inflection. The second problem examines models for radioactive decay. Again data are fit with appropriate models of decay, using exponentials. Derivatives are used to find the maximum of one of the decay products. The last problem uses a series of trigonometric functions to approximate a classic data set from the pelts gathered of lynx and hares by the Hudson Bay Company about a century ago. This problem utilizes Maple to find the maxima and minima of the models approximating the data.

Problem 1:This problem examines the variation of the female body temperature over the period of a month. The first part of the problem uses a cubic polynomial to fit the data, then the maximum and minimum are found. The point of inflection corresponds to the maximum increase in temperature, which also matches the point of ovulation or greatest fertility. This is a classic use of differential Calculus and follows the notes in the text. The problem uses Excel's Trendline with the polynomial curve fitting algorithm. The derivatives are most easily found with Maple, which allows easy computation of the minimum, maximum, and point of inflection.

The second part of this problem combines the techniques from the daily temperature of a city problem worked in an earlier lab and the differential Calculus aspect of this problem noted above. The daily body temperatures are averaged to estimate the coefficient A, while B is estimated by half the distance between the maximum and minimum temperatures over the month. The frequency, w, is computed by estimating the period to be 28 days (T = 28), then taking w = 2p/T. The phase shift depends on whether you have the cosine function, in which case you estimate d to be the time of the maximum temperature in the menstrual cycle, or the sine function, where you estimate d to be the time in the middle of the menstrual cycle where the temperature nearly matches the average temperature, A. With these estimates you create the trigonometric model and use Solver to find the best fitting parameters. After finding the best fitting model, you use Maple to compute the first and second derivatives. From the derivatives or a good understanding of these trigonometric functions you find the model's minimum, maximum, and point of inflection.

Problem 2: This problem examines two radioactive isotopes that are used in medical imaging. The first isotope simply decays exponentially and is fit with Excel's Trendline with the exponential fit. The second isotope's data are fit using the difference of two decaying exponentials. One decay rate comes from the analysis of the first part of the problem. The other two parameters are fit to the data with Excel's Solver, obtaining the other decay rate and the constant multiplying the exponentials. This maximum and point of inflection can be done by hand or you can use Maple to find the values more quickly. Again the techniques for this problem are similar to the ones using Excel's Trendline and Solver and Maple, as you have done in the past. No new computer techniques are introduced.

Problem 3: This problem addresses the ideas of fitting data with a finite sum of trigonometric functions. The problem uses data from the Hudson Bay company on either lynx or hares. Begin by downloading the data for your particular problem, being the years the pelts were collected and the number of hare or lynx pelts (in thousands). You should put the year in Column A and move the pelt count to Column C. In Column B put the variable t, which will go from 0 to 20, matching the number of years after your starting year.

It is probably easiest to work all 4 trigonometric approximations for this problem on a single spreadsheet. You will have 4 models simulating the data, so put the models in alternating Columns D, F, H, and J. Use Columns E, G, I, and K to compute the square errors (which you sum at the bottom of each of these columns) between the 4 models and the data. Use Column M to label your parameters for the models and Column N to list the values of the parameters. Note that each of the 4 models will have slightly different values for the parameters (e.g., the amplitude of the trig function, a1, might be 18.7 for the first model, 18.6, for the second, then 18.9 for the third), so each model's parameters will need to be set up as a list in Column M separately. You will name all these parameters for use in the model, then later to allow Solver to change as you minimize the sum of square errors. (For example, the constants a0, a1, w, and f1 are named just as we have done in earlier labs.)

To find an approximation for a0, you want the average of the data (which is readily found using the Excel function =average(C2:C22) and should be entered below the data). You approximate a1 by taking the difference between the maximum of the data and a0. We estimate the period, T, by finding the number of years between the two peaks in the data. This allows us to estimate the frequency, w, by computing w = 2p/T. As an initial guess, take all phase shifts, fi, to be 0.

With your estimates above Excel's Solver will converge to the unique a0, a1 > 0, and w > 0 . However, it may select f1 outside the principle phase shift range of 0 < f1< T, where T = 2p/w. If this is the case, then add (or subtract) an integer multiple of T to f1 and run Solver again. For the subsequent models we add an increasing number of trigonometric function with increasing frequencies. For ease of selection, we take ai = 1 and fi = 0. When you run Excel's Solver for these increasingly complex models, then occasionally the ai or fi will be negative or outside the range of the principle phase shift. If ai is negative, then make it positive and adjust the phase shift fi by half a period. You should then run Excel's Solver again. If only fi is outside the range of the principle phase shift for that trigonometric function, then add or subtract an integer multiple of the period, T, for the appropriate trigonometric function and run Excel's Solver again. Don't forget that with as the frequency increases the period decreases, so when the trigonometric function is say sin(2w(t - f2), then the period is now T = p/w. The WeBWorK answers expect the unique parameters with the amplitudes, ai, positive and the principle phase shift with 0 < fi< T.

In Column D, you type the formula for your Model 1, using the parameters you named in Column M and taking the time value from Column B. Thus, in the Cell D2, you might type

= a0a + a1a*sin(wa*(B2 - f1a))

where you defined a0a to be a0, a1a to be a1, wa to be w, and f1a to be f1. (Be sure to use the appropriate trig function sine or cosine given in your lab.) Simply pull down this formula to get all your values to compare against the data (square errors in Column E). The next step is to use Solver to minimize the sum of square errors by changing your parameters, a0, a1, w, and f1. When you are in Solver for Excel 2010, you need to uncheck the box labeled: Make Unconstrained Variables Non-negative. Take the best values and into them into WeBWork, including the sum of square errors.

You repeat this process with Models 2, 3, and 4 in Columns F, H, and J. In this case, you will want to have named your parameters something slightly different. (For example, you might choose a0b to be a0, a1b to be a1, wb to be w, etc.) Then the second model would have the formula:

= a0b + a1b*sin(wb*(B2 - f1b)) + a2b*sin(2*wb*(B2 - f2b))

Again you record the least sum of square errors and the best fitting parameter values in WeBWork.

The next step is to carefully graph these models. You will need a good graph for these models to help you select the right regions to find the absolute minimum and maximum for the models. (If you shortcut using the smooth curve fitting, then you might get the wrong answers.) You should go to Columns P-T, putting t in Column P starting at t = 0 and taking stepsizes of 0.25, giving 81 points to create a nice set of curves. In Columns Q-T, you put the 4 Models, pulling down the formulae that are based on your best fitting parameters. You add these smooth curves to the graph of the data that you create.

You find the absolute minimum and maximum for your models by putting the model formula into Maple and differentiating the formula for the model. Since there are many places that the derivative could be zero, you look carefully at your graph in Excel to find the region where you expect the absolute minimum or maximum, then find the value t of that gives the derivative equal to zero, then evaluate the function at that critical value of . Below lists the key Maple commands assuming you know P(t).

dp := diff(P(t),t);

tmin :=fsolve(dp = 0,t = 8..11); P(tmin);

Record the first appearance of your absolute minimum and absolute maximum in WeBWork. Note there are often 2 absolute maxima and 2 absolute minima on the interval of the data, but you need to choose the earliest one to get the correct answer in WeBWork.

 

Copyright © 2015 Joseph M. Mahaffy.