Mat/Wrzodak_Koszarek_Zadania.ipynb
2023-06-14 21:20:54 +02:00

4.0 KiB
Raw Blame History

Zadanie 4.6

A=matrix(QQ,5,3,[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 31])
print('A =')
print(A, '\n')

print('b =')
b=vector(QQ,[-1,0,1,0,1])
print(b, '\n')

print('A^T * A =')
print(A.transpose()*A, '\n')
print('Macierz A^T*A jest kwadratowa, więc rozwiązanie istnieje\n')

u=(A.transpose()*A)^(-1)*A.transpose()*b
print('u = (A^T * A)^-1 * A^T * b =')
print(u, '\n')


print('b - A * u = ')
print(b - A * u, '\n')
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[1], line 5
      2 from sympy import symbols, Matrix
      3 from numpy.linalg import eig
----> 5 A=np.matrix(QQ,5,3,[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 31])
      6 print(A.transpose()*A)
      7 print((A.transpose()*A)^(-1))

NameError: name 'QQ' is not defined

Zadanie 4.7

zbior=[(1,1),(2,3),(4,5)]
print('zbior punktów = ', zbior)
m=matrix(3,2,[1,exp(1.0),1,exp(2.0),1,exp(4.0)])

a,b,t=var('a,b,t')

m*vector([a,b])-vector([1,3,5])

print('\n (m^T * m)^-1 * m^T * vector =')
z = (m.transpose()*m)^(-1)*m.transpose()*vector([1,3,5])
print(z)

plot(z[0] +z[1]*exp(t),(t,0,4))+sum([point(x) for x in zbior])

Zadanie 4.9

m=matrix(3,3,[1,1,0,1,2,2,0,2,3])

eigenvalues = np.m.eigvals(matrix)

eigen=m.right_eigenvectors()
e1=eigen[0][1][0]
e2=eigen[1][1][0]
print(e1.dot_product(e2))
e3=eigen[2][1][0]
print(e3.dot_product(e1))
print(e2.dot_product(e3))