Question: Do task 5 , i also provided an example code of another problem here below: # import numpy module import numpy as np import math

Do task 5, i also provided an example code of another problem here below:
# import numpy module
import numpy as np
import math
def g0(x):
return np.log(x)
def g1(x):
return np.cos(x)
def g2(x):
return np.exp(x)
x = np.array([[0.24],[0.65],[0.95],[1.24],[1.73],[2.01],[2.23],[2.52],[2.77],[2.99]])
# create matrix A and vector y of the exervise on Slide 37 of Topic 3.3
A = np.zeros((10,3))
A[:,0]= g0(x).ravel() # numpy.ravel() functions returns 1d array
A[:,1]= g1(x).ravel()
A[:,2]= g2(x).ravel()
y = np.array([[0.23],[-0.26],[-1.10],[-0.45],[0.27],[0.10],[-0.29],[0.24],[0.56],[1.00]])
# compute A'A
ATA = np.matmul(np.transpose(A), A)
# compute inverse of A'A
inv_ATA = np.linalg.inv(ATA)
# compute A'y
ATy = np.matmul(np.transpose(A), y)
# compute z = inverse(A'A)*A'y
z = np.matmul(inv_ATA, ATy)
print(z)
Do task 5 , i also provided an example code of

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 Programming Questions!