Question: a ) Create an array of integers running from 1 through to n using a numpy function, and print the result. You choose the value

a) Create an array of integers running from 1 through to n using a numpy function, and print the result. You choose the value of n.
b) Create two n \times n matrices: one in which each row is your array of integers created in part a); the other where each column is your array. Name one 2D array numerator and the other denominator. Note, the numpy function tile may be helpful here. Consider also the transpose operation.
c) Set up an error matrix to compare fractions ij(where i and j independently run from 1 to n):
err=|ij-|
and return the smallest error when n=100.
d) Use argmin and un ravel_index to find the location of the minimum in your 2D array, and with this find the values of the numerator and the denominator. Example usage from numpy manual:
ind = np.unravel_index(np.argmin(a, axis=None), a. shape)
e) Write down the best approximations to z when n =100, n =1000 and n =10000.
f) Using the series formula provided in lectures:
=(8(1+132+152+172+...+1n2+...))12
to obtain a value for with n ranging from 1 to 101 and plot these values versus the number of terms in the series. Include on your plot a horizontal
dashed line showing the value of given by your best fractional approximation in part e).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!