SDSU

Math 121 Calculus for Biology
Spring Semester, 2007
Lab Help

08-Feb-07

San Diego State University


The first problem is meant to introduce you to Maple.
The second question examines weak acids much as it appears in the text.
The third problem is introduces more Maple commands.


Question 1 (C1): This exercise is meant to introduce you to Maple. Part a. can be worked completely by hand, but I want you to try Maple to learn how to enter functions and solve for various 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. The ; is crucial for ending all Maple commands. 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);

The rest of this Question is much like what you have done before as far as graphing in Excel.


Question 2 (C2): This problem is very much like the lecture notes on weak acids. The graphing part of this problem is easily done using Maple. The graph cannot start at x = 0 because the logarithm is undefined at zero. Thus, do your graph for the given interval. To answer part c, you will need to compose the two functions. This means find: pH([H+](x)) and then solve pH([H+](x)) = 1. Hint: to solve your equation you may use the fact that x = log10(y) implies 10x = y and log(1/a) = -log(a). This is review material but you can look up in page 85 of the text book for the exponents and logarithmic rules.


Question 3 (D1): 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. 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);