In this assignment we are going to start using functions more precisely. Maple has two ways of representing functions. There is a one line notation that uses an arrow (some of you have started using this in your assignments) and there is a second way that is good for representing functions that take more than one line called a procedure. In this assignment we will consider lists of elements and functions on those lists.

Method 1 for creating a function:

Example:

Then this is how you would use this function:

y^2

> f(7);

49

> [seq(f(i),i=0..10)];

[0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

This method for creating a function is good only if your function can be expressed as a single command. If you want to make a function that takes several steps or several Maple commands, then you will need to make a 'procedure' or make a bunch of smaller functions which you combine. We will look more closely at procedures in our next assignments. In this assignment, we will will work with one line functions and the arrow

We will also work a command which can be used to create a sequence in Maple called

For instance,

makes a list of values of

In general we will see this command used as

Understand what the following commands do by seeing what Maple returns, using the help functions, and by experimenting by changing the commands around so that you understand what they do. The command

In the following two examples the function> S:={ seq( 3*r mod 8, r=1..7 )};

> L:=[ seq( 3*r mod 8, r=1..7 )];

> N:=seq( 3*r mod 8, r=1..7 );

> f:=(a,b,n)->a*b mod n;

> L:=[seq(f(3,r,8), r=1..7)];

> L:=[seq(f(5,r,8), r=1..7)];

> M:=[seq([seq(f(r,s,8),r=1..7)],s=1..7)];

> M:=[seq([seq(f(r,s,11),r=1..10)],s=1..10)];

> g:=L->[seq(L[-i], i=1..nops(L))];

> g([1,2,3,4,5,6]);

> g(6); # should be an error

> g(g([1,2,3,4,5,6]));

> combinat[partition](5);

> g(combinat[partition](5));

> map(g, combinat[partition](5));

> h:=n->n mod 2=0; h(5); h(6);

> map( h, [1,2,3,4,5] );

> convert( map(h, [1,2,3,4,5]), `and`);

> convert( map(h, [1,2,3,4,5]), `or`);

> convert( map(h, [1,3,5,7]), `or`);

> convert( map(h, [2,4,6,8]), `and`);

> count:=(f,L)->nops(select(f, L));

> count(h,[1,2,3,4,5,6,7,9,11,13,15]);

Write a function called

* Write a function

* Write a function

* Write a function which

Calculate the number of odd partitions of $n$ for $n$ between 1 and 15. Now write a function

You should open up a new worksheet and start from scratch. You will have to save your work in a file and upload that file on to the course moodle. Your solution should be a sequence of commands where it is easy to change the input string and after you execute the sequence of commands you should have the correct output string. Please add documentation to your worksheet to explain how it works. Just a few sentences is sufficient, but imagine that you were opening up the worksheet for the first time and wanted to know what it did. You will be marked down if what you write is not clear and coherent.

You should finish your assignment before class Wednesday October 17 by 11:59pm. Assignments submitted after this date will be assessed a penalty of 10% per day.