Here is original Maple file:   demo.mws   (Maple won't accept this webpage as a valid input file.)

Sample Maple session: How to handle simple math/stats operations on data sequences in Maple
Math 2120 Fall 2004 Instructor: S.Sadov
Lab 11, Nov 25 2004

> 1+2+3; Direct summation

6

As told in class, make a guess about a possible keyword for a certain mathematical operation, type in the word, put the mouse
pointer on it, and click on Help/Help on <keyword>. If your guess was right, Maple will show the corresponding Help topic.
In the next line, I guessed the word "sum", found the help topic, and mimiced an example from the help page.

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

6

Now, I will try to find the sum of a sequence described as an array, avoiding direct summation.

> a:=[1,2,10,67]; Here I have defined the sequence.

a := [1, 2, 10, 67]

> a[3]; We can refer to individual members by index. Unlike in C/C++/Java, where the first element of an array has index 0,
here it has index 1.

10

> sum(a[i],i=1..3); To find the sum of first three elements of the sequence (1+2+10)

13

> sum(a); Unfortunately, this simplest form doesn't work.

Error, (in sum) expecting two arguments

> sum(i,i=1..n); Maple can also do indefinite (symbolic) summation

1/2*(n+1)^2-1/2*n-1/2

> simplify(%); Previous answer didn't have a familiar standard form, so I force Maple to transform it.
The % sign means immedaitely preceding result (the blue formula above).

1/2*n^2+1/2*n

> factor(%); Finally, by this we obtain the familiar form:

1/2*n*(n+1)

In the next few lines, I am using Maple to find the mean value and Standard Deviation of a given sequence.

> a:=[1,2,3]; Re-define the array a to make it easier to check calculations by hand.

a := [1, 2, 3]

Examples (Copied from Help on "mean")

> with(stats):

What is the average of the numbers 3 and 5

> describe[mean]([3,5]);

4

Comment (S.S) Here stats is a package; (analog of library in C/C++, like <math.h>).
"
with " is a keyword, Maple's analog of #include.
"
describe " is a collection of procedures, analog of C++ class, and describe[mean] is an analog of a filename with prefix.

> describe[mean](a);

2

> (1+2+3)/3; check the mean by direct calculation

2

> min(1,2,3); (Maple has many standard mathematical functions in a familiar form.)

1

> max(1,2,3);

3

> min(a); Tricky: this doesn't work! See next comment.

Error, (in simpl/min) arguments must be of type algebraic

> min([1,2,3]); Equivalent to the previous line. Maple understands that [1,2,3] is not a number, but some aggregate type.
So it refuses to calculate a numeric function of it.

Error, (in simpl/min) arguments must be of type algebraic

> op(a); Workaround: the operator op removes brackets around the list of sequence members

1, 2, 3

> op([1,2,3]);

1, 2, 3

> min(op(a)); This works! It's equivalent to min(1,2,3) , and not to min( [1,2,3] )

1

> max(op(a)); Similarly, we find maximum of the sequence.

3

> standarddeviation In many "universal" systems, the first reasonable guess about a keyword should be the full form
of the term. I typed "standarddeviation" without much hope that Help will find it, but

surprisingly there is a function with this very name in Maple! If my first guess failed,
I was going to try "stdev", "deviation", "standard", "statistics", and variations.

> describe[standarddeviation](a);

1/3*sqrt(6)

> evalf(%); Decimal answer can be obtained from "exact" (symbolic) answer by evalf

.8164965809

> x:=(1-2)^2+(2-2)^2+(3-2)^2; Preparing to check the value using definition of st.dev. (see Asst.5)

x := 2

> sqrt(x/3); Here it goes. Same value!

1/3*sqrt(6)

You can use Maple to verify means and deviations computed by your assignment program.