4.6 KiB
4.6 KiB
Zadanie 4.6
import numpy as np
from sympy import symbols, Matrix
from numpy.linalg import eig
A=np.matrix(QQ,5,3,[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 31])
print(A.transpose()*A)
print((A.transpose()*A)^(-1))
mm=(A.transpose()*A)^(-1)
mm=(A.transpose()*A)^(-1)*A.transpose()
print(mm)
b1=np.vector([-1,0,1,0,1])
mm1=mm*b1
print(mm1)
print((b1-A*mm1))
b2=np.vector([1,1,1,1,1])
mm2=mm*b2
print(mm2)
print((b2-A*mm2))
b2 in (m.transpose()).image()
[1;31m---------------------------------------------------------------------------[0m [1;31mNameError[0m Traceback (most recent call last) Cell [1;32mIn[1], line 5[0m [0;32m 2[0m [39mfrom[39;00m [39msympy[39;00m [39mimport[39;00m symbols, Matrix [0;32m 3[0m [39mfrom[39;00m [39mnumpy[39;00m[39m.[39;00m[39mlinalg[39;00m [39mimport[39;00m eig [1;32m----> 5[0m A[39m=[39mnp[39m.[39mmatrix(QQ,[39m5[39m,[39m3[39m,[[39m2[39m, [39m4[39m, [39m6[39m, [39m8[39m, [39m10[39m, [39m12[39m, [39m14[39m, [39m16[39m, [39m18[39m, [39m20[39m, [39m22[39m, [39m24[39m, [39m26[39m, [39m28[39m, [39m31[39m]) [0;32m 6[0m [39mprint[39m(A[39m.[39mtranspose()[39m*[39mA) [0;32m 7[0m [39mprint[39m((A[39m.[39mtranspose()[39m*[39mA)[39m^[39m([39m-[39m[39m1[39m)) [1;31mNameError[0m: name 'QQ' is not defined
Zadanie 4.7
zb1=[(1,1),(2,3),(4,5)]
zb2=[(1,1),(2,3),(3,4),(4,5),(5,7),(6,9)]
m1=matrix(3,2,[1,exp(1.0),1,exp(2.0),1,exp(4.0)])
m2=matrix(6,2,[1,exp(1.0),1,exp(2.0),1,exp(3.0),1,exp(4.0),1,exp(5.0),1,exp(6.0)])
a,b,t=var('a,b,t')
m1*vector([a,b])-vector([1,3,5])
m2*vector([a,b])-vector([1,3,4,5,7,9])
M1=m1.transpose()*m1
M1.det()
M2=m2.transpose()*m2
M2.det()
M1^(-1)*m1.transpose()*vector([1,3,5])
M2^(-1)*m2.transpose()*vector([1,3,4,5,7,9])
plot(1.64148598265947+ 0.0629860338045423*exp(t),(t,0,4))+sum([point(x) for x in zb1])
plot(3.10041190358990+ 0.0163320609303546*exp(t),(t,0,6))+sum([point(x) for x in zb2])
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))