|
|||
|
|||
| 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:
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:
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:
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. |