> Warning, the name changecoords has been redefined Maple Basics Here are some basic Maple examples. They illustrate the syntax of some useful commands for calculus. You can make the commands ``happen'' by hitting RETURN at the end of any input line. Input lines are in red on a color monitor, and they start with a > symbol. Define an expression to work with in various ways: > f := x^2*sin(x); 2 f := x sin(x) Note that every command ends with a semicolon. Having defined f , we can use it in various ways. Maple will remember what's meant by the symbol f. Now let's try doing some calculus-style things to f, such as differentiating f with respect to x. > diff(f,x); 2 2 x sin(x) + x cos(x) Look what happens if we use another variable than x : > diff(f,y); 0 Do you agree with the answer? (You should.) Let's do something else. > g := int(f,x); 2 g := -x cos(x) + 2 cos(x) + 2 x sin(x) The previous command defined g as a new expression --- an antiderivative of f. > diff(g,x); 2 x sin(x) That's reasssuring ... Let's try plotting something. Maple can plot all kinds of things. > plot( f, x=-3..3 ); As you see, a new window pops up. You can do various things with the buttons in the menu at the top of the plot window, such as changing the style of axes. When you're done with the window you can use the File menu to close it or kill it. There are many variations on the plot command. To find out more, use the built-in help system. To do so, give a command like this: > ?plot A help window pops up, with lots more information than you want. The most useful stuff is often the examples at the bottom of the window. Note that you can try any example by highlighting it with the mouse, then moving to an input position in the Maple window, and pressing the middle mouse button. (This copies the highlighted stuff from one window into the input position.) Here are a few more plot examples, to illustrate the possibilities: > plot( sin(x), x=-Pi .. Pi, -2 .. 2 ); > plot( sin(x), x=-Pi .. Pi, -5 .. 5 ); > plot( [sin(t),cos(t), t=0..Pi] ); The plot above is a parametric plot---it produces a semi-circle. If the plot doesn't look right to you, try something in the Projection menu in the plot window to see what it does. Note carefully how the square brackets are used. In particular, the t-range is included INSIDE the square brackets, for some reason. In the next example, the last two bits of information control the ``window'' in which the plot is drawn. > plot( [sin(t),cos(t), t=0..Pi] , -5..5, -5..5); > plot( [sin(t),cos(t), t=0..2*Pi]); Try playing with any of the commands above, by using the mouse and arrow keys to change whatever you want. Plotting in 3d Maple is especially useful for plotting surfaces and other objects in three dimensions. The basic 3-d plotting command has the following form: > plot3d( x^2+y^2, x=-3..3, y=-3..3 ); The result is a surface in xyz-space, as you'd expect. Note that you might have to fool with some of the menu items at the top to get axes, different color schemes, etc. After you've made new choices for such things, either click again on the picture (use the MIDDLE mouse button) or type ``p'' to get the new plot. Try clicking on the picture and dragging the bounding box around to see the surface from different angles. Try changing the function or the domain region to see what happens. Other 3d plotting tools Maple has many other 3d plotting tools. To get access to most of them, use this command: > with( plots ); This loads a lot of new plotting functions into Maple. For example, you can type > contourplot( x^2+y^2, x=-3..3, y=-3..3 ); The result is a set of level curves for the function. (You may want to experiment with some of the menu items at the top of the plot window to get axes, etc.) For more information about any function, such as contourplot , you can always use the Maple help system. Type, e.g., > ?contourplot You'll get a window full of information. The bottom of the window often contains the most useful information and examples. Defining functions Above we showed how to define f and g as EXPRESSIONS. Doing so can save a lot of typing and retyping, but it does NOT define f and g as FUNCTIONS in the usual mathematical sense. For example, we might like to find f(3), but Maple won't do this properly (yet): > f(3); We got some nonsense, but not what we wanted. Here's how to define f as a FUNCTION, not an expression. Notice the use of the ``arrow''---it's actually just a hyphen and a greater than sign. > f := x -> x^2*sin(x); Now we've defined f successfully as a function in the usual sense. > f(3); To get a decimal form of the answer above, type something like this: > evalf(%); The evalf command tries to evaluate anything to a decimal (or ``floating point'') number. The percent sign represents the previous output. If you feed f a decimal number to start with, it will give a decimal output. > f(3.0); >