Doing Calculus & Linear Algebra with the math package |
This page explains how to use the math package in undergraduate calculus. Please use math version 3.04 or higher.
For general help on the math package see: ?math.
> restart:
At first, make sure that Maple can find the package by assigning the path where the math package is located to libname. If in Windows you have saved the package to drive C, directory `maple7\math`, enter:
> libname := `c:/maple7/math`, libname;
libname := `c:/maple7/math`, "E:\\maple7/lib"
After that assign short names to the package functions:
> with(math);
reading math ini file: e:/maple7/math/math.ini
math v3.6.4 for Maple 7, current as of September 22, 2001 - 16:06
written by Alexander F.
Walz, alexander.f.walz@t-online.de
Warning, the protected name extrema has been redefined and unprotected
[Arclen, END, PSconv, V, _Zval, arclen, assumed, asym, cancel,
cartgridR3, cartprod, colplot,
cont, curvature, curveplot,
cutzeros, dec, deg, diffquot,
diffquotfn, dim, domain,
domainx, ex, extrema, fnull,
fnvals, getindets, getreals,
gridplot, inc, inflection,
inter, interpol, interpolplot,
isAntiSymmetric, isCont,
isDependent, isDiagonal, isDiff,
isEqual, isFilled, isIdentity,
isQuadratic, isSymmetric, jump,
lineangle, load, mainDiagonal,
makepoly, mat, mean, names,
nondiff, normale, padzero,
pointgridR3, pole, printtree, prop,
rad, rangemembers, realsort,
recseq, redefdim, reduce,
removable, retrieve, rootof,
rotation, roundf, seqby, seqnest,
seqplot, setdef, singularity,
slice, slopefn, sortranges,
sortsols, split, symmetry,
tangente, tree, un, unique]
Be f a function in one real:
> f := x -> x^2*exp(-x);
Determine the domain of f with math/domain:
> domain(f(x));
math/symmetrychecks for symmetry:
> symmetry(f(x));
The interception with the x-axis (i.e. zeros of f) math/fnull:
> fnull(f(x), x);
Interception with the y-axis:
> f(0);
f and its first three derivatives:
> f(x);
> f1 := diff(f(x), x);
> f2 := diff(f(x), x$2);
> f3 := diff(f(x), x$3);
Collecting to e(-x):
> f1 := un(collect(f1, exp(-x)));
> f2 := un(collect(f2, exp(-x)));
> f3 := un(collect(f3, exp(-x)));
You can find extremas with math/ex:
> ex(f(x), x);
Inflections are calculated with math/inflection:
> inflection(f(x), x);
The from the left to infinity and from the right to -infinity:
> limit(f(x), x=-infinity);
> limit(f(x), x=infinity);
> restart:
> with(math):
> f := x -> abs(1/10*x^3+27/10)-2;
Find all zeros, return floating point numbers; as opposed to fsolve, you do not need to specify intervals since the default is -10 .. 10 (you can change this by assigning _MathDomain another range). fnull then divides this intervall into even smaller parts, scanning each for zeros. See ?math,fnull for further information.
> fnull(f(x), x);
A plot of f shows that f is not differentiable at x=-3 and has a saddle point at x=0. A graph on coordinate paper (horizontal and vertical grid lines) computes math/gridplot.
> gridplot(f(x), x=-5 .. 3, -3 .. 4);
math/unis an interface to unapply, you do not need to specify the indeterminates.
> f1 := un(diff(f(x), x));
> f2 := un(diff(f(x), x$2));
There is no standard function in Maple that knows that a function is not differentiable at a point x, here x=-3. But you may check this by entering f1(-3) and getting an exception message generated by the internal help procedure simpl/abs in this case. solve determines a solution of f'(x) = 0 only at x=0:
> solve(f1(x), x);
> is(f2(0) <>0);
math/ex calculates extrema even at these points where a function is not differentiable). Note that P(0, 7/10) is a saddle point, not an extrema.
> ex(f(x), x);
You can search for points of a function not being differentiable using math/nondiff:
> nondiff(f(x), x);
math/inflection also determines saddle points.
> inflection(f(x), x);
With math/tangentewe now draw a tangent at x = 0, thus plotting the graph of f along with this tangent. You have more options than student/tangent offers to specify the appearance of this tangent, especially its length, color and thickness.
> tangente(f(x), x=0);
> curveplot(f(x), x=0, x=-5 .. 3, y=-3 .. 4, length=4, tangentline=[color=navy, thickness=2]);
> restart:
> with(math):
> f := x -> sqrt((4-x)/(2+x));
As you have seen above, math/domain determines the domain of a function in one real. Points that to not belong to this domain are denoted with a call to Open.
> domain(f(x));
> symmetry(f(x));
> fnull(f(x), x);
> ex(f(x), x);
> inflection(f(x), x);
> gridplot(f(x), x=-3 .. 5, -1 .. 2, step=[1, 0.5]);
math/cont or math/isCont check whether a function is continuous at a given point. f is continuous at x=4,
> cont(f(x), x=4);
true, left
because the limit that exists at x=4 from the left side
> limit(f(x), x=4, left);
is equal to the value of f at this point:
> f(4);
> restart:
> with(math):
> f := x -> (x^2-3*x+2)/(x^2+2*x-3);
math/singularity is more precise than discont (actually using discont) by checking if the points returned by discont are defined.
> singularity(f(x), x);
You can analyse these singularities with cont:
> cont(f(x), x=-3);
> cont(f(x), x=1);
This means that the singularity is removable at x=1 (with simplify(f(x)) the zero at -1 in the denominator has vanished).
Zeros:
> fnull(f(x), x);
The result is incorrect (see above)
> domain(f(x), singularity);
since 1 is not part of the domain of f. To see why fnull returns a wrong answer, first delete the remember table of fnull and then set infolevel[fnull] to value > 0 to see how this function determines the result:
> infolevel[fnull] := 1: readlib(forget)(fnull);
> fnull(f(x), x);
fnull: using default domain (_MathDomain):
-10 .. 10
fnull: Fraction found, now proceeding
with numerator: x^2-3*x+2
fnull: using fsolve to determine
roots
fnull: Searching for roots in expression
x^2-3*x+2
fnull: Searching for roots in derivative
2*x-3
fnull: Roots found in original
function: 1.000000000, 2.000000000
fnull: Possible roots found in
derivative: 1.500000000
The second line shows that fnull checks whether the function passed is a quotient and then by default only processes its numerator. To suppress this behavior pass the option numerator=false.
> fnull(f(x), x, numerator=false);
fnull: using default domain (_MathDomain):
-10 .. 10
fnull: using fsolve to determine
roots
fnull: Searching for roots in expression
(x^2-3*x+2)/(x^2+2*x-3)
fnull: Searching for roots in derivative
(2*x-3)/(x^2+2*x-3)-(x^2-3*x+2)/(x^2+2*x-3)^2*(2*x+2)
fnull: Roots found in original
function: 2.000000000
fnull: Possible roots found in
derivative: none
Reset infolevel[fnull]:
> infolevel[fnull] := 0:
Now we will compute the asymptote with math/asym:
> asym(f(x), x);
The slope of f at x=2 using math/slopefn:
> slopefn(f(x), x=2);
The arc length of the curve over the interval [2, 6] with math/arclen:
> arclen(f(x), x=2 .. 6);
> evalf(%);
You can delete the small imaginary part with math/cancel:
> cancel(%, eps=1e-5);
4.027479000
> restart: libname := `e:/maple7/math`, libname;
libname := e:/maple7/math, "E:\\maple7/lib"
> with(math):
reading math ini file: e:/maple7/math/math.ini
math v3.6.4 for Maple 6 & 7, current
as of September 22, 2001 - 15:34
written by Alexander F. Walz, alexander.f.walz@t-online.de
With trigonometric functions, and inverse transcendental functions in general, solve only returns one solution:
> solve(sin(x), x);
0
By setting _EnvAllSolutions to true, you will receive general solutions:
> _EnvAllSolutions := true:
> solve(sin(x), x);
If you would like to see all solutions within a specified range, use math/_Zval:
> _Zval(%%, -3*Pi .. 3*Pi);
> evalf(%);
> restart: libname := `e:/maple7/math`, libname;
libname := e:/maple7/math, "E:\\maple7/lib"
> with(math):
reading math ini file: e:/maple7/math/math.ini
math v3.6.4 for Maple
7, current as of September 22, 2001 - 16:06
written by Alexander
F. Walz, alexander.f.walz@t-online.de
Warning, the protected name extrema has been redefined and unprotected
math also has a series of special tools math:
Trailing zeros of a floating point expression can be deleted with math/cutzeros:
> solve((x-4.11)^4, x);
> op({%});
> cutzeros(%);
math/getreals retrieves all real solutions in a sequence:
> solve(x^3-1, x);
> getreals(%);
math/realsort sorts real values in ascending order:
> folge := 1, 0, exp(1), -Pi;
> sort([folge]);
> realsort(folge);
For many other functions available check the online help: ?math