Numerical Analysis and Computing
Programming Assignment 1
1. (5 points) Write a program to compute the absolute and relative errors in Stirling’s approximation n! ≈ √2πn?n e?nfor n = 1,2,…,10. Does the absolute error grow or shrink as n increases? Does the relative error grow or shrink as n increases? Is the result aﬀected when using double precision instead of single precision?
2. (15 points) Implement the bisection, Newton, and secant methods for solving nonlinear equations in one variable, and test your implementations by ﬁnding at least one root for each of the following equations. (a) f(x) = ex −sin(x)−2; ε = 10−10 (b) f(x) = x2 −4x + 4−ln(x) = 0; ε = 10−10