An Introduction to Maplewritten by Professor Fasshauerslightly modifed by Professor PelsmajerWe will always work in what is called a worksheet (or "worksheet mode"). In this environment red text after the Maple prompt (>) represents Maple input. It can be executed by moving the cursor anywhere into that line and hitting the enter key (try this with any red line below). Maple input usually is terminated by a semicolon (;). The execution of a Maple command will usually be followed by some kind of output displayed in blue. The display of the output (but not the actual calculation) can be suppressed by ending a command with a colon (:) instead of a semicolon (;).Read through the following, to get acquainted with Maple's syntax and some of the commands needed more frequently in the assignments to come. Other commands will be introduced when they are needed. Every time you get to a line in red, click on it and hit the "Enter" key! Most of the time, something visible will happen. For example, the second red line should produce a blue fraction.restart; This command is useful at the beginning of every worksheet. It clears Maple's memory.Maple can do simple arithmetic. Here are a few examples:2-3+4/5*6^7;If you need to use floating point arithmetic then do evalf(1/3 + 1/2);By default 10 digits are displayed, although this can be changed easily by adding the desired number of digits to the evalf command.evalf(1/3 + 1/2, 50);Maple also knows certain mathematical constants. (Note the capitalization)Pi;As a floating point numberevalf(Pi);Another constant that you might use is the number LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbWlHRiQ2JVEiZUYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNi1RIj1GJy9GM1Enbm9ybWFsRicvJSZmZW5jZUdRJmZhbHNlRicvJSpzZXBhcmF0b3JHRj0vJSlzdHJldGNoeUdGPS8lKnN5bW1ldHJpY0dGPS8lKGxhcmdlb3BHRj0vJS5tb3ZhYmxlbGltaXRzR0Y9LyUnYWNjZW50R0Y9LyUnbHNwYWNlR1EsMC4yNzc3Nzc4ZW1GJy8lJ3JzcGFjZUdGTC1JI21uR0YkNiRRJzIuNzE4MkYnRjlGOQ==...This is how to get it in Maple:exp(1);orevalf(exp(1));A useful shortcut is the operator %. It refers to the most recent output. For example (note again that Maple treats the following as an exact value)sqrt(2);%^3;does the same as(sqrt(2))^3;Alternatively, we can use assignments. In the previous example this would meanroot2 := sqrt(2);Here we assigned the value sqrt(2)=LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkmbXNxcnRHRiQ2Iy1JI21uR0YkNiRRIjJGJy8lLG1hdGh2YXJpYW50R1Enbm9ybWFsRicvJStmb3JlZ3JvdW5kR1EqWzAsMCwyNTVdRicvJTBmb250X3N0eWxlX25hbWVHUSoyRH5PdXRwdXRGJ0Yy to the variable root2. Thus, the following command will also produce the desired answer:root2^3;The next Maple concept we need to understand is that of an expression. All of the examples used above were expressions.To illustrate the use of expressions better we make use of the real strength of Maple - it's symbolic capabilities.We know that the area of a circle is given by the expression LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYoLUkjbW9HRiQ2LVEhRicvJSxtYXRodmFyaWFudEdRJ25vcm1hbEYnLyUmZmVuY2VHUSZmYWxzZUYnLyUqc2VwYXJhdG9yR0Y0LyUpc3RyZXRjaHlHRjQvJSpzeW1tZXRyaWNHRjQvJShsYXJnZW9wR0Y0LyUubW92YWJsZWxpbWl0c0dGNC8lJ2FjY2VudEdGNC8lJ2xzcGFjZUdRLDAuMjc3Nzc3OGVtRicvJSdyc3BhY2VHRkMtRiM2KC1JI21pR0YkNiVRJSZwaTtGJy8lJ2l0YWxpY0dGNEYvLUYsNi1RMSZJbnZpc2libGVUaW1lcztGJ0YvRjJGNUY3RjlGO0Y9Rj8vRkJRJjAuMGVtRicvRkVGUi1JJW1zdXBHRiQ2JS1GSTYlUSJyRicvRk1RJXRydWVGJy9GMFEnaXRhbGljRictSSNtbkdGJDYkUSIyRidGLy8lMXN1cGVyc2NyaXB0c2hpZnRHUSIwRicvJStmb3JlZ3JvdW5kR1EqWzAsMCwyNTVdRicvJTBmb250X3N0eWxlX25hbWVHUSoyRH5PdXRwdXRGJ0YvRitGX29GYm9GLw==. Let's assign this expression to a variable area_e (the _e being used here to emphasize that we are dealing with an expression) :area_e := Pi*r^2;So the expression Pi*r^2 is now stored under the name area_e.
If we want to know the area of a specific circle, say the one with r=3, we can do this as follows:subs(r=3,area_e);Note that we had to enter Pi*r^2 even though Maple displays the result as LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYoLUkjbW9HRiQ2LVEhRicvJSxtYXRodmFyaWFudEdRJ25vcm1hbEYnLyUmZmVuY2VHUSZmYWxzZUYnLyUqc2VwYXJhdG9yR0Y0LyUpc3RyZXRjaHlHRjQvJSpzeW1tZXRyaWNHRjQvJShsYXJnZW9wR0Y0LyUubW92YWJsZWxpbWl0c0dGNC8lJ2FjY2VudEdGNC8lJ2xzcGFjZUdRLDAuMjc3Nzc3OGVtRicvJSdyc3BhY2VHRkMtRiM2KC1JI21pR0YkNiVRJSZwaTtGJy8lJ2l0YWxpY0dGNEYvLUYsNi1RMSZJbnZpc2libGVUaW1lcztGJ0YvRjJGNUY3RjlGO0Y9Rj8vRkJRJjAuMGVtRicvRkVGUi1JJW1zdXBHRiQ2JS1GSTYlUSJyRicvRk1RJXRydWVGJy9GMFEnaXRhbGljRictSSNtbkdGJDYkUSIyRidGLy8lMXN1cGVyc2NyaXB0c2hpZnRHUSIwRicvJStmb3JlZ3JvdW5kR1EqWzAsMCwyNTVdRicvJTBmb250X3N0eWxlX25hbWVHUSoyRH5PdXRwdXRGJ0YvRitGX29GYm9GLw==. If we omit the multiplication operator *, this is what will happen:(You always have to include arithmetic operators when you are formulating Maple input.This is a common source of mistakes!)junk := Pir^2;orjunk := Pi r^2;As an alternative to using expressions (whose evaluation is sometimes a bit cumbersome) we can (and most often will) use functions. Let's repeat the area example using function notation (now we use area_f for function).Read this as "to every LUkjbWlHNiMvSSttb2R1bGVuYW1lRzYiSSxUeXBlc2V0dGluZ0dJKF9zeXNsaWJHRic2JVEickYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJw== the function area_f assigns the value LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYnLUkjbW9HRiQ2LVEhRicvJSxtYXRodmFyaWFudEdRJ25vcm1hbEYnLyUmZmVuY2VHUSZmYWxzZUYnLyUqc2VwYXJhdG9yR0Y0LyUpc3RyZXRjaHlHRjQvJSpzeW1tZXRyaWNHRjQvJShsYXJnZW9wR0Y0LyUubW92YWJsZWxpbWl0c0dGNC8lJ2FjY2VudEdGNC8lJ2xzcGFjZUdRLDAuMjc3Nzc3OGVtRicvJSdyc3BhY2VHRkMtRiM2Ji1JI21pR0YkNiVRJSZwaTtGJy8lJ2l0YWxpY0dGNEYvLUYsNi1RMSZJbnZpc2libGVUaW1lcztGJ0YvRjJGNUY3RjlGO0Y9Rj8vRkJRJjAuMGVtRicvRkVGUi1JJW1zdXBHRiQ2JS1GSTYlUSJyRicvRk1RJXRydWVGJy9GMFEnaXRhbGljRictSSNtbkdGJDYkUSIyRidGLy8lMXN1cGVyc2NyaXB0c2hpZnRHUSIwRidGL0YrRlpGZm4=":area_f := r -> Pi*r^2;Then the area of the circle with radius 3 is obtained by asking forarea_f(3);The difference between expressions and functions might seem confusing at the beginning. Let's illustrate the difference in their use in connection with some other frequently used commands.First we could plot the area as a function of the radius.Using expressions we doplot(area_e, r=0..4);In function notation the same is accomplished via (note the missing r; Maple knows from the function definition above that r is the independent variable)plot(area_f, 0..4);However, the following also worksplot(area_f(r), r=0..4); This shows us that we can easily get an expression from a function:area_f(r);is the same asarea_e;How do we go the other way, i.e., how can we turn an expression into a function?This is done with the help of the command unapply. Here is how it works (for a similar example):circumference := 2*Pi*r;So circumference holds the expression 2*Pi*r.To get a function we do (i.e., we tell Maple which expression to convert to a function, and what the independent variable will be): circumf := unapply(circumference, r);We end this introduction with a simple calculus problem.First we will define a simple function f := x -> sin(x/2)*(x-1);Let's plot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HVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYrLUkjbW9HRiQ2LVEifkYnLyUsbWF0aHZhcmlhbnRHUSdub3JtYWxGJy8lJmZlbmNlR1EmZmFsc2VGJy8lKnNlcGFyYXRvckdGNC8lKXN0cmV0Y2h5R0Y0LyUqc3ltbWV0cmljR0Y0LyUobGFyZ2VvcEdGNC8lLm1vdmFibGVsaW1pdHNHRjQvJSdhY2NlbnRHRjQvJSdsc3BhY2VHUSYwLjBlbUYnLyUncnNwYWNlR0ZDLUYsNi1RIixGJ0YvRjIvRjZRJXRydWVGJ0Y3RjlGO0Y9Rj9GQS9GRVEsMC4zMzMzMzMzZW1GJy1JI21uR0YkNiRRIjJGJ0YvRistSSNtaUdGJDYlUScmIzk2MDtGJy8lJ2l0YWxpY0dGNEYvLUYsNi1RIl1GJ0YvL0YzRkpGNS9GOEZKRjlGO0Y9Rj8vRkJRLDAuMTY2NjY2N2VtRicvRkVRLDAuMTExMTExMWVtRicvJStmb3JlZ3JvdW5kR1EqWzAsMCwyNTVdRicvJTBmb250X3N0eWxlX25hbWVHUSoyRH5PdXRwdXRGJ0Yv.plot(f, -2*Pi..2*Pi);To find the intersections of the graph with the LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYkLUkjbWlHRiQ2JVEieEYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy9GM1Enbm9ybWFsRic=-axis we can attempt to use either solve or fsolve (note that both functions cannot be blindly trusted; they often find only some - but not all solutions)solve(f(x)=0, x);We missed the intersections at the endpoints of the interval.Using fsolve on the entire interval even gives only one solutionfsolve(f(x)=0, x, -2*Pi..2*Pi);However, some fine tuning helpsfsolve(f(x)=0, x, 1/2..2);and (e.g.)fsolve(f(x)=0, x, -6.5..-6);To locate critical points we need to know the derivative of LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYnLUkjbWlHRiQ2JVEiZkYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNi1RIUYnL0YzUSdub3JtYWxGJy8lJmZlbmNlR1EmZmFsc2VGJy8lKnNlcGFyYXRvckdGPS8lKXN0cmV0Y2h5R0Y9LyUqc3ltbWV0cmljR0Y9LyUobGFyZ2VvcEdGPS8lLm1vdmFibGVsaW1pdHNHRj0vJSdhY2NlbnRHRj0vJSdsc3BhY2VHUSwwLjI3Nzc3NzhlbUYnLyUncnNwYWNlR0ZMLyUrZm9yZWdyb3VuZEdRKlswLDAsMjU1XUYnLyUwZm9udF9zdHlsZV9uYW1lR1EqMkR+T3V0cHV0RidGOQ==. Since we are using function notation this is done viaD(f);Expressions are differentiated with the help of diffdiff(f(x), x);We can plot the graph of the derivative on the same interval as aboveplot(D(f), -2*Pi..2*Pi);Or even both graphs togetherplot({f, D(f)}, -2*Pi..2*Pi);Finally, we can compute integrals.The antiderivative of the derivative of LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYnLUkjbWlHRiQ2JVEiZkYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNi1RIUYnL0YzUSdub3JtYWxGJy8lJmZlbmNlR1EmZmFsc2VGJy8lKnNlcGFyYXRvckdGPS8lKXN0cmV0Y2h5R0Y9LyUqc3ltbWV0cmljR0Y9LyUobGFyZ2VvcEdGPS8lLm1vdmFibGVsaW1pdHNHRj0vJSdhY2NlbnRHRj0vJSdsc3BhY2VHUSwwLjI3Nzc3NzhlbUYnLyUncnNwYWNlR0ZMLyUrZm9yZWdyb3VuZEdRKlswLDAsMjU1XUYnLyUwZm9udF9zdHlsZV9uYW1lR1EqMkR+T3V0cHV0RidGOQ== should be LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYnLUkjbWlHRiQ2JVEiZkYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNi1RIUYnL0YzUSdub3JtYWxGJy8lJmZlbmNlR1EmZmFsc2VGJy8lKnNlcGFyYXRvckdGPS8lKXN0cmV0Y2h5R0Y9LyUqc3ltbWV0cmljR0Y9LyUobGFyZ2VvcEdGPS8lLm1vdmFibGVsaW1pdHNHRj0vJSdhY2NlbnRHRj0vJSdsc3BhY2VHUSwwLjI3Nzc3NzhlbUYnLyUncnNwYWNlR0ZMLyUrZm9yZWdyb3VuZEdRKlswLDAsMjU1XUYnLyUwZm9udF9zdHlsZV9uYW1lR1EqMkR+T3V0cHV0RidGOQ== again (note that Maple doesn't bother with the additive constant): int(D(f)(x), x);Note that we integrated an expression above, and Maple also returned an expression.It does not seem to be possible to antidifferentiate a function in Maple (or obtain the result of integration as a function - if you want this you need to use unapply).Also note that the answer does not look quite like what we expected.Another useful command is simplify. It might help in situations like this.simplify(%);It doesn't here. Since we really started with a factored version of this answer let's try factor(%);To compute a definite integral we simply add the limits of integration as inint(f(x), x=-2*Pi..2*Pi);One more thing:To start a new line of input (the lines that begin with ">"), click on the button labeled "[>" at the top. Then immediately press Ctrl-M, which will make the input red and fixed-width.To start a new line of text, click on the button at the top labelled "T".As a simple exercise you might want to compute the zeros of the derivative of LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYnLUkjbWlHRiQ2JVEiZkYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNi1RIUYnL0YzUSdub3JtYWxGJy8lJmZlbmNlR1EmZmFsc2VGJy8lKnNlcGFyYXRvckdGPS8lKXN0cmV0Y2h5R0Y9LyUqc3ltbWV0cmljR0Y9LyUobGFyZ2VvcEdGPS8lLm1vdmFibGVsaW1pdHNHRj0vJSdhY2NlbnRHRj0vJSdsc3BhY2VHUSwwLjI3Nzc3NzhlbUYnLyUncnNwYWNlR0ZMLyUrZm9yZWdyb3VuZEdRKlswLDAsMjU1XUYnLyUwZm9udF9zdHlsZV9uYW1lR1EqMkR+T3V0cHV0RidGOQ== above:Try it, now!