CS323: Numerical Analysis and Computing Homework #1

Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due

CS323: Numerical Analysis and Computing Homework #1

For all programming assignments, please turn in your code along with your solution. Submissions should be made on Sakai.

Problem 1

What are the approximate absolute and relative errors in approximating π by each of the following quantities?

  1. 33
  2. 3.143.14
  3. 22/722/7

You can use either single or double precision for your computations. Please state your choice.

Problem 2

In either single or double precision, is the machine epsilon the smallest number ε that can be stored on the computer, such that 1+ε≠11+�≠1? Justify your answer.

Problem 3

Write a program to compute the absolute and relative errors in Stirling’s approximation

n!≈2πn−−−√(n/e)n�!≈2��(�/�)�

for n=1,2,…,10�=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?

Problem 4

Let x∈Rn�∈�� be an n-dimensional vector. Show that ∥x∥2‖�‖2 and ∥x∥∞‖�‖∞ are equivalent.

Problem 5

Consider the image blurring example discussed in class, and suppose we denote the matrix of grayscale pixel values as I. Modify the Python script blur.py to use the following operation instead:

I[i,j]=+116(8⋅I[i,j]+I[i−1,j]+I[i−1,j−1]+I[i−1,j+1]+I[i,j−1]I[i,j+1]+I[i+1,j]+I[i+1,j−1]+I[i+1,j+1])�[�,�]=116(8⋅�[�,�]+�[�−1,�]+�[�−1,�−1]+�[�−1,�+1]+�[�,�−1]+�[�,�+1]+�[�+1,�]+�[�+1,�−1]+�[�+1,�+1])

Compute the blurred image after 2020 iterations of this modified scheme.

发表评论

电子邮件地址不会被公开。 必填项已用*标注