next up previous
Next: About this document ... Up: Introduction Previous: Programming

Homework

Please submit a worksheet (or worksheets) for the following. These are due by Monday, April 29th.
  1. Write a procedure to compute a partial sum of an infinite series. We are considering

    \begin{displaymath}
\sum_{n=1}^N a_n
\end{displaymath}

    with partial sum given by

    \begin{displaymath}
s_n=\sum_{n=1}^N a_n.
\end{displaymath}

    Your procedure should have as arguments 1) the function, or expression, for $a_n$, and 2) the number of terms $N$.

  2. Write a procedure to determine the arithmetic-geometric mean of two numbers. Let $0<a<b$, set $a_1=\sqrt{ab}$ and $b_1=\frac{a+b}{2}$. Then define $a_{n+1}=\sqrt{a_nb_n}$ and $b_{n+1}=\frac{a_n+b_n}{2}$. Let

    \begin{displaymath}
\bar{(a,b)}=\lim_{n \to \infty} a_n =\lim_{n \to \infty} b_n.
\end{displaymath}

    This is the arithmetic-geometric mean of $a$ and $b$. Your program should input $a$, $b$, and $t$, a tolerance. You may wish to use the while command, you may see the help on this, or
    http://www.maths.uq.edu.au/~mrb/tutors/mapleprog.html
    
    for a nice use of while in a program to apply Newton's method.

  3. Study the program to generate the Fibonacci sequence.
    > nums := [seq(i,i=1..20)];
    > fibnums := map(fibonacci, nums);
    > plot( zip( (x,y)->[x,y], nums, fibnums) );
    
    taken from http://www.maths.uq.edu.au/~mrb/tutors/mapleprog.html . Do the following exercise listed there:
    1. Write a function M-file in Matlab (and include this with your homework) which works out Fibonacci numbers using the recursive definition we used in Maple.
    2. The recursive definition is elegant but hopelessly inefficient - even finding the 25th number takes a long time. Write a faster Fibonacci function in Maple, similar to fact1. You should be able to find the 2000th Fibonacci number in a second.
    3. Use ?stats[fit] to learn about Maple's fitting abilities. With your larger Fibonacci numbers, fit a straight line to the logarithms and find an approximate formula for the nth number. Compare your formula with some further values, such as the 10000th number.


next up previous
Next: About this document ... Up: Introduction Previous: Programming
Timothy J Flaherty 2002-04-22