Starting from:
$30

$24

Programming Assignment 1 Solution




Important




Sakai submission only.




Please turn in your code along with your solution. Use Python or Matlab for your implementation. No late submission will be accepted.




Follow the collaboration policy described in the syllabus.







1. (5 points) Write a program to compute the absolute and relative errors in Stir-ling’s approximation

n! p2 n ne n







for 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?




(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

















































































1

More products