Math 122 Calculus for Biology II
Fall Semester, 2012
Lab Help
21-09-12
San Diego State University

Laboratory Help Page

This page is designed to provide helpful information about the laboratory questions. You should start with your Cover Page and be sure that you have all the important contact information about your lab partner for coordination later in the week. On the cover page you begin by typing in the name of each team member and your Computer number. For your WeBWork answers, it is important that you keep all calculations to 5 or 6 significant figures. Too few digits have been one of the leading causes of errors that we have found when approached by students.

This week we extend our use of trigonometric functions. The first problem is a classic optimization problem that uses trigonometric functions to compute an optimal volume. The last two problems use a combination of trigonometric functions with different frequencies to fit data. One data set follows the classic oscillations seen in a predator prey system, while the second set follows tide tables to estimate the complex tidal flows observed.

Problem 1: This question examines two optimization problems from classical Calculus that involve trigonometric functions and their understanding. In each case, a diagram is provided in the lab to help you visualize the cross-sectional area of the trough. The cross-sectional area is a trapezoid. (You may want to review the area of a trapezoid in wikipedia.) For Trapezoid A, you can readily find the value of x, then the height of the trapezoid is associated with cos(q). Use your definition of cos(q) to find height as a function of x and cos(q). One base of the trapezoid is x, while the other is x plus the other legs of the triangular regions on either side of the central rectangle. The legs of these triangular regions are associated with sin(q), so use the definition of sin(q) to find the length of these legs as a function of x and sin(q). This will give you the formula for the cross-sectional area, then the volume for this trough is simply the area of the trapezoid times the length of the metal strip. Clearly, the only variable in the area function is q, so graphing the area on the given domain is relatively simple. The optimization of this volume is a problem that you can do either on paper or by taking advantage of Maple and its ability to differentiate.

For Trapezoid B, you cannot simply divide x into three equal pieces. You must start by finding both x(q) and the height h(q) (taking advantage of the definitions of the trigonometric functions. After doing this, you use the formula for the area of a trapezoid and to find the volume of the trough. In this case, the volume of Trough B is a more complicated expression of q, so you will almost certainly want to use Maple to optimize the volume.

Question 2: The last question addresses the ideas of fitting data with a finite sum of trigonometric functions. This question 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.

Problem 3: This problem asks you to repeat some of the calculations required to produce the graphs that appear in the derivative of the trigonometric functions section on tides. Much of the most difficult work has already been done for you and is provided by a downloadable Excel worksheet. This sheet contains a cover page with instructions to read about the Tide problem and one sheet for each of the 12 months in 2009. These sheets summarize all the high and low tides for each month gathered from the NOAA website on tide tables.

You begin by finding the appropriate month for your particular lab. The particular worksheet has the time in hours from the beginning of the month, the hours converted to days, and the height in feet of all the high and low tides. To the right you'll find a table of parameter values. You will begin by naming all the parameters in the usual way (Insert - Name - Create). For this problem you will keep the force periods Pi (labeled p1t, p2t, p3t, and p4t) the same. The initial values are provided for the parameters Ai and fi. A0 represent the average height of the tides over the entire month; however, a reasonable approximation for the initial value of A0 is 3. The next step is to enter the formula given to you in the problem, using these parameters, in Column D and pull it down to the end of the month. For the t-values use the values in Column A. In Column E, you compute the square error, and sum this at the bottom of the column.

As we have done before, we use Excel's Solver to minimize the sum of square errors. When you are in Solver for Excel 2010, you need to uncheck the box labeled: Make Unconstrained Variables Non-negative. In this problem you allow solver to change the Variable Parameters in Column L. You should implement Excel's Solver twice to guarantee convergence of such a large set of parameters.

Important: The next step is to convert the parameters of amplitude, Ai, and principle phase shift, fi, to a unique set. If your value of Ai is negative, then you need to shift your phase by half a period, remembering that the specific periods are set by each force with period, Pi. Also, you need to adjust all phases, fi, so that you select 0 < fi < Pi. This may require that you add or subtract an integer multiple of the period. It is recommended that after you make these adjustments that you apply Excel's Solver again twice. There should be no change in the sum of square errors and the magnitudes of the amplitudes should be unchanged.

Create a graph for the week requested by first plotting the data for that week. In this case, use the values in Column B on the x-axis. Do not forget to account for the fact that the first of the month goes from 0-24 hours, so a particular date, say June 8, uses the times between 7 and 8. For the model of the tides, you create one column like Column A, another like Column B, and another like Column D with the model depending on Column A. Start with the appropriate time for your particular week (if it starts on June 8, then start with t = 24*7 = 168) and add 0.5 hours for each time step until you reach the end of the week (which is June 15 for our example, so t = 24*14 = 336, which is 337 data points, not the usual 50 data points). Add this smooth curve over the data points from the NOAA data to get your graph of the week.

For your graph of a day, you do the same process as you did for the graph of a week, but you use time steps of only 0.25 hours. You include the data also in this graph along with appropriate labeling.

To find the minima and maxima, you are going to use Maple. You enter the function in Maple from the numbers on your Excel spreadsheet. Use the information on the spreadsheet or the graph to narrow the range of search for the key values (in hours) of the highest and lowest tides (or any other high or low tide), then proceed as you have always done to differentiate your function for the height of the tides and set the derivative equal to zero (diff and fsolve commands). Because of the difference in times between the tides you can use a 2-4 hour spread of times around your estimate of a high or low tide to allow Maple's fsolve to find the precise timing of the model relative extrema. These times can be compared to the ones provided in Column A. The remainder of the questions should follow readily from the answers provided above.