next up previous
Next: About this document ...

ESC 251 HW 32 Due: Nov. 27

(15 pts) A well known formula is the binomial expansion formula for the sum of 2 values x and y raised to the power n.
(x + y)^n = \sum_{i=0}^n
\matrix{c} n \\ i \endmatrix x^i\,y^{n-i},
\end{displaymath} (1)

where $\displaystyle{ \matrix{c} n \\ i \endmatrix}$ is the usual binomial coefficient.

Write a F90 function that will compute the right hand side of Equation (1) above given the values of x, y and n. This function should make use of the bincoeff function that your wrote in Homework 31.

Next, write a main program that will evaluate both sides of Equation (1) and compute the relative error between the two expressions.

Test your program for x = 1.3, y = 2.4 and n = 6. What is the relative error in this case?
Run your program for x = 1.0000001, y = -1.0000002 and n = 20. What is the relative error for this case (use the left hand side of Equation (1) as the exact answer)? Is the relative error for this case significantly different than for part a)? If so, why?