Maple is an algebraic calculator that allows you to define functions and expressions, factor and expand expressions, convert back and forth from different formats, and find unique algebraic solutions easily.
Let's look at a simple algebraic equation:
> 200*x^5+60*x^4*y-138*x^3*y^2-47*x^2*y^3+24*x*y^4+9*y^5; 5 4 3 2 2 3 4 5 200 x + 60 x y - 138 x y - 47x y + 24 x y + 9 y
If we wanted to factor this expression, all we
would need to do is use the
factor
command:
> factor("); 2 3 (5 x - 3 y) (2 x+ y)
Likewise, if we wanted to expand this
expression we would use the
expand
command:
> expand("); 5 4 3 2 2 3 4 5 200 x + 60 x y - 138 x y - 47x y + 24 x y + 9 y
It is as simple as that.
Let us go ahead and define a simple
expression, sample:
> sample:=(a^2+bx^2)/(a*b^2*x^2-2*a*b); 2 2 a +bx sample :=--------------- 2 2 a b x -2 a b
We used the colon equals
:=
to define the
expression sample. Notice that we can
factor
sample:
> factor(sample); 2 2 a + bx -------------- 2 a b (b x -2)
Actually, it might be to our advantage to use
this factored expression from now on. So we
will factor
sample and
save it as newsample:
> newsample:=factor(sample); 2 2 a +bx newsample :=-------------- 2 a b (bx - 2)
Anytime in the future we can use newsample as a true algebraic expression. Suppose we later do some math that involves this expression. We no longer need to type it in:
> expres:=((b*x^2-2)*newsample); 2 2 a +bx expres :=-------- ab
Maple already factored the expression. Now, go ahead and assign values for a and b:
> a:=12.4; a := 12.4 > b:=-5.2; b := -5.2 > expres; 2 - 2.384615384 +.08064516127 x
Maple can solve equations:
> myeqn:=5*x^3-3*x^2+x=12.8; 3 2 myeqn := 5 x - 3 x +x = 12.8 > solve(myeqn,x); 1.544138995, - .4720694975 + 1.197928308 I, - .4720694975 - 1.197928308 INotice that two of the solutions are complex in nature.
> eqn1:=3*x-5.5*y+z = 199.547; eqn1 := 3 x - 5.5 y + z= 199.547 > eqn2:=9*x-y-5.8*z = -74.634; eqn2 := 9 x - y - 5.8 z= -74.634 > eqn3:=28*x-15.87*y+43.432*z = 1352.4355; eqn3 := 28 x - 15.87 y +43.432 z = 1352.4355
Next, solve the equations for x,
y, and z using the
solve
command. Notice that both
the equations and the variables are enclosed
in curly brackets, {}:
> solve({eqn1,eqn2,eqn3},{x,y,z}); {z = 18.99999999, x =.32400000, y = -32.65000000}
Expressions are nice, but what about full
blown functions? Maple handles them smoothly.
So, we will define a function
F(x) with maple. It is almost
the same as defining an expression. But we
will utilize the arrow command (
->
) to denote the
variables.
> F := x -> (x^3-4.5*x^2+0.24*x); 3 2 F := x -> x - 4.5 x + .24 x
We can now calculate the value of F for different values of x:
> F(0); 0 > F(3); -12.78 > F(34.56); 35911.76602 > F(a+b); 141.696
Did you remember that a = 12.4 and b = -5.2 ? Maple did! Now, let's go ahead and define two more functions, G(x) and H(x):
> G:= x -> log(x); G := log > H:= x -> abs(x); H := abs
We can now plot these two functions together:
> plot( {G,H},-10..10); AA 10 + AA AAA + AAA AA + AA AA 8 + AA AAA + AA AAA + AAA AAA + AAA AA 6 + AA AAA + AAA AAA + AAAA AAA 4 + AA AAA + AAA AAA + AAA AA + AAA BBBBBBBB AAA 2 + AAA BBBBBBBBBBBBBB AA + AA BBBBBBBB AA +AAABBBBB +---+--+---+---+--+---+---+---+--+--***-***-+---+---+---+--+---+---+--+---+ -10 -5 0 0 BB 5 10
L O S A L A M O S N A T I O N A L L A B O R A T O R Y
Operated by the University of California for the U.S. Department of Energy