Part D --- Using iteration to create functions (10 minutes)

Let's look at some graphs (a good use for iteration). Here are some closely related functions:

> f2 := x -> Pi/2 - sin(x) - sin(2*x) / 2;
f3 := x -> Pi/2 - sin(x) - sin(2*x) / 2 - sin(3*x) / 3;
f6 := x -> Pi/2 - sin(x)
- sin(2*x) / 2
- sin(3*x) / 3
- sin(4*x) / 4
- sin(5*x) / 5
- sin(6*x) / 6;

Note that the above are Maple functions (they use the arrow notation).
Let's plot all three functions in a single graph (colored red, blue and green, respectively):

> plot( [f2(x), f3(x), f6(x)], x = 0 .. 2*Pi, color = [red, blue, green] );

Exercise (do now, but not to turn in): define f8 (use copy-and-paste from f6 !!!)
and plot it along with the previous three functions (copy-and-paste again!). Can you see a pattern emerging?

>

Can you see the trend? Wht do you think will happen as we add more and more terms? One thing is certain, we do not want to keep adding in extra terms by typing each one in individually! What if we wanted to plot f30 ? Or f76 ? Let's use the add command to help us with f10 :

> f10 := x -> Pi/2 - add( sin(k*x) / k, k = 1 .. 10 );

Don't worry about the warning message: we'll learn more about that soon enough.
We can evaluate
f10 at any particular value:

> f10( 0.5 );
f10( 1.2 );
f10( Pi );
f10( x );


and we can plot
f10 :

> plot( f10(x), x = 0 .. 2*Pi );

Exercise (do now, but not to turn in): define f88 (using add, of course!) and plot it from 0 to [Maple Math] :

>

>

Whoa, this is cool! Isn't it interesting what happens to the sum of the sine functions?!