[an error occurred while processing this directive] [an error occurred while processing this directive] newuser,topic04

(4) Algebraic Computations

Before examining this topic, please make sure that you have read: (1) Working Through the New User's Tour.

Maple is a very powerful algebraic calculator that can manipulate and find solutions to many problems symbolically. Being able to use variables instead of specifying numbers at the beginning of a problem allows you to ask "What if...?" types of questions.

Use the restart command to clear Maple's internal memory and get started with this page of the tour.

> restart;

Working with Expressions

Maple provides different ways of manipulating and displaying expressions to make them easier to verify, or more effective to use. This flexibility allows you to do such things as expand binomials, factor results, simplify trigonometric expressions, assign variable names to results, and convert expressions to different forms.

Expanding and Factoring Expressions

Maple can expand binomials such as (x+y)^15 . The following Maple commands create the expression, and then expand it.

> expr := (x+y)^15;

expr := (x+y)^15

> expand(expr);


After viewing the results, you can use the factor command to factor the last result and check the computation.

> factor(%);


Simplifying Expressions

Maple can apply identities to simplify many lengthy mathematical expressions, such as trigonometric expressions.

Consider cos(x)^5+sin(x)^4+2*cos(x)^2-2*sin(x)^2-cos(2*x) .

> simplify( cos(x)^5 + sin(x)^4 + 2*cos(x)^2 - 2*sin(x)^2 - cos(2*x) );


Another way to simplify expressions is to use the normal command, which puts fractions on a common denominator and removes common factors in the numerator and denominator.

The fraction (x^3-y^3)/(x^2+x-y-y^2) is much simpler after Maple removes the common factors.

> normal( (x^3-y^3)/(x^2+x-y-y^2) );


Assigning Variable Names

You can assign a variable name to the results of a computation. The use of variables is essential for managing large numbers of expressions and functions, especially if you want to reuse the output later in a session.

For example, create the expression (41*x^2+x+1)^2*(2*x-1) , and store it as expr1 .

> expr1 := (41*x^2+x+1)^2*(2*x-1);

expr1 := (41*x^2+x+1)^2*(2*x-1)

Use the expand command on expr1 and store the result as a variable, expr2 .

> expr2 := expand(expr1);

expr2 := 3362*x^5-1517*x^4+84*x^3-79*x^2-1

Evaluate expr2 at x =1.

> eval(expr2 , x=1 );


In the next example, answer is assigned the normalized quotient of the expansion of two expressions, top and bottom .

> top := expr2;

top := 3362*x^5-1517*x^4+84*x^3-79*x^2-1

> bottom := expand((3*x+5)*(2*x-1));

bottom := 6*x^2+7*x-5

> answer := normal( top/bottom );

answer := (1681*x^4+82*x^3+83*x^2+2*x+1)/(3*x+5)

Converting Expressions to Different Forms

The convert command allows you to convert many types of expressions into specific forms. For a complete list of conversions available in Maple, see the Help page for the convert command.

The following example converts a symbolic expression, (a*x^2+b)/(x*(-3*x^2-x+4)) , into its partial fraction decomposition.

> my_expr := (a*x^2+b)/(x*(-3*x^2-x+4));

my_expr := (a*x^2+b)/(x*(-3*x^2-x+4))

> convert( my_expr, parfrac, x );


The following example converts a trigonometric expression, cot(x) , into an exponential expression.

> convert( cot(x), exp );


Function Notation

Maple provides several ways to define functions. One way is to use arrow notation (which closely resembles standard mathematical notation for a mapping). You can also use the unapply command, which turns an expression into a function.

Define the function proc (x) options operator, arrow; x^2+1/2 end proc .

> f := x -> x^2+1/2 ;

f := proc (x) options operator, arrow; x^2+1/2 end ...

Evaluate the function at numeric and symbolic values.

> f(2);


> f(a+b);


Use the unapply command to turn an expression into a function.

> g := unapply(x^2 + 1/2, x);

g := proc (x) options operator, arrow; x^2+1/2 end ...

Solving Equations and Systems of Equations

You can use Maple to solve and verify solutions to equations and systems of equations.

Solving an Equation

Use Maple to solve the following equation: x^3-a/2*x^2+13/3*x^2 = 13/6*a*x+10/3*x-5/3*a .

> eqn := x^3-1/2*a*x^2+13/3*x^2 = 13/6*a*x+10/3*x-5/3*a;

eqn := x^3-1/2*a*x^2+13/3*x^2 = 13/6*a*x+10/3*x-5/3...

> solve( eqn, {x} );

{x = 2/3}, {x = -5}, {x = 1/2*a}

To verify one of the solutions, evaluate the equation at that particular value of x .

> eval( eqn , x=1/2*a );

13/12*a^2 = 13/12*a^2

Solving a System of Equations

You can also solve systems of equations in Maple.

Consider the following set of four equations and five unknowns:

> eqn1 := a+2*b+3*c+4*d+5*e=41;

eqn1 := a+2*b+3*c+4*d+5*e = 41

> eqn2 := 5*a+5*b+4*c+3*d+2*e=20;

eqn2 := 5*a+5*b+4*c+3*d+2*e = 20

> eqn3 := 3*b+4*c-8*d+2*e=125;

eqn3 := 3*b+4*c-8*d+2*e = 125

> eqn4 := a+b+c+d+e=9;

eqn4 := a+b+c+d+e = 9

Now solve the system for the variables a , b , c , and d . Maple will return its solutions in terms of the fifth variable, e . Since there are four equations and five unknowns, we will have a parametric set of solutions. On the other hand, if we solved for a , b , c, d and e , Maple would choose one of the variables (at random) as a free parameter.

> solve( {eqn1, eqn2, eqn3, eqn4}, {a, b, c, d} );

{c = 483/13-31/13*e, b = -313/13+22/13*e, d = -79/1...

To verify that this solution satisfies eqn1 and eqn2 , evaluate both of them at this solution.

> eval( {eqn1, eqn2} , % );

{41 = 41, 20 = 20}

Further Examples of Solving Equations

The following examples show other types of equations that you can solve using Maple, such as equations using trigonometric functions and absolute values.

Solve an equation involving trigonometric functions.

> solve( arccos(x) - arctan(x)= 0, {x} );

{x = 1/2*sqrt(-2+2*sqrt(5))}

As a final example, solve an equation containing absolute values: abs((z+abs(z+2))^2-1)^2 = 9 .

> solve( abs( (z+abs(z+2))^2-1 )^2 = 9, {z});

{z = 0}, {z <= -2}

> abs( (z+abs(z+2))^2-1 )^2 = 9;

abs((z+abs(z+2))^2-1)^2 = 9

Solving Inequalities

The following examples show how easy it is to solve systems of inequalities in Maple.

Use Maple to solve systems of inequalities, such as x^2 < 1, y^2 <= 1, x+y < 1/2 .

> solve( {x^2<1, y^2<=1, x+y<1/2}, {x,y} );

{x+y < 1/2, -1 < x, x < 1, -1 <= y, y <= 1}

Another example involves solving the inequality x+y+4/(x+y) < 10 , for x in terms of y .

> ineq := x+y+4/(x+y) < 10:

> solve( ineq, {x} );

{x < -y}, {5-sqrt(21)-y < x, x < 5+sqrt(21)-y}

Not only does Maple solve inequalities, but it can also consider a complex inequality such as 2*sqrt(-1-I)*sqrt(-1+I) <> 0 , and compute its Boolean value, by using the is command.

> expr := 2*sqrt(-1-I)*sqrt(-1+I):

> is( expr <> 0 );


Click here to return to the Main Menu.

[an error occurred while processing this directive]