## Description

Submit your assignment including your code through myCourses.

- (5 points) Write a C program to find the smallest positive integer
*x*such that the floating point expression

1 âŠ˜ (1 âŠ˜ *x*)

is not equal to *x*, using single precision. Make sure that the variable *x *has type float, and assign the value of the expression 1 âŠ˜ *x *to a float variable before doing the other division operation. Repeat with double precision.

- (5 points) A calculus student was asked to determine lim
*n*_{â†’âˆž }*x**n*, where*x**n*= (100)^{n}*/n*!. He wrote a C program in single precision to evaluate*x**n*by using

*x*_{1 }= 100*,Â Â Â Â Â Â x**n *= 100*x**n*_{âˆ’1}*/n,Â Â Â Â Â Â Â Â Â n *= 2*,*3*,…,*70*.*

The numbers printed became ever larger and finally became âˆž. So the student concluded that lim*n*_{â†’âˆž }*x**n *= âˆž. Please write a C program in single precision to verify the studentâ€™s observation. The studentâ€™s conclusion is actually wrong. What is the problem with his program?

**Bonus **(2 points): Can you rewrite a C program to evaluate *x**n *so that you can make a right conclusion about lim*n*_{â†’âˆž }*x**n *?

- (10 points) In 250 B.C.E., the Greek mathematician Archimedes estimated the number
*Ï€*as follows. He looked as a circle with diameter 1, hence circumference*Ï€*. Inside the circle he inscribed a square; see the following figure. The perimeter of the square is smaller than the

circumference of the circle, and so it is a lower bound for *Ï€*. Archimedes then considered an inscribed octagon, 16-gon, etc., each time doubling the number of sides of the inscribed polygon, and producing ever better estimates for *Ï€*. Using 96-sided inscribed and circumscribed polygons, he was able to show that 223*/*71 *< Ï€ < *22*/*7. There is a recursive formula for these estimates. Let *p**n *be the perimeter of the inscribed polygon with 2* ^{n }*sides. Then

*p*

_{2 }is the perimeter of the inscribed square,

*p*

_{2 }= 2âˆš2. In general

*.*

- Write a program to compute
*p**n*for*n*= 3*,*4*,…,*35 in**double precision**by using the formula. Explain your results. - Improve the formula to avoid the difficulty with it. Compute
*p**n*for*n*= 3*,*4*,…,*35 by your new formula in**double precision**. Comment on your results.

Note: Your program should not do unnecessary computation.