Section 2: Algebraic Calculations
Maple is a "C.A.S", i.e., a C omputer A lgebra S ystem. This means that Maple knows every rule of algebra that you know. As you progress through calculus, differential equations and linear algebra you will find that Maple also has the essential operations from those subjects built into its large command set.
In this section you will learn how to enter an algebraic expression and substitute values in for the variables. Then you will learn the commands that allow you to expand, factor and simplify expressions.
The eval command
Example 1
For our first example let's start with the expression and assign it the name W.
Suppose now that you want to evaluate the expression where x has the value 4. The quickest way to do this is to use Maple's eval command. Here's what it looks like:
Alternatively, you can apply the eval command to W.
Example 2
The eval command works equally well with symbolic values:
To replace x by in the expression execute the following line. In this case we label the result M.
And now to get Maple to "multiply out" this expression we use the expand command.
Example 3
The eval command is very versatile. You can use it to evaluate expressions involving more than one variable. Here we replace by 7 and y by 12 in the expression .
Since U has two variables, the evaluating point then needs to be in a list, in square brackets [ ] separated by commas. Note x=7, y=12 are enclosed by a square bracket [ ].
As a floating-point (decimal) number, we have
Example 4
You can also use the eval command to substitute a value into an equation. This is the sort of thing you might want to do to test whether a particular value "satisfies" the equation. In the next few lines we substitute different values into the equation . Are any of these values a solution to the equation?
Note we use " := " to assign the name and just " = " for the equation itself.
To see if 3 is a solution for eqn, execute:
Similarly, to see if 4 is a solution for eqn, execute:
As you can see, since -9 is not equal to 0, 3 is not a solution to , and 0 = 0 indicates that 4 is in fact a solution. Again, 5 is not a solution as when , which the following shows.
Exercise 2.1
Assign the name k to the expression . Then assign the name M to the expression .
Finally have Maple calculate .
Note: to get Maple to multiply the expression out use the expand command. That is enter: expand(3*M+6); You will learn more about the expand command in the next subsection.
Student Workspace 2.1
Answer 2.1
Exercise 2.2
Expand using the expand command.
Student Workspace 2.2
Answer 2.2
or we can do this all in one step with:
Exercise 2.3
Let . Find P if x = 0.01 , a = , , , and .
Student Workspace 2.3
Answer 2.3
Exercise 2.4
Use the eval command to check if any of the numbers: 1,2 or 3 is a solution to the equation:
Student Workspace 2.4
Answer 2.4
Therefore and are solutions of the equation. (In Section 5 you will learn how to solve equations using Maple.)
The expand command
The principal use of the expand command is to "multiply out" products of polynomial expressions. It can also be used to expand trigonometric and other more general functions.
Use the expand command to multiply out .
Maple applies some familiar trigonometric identities to expand and .
Try expanding the sine and cosine of some other integer multiples of x . For example: , , etc.
Here is a final example. Have Maple multiply out the expression:
Exercise 2.5
Expand for n =2,3 and 4.
Student Workspace 2.5
Answer 2.5
The factor command
Factor the expression:
Or you can do it all on one line:
First enter in the expression .
Expand H using the exapand command.
Then apply the factor command to the result.
Can you explain why the final result looks different than the original expression ?
Maple can factor expressions with more than one variable. For example, the expression , that is,
factors to
If Maple can't factor an expression using rational numbers (i.e. integers and fractions) then it returns the input unchanged.
Example 5
The factor command is not limited to polynomials. It can be used to factor other forms.
Factor .
Example 6
If the factor command is used with a rational expression such as
the numerator and denominator are each factored, as we see from
The common factors in the expression
are cancelled to simplify the expression, as we see from
The next example allows you to see the factored form without cancellation.
Example 7
Maple's numer and denom commands allow you to isolate either the numerator or denominator of a fraction.
For example, consider .
Here we use numer and denom commands to examine the factors of the numerator and denominator separately (i.e. before cancellation of common factors).
Exercise 2.6
Factor the expression .
Student Workspace 2.6
Answer 2.6
Exercise 2.7
Factor the expression and then use the expand command to check the result.
Student Workspace 2.7
Answer 2.7
The simplify command
Maple can apply identities to simplify many lengthy mathematical expressions, such as trigonometric expressions. For example, c onsider the expression
that is,
which Maple simplifies to
Trigonometric expressions with arguments in multiples of some angle will be simplified to trig functions in the single angle if possible:
The simplify command can be used to add rational expressions.
Rewrite the sum , that is,
as a single fraction via
Exercise 2.8
Simplify the expression
Student Workspace 2.8
Answer 2.8
Exercise 2.9
How does Maple simplify ? Whether or not this "simplified" form is of use to you will depend on what you plan to do with it.
Student Workspace 2.9
Answer 2.9