New Student Package Makes Visualizing Calculus 1 Concepts Easy
Copyright 2002 Waterloo Maple Inc.
Maple 8 introduces a new package called Calculus1 that can help educators and students visualize concepts of 1st-year calculus. You can use the routines in the Calculus1 package to visualize concepts such as tangent lines and derivatives, function inverses, Newton's method, Taylor series approximate integration, surfaces of revolution, and much more. Calculus1 is a subpackage of the new Student package in Maple 8.
Getting Started
While any command in the package can be referred to using the long form, e.g., Student[Calculus1][DerivativePlot] , it is easier, and often clearer, to load the package first and then just use the shorter command names.
| > | restart; |
| > | with(Student[Calculus1]); |
The following examples show how the various routines work. In some cases, examples show how to use these visualization routines in conjunction with the single-stepping Calculus1 routines.
Tangents, Inverses, and Sampling
Tangents
The Tangent routine returns the tangent to a curve at a given point. By including the output option, you can control the return value of the function. Other possibilities include output = plot and output = slope.
| > | Tangent( sin(x), x=1, output = line ); |
Where the tangent is vertical, an equation form is returned.
| > | Tangent( surd(x,3), x=0, output = line ); |
| > | Tangent( sin(x), x=1, output = plot ); |
| > | Tangent( surd(x - 1,3), x=1.2, output = plot ); |
Inverse of a Function
The inverse of a function can be plotted using the InversePlot routine. The default plot domain and range are chosen to the display reasonable portions of both the function and its inverse.
| > | InversePlot( sin(x), x=0..4*Pi ); |
| > | InversePlot( tan(x), x=0..Pi ); |
| > | InversePlot( (3*x^3 + x + 1)/(x^2 + 1), x=-3..3 ); |
| > |
The Failures of Approximating by Sampling
One reason for studying derivatives is to get qualitative information about a function. The easiest way to sketch a function is to sample it at a number of points and connect the dots. For example, sampling the function
at the points
x
=
, and
would suggest the following approximation (shown in blue), and knowing that the sine function oscillates, one may be satisfied with this result. The actual expression is plotted in red.
| > | PointInterpolation(sin(12*x), x=0..5 ); |
In the following example, the global cubic behavior is very well picked up by the sampling, but the asymptote at
is completely missed.
| > | PointInterpolation( (x^4 - 2*x^3 - 3*x^2 + 3*x + 1)/(x + 1), x=-6..6 ); |
In other cases, some of the behavior of the expression may occur outside the region you are sampling on. The following misses that the expression goes to
, and not
as the plot would suggest.
| > | PointInterpolation(x^4-3*x^3-x+3, x=-2..2); |
| > |
Derivatives
Newton Quotients
The slope of the line connecting the two points
and
is given by the formula
. Given a function
, a point
, and a value, the slope of the line between the points
and
is thus
, which simplifies to
| > | NewtonQuotient( f(x), x = x[0], h = h ); |
We can define a given sequence of values of
and use this to calculate the Newton Quotient at these parameters.
| > | hl := [seq( 1/2^n, n=1..10 )]; |
| > | NewtonQuotient( sin(x), x=2.0, output=value, h = hl ); |
In this case, the slope approaches the value of the derivative at the point 2.0:
| > | eval( diff( sin(x), x ), x = 2.0 ); |
This convergence to the derivative can be seen using the option
| > | NewtonQuotient( sin(x), x=2.0, output=animation, h = hl ); |
| > |
Plotting the Derivative
You can easily plot an expression and its derivative using the DerivativePlot routine.
| > | DerivativePlot(x*sin(x), x=-3..3); |
The option
order
may be used to plot more than just the first derivative. In the next example, the first 4 derivatives of
are plotted, where the 1st and 4th derivatives are colored blue and green, respectively, and the intermediate derivatives are interpolated between blue and green. The function itself is plotted in red.
| > | DerivativePlot(x^4-4*x+3, x=-3..3, order = 1..4); |
The following example plots the expression
and the first 10 derivatives. To control the range of the y axis, we simply specify that the default view runs from -2 to 10.
| > | DerivativePlot((x^2 - x)*exp(x), x=-5..1, order = 1..10, view = [DEFAULT, -2..10]); |
| > |
Various Theorems about Derivatives
Rolle's Theorem
Rolle's theorem states that if
is a function which satisfies:
then there exists a point
in the open interval (
) such that f'(
) = 0.
The routine RollesTheorem takes an expression representing the function, checks that the requirements of the theorem hold, and plots the expression and all points where the derivative is zero.
| > | RollesTheorem(x*(x - 4), x=1..3); |
If the output=points option is included, the points that satisfy Rolle's theorem will be returned.
| > | RollesTheorem(x*(x - 4), x=1..3, output=points); |
| > | RollesTheorem(sin(x), 1..2*Pi + 1); |
| > |
The Mean Value Theorem
The Mean Value Theorem is a generalization of Rolle's Theorem which states that if
is a function which satisfies:
then there exists a point
in the open interval (
) such that f'(
) =
where the right hand side is the slope of the line connecting the points (
) and (
). Rolle's theorem follows from this since the right hand side is
if
.
The
MeanValueTheorem
routine plots the expression and all points where the derivative equals the slope of the secant line connecting the endpoints of the graph of
on
. We simply enter an expression representing the function and this routine checks that the requirements of the theorem hold before displaying the result.
Similarly with the RolesTheorem routine, if output=points is stated in the definition input, then only the points that satisfy the Mean Value Theorem are returned.
| > | MeanValueTheorem(x^3 - 5*x^2 + 8*x - 1, x=1..3, output=points); |
| > | MeanValueTheorem(x^3 - 5*x^2 + 8*x - 1, x=1..3); |
| > | MeanValueTheorem(sin(x), x=-4..2*Pi); |
| > |
Applications of Derivatives
Taylor Approximations
If at a point
, a function
has a power series expansion
the coefficients
are given by
where
is the
n'th
derivative of
evaluated at the point
. Named after the English mathematician Brook Taylor, this infinite series is called the Taylor expansion of the function
at
.
The Taylor expansion of the exponential function
is:
from which it follows that:
Using the TaylorApproximation routine, we enter both an expression and a point around which to expand to demonstrate this approximation
| > | TaylorApproximation(x^7 - 5*x^5 + 4*x^4 - 7*x^2 + 3, x=1, order=3); |
By stating
output=plot
in the input definition, we see that the polynomial
behaves like
around the point
.
| > | TaylorApproximation(x^7 - 5*x^5 + 4*x^4 - 7*x^2 + 3, x=1, order=3, output=plot); |
By stating output=animation , an animation is displayed of the expression and the specified Taylor approximations (arranged by approximation order). To start the animation, we simply right click the graph region and select Animation..Play.
| > | TaylorApproximation(sin(x), x=1, output=animation, order=1..16, view=[-2*Pi..2*Pi, DEFAULT]); |
The derivative of the arctan function has singularities at
and
, and therefore the radius of convergence of the Taylor approximation around the origin is
. We can see this behaviour by animating the plot.
| > | TaylorApproximation(arctan(x), x=0, output=animation, order=1..20, view=[-3..3, DEFAULT]); |
| > |
Function Chart
The
FunctionChart
routine plots a function and shows regions of positive and negative sign, increasing and decreasing, and positive and negative concavity. By default,
| > | FunctionChart(sin(x), x=0..2*Pi); |
| > | FunctionChart(x^4 + 2*x^3 - 9*x^2 - 3*x + 6, x=-4.5..3, view=[DEFAULT, -50..75]); |
| > |
Newton's Method
Given a point
and an expression
, we could argue that the
-intercept of the tangent line through (
,
) may be an approximation to a root of the original expression
.
| > | Tangent(f(x), x=a, output=line); |
Convert the previous result to use the D operator in Maple.
| > | collect(convert(%, D),D(f)(a)); |
We solve the previous expression for x when the expression is equal to zero.
| > | solve(% = 0, x); |
By expanding the previous expression, Newton's Method is displayed.
| > | result:=expand(%); |
As an example, consider the function
and an initial point
| > | F := x -> x^2-1; |
Placing this function and initial point into expression named "result", we can see the approximation for solving this function.
| > | aroot := 2.0 - F(2.0)/D(F)(2.0); |
For better results to see where this function and initial point converges, lets repeat this another 9 times.
| > | for i from 1 to 5 do aroot := aroot - F(aroot)/D(F)(aroot); end do; |
Using the NewtonsMethod routine, we may go through the same process easily.
| > | NewtonsMethod(F(x), x=2, output=sequence); |
| > | NewtonsMethod(F(x), x=2, output=plot); |
| > | NewtonsMethod(sin(x)/x, x=1, output=plot); |
The root to which a sequence of Newton iterations converges to depends on the initial point.
| > | NewtonsMethod(sin(x)/x, x=2, output=plot); |
In general, when the root is not a double root, Newton's method is very efficient. In the following example with
Digits
set to
, Newton's method converges to the root after just
iterations.
Compute all floating point approximations with 30 digits of precision.
| > | Digits := 30: |
| > | NewtonsMethod(x^4-4*x^3+4*x^2-3*x+3, x=1, output=sequence, iterations=10); |
Reset the value of digits to the default value of 10.
| > | Digits := 10: |
| > |
Integration
Approximating an Integral
The methods of approximating an integral fall into two categories:
1. Riemann sums, and
2. Newton-Cotes methods.
Riemann sums approximate an integral by summing the areas of adjacent rectangles, where the height of the rectangle depends on the value of function in that interval.
Newton-Cotes methods assume knowledge of integration of polynomials, interpolate the function on each sub-interval, and integrate this interpolating polynomial. The trapezoid rule is a case where the approximating polynomial is a linear function, and Simpson's rule uses quadratic functions to approximate the expression.
The ApproximateInt routine accepts the following methods when approximating the integral.
bode Bode's rule
left / right left / right Riemann Sum
lower / upper lower / upper Riemann Sum
midpoint midpoint Riemann Sum
newtoncotes[N] Newton-Cotes' method of order N
random random selection of point in each interval
simpson Simpson's rule
simpson[3/8] Simpson's 3/8 rule
trapezoid trapzoid rule
procedure custom procedure
By default, the midpoint Riemann sum is used.
| > | ApproximateInt(cos(x), x=0..20, output=plot); |
| > | ApproximateInt(sin(x), x=0..20, method=simpson, output=plot); |
In every case, an animation may be returned where each frame shows a refinement of the previous partition.
| > | ApproximateInt(sin(x), x=0..3*Pi/2, output=animation); |
An interesting variation is to begin with a random partition, and at each step, choose a refinement which divides the largest sub-interval randomly:
| > | ApproximateInt(sin(x), x=0..4*Pi, partition = random[2], subpartition=width, refinement=random, output=animation, iterations=50); |
When doing this with a partition, you may note how the total area appears to converge to a value and then jumps.
| > | ApproximateInt(1/(x^2 - 2), x=-2..2, partition = random[2], subpartition=width, refinement=random, output=animation, iterations=50); |
| > |
Antiderivatives
Given a function
, an antiderivative of
is any function
such that
. By this definition, if
is an antiderivative of
, then so is
for any constant
.
The routine AntiderivativePlot can plot either a single antiderivative or a class of antiderivatives.
| > | AntiderivativePlot( x^3 - 2*x^2 - 4*x + 2, x=-2..2 ); |
By including the showclass option, the class of antiderivatives are viewed.
| > | AntiderivativePlot( x^3 - 2*x^2 - 4*x + 2, x=-2..2, showclass ); |
| > |
Applications of Integration
Function Average
The FunctionAverage routine command returns the average value of a function
on the interval
.where the output can be either the integral, value or plot of the function.
| > | FunctionAverage(f(x), x=a..b, output=integral); |
| > | FunctionAverage(sin(x) + x, x=0..2*Pi, output=plot); |
The integral output option can be used with the single-stepping functionality. For more information on single-stepping functionality, visit the Maple Application Center and refer to the Single Stepping worksheet from the Maple 8 Demos category or refer to Maple's extensive help pages and locate Single Stepping Overview.
| > | FunctionAverage(sin(x) + x, x=0..2*Pi, output=integral); |
We can see that the sum rule would be the next step in solving this problem. Since we understand this rule, we apply it to the previous output
| > | Rule[sum](%); |
The next step in solving this problem requires the
sin
rule. Apply the
sin
rule to the previous output. ie to
| > | Rule[sin](%); |
To complete the problem we apply the
power
rule to the previous output. ie to
| > | Rule[power](%); |
| > |
Volume of Revolution
The
VolumeOfRevolution
routine finds the volume of revolution of a curve given a function
. The graph is rotated around the
-axis, if the
output
option is set equal to plot, where the red line represents the value of the function. You can also ask what the volume of the resulting solid is or display the inert integral with the appropriate integrand through the
output
options.
| > | VolumeOfRevolution(sin(x) + 2, x=0..4*Pi, output=plot); |
The volume of this 3-D shape is given by the integral:
| > | VolumeOfRevolution(sin(x) + 2, x=0..4*Pi, output=integral); |
The volume of this 3-D can also be calculuated using the value command by referring to the previous integral.
| > | value(%); |
Similarly, one can rotate the graph of
around the
-axis. In this case, we ask what is the volume under the resulting surface.
| > | VolumeOfRevolution(-cos(x), x=Pi/2..Pi, output=plot, axis=vertical); |
This volume is given by displaying the integral of the expression.
| > | VolumeOfRevolution(-cos(x), x=Pi/2..Pi, output=integral, axis=vertical); |
| > | value(%); |
You may also ask what is the volume between two functions rotated around an axis. Consider the two expressions
and
on the interval
.
| > | VolumeOfRevolution((x-1)^10 + 1, x, x=1..2, output=plot); |
| > | VolumeOfRevolution((x-1)^10 + 1, x, x=1..2, output=plot, axis=vertical); |
Calculate the volume of the shapes displayed previously.
| > | VolumeOfRevolution((x-1)^10 + 1, x, x=1..2); |
| > | VolumeOfRevolution((x-1)^10 + 1, x, x=1..2, axis=vertical); |
| > |
Negative Values
The interpretation of negative values requires some explanation. When rotating a function around the
-axis the volume is always positive.
| > | VolumeOfRevolution(abs(sin(x)), x=0..2*Pi); |
| > | VolumeOfRevolution(sin(x), x=0..2*Pi); |
When the expression is rotated around the
-axis, the function must be properly analyzed.
| > | VolumeOfRevolution(sin(x - 1), x=-4..2, axis=vertical); |
When we evaluate the previous result, the volume size is negative.
| > | evalf(%); |
In order to get the volume of this object, we first look at the volume and a profile.
| > | VolumeOfRevolution(sin(x - 1), x=-4..2, axis=vertical, output = plot); |
The profile of this object is shown by displaying a plot of
ranging from
to
as stated in our original problem. Since the expression is rotated around the x-axis, a second plot is required of
ranging from -2 to 4.
| > | plots[display]( plot( sin(x - 1), x=-4..2, filled=true ), plot( sin(-x - 1), x=-2..4, filled = true, color = blue ) ); |
From the profile displayed above, we calculate the volume by identifying all sections of the object.
| > | VolumeOfRevolution(sin(-x - 1), x=Pi - 1..4, axis=vertical) + VolumeOfRevolution(-sin(-x - 1), x=0..Pi - 1, axis=vertical) + VolumeOfRevolution(sin(x - 1), x=1..2, axis = vertical); |
| > | evalf(%); |
| > |
Arc Length
Given a function
, you may ask what the length of the curve (or arc) is from the point (
) to the point (
). The formula can be shown using the
ArcLength
routine.
| > | ArcLength(f(x), x=a..b, output=integral); |
When calling ArcLength with the plot output option, three curves are plotted:
1. The expression in red,
2. The integrand in blue,
3. The expression
and thus, the value of the green line at the point b is the total arc length of the curve.
| > | ArcLength(2*sin(x), x=0..2*Pi, output=plot); |
In general, the resulting integrand can be difficult to solve except for very simple cases.
Simple Example Using Single Stepping
By returning the integral to the Arc Length of a function, we step through the problem.
| > | ArcLength(x^2 - ln(x)/8, x=1..3, output=integral); |
Before stepping through the problem, we will simply the previous result.
| > | simplify(%); |
We see that the next step in this problem is to rewrite it.
| > | Rule[rewrite, (16*x^2+1)/x = 16*x+1/x](%); |
Creating problem #3
The
sum
rule should be applied next. We apply the
sum
rule to
| > | Rule[sum](%); |
The constant multiple rule is the next step and should be applied to
Rules can be applied using the rule name (constantmultiple) or an alternative name (`c*`). Refer to the help pages for a complete list of alternate names for rules.
| > | Rule[`c*`](%); |
The power rule is next
| > | Rule[`^`](%); |
Finally, the power rule must be applied again to
.
| > | Rule[`^`](%); |
Advanced Example Using Hyperbolic Cosine
One special case is the hyperbolic cosine function which is defined as:
Among other uses, this function gives the shape of a wire hanging from two points:
| > | plot( cosh(x), x=-1..1.1); |
In this special case, the length of the curve
is equal to the integral of
.
| > | ArcLength(cosh(x), x=-1.0..1.1); |
| > | int(cosh(x), x=-1.0..1.1); |
| > |
Surface of Revolution
The
SurfaceOfRevolution
routine finds the surface of revolution of a curve given a function
. Similar to the
VolumeOfRevolution
routine, you can rotate its graph around the
-axis and ask what the area of the resulting surface is. The red line represents the value of the function on the graph.
| > | SurfaceOfRevolution(sin(x) + 2, x=0..4*Pi, output=plot); |
By stating the output=integral option, the area of this surface is given.
| > | SurfaceOfRevolution(sin(x) + 2, x=0..4*Pi, output=integral); |
Another example
| > | SurfaceOfRevolution(exp(x), x=0..1, output=integral); |
| > | value(%); |
Similarly, one can rotate the graph of
around the
-axis and ask what the area of the resulting surface is.
| > | SurfaceOfRevolution(sin(x) + 2, x=2*Pi..4*Pi, output=plot, axis=vertical); |
When determining the area of the surface of revolution around the
- or
-axis, the difference to the integrand is limited to the term multiplying the square root in the integrand:
| > | SurfaceOfRevolution(f(x), x=a..b, output=integral); |
| > | SurfaceOfRevolution(f(x), x=a..b, output=integral, axis=vertical); |
Negative Values
The interpretation of negative values requires some explanation. When rotating a function around the
-axis, a negative value of the function is interpreted as a negative surface.
| > | SurfaceOfRevolution(sin(x), x=0..2*Pi); |
The absolute value function can be used to get the expected value.
| > | SurfaceOfRevolution(abs(sin(x)), x=0..2*Pi); |
Similarly, when the graph is rotated around the
-axis, negative
values may be interpreted as negative surface values.
| > | SurfaceOfRevolution(cosh(x), x=-Pi..Pi, axis=vertical); |
If the function is symmetric, the integral should be calculated from the origin, otherwise the surface area is added twice.
| > | SurfaceOfRevolution(cosh(x), x=0..Pi, axis=vertical); |
When the function is not symmetric, the sum of each positive branch should be added:
| > | SurfaceOfRevolution(exp(x), x=0..Pi, axis=vertical) + SurfaceOfRevolution(exp(-x), x=0..Pi, axis=vertical); |
| > | SurfaceOfRevolution(exp(x), x=-Pi..Pi, axis=vertical, output=plot); |