INTRODUCTION TO MAPLE
DR. JOHN C. NARDODIVISION OF MATHEMATICS & COMPUTER SCIENCEOGLETHORPE UNIVERSITYjnardo@oglethorpe.eduhttp://www.oglethorpe.edu/faculty/~j_nardo/This worksheet provides a basic introduction to the Maple Computer Algebra System. It is intended as a quick-paced tutorial to familiarize the reader with Maple's power abilities with numeric calculations, functions, algebra, and graphing. This worksheet will prepare the reader for using Maple in College Algebra, Analytic Geometry, Calculus, and beyond.
Note that this worksheet is in a "read, point, and click" format. You will read about command and then execute the statements already prepared for you in advance. This is unlike the way that you will use Maple when creating mathematics! You will have to know the syntax/commands to use for exploring the given situation.This introduction is divided into the topics below. To access/open a particular section, click on the plus sign to the left of its heading. This reveals the instructions through which you should work. To hide/close an open section, click on the minus sign to the left of its heading. IMPORTANT NOTES:When using any of the sections below or creating your own work in Maple, it is necessary to clear any previous Maple definitions and calculations by using the restart command. After a command prompt >, type the word restart followed by a semicolon and then press enter. If there is no command prompt present, click the toolbar button, the 13th button on the first row, [> to create one.Though you can type certain expressions into Maple in "standard" mathematics notation, it is best to work with the syntax/language of Maple. From the Options menu, highlight Input Display with your mouse. A cascading menu will open to the right. Make sure that Maple Notation is checked. If not, click on that phrase to "check" it.When working through the tutorial, read through the text using the standard Windows scrollbar on the right to move your position. When you encounter an exression in red following a command prompt, click anywhere in the expression and press the Enter key to execute the command.<Text-field layout="Heading 1" style="_cstyle257"><Font bold="true" family="Times New Roman" foreground="[0,0,0]" italic="false" underline="false">What is Maple?</Font></Text-field>Maple is a sophisticated piece of software designed for doing various types of mathematics via a computer. Maple can perform numerically. Like your scientific or graphing calculator, it can execute basic arithmetic operations and calculate values for exponential, logarithmic, trigonometric, and root functions. Maple can perform graphically. Like your graphing calculator, Maple can graph explicit functions of the form NiMvJSJ5Ry0lImZHNiMlInhH. Unlike most graphing calculators, Maple can graph implicit functions and multivariable functions. Maple can perform symbolically. Unlike calculators, Maple can factor algebraic expressions, expand algebraic expressions, solve equations, etc. Also, it can be an invaluable tool in Calculus by calculating limits, derivatives, and integrals. Furthermore, Maple has a built-in programming language and export features to spreadsheets in Microsoft Excel and to matrix-related objects in MATLAB.<Text-field layout="Heading 1" style="_cstyle258"><Font bold="true" family="Times New Roman" foreground="[0,0,0]" italic="false" underline="false">Numerical Calculations</Font></Text-field>Maple can act as a regular scientific or graphing calculator. Type expressions after the command prompt > in the usual way. However, each calculation must be terminated by typing a semicolon before pressing enter.restart;1+2;150-3;2*159;10/5;2^4;1+(3-2)*(18/6);1+3-2*18/6;1+3/2;1.0+3/2;Notice that Maple follows the usual algebraic order of operations: parentheses, exponentiation, multiplication/division, and then addition/subtraction. If you are unsure about how the order of operations will be executed in Maple, then feel free to force the order you wish by using parentheses.WARNING: Maple requires an asterisk for multiplication! You may not use the traditional mathematics shortcut of juxtaposing terms.2*3;2 3;Maple operates with exact numbers when possible. In the next to the last example above, Maple returned a rational number 5/2 instead of the decimal number 2.5. This is standard for this program. If you wish a expression to be viewed as an approximation or decimal, you may force this by using the evalf command (or many times, by typing a decimal in the expression to be evaluated).1-Pi;evalf(1-Pi);Be sure to capitalize in the previous example. To Maple, the expression "Pi" is the mathematical constant representing the ratio of a circle's circumference to its diameter. To Maple, the expression "pi" is the greek letter without any numerical meaning.Pi;evalf(Pi);pi;evalf(pi);Maple has a wealth of built-in mathematical functions.Square Root Functionsqrt(4);sqrt(2);The above expression is the exact value of the square root of two. If you wish to see the decimal form, then "wrap" the command with the evalf command. You can use Maple's memory. The % symbol refers to the previous expression.evalf(%);Instead of typing the above expression, you may edit the original line. In the line >sqrt(2); click to the left of the command name sqrt. Type evalf(. Then click before the semicolon and add another parenthesis. Press enter to execute the modified command. Other Root Functions (Use Fractional Exponents)(8)^(1/3);evalf(%);Exponential Functionsexp(1);exp(0);exp(2);evalf(exp(1));2^8;Logarithmic Functionslog(10);ln(10);ln(exp(1));To use other bases, insert [base] in between the word log and the parentheses. Probably, you wish to use the evalf command to approximate function values. Otherwise, you will get familiar with The Change of Base Theorem from College Algebra. For example, the common base 10 logarithmic function would appear as below.log[10](10);log[10](100);evalf(log[10](100));Trigonometric Functions ... by default in radians!sin(0);cos(0);tan(0);Maple lets you know when functions are undefined.tan(Pi/2);sec(Pi);csc(Pi/2);cot(Pi/4);Inverse Trigonometric Functionsarcsin(1/2);arccos(1);arctan(1);arcsec(sqrt(2));arcsin(0.1);Hyperbolic Trigonometric Functionsevalf(sinh(1));If you wish, you may use the actual definition of the hyperbolic sine function to calculate this function value. Of course, you get the same value.evalf((exp(1)-exp(-1))/2);<Text-field layout="Heading 1" style="_cstyle259"><Font bold="true" family="Times New Roman" foreground="[0,0,0]" italic="false" underline="false">Symbolic Algebra</Font></Text-field>restart;Maple works with variables, expressions, equations, and other algebraic objects in much the same way that we do on paper. When using Maple, any object that you believe you'll need to use later needs tobe given a name. Naming is done with a colon followed by an equal mark (with no space).x:=5;We read the object above as "the name/object/variable x gets the value 5.y=5;We read the object above as a simple equation y = 5.To understand the difference, to Maple, whenever it encounters the object x it replaces it with the number 5. To Maple, the statement y = 5 is a conditional equation (an equation may be true for some values of the variable and false for others).x+2;y+2;We can use "names" of any length in our work sessions. (Do not use names that Maple has already used as commands, for example int, diff, plot, ... Maple will give an error message if you try to do this. Just use a different name.) Let's borrow an example from geometry. Consider a circle. We may define the area of the circle as:area:=Pi*radius^2;If we decide on a particular value for the radius (say 5 inches), we should be able to calculate the corresponding area.radius:=5;area;For the remainder of the work session, radius will retain the value of 5 -- unless we restart the sesion, give radius a new value, or clear out the definition of radius. In the commands below, we redefine radius with a new value and recompute.radius:=7;area;In the commands below, we clear out all definitions of radius and look at the formula for area again.radius:='radius';area;If you wish to substitute values into the area formula without giving radius a permanent value, you may use the substitute command.subs(radius=7,area);Note that in the subs command the regular equal mark without a colon was used.Maple will perform all the excruciatingly tedious operations from algebra: multiplication/expanding, simpligying, rationalizing, common denominators, etc.Before we can use the variable x, we must clear out the old definitions we used. Otherwise, Maple will assume that x is still 5!x:='x';x;expand((x+1)^7);simplify(cos(x)^2+sin(x)^2);rationalize(1/sqrt(3));rationalize(1/(sqrt(x)+5));normal(1/a+1/b);You can also give names to equations. We wish to name a quadratic equation in x. equation1:=6*x^2+x-2=0;Maple has built-in ability to factor over the integers and real numbers.factor(equation1);equation2:=x^2+1=0;factor(equation2);As above, when Maple encounters a expression that will only factor with complex numbers, it returns the original expression to indicate this irreducibility over the reals.We may also factor rational expressions.myrational:=(2*x^2+5*x-3)/(4*x^2-11*x-3);factor(myrational);Maple has built-in ability to solve equations.solve(equation1);solve(equation2);When solving equations, Maple will return complex numbers as solutions and attempts to use exact arithmetic. If you wish to use decimal approximations, then "wrap" the command in the evalf command.solve(equation1);evalf(%);evalf(solve(equation1));Alternatively, you could use the fsolve command, which returns floating point/decimal approximations to solutions.fsolve(equation1);You may use the solve command on systems of equations.solve({2*x-y=0,5*x+y=7});You may use this command to solve for a variable in an expression. We may solve the area formula for a circle for the radius. Note that Maple rationalized the square roots in the denominator to get an "appropriate" final answer.solve(A=Pi*radius^2,radius);<Text-field layout="Heading 1" style="_cstyle260"><Font bold="true" family="Times New Roman" foreground="[0,0,0]" italic="false" underline="false">Functions</Font></Text-field> Consider the simple quadratic function y = x^2 or f(x)=x^2. In mathematics, these two statements are equivalent. However, special care must be taken in Maple when defining functions. Though these two forms are still equivalent, defining functions is more efficient.restart;y:=x^2;This gives the "name" y to the expression x^2. Everywhere you type y Maple will substitute x^2. This is technically not the same as defining a function, as below. NOTE: The arrow is made by typing a dash and then the greater than symbol with no space in between!f:=x->x^2;To see the advantage for defining functions, let's calculate a few function values. When dealing with y, you must use the substitute command. When using functions, you may use traditional mathematics notation.subs(x=0,y);subs(x=1,y);subs(x=x+h,y);subs(x=sqrt(x),y);subs(x=a,y);f(0);f(1);f(x+h);f(sqrt(x));f(a);You may need to use the evalf command, as demonstrated below.g:=x->sqrt(x);g(0);g(1);g(2);evalf(%);g(Pi);evalf(Pi);Maple distinguishes between the "name" of a function and its rule.f;f(x);If a command dealing with functions gives you an unexpected result. Try switching between the name f and the rule f(x). For example, in the next section about graphing, you'll discover which is desirable: plot(f) or plot(f(x)).<Text-field layout="Heading 1" style="_cstyle261"><Font bold="true" family="Times New Roman" foreground="[0,0,0]" italic="false" underline="false">Graphing</Font></Text-field>Maple has many powerful graphing routines built-in and also other available in the package "plots."restart;Graphing Explicit FunctionsThese are equations that can be explicitly solved y = f(x). The syntax for the plot command is: plot(expression or function, interval of x's, options);plot(x^3-2*x^2+x-1,x=-10..10);plot(sin(x),x=-2*Pi..2*Pi);f:=x->ln(x);plot(f(x),x=0..50);plot(f,x=0..50);Note the unexpected result when using the "name" f when you mean the "rule" f(x). When plotting functions, either enter their rule directly or use the f(x) notation!You can plot more than one function/expression at a time. Wrap the objects in braces separated by commas.plot({x^2,2*x,2},x=-10..10);You can also specify a range of values for y.plot(x^2,x=-10..10,y=-1..500);You have many options when graphing. You can add titles and legends to your graphs for clarity. You can label the axes. You can change the thickness of the graphs and their colors. profit:=x->x^2+x+1;plot(profit(x),x=0..10,title="Our Profit",labels=["Number of Units","Profit"],thickness=3,color=blue);plot([sin(x),cos(x)],x=-2*Pi..2*Pi,y=-1..1,title="Basic Trigonometric Functions",legend=["sine","cosine"],labels=["x","y"]);Note that in the above plot of two graphs, instead of enclosing the two functions in braces, we used brackets. This was necessary for the legend to work. (Basically braces indicate a set, which has no particular order. Brackets indicate a list, which has an order.)Special care must be made when graphing functions with discontinuities.dis:=x->1/(x-1);plot(dis(x),x=-10..10,y=-10..10);plot(dis(x),x=-10..10,y=-10..10,discont=true);Recall that Maple draws graphs by computing many points that lie on the graph and connecting those points with small line segments. In the first graph of the rational function above, Maple connected a point low on the graph with a point high on the graph to give the illusion of an asymptote. But remember that asymptotes guide a function but are not part of the graph. If you see a solid vertical line in the graph, then the graph fails the Vertical Line Test and is not a function! Thus, asymptotes must be dotted or not shown explicitly in the graph, as done in the second graph of the rational function above.Graphing Implicit Functions or Equations in GeneralThese are equations that cannot be explicitly solved y = f(x) ... or it would be unwieldly or difficult to accomplish this solution. In order to plot these kinds of graphs, the plots package must be loaded.with(plots);Don't worry about the warning! Look at all the special plots that are at your disposal. The syntax/command for implicit graphing is similar to the plot command. Let's graph the unit circle.implicitplot(x^2+y^2=1,x=-1..1,y=-1..1);Note that the circle looked more like an ellipse than a true circle. Thatis because the scaling on the two axes usually is not forced to be the same. You can make equal scaling on the x and y axes by using the constrained option in scaling, as shown below.implicitplot(x^2+y^2=1,x=-1..1,y=-1..1,scaling=constrained);Now, let's graph an ellipse.implicitplot(x^2-x*y+y^2=3,x=-3..3,y=-3..3);Suppose that a figure looks jagged or is not smooth. There are two possibilities. One, the graph really looks that way. Two, Maple has not drawn enough points. Use the option numpoints to increase the number of points used.implicitplot(x^2-x*y+y^2=3,x=-3..3,y=-3..3,numpoints=1000);Graphing Data SetsSuppose that you have a collection of data points that you wish to graph in a 2D (or 3D) coordinate system. This graph is called a scatterplot. If you wish to "connect the dots," then the graph is called a line graph. Make sure that the plots package is loaded. Define the data set as a list of ordered pairs, using brackets to denote order.with(plots);dataset:=[[0,0],[1,4],[3,4],[5,2],[3,0],[5,-2],[3,-4],[1,-4],[0,0]];pointplot(dataset);You may control the size of the points in the scatterplot by using the symbolsize option.pointplot(dataset,symbolsize=16);You may transform this scatterplot into a line graph by using the style option.pointplot(dataset,style=line);<Text-field layout="Heading 1" style="_cstyle262"><Font bold="true" family="Times New Roman" foreground="[0,0,0]" italic="false" underline="false">Word Processing: Text, Mathematical Expressions, & "Live" Mathematics</Font></Text-field>You may "word process" documents by using Maple's built-in worksheets. As with any new document you create, start with a blank document. Close all windows in Maple. Then click the first button in the toolbar row. Or click on the FILE menu and then NEW.To insert text, click the second button in the third group of toolbar buttons: "T." This will insert a new text field. One text field can hold a sentence, a paragraph, a chapter, etc. You may separate paragraphs in separate text fields or collapse them into one; use your personal stylistic preference.To insert commands for Maple to calculate, click on the last button in the third group of toolbar buttons: "[>." This creates a new Maple execution field. Then type your Maple syntax. Press enter for the result.To insert "Mathematics" statements into your text which you do NOT wish Maple to execute, you have two choices.First, create a new Maple execution field. Type your "Mathematics" as Maple would understand it. Since you do not want Maple to execute the statement, do not press enter. Simply press the "[>" button to get a new field and continue. (If you do press enter, Maple will probably give you an error message.) The drawback to this approach is that your reader has to understand how Maple writes Mathematics. He/she must interpret "f(x)=x^2" as "NiMvLSUiZkc2IyUieEcqJClGJyIiIyIiIg== ."And now for a second better way ...In the middle of your text field, press the first button in the third group of toolbar button: NiMlJlNpZ21hRw==. This will insert a ? placeholder temporarily in your document. Notice that a large blank field/row has appeared in the second line of the toolbar. Type your "Mathematics" here as Maple would understand it, for example, f(x)=x^2. Then when you press enter, Maple will insert the correct typeset "standard" Mathematics into your text field, for example NiMvLSUiZkc2IyUieEcqJClGJyIiIyIiIg==.One final note, if you need more room in a document, then insert a new Maple execution group with the "[>" button. If you want it to be text, simply press the "T" button.You have the normal print, print setup, and print preview options from the FILE menu. The document you create in Maple will be saved with the Maple Worksheet extension ".mws" in Windows.