**This is an old revision of the document!** ----
====== Math 445 lecture 10: more ''for'' ====== The following example problem spells out in great detail how to translate a formula in summation notation into a Matlab ''for'' loop. Recall this classic formula for $\pi^2/6$ due to Euler: \begin{eqnarray*} \frac{\pi^2}{6} = \sum_{n=1}^{\infty} \frac{1}{n^2} = 1 + \frac{1}{2^2} + \frac{1}{3^2} + \frac{1}{4^2} + \frac{1}{5^2} + \ldots \end{eqnarray*} We can sum the first N terms of this series with the Matlab one-liner <code matlab> N=100; sum((1:N).^(-2)) </code> Rewrite this with summation notation \begin{eqnarray*} \frac{\pi^2}{6} = \sum_{n=1}^{\infty} \frac{1}{n^2} \end{eqnarray*} The Nth partial sum $P_N$ of the infinite series is \begin{eqnarray*} P_N = \sum_{n=1}^{N} \frac{1}{n^2} \end{eqnarray*} Then $\pi^2/6 = \lim_{N \rightarrow \infty} P_N$. Now