|
Let me start with a suggestion. Read all of Maple Think before starting the other sections of this tutorial, because without question this is the most important section of the whole tutorial. This section introduces Maple's help facilities, functions you will use frequently, and the important concept of assignment. It also begins to present the bigger picture of how Maple "thinks". The sections of the tutorial with physics concept titles tend to show smaller pictures of Maple, presenting just the details needed to solve particular problems. This section's bigger picture reveals a few of the essential "whys". This is important because without a solid understanding of the reasoning behind Maple's actions, you might end up frustrated and thinking that Maple is not a very intelligent tool. A special place exists for people who end up frustrated with Maple. Check it out now (WARNING: Do not click the link that says, in effect, "Click me if you think the Maple V ... page ..." -- it might crash your computer. All the other links are safe.), and check it out again after completing all sections of this tutorial. That such a page exists indicates the passions such a powerful and potentially confusing tool can incite. A few of the complaints on the page are valid (no software package approaches perfection, especially one as large and ambitious as Maple). However, a decent knowledge of Maple reveals that most of the complaints are the unfounded opinions of people lacking a solid knowledge of Maple's underpinnings, Maple's philosophy, and, most importantly, the current limitations of CAS technology. Of course, there are many more pro Maple pages that would probably be a better place to spend your online Maple investigation time. Maple calculates. Maple is not a calculator. Maple is a Computer Algebra System (CAS). CASs manipulate and reason about symbols under a given set of syntactic and semantic rules. For a short discussion of symbols, syntax, and semantics click here. Unlike the vast majority of calculators, the moment you turn on Maple it is ready to handle the symbols, syntax, and semantics of many more languages than just numeric mathematics. For the next few years, many of problems that you will solve with Maple could also be solved with a programmable calculator. And for some of them, once you write the program, the calculator might yield the answer faster. Most calculators are built from the ground up to manipulate numeric symbols, and numeric symbols only, in a very rigid environment. Maple's design handles many more types of data, in a much more communicative way, and in a much more general computer setting. Please try to avoid narrow comparisons of Maple's numeric calculation speeds on say a 200 MHz PC with those of a HP48 running on circuitry dedicated to just HP48 style calculations. Learn Maple now using the mathematics familiar to you, and then more easily benefit from its true power later when, unlike your handheld calculator, it can still offer large amounts of assistance to your more advanced mathematical projects. Maple is not a very intelligent tool. Unlike human brains like yours, which were the original sources of the ideas programmed into it, Maple does not understand any of the algorithms it executes. It only follows a set of rules for manipulating input data in a certain context. You control the input data and you tell Maple which set of rules to use. For example, one set of rules gives Maple the ability to take the derivative of a mathematical expression. You supply the expression and you tell it which set of rules to use, i.e. you enter the diff command (the rules) with the expression (the input) as its argument. From this point Maple takes over, differentiating the expression according to a very complex set rules, and never experiencing a single thought in the whole process. Like almost every function Maple performs, differentiation can get very complex and is full of lots of subtlety and decision making. At this point in the development of computing, no program as all encompassing as Maple always makes every decision the way you think it should. The lesson? Stay on guard and always check your work. In addition, learn something about the inner workings of Maple's reasoning processes. Maple does what you tell it to do given the set of rules with which it has to work. The more you know about Maple's rules, the more you will get out of it. Often the slightest variations in your inputs cause great variations in Maple's outputs. Knowledge of how Maple makes decisions sheds a lot of light on Maple's "wrong" answers. The cautionary tone of these first comments are not intended create a lot of fear or anxiety, but to stress that you are about to learn how to use a very powerful tool, and as with any really powerful tool there are many complexities in Maple, and you must pay close attention to what you do with it. The rewards are great, but the mastery is not as simple as riding a bike. However, on the other hand, the mastery is not like learning brain surgery, either. Start Maple up. Your instructor should supply the necessary operating system dependent information to accomplish this and other basic file manipulation operations. If your screen has palettes on it containing mathematical symbols, click the button in the upper left corner of each of them. With a little Maple knowledge the uses for these palettes will become obvious to you, and you can use them if you like (I don't find them very useful). I also suggest that for at least a little while you use balloon help. In the Help menu select "Balloon Help". To make sure your Maple worksheets look like the worksheets displayed in this tutorial, set the following parameters. The last word in each of the following menu selections should have a checkmark beside it.
Alert! The first two sentences of the next paragraph are the two most important sentences of the whole tutorial. You will gain more from this tutorial if you echo everything presented in your own Maple sessions. You will gain the most if, in addition, you echo things with your own variations. You will not break the software, and you can simply select and cut out anything you do that gets real ugly. Every Maple command displays in bold red text in both this tutorial and your Maple worksheets. On many operating systems you may select and copy the commands in your browser window, and then paste them in your Maple worksheet. Command Lines, Variables, and Assignment Although there are variations, like palettes, you usually communicate with Maple through command lines. For example, > 2 + 3, 2^3;
> much + 2 * simple;
Both of these are command lines, consisting of a Maple prompt ( > ) followed by a series of expressions separated with commas, and ending with a semicolon (do not copy the prompt when copying and pasting from your browser to your Maple worksheet). You press enter/return to tell Maple to act on the command. Maple enters much and simple into memory as undefined/unbound variables. Maple thinks of what you typically call a variable as a name for reasons that involve the storage of values in memory. Most of the time I use the word variable. The symbol * is the Maple input symbol for multiplication, and ^ indicates that what follows it is an exponent. Try entering a command line without a semicolon and then pressing enter. The square bracket to the left of each of the calculations in your Maple worksheet (not shown here) delineates an execution group. If the cursor rests anywhere inside an execution group and you press return/enter, Maple executes all of the command lines in that execution group. Think of them as mathematical paragraphs. If you want to write two or more commands on consecutive lines in a single execution group before executing them all together, simply press shift when you press return/enter. This creates a new line for input below the one in which the cursor currently rests. Give it a try. Maple handles many different types of data under many different sets of rules, and it tries to make as few assumptions as possible. It provides you with many operators and functions with which to guide it in making decisions about how to manipulate the data you enter. This philosophy makes Maple a flexible tool. A as simple example of this idea, enter the expression > sim + ple;
And then, using the assignment operator ( := ), enter
Now enter > sim + ple;
The variable sim is assigned the value Like a handheld calculator, Maple knows how to evaluate > evalf( sim );
But note that sim is still associated with the object > sim;
To change the value of a variable you must use the
assignment operator ( := ). No other Maple
operator changes the value of a variable. In this case the variable sim is
assigned to the object You may ask questions about the the nature of objects and relationships between objects with the is function. The following command line asks Maple to decide if the object associated with the variable sim has the same representation in memory as the object an evalf( sim ) function call produces. > is( evalf( sim ) = sim ); (discussed later, = is a Boolean operator and has nothing to do with :=)
The function call evalf( sim ) produces a different type of object from the one assigned to the variable sim. As objects with particular representations in memory (and even in a literal sense), > evalf( sim ) <> sim; (not equal to ( <> ) is another Boolean operator)
In fact, > is ( evalf( sim ) <> sim );
Keep this in mind; similar situations arise often and easily cause confusion about Maple's behavior. If you want to use the decimal approximation of sim instead of the radical representation, do something like the following.
> sim;
Alert! The next two paragraphs provide a nugget of simple wisdom and insight. The two command lines above make sense in the context of Maple's memory management and assignment rules. First, you can reassign the object associated with any variable with the assignment operator. Second, the expression on the right side of := is evaluated completely, and then the resulting object is placed in memory and assigned to the variable on the left side of :=. Here is the order of events in this case: In the top command the
first thing Maple does is find the object associated with sim, The is function is very versatile. To find out more about it, place the cursor over it and then in the Help menu choose "Help on is". Maple offers extensive help facilities. Often times it is sufficient to move straight to the bottom of a help page and view the examples. The tool bar at the top of any help page contains a number of buttons to aid you in navigating the help pages. Make sure to select "Balloon Help" in the Help menu, and then place the cursor over each of the buttons on the help page tool bar. Close help pages when you finish viewing them and use "History..." in the Help menu if you need to access them later in the session. Place the cursor over evalf and choose "Help on evalf" from the Help menu. After looking it over a bit, close it and then choose "History..." in the Help menu. If you also viewed the is help page, the History list now contains at least two entries. Click on one of them and then click O.K. This is a very useful feature. The Window menu contains another useful help feature. Often times you will open many help windows consecutively. To close them all at once select "Close All Help" from the Window menu. Most of the help pages provide a somewhat in-depth overview of the way a particular function operates, its limitations, and subtleties. Use these as a great source of knowledge about Maple's reasoning processes. Operators, Arguments, and Functions The following are all Maple operators: + , ^ , = , <> , etc. Each of these is a binary operator because each one requires two operands/parameters/arguments (use whatever name you like), one on the left side and one on the right. An example of a Maple function is evalf. Many Maple functions accept one, two, or more arguments, depending on how much information you want to give Maple. For example, > evalf( Pi );
> evalf( Pi, 20 );
Computer programmers call this function overloading: the ability to give the same function name different numbers of arguments (or even different types). A few Greek letters, such as Pi, have set values in Maple. Note that pi does not. Try > evalf( pi );. Maple allows you to set the default value of the number of significant digits for any session with the Digits variable. The default value of ten is set when you start Maple. > Digits := 3;
> evalf( Pi );
For more information type any of the following command lines. Note that this works with any Maple property for which you want information and for which a help file exists. You do not need a semicolon. > ?operator > ?function "Topic Search..." in the Help menu provides yet another way to access a particular help page. Select "Topic Search..." from the Help menu and type env in the Topic box. Click on envvar in the Matching Topics box and then click O.K. A Few Thoughts On Assignment and Equality Assignment A mental picture of what is going on in memory can be very helpful in understanding assignment and a related process called full evaluation. A few of the assignment statements in the rest of this section are accompanied by picture snippets of what the computer's memory looks like just after execution of an assignment statement. While these pictures are not exact replicas of what is going on in memory, they do provide an accurate enough model to shed a clear light on what is going on with assignment and full evaluation. Introduce the unbound variable piglet. > piglet;
Rather than assigning piglet a value you might expect, like a number, assign it the value pig, another unbound variable.
Maple now associates piglet with pig. Every time Maple sees the variable piglet it will evaluate to pig; at least until another assignment command associates piglet with another object. Note that even variables like pig are objects. > piglet; pig;
The following picture illustrates how the objects piglet and pig are associated in memory. The boxes represent units of memory, and the ellipses (...) indicate that memory goes on and that exactly where piglet and pig are placed in memory is not important to us -- the computer takes care of that information. What is important is that associated with each of these variables is a pointer (the blue dot), and that after the assignment statement above, the pointer associated with piglet points to the place in memory that holds pig. Note that at this point pig's pointer points nowhere. The empty boxes do not mean that those units of memory are empty, they could be holding very important pieces of information, but for our current purposes we don't care. For example, for all we know pig could actually start in the box just below piglet's pointer, but that doesn't change anything about what we need to know in order to understand what is going on.
Now enter the following commands. > pig := cow; cow := camel;
Alert! The following paragraph grants insight into a fundamental Maple concept. What happens now if you enter the command line > piglet;? Think about it first, then do it and find out. Hint: Because of the assignment command > pig := cow;, pig is now a bound variable associated with cow. Every time Maple sees pig it evaluates pig (follows its pointer) and finds the value cow (also see the picture below). This process is called full evaluation, and, unless told otherwise, Maple usually executes commands with full evaluation.
Equality As stated earlier, the only similarity between the assignment operator ( := ) and the equality operator ( = ) is appearance; := assigns objects to variables and = defines equalities. Try to avoid confusing them. An equality as defined with = is an object, and you may assign it a name. For example, > one_half := 1/2 = 5/10;
> one_half;
In certain contexts Maple makes common simplifying assumptions about the nature of an object, i.e. it often puts objects into standard mathematical form. Maple makes no judgement on the truth or falsehood of the equalities you define. > 1/2 = 1/3; duck = duckling; distance = rate * time;
But, it will if asked. > is(one_half); is(1/2=1/3); is(duck=duckling); is(distance=rate*time);
Since the unbound variables duck and duckling are not associated with any objects, is does not know which of their properties to compare. It thus returns FAIL, because it is unable to make a comparison. The same goes for the comparison of distance and rate time. Of course, you might straighten out Maple's reasoning in one of the following ways. > distance := rate * time;
> is ( distance = rate * time );
Or, > distance := 20*m; rate := 5*m/s; t := 4*s;
> is ( distance = rate * t );
Because, of course, > distance = rate * t;
Notice a couple of additional things. First, in another case of Maple making some simplifying assumptions, it cancels the variable s that appears in both the denominator and numerator on the right side of the above equation. And second, I use t instead of time because I want to assign it a value and time is a protected variable. Try to assign a value to time, and check out ?protected and ?reserved. Assignment and full evaluation give rise to something for which you should watch out, and illustrating it also yields some more insight into the full evaluation process. The command from earlier in this section, sim := evalf( sim ), is a recursive definition/assignment of the variable sim. In recursive definitions, a "new" definition of a variable is obtained by manipulating an "older" version of that variable. Although computers can typically handle most cases of recursive definitions, because they store and manipulate variables in two different places, Maple has an issue with recursive definitions. A rule of thumb to avoid this issue: Do not define a variable recursively that has not yet been assigned to some object other than itself. For example, consider the following set of commands. > p ;
> q := 3;
> p := p + 1; Warning, recursive definition of name
Since p is not assigned to some object other than itself, this recursive assignment violates the rule of thumb, and Maple lets you know that it is a little worried about your actions. > q := q + 1;
Since q is assigned to an object other than itself, namely the number 3, Maple is not worried about this recursive assignment. Full evaluation (following q's pointer) of the expression on the right hand side of the assignment statement results in q being replaced with the value 3, then an addition occurs, and then lastly an assignment. No problem. > p^2; Error, too many levels of recursion > q^2;
Due to full evaluation, Maple evaluates the command p^2 as ((((...+1 )+1 )+1 )+1 )^2. Each time it sees the variable p, it follows its pointer and replaces p with the found value, then it executes full evaluation on the found value. In this case the found value is always p+1, and the next round of full evaluation always involves looking up the value of p again. Maple finds itself caught in a infinite loop. Situations arise in which you need to use a variable as itself, not as the object it represents. To do this use the suppression operator ( 'variable_name' ). For example, > 'distance' = 'rate' * 't';
Whereas > distance = rate * t;
The suppression operator inhibits full evaluation; it tells Maple not to follow the object's pointer. The suppression operator also works for reassigning a variable back to its own name. > rate;
> rate := 'rate';
> rate;
The unassign function also accomplishes this task. It has no output and takes as many arguments as you want to give it. > distance, t;
> unassign( 'distance', 't' ); > distance, t;
Use the restart function to clear memory of all objects created and/or assigned to variables since the beginning of a Maple session. The restart function also has no output. > restart; Now enter as command lines some of the variables that had values assigned to them earlier in this worksheet. Note: In the above examples the values assigned to rate, distance, and t included the dimensions of each of these variables for illustrative purposes. You may include dimensions in most calculations with Maple, and the few exceptions will be clear when they occur. However, many of the command lines displayed in this tutorial are rather long, and including the dimensions of each variable in every calculation would cause long command lines to grow even longer and more difficult to read. So, in the rest of this tutorial dimensions accompany all variables and constants in text discussions, but the variables and constants in Maple command lines do not contain their associated dimensions. The following two sets of commands look very much alike, with the second containing slight variations on the first. If you understand why the last line of Maple output from the first set differs from the last line of the second set, then you possess a good understanding of the concepts introduced in Maple Think. Hint: The answer has a lot to do with the exact steps involved in an assignment command, and with the process of full evaluation. The first set. > r := 2;
> circle_area := Pi*r^2;
> circle_area;
> r := 8;
> circle_area;
The second set. > r := 'r';
> circle_area := Pi*r^2;
> r := 2;
> circle_area;
> r := 8;
> circle_area;
If you do not see it right away, think about it and then check out an explanation. If you understand the little test, then you now have a very solid
understanding of some of the most basic and important aspects of how Maple operates.
From here on out this tutorial focuses on solving physics problems with Maple, and only
focuses on the details of Maple's reasoning processes when a lack of this knowledge might
cause confusion or mistakes. Physics Index Maple Index Problem Set Index
|