plot( x^2, x = -1..1 );
plot( { sin(x), (1/3)*x }, x = -Pi..Pi );
By looking at the graph we can solve the equation sin(x) = x/3. The roots
are determined by the places where the two curves cross.
solve(x^3 = 27); Note that there are three solutions, two of which are complex.
Now let's try something more complicated:
solve(x^3 + 1.5*x = 27);
Note: There is a good reason why we wrote "1.5 " instead of "(3/2)" as the coefficient of x in the last equation. If one of the numbers in the equation is in decimal form, then Maple tries to find an approximate solution in decimal form. If none of the numbers are in decimal form, as in the first example, then Maple tries to find an exact solution. This may fail, since there is no algebraic formula for the roots polynomial equations of degree five or more.
solve( { 2*x + 3*y = 1, 3*x + 5*y = 1} );
These can contain literal as well as numerical coefficients:
solve( { a*x + 5*y = 1, 3*x + b*y = c}, { x, y } );
In the second example we have to tell Maple that x and y are the variables
to be solved for. Otherwise it wouldn't know.
You can solve systems of two equations in two unknowns of the form f(x)
= 0, g(x) = 0 by graphing the functions f(x) and g(x) and seeing where
the curves cross.
3*(1.3 + 1.7)^2/2 - 0.1;It has built-in commands which can do a lot of work quickly. For example, to add up the numbers 1, 1/2, 1/3, ... 1/10, we do this:
> sum(1/n, n= 1..10);Note that Maple gave us the exact answer as a fraction in lowest terms. For an approximate answer in decimal form, do this:
> sum(1.0/n, n= 1..10);The only difference was the 1.0 in place of 1 . Note the decimal point. We can also things like factor numbers:
> ifactor(123456789);
Define p to be the square of (a + b).
> p := (a+b)^2;Expand it.
> expand(p);
Factor this.
> factor(a^2 + 2*a*b + b^2);
Define a to be 1.
> a := 1;
Re-evaluate p.
> p;
Define a to be a again.
> a := 'a';
Now look at p again.
> p;
> sin(Pi/2); > arcsin(1);We can set things up for conversions like this:
> rad := 1/deg;
> sin(90*deg);
> arcsin(1)*rad;
Next, we see that " stands for the result of the preceding computation.
Also, evalf stands for evaluate in floating point form,
i.e a decimal.
> evalf(");
Note two things. Sometimes we need to use the evalf function
to convert results from exact to floating point (decimal) form. Sometimes
it is convenient to use the quote(") sign: it stands for the result of
the preceding computation.
Evaluate the function at x=1.
> f(1);
Evaluate the function at x=a+3.
> f(a+3);
Functions in Maple can also have more than one variable. For example:
> g := (x,y) -> sqrt(x^2 + y^2); > g(3,4);
> diff( sin(cos(x)) + x^3 + 1, x );Note that the basic form of this Maple function is diff( function, variable);
> int( x^2, x );Note that the basic form of this Maple function is int( function, variable);
Here is an analagous definite integral.
> int( x^2, x = 0..1);
Another definite integral:
> evalf( int( sqrt( 1 + x^3 ), x = 0..1 ) );
The last computation deserves comment. Suppose we just do the obvious thing (try it!).
> int( sqrt( 1 + x^3 ), x = 0..1 ):Maple does not give us a numerical answer because the integral of this function cannot be expressed in terms of elementary functions. In particular it cannot be integrated by the usual techniques. However, note that we have surrounded our computation with evalf( ... ). This forces Maple to evaluate the integral numerically: evalf stands for evaluate in floating point form.
> ?solvegives information on the solve command. Often it is helpful to scroll to the end of the help window and look at the examples, bypassing the technical discussion that precedes it.
Modified version of Maple Tutorial by the University of Utah.
Copyright © 1995 Department of Mathematics, University of Utah