Back to Contents!
Next: Dealing with Data... Up: Working with Maple Previous: Linear models

Quadratic and polynomial models

The idea for this week is to provide you with examples of how to use Maple to produce plots and then use the plots to draw conclusions. You will also do some exercises which emphasize how plots relate to equations and vice versa. Throughout the course, you will be asked to interpret your result about a problem by plotting it and then thinking critically about what you've drawn and what it tells you about a real situation. The previous problems were about linear relationships. Linear relationships cover an enormous number of situations, but the world is a complicated place, so straight lines are far from complete in describing things. After linear functions and graphs, quadratic ones are the next simplest. A quadratic expression is one of the form for some fixed values of a, b, and c. Some examples are , etc. One of the advantages of a computer-assisted approach to math is that the techniques for handling the more complicated quadratic equations are pretty much the same as for the simple linear ones.

How would you plot a circle? We start by thinking about the characteristics of a circle. It's round because every point on the circle is the same distance from the center. In terms of our standard axes we should therefore write an equation in which each point is the same distance from the center (let's assume for the moment that the center is at zero). You should remember that the distance of any point from the origin is given by so, to make each point of our drawing lie an equal distance from the center, we need the equation That means that is the radius of the circle. Let's write down the commands to draw it in Maple (note that not all output from Maple is shown below; the Maple output is always centered).


#Note that we will be using the variables r and b, so if you are still in
#the same Maple session in which you did exercise 1-1, you need to declare
#r and b as a free variables again.
#
r := 'r';
b := 'b';
y := sqrt{(r^2 - x^2)};

#Let's initially define a radius of 1
r := 1;
#Now plot it over what we think might be a reasonable range of x
plot(y, x=-1..1);
#That doesn't look right!  Maple is not very smart about giving us
#the whole picture.  What's the problem?  Why do we only get half a circle?
#Try an alternative, provide two kinds of y for the positive and negative
#values of the square root.
#
ypos := sqrt(r^2 - x^2);

yneg := -sqrt{r^2 - x^2};

#Now try to plot both the negative and positive values of y.  If your circle
#looks squashed, try changing the window size until the width and length of
#the plot look about alike.
#
plot({ypos, yneg}, x=-1..1);
#
#Let's see how the value of r changes things by plotting different
#circles with different values of r on the same plot.
#First we need to redefine everything so that r is a variable rather than
#a fixed number
r:= 'r';
ypos := sqrt{r^2 - x^2};

yneg := -sqrt{r^2 - x^2};

#Now plot circles for a range of r's 
plot({subs(r=1,ypos), subs(r=1,yneg), subs(r=2,ypos), subs(r=2,yneg)
subs(r=3,ypos), subs(r=3,yneg)}, x=-5..5);
############################################################################
#(note: for aficianados you can also animate this step,                    #
#but ONLY on machines running Maple V, version 2.  If you don't have       #
#access to one, then SKIP THE FOLLOWING TWO STEPS!)                        #
with(plots):
animate({ypos, yneg}, x=-5..5, r=1..3);
############################################################################
#Now we should have seen that the changing values of r change the size of the
# circle.
#Now here's a challenge: how do we make a circle whose center is not
# at (x,y) = (0,0)?
########################################################################
#Solution:  Let's say we want the center of the circle to be at        #
#           x=a, y=b where a and b are any numbers we choose.  Then    #
#           each point on the circle is located a distance r from the  #
#           the point (a,b), so the distance r is measured relative to #
#           (a,b) and the equation for relative distance is            #
#           sqrt((x - a)^2 + (y - b)^2} = r ==>                        #
#               (x - a)^2 + (y - b)^2   = r^2  ==>                     #
#                                y - b  = sqrt(r^2 - (x - a)^2)        #
#                                    y  = b + sqrt(r^2 - (x - a)^2)    #
#                                                                      #
#Therefore, we need the positive and negative equations to be:
ypos := b + sqrt(r^2 - (x - a)^2);

yneg := b - sqrt(r^2 - (x - a)^2);

########################################################################
#Let's try this out.  Let's say we want a circle of radius 1 with the 
# center at (x,y) = (1.5, 2.5)
a:= 1.5;
b:= 2.5;
r:= 1.0;
plot({ypos, yneg}, x=0..3);
#You can try out your new found skill by plotting several circles with
#centers at different points along the x axis.
#
#Next challenge: How would you plot several circles with centers along
#a 45 degree line which passes through x = -3?  How about a circles that
#have centers on a larger circle of radius 6?  If you can do this, think
#of a more complicated pattern on top of which you can plot your circles.
#(Again for experts - this looks impressive if you figure out how to
# animate the path!)

Quadratic functions are especially important in physics problems which involve the motion of a body which undergoes a constant acceleration, as we shall see in the next section. More exotic polynomials arise much less frequently than do linear and quadratic ones, but it is useful to understand the general nature of the graphs of cubics, quartics, and higher-order polynomials. Remember that Maple makes dealing with these higher-order equations as easy as dealing with lines.

Do exercises 1-4, 1-5, and 1-6 to gain experience with quadratics and higher-order polynomials.



Next: Dealing with Data... Up: Working with Maple Previous: Linear models


larryg@upenn5.hep.upenn.edu
Fri Mar 4 09:58:36 EST 1994
subsubsection1_1_1_2.html