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 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 D 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 where i and independently run from to :
err
and return the smallest error when
d Use argmin and un ravelindex to find the location of the minimum in your D array, and with this find the values of the numerator and the denominator. Example usage from numpy manual:
ind npunravelindexnpargmin axisNone a shape
e Write down the best approximations to z when n n and n
f Using the series formula provided in lectures:
to obtain a value for with ranging from to 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
