Starting from:

$25

Numerical Analysis and Computing A1

Numerical Analysis and Computing
Programming Assignment
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 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 affected 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 finding 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