'factor' and 'expand'
These commands are opposites in a sense, so we'll learn about them at the same time.
First we'll look at factor.
The syntax of the factor command is factor(expr,K). K is optional and is used to give an option to factor with respect to, which can be either a number or a field. If K is not typed in, then Maple tries to infer a correct value from the coeffiecents in the expressionl. This works well for most purposes.
Examples
| > |
f:=3*x^2-x*exp(1)+3*Pi*x-Pi*exp(1); |
![Typesetting:-mprintslash([`:=`(f, `+`(`*`(3, `*`(`^`(x, 2))), `-`(`*`(x, `*`(exp(1)))), `*`(3, `*`(Pi, `*`(x))), `-`(`*`(Pi, `*`(exp(1))))))], [`+`(`*`(3, `*`(`^`(x, 2))), `-`(`*`(x, `*`(exp(1)))), `*...](images/Lab6_242S08_1.gif) |
(1.1) |
 |
(1.2) |
![Typesetting:-mprintslash([`:=`(f, `+`(`*`(`^`(x, 3)), 5))], [`+`(`*`(`^`(x, 3)), 5)])](images/Lab6_242S08_3.gif) |
(1.3) |
 |
(1.4) |
Note how in the last example, a value for K was specified. The result reflects this specified value. Although this example is somewhat contrived, it is easy to imagine that there are situations where this functionality could be useful.
In the next example, we see that both the numerator and denominator of rational expressions are factored.
| > |
f:=(x^2+2*x+1)/(x^2-1); |
![Typesetting:-mprintslash([`:=`(f, `/`(`*`(`+`(`*`(`^`(x, 2)), `*`(2, `*`(x)), 1)), `*`(`+`(`*`(`^`(x, 2)), `-`(1)))))], [`/`(`*`(`+`(`*`(`^`(x, 2)), `*`(2, `*`(x)), 1)), `*`(`+`(`*`(`^`(x, 2)), `-`(1)...](images/Lab6_242S08_5.gif) |
(1.5) |
 |
(1.6) |
Now we'll look at expand.
This function expands factors, trig functions, logarithms, etc. It is very powerful and easy to use. The syntax is expand(expr). (See Maple help for additional functionality.)
Examples
 |
(1.7) |

 |
(1.8) |
 |
(1.9) |