Introduction to Differential Calculus Labs
Part 1. Defining and Plotting Functions
In calculus we deal with functions and their graphs. In this brief introduction, we use Maple to plot several functions.
To enter mathematical expressions in Maple you will need to use standard graphing calculator syntax. For example, multiplication is represented by *, so if you want to enter
you need to enter the expression
2*(x+7*cos(x));
To get Maple to use this expression in its "math mode" you need to enter it on a command line:
| > | restart: |
| > | 2*(x+7*cos(x)); |
Clicking on the button in the toolbar with the symbol [> will create a new command line after the cursor. To return to text typing, use the button with the T on it.
To have Maple enter the expression you have typed, place the cursor anywhere in the command line, and hit return. Here are a few examples of expressions using typical syntax you will need to know for this and future lab projects. Enter them now:
| > | x^2+3; |
| > | exp(x); |
| > | (x+1)/(x^(1/2)+4); |
| > | x+1/(x^(1/2)+4); |
| > | x+1/x^(1/2)+4; |
| > | (x+1)/x^(1/2+4); |
| > | sqrt(x^2-6); |
A few things to notice:
To enter a function in Maple we use the following format
| > | f:=x->2*(x + 3*cos(x)); |
The f denotes the name of the function, the := denotes that we are making a definition, the x is the variable, the -> (which is typed with two keystrokes - and > ) denotes the notion that the function sends each input value, x, to an output value, f(x), which is determined by the expression, in this case that expression is
.
Once you have entered the function into Maple, you can refer to it by name to enter it into other Maple commands:
| > | f(2); |
| > | plot(f(x), x=-10..10); |
You can give a function any name you wish. It is often good to give it a name that suggests its meaning from the context of the report. Here are a few more examples of some functions, along with their graphs (as well as a few other miscellaneous manipulations):
| > | line1:=x-> 3*x +1; |
| > | line2:=x-> -2*x-3; |
| > | plot([line1(x),line2(x)], x=-3..3); |
In the next line we use the solve command to find where these two lines intersect.
| > | solve(line1(x)=line2(x),x); |
Now we enter a couple more functions and show their graphs.
| > | g:=x-> -x^2 +2; |
| > | tangentline:=x-> -2*x+3; |
| > | plot([g(x), tangentline(x)],x=-3..4,color=[magenta, green]); |
The plot command is one of the most useful Maple commands for Calculus. As the old adage says, "A picture is worth a thousand words." As a rule, whenever you enter a function into Maple it is a good idea to plot it. The above examples will hopefully help you get started using the plot command, but this command is very versatile and has many features that can be altered. To learn more about a command in Maple you can use Help. Either click on Help above, or simply enter
| > | ?plot |
The above command brings up a fairly unreadable description of how the plot command can be used, but if you scroll down to the bottom of the page you will see several examples that usually show you what you want to know.
Exercise Group 1.1
1.) Define each of the following functions in Maple
f1(x) =
f2(x) =
f3(x) =
Use Maple to answer each of the following questions:
a.) Which function has the largest value at x = 1? What is this value?
b.) Which function has the smallest value at x = -1? What is this value?
c.) Determine the sum of the values of all three functions when x = -1.75.
d.) Determine the value of the composition of f1(x) with f2(x) when x = 2.3.
2.) Enter the following functions as Maple commands and then plot them over the range of x-values which is specified.
a.)
f(x) =
, x between -5 and 5
b.)
g(x) =
, x between -5 and 5
c.)
h(x) =
, x between -5 and 5
d.)
k(x) =
, x between -5 and 5 (When plotting this and the next function you may want to add constraints on the y-values. Try y=-20..20. You may also want to try adding the command discont = true, I.e. enter this as plot(k(x), x=-5..5,y=-20..20, discont = true) )
e.)
l(x) =
, x between -5 and 5
f.)
m(x) =
, x between -5 and 5
g.) n(x) = cos(x), x between -5 and 5
h.) p(x) = ln(x), x between -5 and 5
i.)
q(x) =
, x between -5 and 3
3.) For the function f(x) in exercise 2.), make a plot showing f(x) and f(x-2), where x varies from -5 to 5. Do the same for the functions k(x), n(x) and p(x). What do you observe?
4.) For the function f(x) in exercise 2.), make a plot showing f(x) and f(x)-2, where x varies from -5 to 5. Do the same for l(x). What do you observe?
5.) For the function f(x) above, make a plot showing f(x) and f(2x), where x varies from -5 to 5. do the same for n(x) and q(x). What do you observe?
Exercise Group 1.2
Plot the three given functions in the same graph. Note that in order to plot more than one function in the same graph, the set of functions should be enclosed in square brackets and separated by commas. Also, you can specify the color of each individual graph as shown in the command line below. If you click inside a plot window, approximate values of the x and y co-ordinates appear at the top of the screen.
f1(x) =
f2(x) =
f3(x) =
| > | plot([f1(x),f2(x),f3(x)],x=-5..5,y=-20..20,color=[red,green,blue]); |
Enter f1, f2, and f3 as functions, plot them with the above command, then answer the following questions
1.) Estimate a value of x between -2 and 2 at which f1(x) has the largest value.
2.) Estimate a value of x between -2 and 2 at which f2(x) has the largest value.
3.) Estimate a value of x between -2 and 2 at which f3(x) has the largest value.
4.) Estimate a value of x between -2 and 2 at which f1(x) has a local maximum.
5.) Estimate a value of x between -2 and 2 at which f2(x) has a local maximum.
6.) Estimate a value of x between -2 and 2 at which f1(x) has a local minimum.
7.) Estimate the largest value of the sum of f1(x), f2(x) and f3(x) over the interval -2 < x <2. (Hint: You might want to add another function to your plot.)
8.) Estimate the smallest value of the sum of f1(x), f2(x) and f3(x) over the interval -2 < x <2.
9.) Estimate the largest interval over which the sum of f1(x), f2(x) and f3(x) is decreasing as x moves to the right.
10.) Which of the functions is one-one over the interval [-2,0]? Explain.
Exercise Group 1.3
Again we let
f1(x) =
f2(x) =
f3(x) =
1.) Define the function g1(x) as the function whose graph is that of f1(x) shifted 2 units to the left and 3 units down. Plot f1(x) and g1(x) in the same graph.
2.) Define the function h1(x) as the function whose graph is that of f1(x) reflected across the x-axis. Plot f1(x) and g1(x) in the same graph.
3.) Define the function k1(x) as the function whose graph is that of g1(x) reflected across the y-axis. Plot g1(x) and k1(x) in the same graph.
4.) Let p(x) be the composition of f1(x) with f2(x) and let q(x) be the composition of f2(x) with f1(x). Plot p(x) and q(x) in the same graph. Do p(x) and q(x) represent the same function? Explain.
Exercise Group 1.4
In Edwards and Penney's Calculus, Early Transcendentals Version, 6 ed. do problems 31 through 37 in section 1.3 (page 33). Use Maple to plot the graphs for some different values of c.
Part 2. Review of Lines
| > | restart: |
We recall two basic forms of equations describing straight lines:
If we know two points, (
) and (
), on a line we can determine the slope of the line from the formula
.
Since many Maple commands want functions for inputs we need to rewrite these in the
, for some function f(x). This gives
Thus we have a choice of two functions to use when describing a line:
| > | slopeint:=x-> m*x +b; |
| > | pointslope:=x->m*(x-x1) +y1; |
We can also enter the slope formula
| > | m := (y2-y1)/(x2-x1); |
Having now defined these functions, if we wish to plot a line with a given slope and y-intercept, we can simply define values for m and b, and then plot
.
| > | m:=2; b:=-1; |
| > | plot(slopeint(x),x=-3..3); |
If we want to plot another line, we can simply redefine m and b and plot again ( Maple remembers the last value you assign to a symbol );
| > | m:=-1; b:=5; |
| > | plot(slopeint(x), x=-3..3); |
This same technique will work for the point slope form:
| > | x1:=1;y1:=.5; m:= -.5; |
| > | plot(pointslope(x), x=-2..3); |
Another approach is to simply retype (or cut and paste) the definition of the function with the numerical values inserted. This is often useful when working with more than one line at a time:
| > | line1:=x-> 2*x -1; line2:=x-> -3*x +4; |
| > | plot([line1(x),line2(x)], x=-3..5); |
To find the intersection of the graphs of two functions,
and
, we look for the x-values at which
. This can be done in Maple with the solve command:
| > | xint:=solve(line1(x)=line2(x),x); |
Then the point of intersection has coordinates (
):
| > | xint,line1(xint); |
Exercise Group 2.1
1.) Plot the lines with the given characteristics:
a.) Slope = 2, y-intercept = 0
b.) Slope = -.3 , y-intercept = 3
c.) Slope =1/2, passing through point (1,2)
d.) Slope = -1/2, passing through point (3,4)
2.) Plot the lines through the given points, and determine their slopes:
a.) (1,2) and (.3,-2)
b.) (0,0) and (-1,1)
3.) Use the solve command to find the point of intersection for the pairs of lines given below. Plot the pairs of lines:
a.)
and
.
b.)
and
.
c.)
and
.
Exercise Group 2.2
For this set of exercises, recall that if two lines with slopes
and
are parellel, then
, but if the two lines are perpendicular, then
.
1.)
Find the line which is parallel to the line given by
and passes through the point (0,-1). Display the two lines in the same plot.
2.)
Find the line which is parellel to the line given by
and passes through the point (-1, -1.5). Display the two lines in the same plot.
3.)
Find the line which is perpendicular to the line given by
and passes through the point (0,0). Display the two lines in the same plot.
Exercise Group 2.3
1.) In Edwards and Penney's Calculus, Early Transcendentals Version, 6 ed. do problems 1 through 10 in section 1.2 (page 21). Use Maple to plot the lines.
2.) In Edwards and Penney's Calculus, Early Transcendentals Version, 6 ed. do problems 19 through 24 in section 1.5 (page 49). Use Maple to plot the lines.
Part 3. Solving Equations
Maple has two commands, solve and fsolve , used for solving equations. These commands are very versatile, and can be used in many general situations. The difference between the two commands is that the solve command gives an algebraic solution while the fsolve command produces a numerical solution. In this introduction we will first explain basic uses of the fsolve command, and then the solve command.
The most basic application of these commands is to find the zeroes of a given function, i.e. to find the values of x for which f(x) = 0. When solving for zeroes, it is always a good idea to plot the functions to see if the numerical results are in agreement with the plot . Adjusting the window for the plot may be necessary to get a good picture of the whereabouts of the roots.
| > | f1:=x->2*x^3-5*x^2+2; |
| > | plot(f1(x), x=-1.5..3); |
The fsolve command will return the numerical values of the three roots that we see above:
| > | fsolve(f1(x)=0); |
Here is another example:
| > | f2:=x->2*x^5-10*x^3 +6*x -1; |
| > | plot(f2(x), x=-2.2..2.2); |
| > | fsolve(f2(x)=0); |
In some cases fsolve will only return one solution of many. In this case, you need to tell it to look for more solutions within specific regions of x-values:
| > | f3:=x->cos(x)-x/4; |
| > | plot(f3(x), x=-5..6); |
| > | fsolve(f3(x)=0); |
In the above graph we see three roots but Maple only gave us the positive one. Now we will ask it to find a root between the x values of -3 and -1.
| > | fsolve(f3(x)=0,x=-3..-1); |
And we can also ask Maple to find the root between the x values of -4 and-3.
| > | fsolve(f3(x)=0,x=-4..-3); |
As a final application of the
fsolve
command we mention that to find the points of
intersection of the graphs of two functions
,
and
, we
simply find the x-values for which
, and then the y-values of the points are given by evaluating the functions at those x-values:
| > | g:=x->-5*x^2 +12*x-2; |
| > | h:=x-> exp(x/2)*(cos(3*x)+x); |
| > | plot([g(x),h(x)], x=-0.2..2); |
| > | x1:=fsolve(g(x)=h(x)); |
| > | y1:=g(x1); |
| > | x2:=fsolve(g(x)=h(x), x=1..2); |
| > | y2:=g(x2); |
The two points of intersection are given by (x1,y1) and (x2, y2). Now we can find the line passing through these two points. First we find the slope of the line:
| > | m:=(y2-y1)/(x2-x1); |
And then we use the point slope formula:
| > | l:=x->m*(x-x1)+y1; |
Finally we plot all three functions:
| > | plot([g(x),h(x),l(x)], x= -0.2..2, color=[red,green,cyan]); |
| > | restart: |
Now let's move on to see some uses of the
solve
command. As mentioned above, the
solve
command will find algebraic solutions of equations if it can. The basic structure of the
solve
command is pretty much the same as the structure of
fsolve
. For example, below we ask Maple to find the solution to
.
| > | f:=x->x^2-2; |
| > | solve(f(x)=0); |
Notice how the output differs from that of fsolve.
| > | fsolve(f(x)=0); |
Depending on the problem, you may need one kind of output or the other. Here is a case where fsolve seems to give the more understandable output:
| > | f1:=x->2*x^3-5*x^2+2; |
| > | fsolve(f1(x)=0); |
| > | solve(f1(x)=0); |
On the other hand, the solve command can solve equations that involve more than one variable, so the solution is not a number, but is an algebraic expression involving some of the variables. In this case, you need to tell Maple which variable you want to solve for:
| > | g:=x->x^2; |
| > | solve(g(x)=a,x); |
| > | solve(g(x)=a,a); |
In the first
solve
command above we asked Maple to solve
for
x
, in the second command we asked it to solve for
a
.
In both solve and fsolve you don't have to enter the equations as functions (but it is a good practice to do this in the situations where it is reasonable). In fact there are situations where you might use the solve command where you don't have a function of one variable:
| > | solve(x^2-2*a*x+a,x); |
There are times when there is no algebraic solution to your equation (or Maple may not be able to find one that is there). Here is the kind of output you will get in such a situation:
| > | solve(cos(x)=x); |
When solve doesn't find a solution, it is a good idea to see if fsolve will.
| > | fsolve(cos(x)=x); |
| > |
Exercise Group 3.1
1.) Plot the following functions and then use the fsolve command to find all of the zeros. Be sure to adjust the windows for your plots to illustrate that you have found all of the zeros.
a.)
b.)
c.)
h(x) =
d.)
j(x)=
e.)
m(x)=
2.) Find all of the points of intersection of the graphs of the following pairs of functions:
a.)
f1(x) =
, g1(x) =
b.)
f2(x)=
, g2(x) =
c.)
f3(x) =
, g3(x) =
3.) Use the solve command to find the zeros of the functions given in problem 1.) a.), b.), and e.) above.
Exercise Group 3.2
1.) Determine the points of intersection of the circle of radius 1 centered at the origin and the circle of radius 4 centered at the point (0,4).
2.) Determine the points of intersection of the circle of radius 3 centered at (0,2) and the line of slope 1/2 with y-intercept equal to 1.
3.) Determine the points of intersection of the circle of radius 3 centered at (0,2) and the line of slope 2 with y-intercept equal to 1.
4.)
The functions
, and g(x) =
i
ntersect in two points. Plot these functions and use fsolve to find the points of intersection. Then find the line through the two intersection points and plot the graphs of f, g and the line in the same window.
5.)
The functions
, and g(x) =
intersect in two points. Plot these functions and use fsolve to find the points of intersection. Then find the line through the two intersection points and plot the graphs of f, g and the line in the same window.
Exercise Group 3.3
1.) In Edwards and Penney's Calculus, Early Transcendentals Version, 6 ed. do problems 31 through 40 in section 1.4 (page 44). Use Maple to find all solutions.
2.) In Edwards and Penney's Calculus, Early Transcendentals Version, 6 ed. do problems 65 through 70 in section 1.5 (page 51). Use Maple to find all solutions.
Academic Honesty Statement:
Place the following statement (by copying and pasting) at the end of your report and sign it in ink. I will not grade your report unless this signed statement appears at the end of your report.
I understand that I may work with others if I give them credit in this statement. I also understand that I am required to write my report--that to copy all or part of someone else's report or to allow someone else to copy all or part of my report constitutes plagiarism, which is a serious violation of academic honesty.
I worked with (replace this parenthetical remark with first and last names of those with whom you worked) on this project. I wrote my own report. I did not copy any of this report from anyone else and I did not allow anyone else to copy any of this report.
Signed: