Details for 4541_topten.mw

Download file: 4541_topten.mw (View Live Worksheet on MapleNet)
Uploaded by Robert Israel(Maple Rating 4 1458) (View other files uploaded by Robert Israel)

The HTML version of this file is shown below. To use the contents of this file in a posting, click here to get the source code


The Top 10 Maple Errors

10.  The exponential function is exp.

  To express Maple Equation, you must use the exp function.

> exp(x);

Maple Equation

> evalf(exp(1));

Maple Equation

It's not e^x, because e is just another name to Maple.  

> e^x;

Maple Equation

> evalf(e^1);

Maple Equation

And it's not exp^x.

9.   Omitting * for multiplication

Maple complains if you try (in 1D Maple input)

> a b;

Error, missing operator or `;`

More of a problem, because Maple doesn't complain, is

> ab;

Maple Equation

Maple thinks this is a variable named ab.

> x(1+x);

Maple Equation

And here it thinks the first x is a function that you're evaluating at 1+x.

In 2D math input, a space is considered as implied multiplication, so this is OK:

> Maple Equation

Maple Equation

However, leaving out the space is still bad: Maple thinks this is the variable ab:

> Maple Equation

Maple Equation

... and that this is the function x evaluated at 1+x:

> Maple Equation

Maple Equation

Moreover, if you do want a function, in 2D math input you'd better not put a space between the function name and the left parenthesis, because this is interpreted as sin * x:

> Maple Equation

Maple Equation

8.  Premature evaluation

Some functions only work with numerical arguments.  If f is such a function, you must avoid using f(x) (e.g. in a plot command) where x is a symbolic variable.  For example,

> f:= x -> add(j, j=0 .. floor(x));
plot(f(x),x = 0 .. 5);

Maple Equation

Error, (in f) unable to execute add

In this case, you can get around it by using

> plot(f, 0..5);

Maple Plot

7.  Those annoying brackets

Every (, [ or needs a matching ), ] or .  If you miss one, Maple complains.  For example,

> pointplot([seq([j,f(j)],j=1..10]);

Error, `]` unexpected

One way to help with this is to put in the ), ] or at the same time as the (,[ or , rather than writing the whole command from left to right.

>

6.  Spelling counts

Maple does not forgive spelling errors.  Get one little letter in a name wrong and Maple thinks it's something completely different, probably an undefined variable or function.  A common clue that something is wrong is that the name appears in the output.

> wiht(plots);

Maple Equation

"Spelling" includes case: Maple is case-sensitive, so it treats x and X as completely different.
Unfortunately, there is no consistent policy on when to use upper and lower case.

5.   To float or not to float

Maple can use  either exact arithmetic, which writes rational numbers as fractions and irrational numbers  as symbolic expressions such as Maple Equation, or floating-point arithmetic, which writes numbers such as 2.506628274 using a certain number of decimal places.  It is often important to decide which of these is more appropriate in a particular problem.  Often there is a tradeoff to consider: exact arithmetic avoids any problems of roundoff error, but can be much slower than floating-point and may result in very complicated expressions.  

In a midterm last year one student wanted to find Maple Equation.  If she had used the exact value for J, it would have worked.  Unfortunately she used evalf to get J, and Maple's result was undefined.  Here's a simpler version of that:

> limit(n*(1/3 - 1/(3+1/n)),n=infinity);

Maple Equation

> limit(n*(evalf(1/3) - 1/(3+1/n)),n=infinity);

Maple Equation

4.  Forgotten "with"

If a command is in a certain package, you must load the package using with or refer to the command using the package name (e.g. orthopoly[T]).  Otherwise Maple doesn't know the command.

> implicitplot(x^2-y^2,x=-1..1,y=-1..1);

Maple Equation

3.  Variable has been assigned a value

If you want to use something as a symbolic variable, but that variable was already assigned a value, you'll have trouble.  Maple sometimes tells you what went wrong.  For example:

> x := 3;

Maple Equation

> sum(x,x=1..3);

Error, (in sum) summation variable previously assigned, second argument evaluates to 3 = 1 .. 3

But sometimes there's no obvious clue.

> solve(x^2=4);

To see what's going on here you'd have to look at the equation you gave to solve.

> x^2=4;

Maple Equation

To use x as a variable you'd need to unassign it.

> x:= 'x';

Maple Equation

> solve(x^2=4);

Maple Equation

2.  Worksheet is out of order

Worksheets are meant to be read (and executed by Maple) from top to bottom.
Unfortunately they are not always produced in the same order.  When you go back
and make changes, it's very easy to produce a worksheet where a certain command
won't work properly without a later one.  For example:

> J:=Int((x^(1/4))/(x^2+1), x=0..1);

> Rule[change, x = s^4](%);

> with(Student[Calculus1]):

1.  Functions versus expressions

This defines an expression:

> a := x^2;

Maple Equation

And this defines a function:

> f := x -> x^2;

Maple Equation

It's important to know which you have, and how to use them.  For example, you might say

> f(t);

Maple Equation

but you don't want

> a(t);

Maple Equation

Or in plotting, this would be good:

> plot(a, x=-1..1);

Maple Plot

But not this:

> plot(f, x=-1..1);

Error, (in plot) invalid plotting of procedures, perhaps you mean plot(f, -1 .. 1)

You could use

> plot(f, -1..1);

Maple Plot

but not

> plot(a,-1..1);

Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

Error, empty plot

This post was generated using the MaplePrimes File Manager

View 4541_topten.mw on MapleNet or Download 4541_topten.mw
View file details


HTML Source Code

Copy this code into any posting to insert this file into a posting on MaplePrimes

IMPORTANT INFORMATION

When pasting this code into a post on MaplePrimes, make sure that you choose the Worksheet HTML input format

Download Link Code

Copy this code into any posting to share this file with other users

}