Introduction to Maple James Rohal What is Maple? Roughly speaking, it is software used for performing computations. Every time you work out a problem in calculus, you are performing some form of computation, whether it be in your head or on paper. Maple is useful to us because it will complete those tasks faster than you can by hand. Layout This is what you should see when you first open Maple if you are running Windows. The red box is called the sidebar. We will never use it. Go ahead and hide it by clicking the left-pointing arrow in the blue circle. I labelled from right to left, the five most important things in Maple. to use Help effectively. (2) Stop computations: this is a kill switch. Sometimes Maple takes a long time to evaluate some code, gets stuck in an infinite loop, etc. Clicking this button forces it to stop whatever it was doing. (3) Insert a new line for computing. More on this in the "Making Inputs" section. (4) Switch between Maple Input (Text) and 2D Input (Math). More on this in the "Making Inputs" section. (5) When Maple is computing something, this changes from "Ready" to "Evaluating." When it reads "Ready", you can perform computations. When it reads "Evaluating", Maple is performing a computation and you must wait until it is done to perform another. You can forcibly stop evaluation by clicking the button circled in (3). Making Inputs Before we get to some examples, we need to talk about some notation first. Typing in a Maple worksheet is unlike Microsoft word; you can add pictures and text (like the stuff above) and do programming too: > f := x^2; diff(f, x); (1) > (2) (2) Above, we illustrated two ways to compute the derivative of x^2. The output is always in blue (unless there is an error, in which case it is in pink). Each method consisted of two lines of code: LINE 1) Store x^2 in the variable f. The output of this computation is simply what you typed in. This is Maple saying it understand that you stored a variable. LINE 2) Take the derivative of f with respect to x. The output of this computation is "2x" which is what we expect. Before we break down the example above any further, let's notice some things the two input types have in common: Now let's talk about the differences. In Maple there are two input types: Maple Input (sometimes called 1D Input) and 2D Math. You can visually see the difference because the fonts differ (red monospace vs black italics), but more importantly, how the math symbols are represented (x^2 vs ). Here is a bit of advice: NEVER USE 2D MATH INPUT Seems strange, right? We always write "x squared" as , so why not do the same on a computer? Long story short, computers have a hard time understanding math written this way and it sometimes causes weird errors. The main reason is because when you write , you are "hiding" the fact that you are exponentiating, leaving it up to the computer to interpret what "x with a superscript 2" means. When you write it like x^2, you are explicitly telling the computer, "raise x to the second power." Keep in mind that computers are dumb, never think that they can read your mind. That also means we need to "teach" them how to interpret our inputs. It turns out, representing math like on a computer is actually quite hard. In that light, let's discuss how to use Maple Input and how to avoid 2D Math. First, put your cursor on the Maple Input text below. > f := x^2; diff(f, x); Remember the five important things I circled? Look at circle (4). If you are typing Maple Input, then this is what it should look like. Now put your cursor on the 2D Math text below. > Now it looks like By looking at this bar, you will know which input type you are using. So now let's discuss how to make a code bracket to type math in. Place your cursor here and press the key (this was circled as (3) in the important things above). Did a show up above in the blank space? This is a blank code block. Put your cursor in it. Now make sure we are using Maple Input by clicking the "Text" bubble above: . This is how you add new lines to your document. Go ahead and type some math (1+1, for example) and put a semi-colon at the end of it all then press Enter. Pressing Enter evaluates the current code block. You will get something that looks like: > 1+1; 2 (3) You can add new blank lines to a code block by holding Shift and pressing Enter. > 1+1; 2+2; 3+3; 2 4 6 That's all there is to typing input in to Maple! (4) Common Maple Notation Let's discuss some common notation that you would use in Maple with some examples. Order of Operations Maple is like a big calculator. You need to tell it what operations to use: addition ( + ), subtraction ( - ), multiplication ( * ), division ( / ), and exponentiation ( ^ ). Parentheses matter! Never forget PEMDAS. > 2*(3+1-0)/5^2; 8 (5) 25 Comments Any code that has a pound sign (#) in front of it will be ignored by Maple. We can use this to create comments in code if we wish. > # the following code will not be evaluated # 2 + 2; Numerical Approximation Maple tries its best to do everything using exact arithmetic. > sqrt(3) + sqrt(4); (6) Sometimes you want the decimal approximation of something, so you use the evalf command. > evalf(sqrt(3) + sqrt(4)); 3.732050808 You can get more decimals by adding an additional argument to evalf: > # this gives you 20 digits in total evalf[20](sqrt(3) + sqrt(4)); 3.7320508075688772935 (7) (8) Mathematical Constants (e, ) and Mathematical Functions The mathematical constant e = 2.71828... is represented as exp(1) in Maple. "Natural log" (ln) is represented as ln or log. > evalf(exp(1)); ln(exp(1)); log(exp(1)); 2.718281828 1 1 (9) You can change the base of the logarithm by including an additional argument to log: > log[10](100000); 5 (10) The mathematical constant = 3.14592... is represented as Pi in Maple. NOTICE THAT IT IS CAPITALIZED. > evalf(Pi); 3.141592654 (11) If you use the lower case pi, you cannot perform computations. > sin(Pi); sin(pi); 0 (12) (12) Maple has lots of built-in mathematical functions. I only listed some below. A big list can be found here. > sqrt(x^2); abs(3+x); sin(3*Pi); cot(2/3*Pi); arctan(1); 0 (13) Hiding Output Sometimes you may want to evaluate some code and hide the output. To do this, you include a colon (:) instead of a semi-colon (;) at the end of your input. Compare > 2+2: which has no output, to > 2+2; 4 (14) which has an output. Assigning Variables As we saw earlier, to assign anything to a variable we must use := For example, I can store the value 2 in the variable b: > b := 2; (15) Now Maple knows that whenever it sees a b it will replace it with a 2. > b + 2; 4 (16) This is what we mean by "computers are dumb." You need to tell a computer explicitly to think that b is the same as 2. If we want, we can change what b is at any time we want. > b := 3: b + 2; 5 (17) If a variable is unassigned, then Maple will just use it as a symbol. > x + 2; (18) Variables can be any number of characters long and can contain underscores ( _ ) but not contain any spaces. > my_variable_name := 2: my_variable_name + 2; 4 (19) Be careful when working with variables. If we have variables c and d and we want to compute the product, we must write c*d rather than cd. This is because Maple will interpret cd as a variable but c*d as a product. > c := 2: d := 4: cd; c*d; cd (20) 8 Above, Maple returned cd as output because nothing was assigned to the variable cd. (20) Unassigning Variables Not very common, but sometimes you want to clear a variable and turn it back into a symbol. You do that by "assigning it to itself." > b := 'b'; (21) Now we can use b as a symbol. > b + 2; (22) Creating Functions A "function" is a machine that takes input and creates an output. For example, , is named f , takes input x, and outputs . In Maple, a function is created this way: function_name := input -> output; For example, > f := x -> x^2; (23) The above is saying, assign to f the function that takes x as input and gives x^2 as output. Now we can use f like we would if we were doing it by hand. For example, if we wanted to "plug-in 3 in to f " we would do > f(3); 9 (24) Keep in mind you need to tell Maple that we are using a function. If I had done, > f := x^2; (25) instead, notice the difference in output (one has an arrow while this doesn't). What this means is that Maple thinks f is simply an expression and not a function. If I try > f(3); (26) we see Maple gives us a weird output which is not what we expected. Making Substitutions In Maple, you will work with lots of things called expressions. In the example above > f := x^2; (27) assigns the expression x^2 to f. As we saw above, to plug in x = 3 we cannot simply do f(2) because to Maple, f is not a function, it is an expression. To substitute into expressions you have two ways: > eval(f, x=2); subs(x=2, f); 4 4 (28) The first command says "evaluate f at x = 2" and the second says "substitute x = 2 in to f". Ranges In Maple, you represent the numbers between a and b as a..b. This is useful for when you have to use an interval for something, like when integrating or plotting (see below). Using Built-In Functions Maple has LOTS of built-in functions. You can find them using Help (which we will talk about a bit later). Anything you can do in calculus, Maple can do. A built-in function has this form: function_name( parameters separated by commas ) Here are some examples. > # derivative with respect to x diff(sin(x), x); (29) > # limit as x goes to infinity limit((x^2+1)/x^3, x=infinity); 0 > # plot where x is on the interval [-1,1] plot(x^2, x=-1..1); (30) > # integrate on the interval [-1,1] int(x^2, x=-1..1); 2 3 (31) Creating/Using Lists A list in Maple is a way to store a sequence of data. It is represented by using square brackets: [entry1, entry2, entry3] > my_list := [x - 4, 5, sin(x)]; (32) (32) You can access entries in your list by indexing in to it. > # gives you the 1st entry my_list[1]; # gives you the 3rd entry my_list[3]; (33) You can update your list by updating the appropriate index. > # change the 2nd entry my_list[2] := tan(x); # my list now looks like this my_list; (34) Loading Packages Even though Maple has lots of built in functionality, not all of it is loaded when you start it up. Sometimes you need to load additional functions. The way you do this is using the with command. > with(plots); (35) The above command loaded several different plotting routines not available to us originally. > implicitplot(x^2 + y^2 = 1, x=-1..1, y=-1..1); Using Help The easiest way to use Help in Maple is to search. For example, let's say we want to find out how to take a derivative. So we search for "derivative" The first result being diff. The function name is circle (1). To understand how to use diff, we look at the calling sequence and parameters. The calling sequence says diff can be written three different ways, depending on what we want to compute. For example, to compute a "mixed-derviative" (circle (2.5)) we use calling sequence (2). The parameters section describe what each symbol in circle (2) mean. Here, it is saying f is an expression (like x^2) and x1 is a variable (in our case, x). When in doubt, scroll down to the examples section. > diff(f, x); (36) Common Problems Forgot a Semi-colon > 2+2 Warning, inserted missing semicolon at end of statement 4 You forgot a semi-colon at the end of your input. > 2+2; 4 (37) (38) Maple Doesn't Compute Expression Sometimes your output is exactly the same as your input. > dif(x^2, x); (39) This happens because you misspelled something. In this case, the command is actually diff and not dif. > diff(x^2, x); (40)
© Copyright 2026 Paperzz