Maple Algebra and Calculus

Maple
Maple Algebra and Calculus
K. Cooper
2012
Maple
Algebra
Simple Tools
We can make more extensive sums or products as required.
Maple
Algebra
Simple Tools
We can make more extensive sums or products as required.
p := sum(sum(sum((i+j+k)*x i*y j*z k, i = 0 .. 2), j =
0 .. 2), k = 0 .. 2) gives something fairly horrible.
Maple
Algebra
Simple Tools
We can make more extensive sums or products as required.
p := sum(sum(sum((i+j+k)*x i*y j*z k, i = 0 .. 2), j =
0 .. 2), k = 0 .. 2) gives something fairly horrible.
product(x-i, i = 1 .. 10)
gives. . .
Maple
Algebra
Simple Tools
We can make more extensive sums or products as required.
p := sum(sum(sum((i+j+k)*x i*y j*z k, i = 0 .. 2), j =
0 .. 2), k = 0 .. 2) gives something fairly horrible.
product(x-i, i = 1 .. 10)
numer(expr)
gives. . .
delivers the numerator of
expr
Maple
Algebra
Simple Tools
We can make more extensive sums or products as required.
p := sum(sum(sum((i+j+k)*x i*y j*z k, i = 0 .. 2), j =
0 .. 2), k = 0 .. 2) gives something fairly horrible.
product(x-i, i = 1 .. 10)
gives. . .
numer(expr)
delivers the numerator of
denom(expr)
gives the denominator
expr
Maple
Algebra
Substitution
Let's review, there are basically two ways to substitute into
an expression.
Maple
Algebra
Substitution
Let's review, there are basically two ways to substitute into
an expression.
subs(var=value,expr)
expression expr.
substitute
value
for
var
in the
Maple
Algebra
Substitution
Let's review, there are basically two ways to substitute into
an expression.
subs(var=value,expr)
expression expr.
substitute
eval(expr,var=value)
by value.
evaluate
value
expr
for
var
in the
when
var
is replaced
Maple
Algebra
Substitution
Let's review, there are basically two ways to substitute into
an expression.
subs(var=value,expr)
expression expr.
substitute
value
for
var
in the
eval(expr,var=value) evaluate expr when var is replaced
by value. Said to be more sophisticated than subs, but who
would know?
Maple
Algebra
Substitution
Let's review, there are basically two ways to substitute into
an expression.
subs(var=value,expr)
expression expr.
substitute
value
for
var
in the
eval(expr,var=value) evaluate expr when var is replaced
by value. Said to be more sophisticated than subs, but who
would know?
algsubs(var=value,expr)
expression expr. This is
substitute
value
for
var
in the
more powerful than the others.
Maple
Algebra
Simplify
This does various simplication tasks: function calls, roots,
cancellation. . .
simplify((x 2+2*x+1)/(x+1))
gives
x + 1.
Maple
Algebra
Simplify
This does various simplication tasks: function calls, roots,
cancellation. . .
simplify((x 2+2*x+1)/(x+1))
simplify(sin(x) 2+cos(x) 2)
gives
gives
x + 1.
1.
Maple
Algebra
Factor
Obviously this factors a polynomial.
factor(x 2+2*x+1
gives
(x + 1)2 .
Maple
Algebra
Factor
Obviously this factors a polynomial.
(x + 1)2 .
factor(x 2+2*x+1
gives
factor(x 3-2)
x3 − 2.
gives
Maple
Algebra
Factor
Obviously this factors a polynomial.
(x + 1)2 .
factor(x 2+2*x+1
gives
factor(x 3-2)
x3 − 2.
gives
factor(x 3-2,2
(1/3))
√
gives√ − x2 + x 3 2 + 22/3 −x + 3 2 .
Maple
Algebra
Factor
Obviously this factors a polynomial.
(x + 1)2 .
factor(x 2+2*x+1
gives
factor(x 3-2)
x3 − 2.
gives
factor(x 3-2,2
(1/3))
√
gives√ − x2 + x 3 2 + 22/3 −x + 3 2 .
If the second argument is neglected, then
factor
assumes
you want it done over the obvious eld. E.g. when all
coecients are integers,
factor
factorization over the integers.
assumes you want
Maple
Algebra
Factor
Obviously this factors a polynomial.
(x + 1)2 .
factor(x 2+2*x+1
gives
factor(x 3-2)
x3 − 2.
gives
factor(x 3-2,2
(1/3))
√
gives√ − x2 + x 3 2 + 22/3 −x + 3 2 .
If the second argument is neglected, then
factor
assumes
you want it done over the obvious eld. E.g. when all
coecients are integers,
factor
assumes you want
factorization over the integers.
factor(x 3-2,real)
x2
(x − 1.25992104989487319)
+ 1.25992104989487319 x + 1.58740105196819936
gives
Maple
Algebra
Collect
This tries to collect terms as in a polynomial.
collect((x-a)*(x-b),x)
gives
x2 − (a + b)x + ab.
Maple
Algebra
Collect
This tries to collect terms as in a polynomial.
collect((x-a)*(x-b),x)
gives
x2 − (a + b)x + ab.
collect(exp(x)+4*exp(x)+x*exp(x)+x*exp(2*x)+exp(2*x),
[exp(x), exp(2*x)]) gives (5 + x)ex + (x + 1)e2x .
Maple
Algebra
Expand
Yes, this expands an expression
expand((x+1)*(x+1))
gives
x2 + 2x + 1.
Maple
Algebra
Expand
Yes, this expands an expression
expand((x+1)*(x+1))
gives
x2 + 2x + 1.
(5+x)*exp(x)+(x+1)*exp(2*x)
5 ex
+
xex
+
(ex )2 x
+
(ex )2 .
gives
Maple
Calculus
Integration
int(x 2,x)
gives
int(x 2,x=0..3)
1 3
3x
gives 9
int(x 2,x=0..sin(2))
gives
Int(x 2,x=0..sin(2))
gives
Int
is the
inert
form of
1
3
sin(2)3
R sin(2)
int.
0
x2 dx
It can be used to delay
evaluation for any reason: algebraic manipulation, or
waiting for a numerical method.
evalf(Int(x 2,x=0..sin(2)));
gives 0.2506089816
Maple
Calculus
Dierentiation
di(expr,x$n)
di(x 2,x)
Di(x 2,x)
D(f )
takes the
gives
nth
derivative of an expression
2x; di(x 2,x$2)
gives 2
d 2
gives
dx x
creates a new function that is the derivative of the
function
f
f:=x->x 2; h:=D(f );
D(f )(3)
D(D(f ))
gives
h(x) = 2x,
and
h(3)
gives 6 as well.
gives a constant function with value 2
gives 6.
Maple
Calculus
Limits
limit(sin(x)/x,x=0)
gives 1
limit((x 2-4)/(x+2),x=-2)
Limit((x 2-4)/(x+2),x=-2)
another inert form
gives -4
gives
limx→−2
x2 −4
x+2 ;
Maple
Calculus
Series
Maple can do Taylor series:
s:=series(exp(x),x=0,5)
1 + x + 12 x2 + 16 x3 +
gives
1 4
24 x
+ O(x5 ).
Maple
Calculus
Series
Maple can do Taylor series:
s:=series(exp(x),x=0,5)
1 + x + 12 x2 + 16 x3 +
gives
1 4
24 x
+ O(x5 ).
We can convert this to a Taylor polynomial using
ps:=convert(s,polynom)
Maple
Calculus
Series
Maple can do Taylor series:
s:=series(exp(x),x=0,5)
1 + x + 12 x2 + 16 x3 +
gives
1 4
24 x
+ O(x5 ).
We can convert this to a Taylor polynomial using
ps:=convert(s,polynom)
We can convert that to a function using
fps:=unapply(ps,x) ;
Maple
Calculus
Simple plots
We can plot the exponential with its Taylor polynomial
using
plot([exp(x), fps(x)], x = -4 .. 4)
Maple
Calculus
Simple plots
We can plot the exponential with its Taylor polynomial
using
plot([exp(x), fps(x)], x = -4 .. 4, 0 .. 10)
Maple
Calculus
Simple plots
We can plot the exponential with its Taylor polynomial
using
plot([exp(x), fps(x)], x = -4 .. 4, 0 .. 10, thickness = [2, 1])
Maple
Calculus
Simple plots
We can plot the exponential with its Taylor polynomial
using
plot([exp(x), fps(x)], x = -4 .. 4, 0 .. 10, thickness = [2,
1],color=[blue,green])
Maple
Calculus
Simple plots
We can plot the exponential with its Taylor polynomial
using
plot([exp(x), fps(x)], x = -4 .. 4, 0 .. 10, thickness = [2,
1],color=[COLOR(RGB,.5,.5,1),green])