Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello. I have this python code (bellow) and I need to calculate, still in python

ID: 3855942 • Letter: H

Question

Hello. I have this python code (bellow) and I need to calculate, still in python, the condition number of V and U and the number of digits that will be lost obtaining the coefficients of the corresponding polynomials.

import random import numpy as np k = 2 # number of equally spaced elements space = 0.3 #value of the spacing between equally spaced elements x = [i"space for i in range(k)] #equally spaced xk elements for i in range(k,6): x.append(-1l+random.random0 ) #randomly spaced rest of the elements y = [np.exp(i) for i imx] #np.sinO, np.cos(), np.expl, np.log0, np.log100, np.logo can be used V = np.vander(x) #constructs vandermonde matrix of the vector X. U = np.vander(y) #constructs vandermonde matrix of the vector 'y.

Explanation / Answer

#Importing libraries. The same will be used throughout the article. import numpy as np import pandas as pd import random import matplotlib.pyplot as plt %matplotlib inline from matplotlib.pylab import rcParams rcParams['figure.figsize'] = 12, 10 #Define input array with angles from 60deg to 300deg converted to radians x = np.array([i*np.pi/180 for i in range(60,300,4)]) np.random.seed(10) #Setting seed for reproducability y = np.sin(x) + np.random.normal(0,0.15,len(x)) data = pd.DataFrame(np.column_stack([x,y]),columns=['x','y']) plt.plot(data['x'],data['y'],'.')