7.7 KiB
7.7 KiB
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')
[1;31m---------------------------------------------------------------------------[0m [1;31mNameError[0m Traceback (most recent call last) Cell [1;32mIn[1], line 1[0m [1;32m----> 1[0m A[38;5;241m=[39m[43mmatrix[49m(QQ,[38;5;241m5[39m,[38;5;241m3[39m,[[38;5;241m2[39m, [38;5;241m4[39m, [38;5;241m6[39m, [38;5;241m8[39m, [38;5;241m10[39m, [38;5;241m12[39m, [38;5;241m14[39m, [38;5;241m16[39m, [38;5;241m18[39m, [38;5;241m20[39m, [38;5;241m22[39m, [38;5;241m24[39m, [38;5;241m26[39m, [38;5;241m28[39m, [38;5;241m31[39m]) [0;32m 2[0m [38;5;28mprint[39m([38;5;124m'[39m[38;5;124mA =[39m[38;5;124m'[39m) [0;32m 3[0m [38;5;28mprint[39m(A, [38;5;124m'[39m[38;5;130;01m\n[39;00m[38;5;124m'[39m) [1;31mNameError[0m: name 'matrix' is not defined
Zadanie 6
Rozwiąż układ równań $Ax=b$ metodą przybliżoną, gdzie
$$A=\left(\begin{array}{rrr} 2 & 4 & 6 \\ 8 & 10 & 12 \\ 14 & 16 & 18 \\ 20 & 22 & 24 \\ 26 & 28 & 31 \end{array}\right)$$
oraz $b=(-1,0,1,0,1)$.
Zadanie 4.7
Zadanie 7
Przybliż funkcją $f(t)=a+be^{t}$ zbiór punktów $(1,1)$, $(2,3)$, $(4,5)$ metodą z zadania 6.
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])
zbior punktów = [(1, 1), (2, 3), (4, 5)]
[1;31m---------------------------------------------------------------------------[0m [1;31mNameError[0m Traceback (most recent call last) Cell [1;32mIn[2], line 3[0m [0;32m 1[0m zbior[38;5;241m=[39m[([38;5;241m1[39m,[38;5;241m1[39m),([38;5;241m2[39m,[38;5;241m3[39m),([38;5;241m4[39m,[38;5;241m5[39m)] [0;32m 2[0m [38;5;28mprint[39m([38;5;124m'[39m[38;5;124mzbior punktów = [39m[38;5;124m'[39m, zbior) [1;32m----> 3[0m m[38;5;241m=[39m[43mmatrix[49m([38;5;241m3[39m,[38;5;241m2[39m,[[38;5;241m1[39m,exp([38;5;241m1.0[39m),[38;5;241m1[39m,exp([38;5;241m2.0[39m),[38;5;241m1[39m,exp([38;5;241m4.0[39m)]) [0;32m 5[0m a,b,t[38;5;241m=[39mvar([38;5;124m'[39m[38;5;124ma,b,t[39m[38;5;124m'[39m) [0;32m 7[0m m[38;5;241m*[39mvector([a,b])[38;5;241m-[39mvector([[38;5;241m1[39m,[38;5;241m3[39m,[38;5;241m5[39m]) [1;31mNameError[0m: name 'matrix' is not defined
Zadanie 4.9
Zadanie 9
Znajdź bazę ortonormalnych wektorów własnych dla macierzy
$$\left(\begin{array}{rrr} 1 & 1 & 0 \\ 1 & 2 & 2 \\ 0 & 2 & 3 \end{array}\right)$$
m=matrix(3,3,[1,1,0,1,2,2,0,2,3])
#wartosci wlasne
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))
#znormalizuj wektor wlasny
#czy wektory wlasne sa ortogonalne?
#postac ortonormalna i normalizacja
[1;31m---------------------------------------------------------------------------[0m [1;31mNameError[0m Traceback (most recent call last) Cell [1;32mIn[3], line 1[0m [1;32m----> 1[0m m[38;5;241m=[39m[43mmatrix[49m([38;5;241m3[39m,[38;5;241m3[39m,[[38;5;241m1[39m,[38;5;241m1[39m,[38;5;241m0[39m,[38;5;241m1[39m,[38;5;241m2[39m,[38;5;241m2[39m,[38;5;241m0[39m,[38;5;241m2[39m,[38;5;241m3[39m]) [0;32m 3[0m [38;5;66;03m#wartosci wlasne[39;00m [0;32m 4[0m eigenvalues [38;5;241m=[39m np[38;5;241m.[39mm[38;5;241m.[39meigvals(matrix) [1;31mNameError[0m: name 'matrix' is not defined