Math 298:   Maple  WS IV

(A)  Symbolic solutions and more about graphing.

Maple offers us the opportunity to obtain symbolic solutions rather than numerical solutions.  For example, consider the quadratic equation  Ax2 + Bx + C = 0.  To solve for the variable x in Maple does not require that we assign numerical values to A, B, and C.

>  restart;
>  y :=  A*x^2 + B*x + C;
>  solve (y = 0);

Notice that we cannot use the fsolve command since A, B, C have not been assigned numerical values.

> fsolve (y = 0);   # No output is obtained here.

Let's investigate the logistic curve.  A population, P, in a constrained environment may grow with time, t, according to the Verhulst equation:
P(t) = L / (1+Ce-kt), where L is called the carrying capacity and L, C, and k are positive constants.

>  restart;
>  P:= L/(1+C*exp(-k*t));
>  firstDerivative := diff(P, t);
>  # Note that P'(t) is always positive.  Why?
>   secondDerivative := diff (firstDerivative, t);
>   tInflection := solve (secondDerivative = 0, t);   # t coordinate of presumed inflection point
>   PInflection := subs(t = tInflection, P);               # P coordinate of presumed inflection point
>   simplify(PInflection);
>  #   Does P have a point of inflection?  Where does it occur?  Give both the t value and the P value.
>  #  Next, let's examine how the graph of P changes if C and k are fixed and L varies.
>   with(plots):  #  Here we invoke the plots library that will allow us to use the display command.
>   P1 := subs(L=50, C=10, k=0.05,  P);
>   P2 :=  subs(L=40, C=10, k=0.05,  P);
>   P3 :=  subs(L=30, C=10, k=0.05, P);
>   graph1 := plot(P1, t=0..200, color=BLUE):  # Use the colon to suppress output.
>   graph2 := plot(P2, t=0..200, color=RED):
>   graph3 := plot(P3, t=0..200, color=BROWN):
>   display({graph1,graph2,graph3}, title = `Effect of changing the value \n of C upon graph of P`);

The \n in the character string above specifies a carriage return that allows the title to be displayed on two lines.  What would happen if we did not use the carriage return here?

If we wish to add additional text to the graphs (for example, describing which graph corresponds to which value of C) we can use the textplot command.

>   graphText := textplot([[200,50, `C = 50`], [200,40,`C = 40`], [200,30,`C = 30`]]);
>   display({graph1,graph2,graph3, graphText}, title = `Effect of changing the value \n of C upon graph of P`);

Here the pair of numbers 200, 50 refers to the coordinates on the graph where the string "C = 50" will begin.  Similarly, for the pairs 200, 40  and  200, 30.
Of course we would need to know something about the graph before inserting the text.  Normally we would first display the graphs and then decide where the text belongs.

Exercises: (1)  Hold L and C fixed, and observe the effect upon the graph of changing the k values.
(2)   Hold L and k fixed, and observe the effect upon the graph of changing the C values.
Add titles and text to make the graphs easier to read.

(B)  Using the maximize and minimize commands.

Let g(x) = x3-5x2+6x.   By factoring or graphing g, we see immediately that g has three zeroes:  0, 2, and 3.  It is also clear that g has a local maximum on the interval (0,2).   To find this maximum we could differentiate:

> restart;
> g := x^3-5*x^2+6*x;
> xMax := fsolve(diff(g, x) = 0, x=0..2);
> yMax := subs(x = xMax, g);

Alternatively, we may use the maximize command. This will give us yMax first, from which we can obtain xMax.

> maxg := maximize(g, x = 0..2);
>  evalf(%);
>  xCoordOfMaxg := fsolve (g = maxg, x=0..2);

Note that fsolve fails to produce an answer.  The reason for this is that small errors normally occur in any numerical computation. Thus, to allow for such errors, we may subtract a small number, say 10-7, from the maximum value.

>  errorTerm := 10^(-7);
>  fsolve( g = maxg - errorTerm, x = 0..2);

Explain why there are two answers to the line above.

Using the maximize command is often more fruitful than differentiating, since occasionally the maximum occurs at an end point rather than at a point at which the derivative is zero.  For example, on the interval [-1,5], where would you expect the max and min values of g to occur?  (Hint: Consider the graph of y = g(x).)
(Note that maximize yields the global maximum over the given interval; minimize yields the global minimum over the given interval.)

>  maximize (g, x = -1..5);
>  minimize (g, x = -1..5);

Exercise:   Find the (global) maximum and minimum values (and the points at which they occur) for the function H(x) = x6 - x + 2 over the interval [-1,1].  Be certain to graph this function to reconfirm that your answers are reasonable.

Warning:  For many functions, Maple's maximize and minimize commands fail to deliver an answer.  In such cases, we will need to find all critical points (including end points) and compare the values of the function at these points.

Since the fabric of the world is the most perfect and was established by the wisest Creator, nothing happens in this world in which some reason of maximum or minimum would not come to light.

- Leonhard Euler
 

 Course Home Page          Department Home Page        Loyola Home Page