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 2


This is your second computer lab. Most likely, you are paired with a different lab partner for this lab. 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 problem asks questions about this help page and should help you work through the Lab more smoothly. The other problems are the main Lab questions. The first problem introduces you to the powerful symbolic programming language Maple. Maple provides a valuable tool for doing a number of mathematical operations symbolically. It also reviews important material about rational functions. The second problem advances the ideas of linear modeling using least squares analysis with a problem associated with measuring the concentration of urea in urine. The last problem examines a least squares best fit to growing yeast, which will later become the basis for a Malthusian growth model. You will be using many of the skills from the first lab to produce a good lab report and adding the ability to use the feature Trendline in Excel along with Maple.

Problem 1 a: This exercise is meant to introduce you to Maple. Part a.shows you how to enter functions and solve for various important points. As an example, let us consider the following two equations:

f(x) = x + 2 and g(x) = x2 - 2x - 2

We want to find the roots of the quadratic and the points of intersection of the two functions.

To enter the functions in Maple, we type

> f := x -> x + 2; g := x -> x^2 - 2*x - 2;

The f:= x -> is used to define the function f in Maple. You can evaluate the function at x = 5 by simply typing

> f(5);

To find the solutions of the quadratic equation, there are two commands. The solve command solves the equations algebraically (exactly), while the fsolve command solves the equations numerically. Try the following commands in Maple to see what you get:

> solve(g(x)=0,x);

> fsolve(g(x)=0,x);

It is usually a good idea to have a graph of the functions with which you are working. The purpose of the graph is often just to visualize the functions in the problem. Graphing in Maple is very simple (though the output is not as elegant as it is in Excel). To graph the two functions f(x) and g(x), you simply type

> plot({f(x),g(x)},x = -5..5);

To find the points of intersection we need to set f(x) = g(x) and solve for x. Again we can do this using either solve or fsolve. (I would recommend against using solve if you have any polynomial of degree higher than 2.)

> solve(f(x)=g(x),x); fsolve(f(x)=g(x),x);

Notice that you can put multiple Maple commands on one line, and Maple does the operations in the order you place them.

If we want both the x and y values of the points of intersection, then we need the following (assuming 2 points of intersection, it varies slightly if there is only one point):

> xs := fsolve(f(x)=g(x),x); f(xs[1]); f(xs[2]);

The xs stores the values of x created by the fsolve command. Since we are assuming there are two values xs[1] gives the first x created by fsolve and xs[2] gives the second one. Writing f(xs[1]); gives the y value as it is the function evaluated at that x value. Note that if there was only one value, then it is xs and you get the y value by typing f(xs);

c. This problem continues in Part c with a rational function and a line. A rational function is a polynomial divided by another polynomial. This form of a function may have horizontal or vertical asymptotes. The vertical asymptotes often occur where the function is undefined. The horizontal asymptotes are found by looking at very large values of the function. All of these properties are easily done in Maple. Excel has a great deal of difficulty graphing functions of this type.

As an example, let us consider the following two equations:

f(x) = x - 1 and g(x) = x/(x2 - 4)

We want to graph these two functions.

To enter the functions in Maple, we type

> f := x -> x - 1; g := x -> x/(x^2 - 4);

Since g(x) is undefined at x = -2 and 2, we need to enter special information to plot these graphs. Below is the command that you want to limit the range and let Maple know that g(x) has vertical asymptotes.

> plot({f(x),g(x)}, x=-5..5, y=-10..10, discont=true);

To find where these functions intersect, you use the fsolve command. We modify this slightly from above because this command would only find one of the 3 solutions. To find all solutions you need to limit where Maple looks for the solutions. Below shows how to find 2 of the points of intersection.

> x1 := fsolve(f(x)=g(x),x=-5..-2); f(x1);

> x2 := fsolve(f(x)=g(x),x=-2..2); f(x2);

You can find where the vertical asymptotes occur by setting the denominator equal to zero. (Maple does this with the command fsolve(x^2-4=0,x);) To find the horizontal asymptote you can use Maple's limit command.

> limit(g(x),x=infinity);

This problem is more of a challenge to create a good Excel graph, so steps for this process will be gone over in Lab. The rational function needs to be plotted in multiple sections with care to have enough points where the function is approaching a vertical asymptote.

Problem 2: This problem is a study of absorbance versus the concentration of urea. Spectrophotometers are standard laboratory equipment and an example of a linear relationship. This lab introduces you to using the Trendline feature of Excel, and supplements the lecture notes for least squares fit to data. Below is a list of steps for solving this problem:

  1. The easiest way in WeBWorK to make an accurate copy of your table in Excel is to first create a hardcopy of your Lab (PDF copy).
  2. Highlight the numbers in the table of the hardcopy of the Lab and copy this into a new Excel file. From the Excel main menu select Data, then choose the item labeled Text to Columns. This will pop up a box where you can select the choice of delimited, then after the button Next you check the box for Space. When you finish this, you should have nice columns of accurately copied data with which to work.
  3. To create a graph, you start by highlighting the appropriate data. From the Main Menu you select Insert and choose the option Scatter. When you press the Scatter option, five graph types appear, and you choose the one for data points, since our problem is from collected data.
  4. Follow the directions for making the graph as you have before, giving it a title, labeling the axes, and giving the x-axis gridlines. Since there is only one graph you should probably remove the labeling option.
  5. After finishing this initial phase, there are two good methods of getting the best fitting linear model. After clicking on the graph, the most straight forward technique is to go to the Main Menu under Chart Tools and click on Layout. From there you find the tab for Trendline. Under this tab you select the More Trendline Options and a box appears with Format Trendline. Alternately, you can simply right click on the data points and select the option to Add Trendline ... , then the box appears with Format Trendline.
  6. In the box Format Trendline, you check the option Linear and the box to Display Equation on Chart.
  7. To get more accuracy to match the answers in WeBWorK, you will want more significant figures. The easiest way to do this is right click on the formula box in your graph. Select Format Trendline Label and the default box says General. In this box you select Scientific, using at least 4 Decimal places. (This will give the equation formula with 5 significant figures.) This must be done before you modify anything in the formula box or Excel will not allow the formula to change.
  8. Move this equation to a more visible part of the graph and make any other touch-ups to make the graph look good. For example, you should click on the equation and change the y to A (for absorbance) and x to U (for Urea concentration) .
  9. Finally, paste this graph in your Word document.

Many of the remaining questions are handled by hand calculations with the information that you have acquired from the Trendline you just created. However, in Part c. you will want to take advantage of the Excel spreadsheet capabilities to compute the sum of square errors. Take your data set (assuming urea concentration in Column A and Absorbance in Column B), then in Column C use the equation from Trendlineto create the predicted values with the urea values from Column A. In Column D, you find the square error between Columns B and C. At the bottom of Column D, you can let Excel sum all the square errors in Column D to obtain your result. For more details on how to calculate absolute error and percent error read about errors in the Least Squares section of the notes (or the 4 panel PDF version of the notes). We note that percent error is defined differently by different people, and we will be using the definition of signed percent error, so do NOT use the absolute value.

Problem 3: This problem is similar to the material in the lecture notes in the Function Review and Quadratics section on the synthesis of mRNA.You will probably want to reread those notes to help you understand this problem.The first part of this problem is similar to the problems you did last time using Excel's Trendline (Linear), except you must Set Intercept = 0.

In Part c, you find the error terms much as you did in your homework. Each error term is the difference between the growth data point and r times the population data point or

ei = g(Pi) - rPi.

The sum of square errors is simply

J(r) = e12 + e22 + e32 + e42.

You can use Maple to easily simplify this expression. In Maple, use the command

> expand(J(r));

assuming you have properly defined J(r). Use the general formula of the parabola to find the r-coordinate of the vertex for Part c.

 

 

 

Copyright © 2014 Joseph M. Mahaffy.