logowanie

matematyka » forum » forum zadaniowe - uczelnie wyższe » zadanie

Algebra, zadanie nr 6003

ostatnie wiadomości  |  regulamin  |  latex

AutorZadanie / Rozwiązanie

monikson
postów: 10
2019-03-29 12:08:10




chiacynt
postów: 749
2019-03-30 11:51:38

Octave


>> clear
>> A=[1,2,-1,3;3,-2,0,1;3,1,-2,3;2,-1,1,2]
A =

1 2 -1 3
3 -2 0 1
3 1 -2 3
2 -1 1 2

>> a=[A,eye(4)]
a =

1 2 -1 3 1 0 0 0
3 -2 0 1 0 1 0 0
3 1 -2 3 0 0 1 0
2 -1 1 2 0 0 0 1

>> a(1,:)=a(1,:)/a(1,1)
a =

1 2 -1 3 1 0 0 0
3 -2 0 1 0 1 0 0
3 1 -2 3 0 0 1 0
2 -1 1 2 0 0 0 1

>> for i = 2:4 a(i,:)=a(i,:)-a(i,1)*a(1,:);end;a
a =

1 2 -1 3 1 0 0 0
0 -8 3 -8 -3 1 0 0
0 -5 1 -6 -3 0 1 0
0 -5 3 -4 -2 0 0 1

>> a(2,:)=a(2,:)/a(2,2);a
a =

1.00000 2.00000 -1.00000 3.00000 1.00000 0.00000 0.00000 0.00000
-0.00000 1.00000 -0.37500 1.00000 0.37500 -0.12500 -0.00000 -0.00000
0.00000 -5.00000 1.00000 -6.00000 -3.00000 0.00000 1.00000 0.00000
0.00000 -5.00000 3.00000 -4.00000 -2.00000 0.00000 0.00000 1.00000

>> for i=1:4; if i~=2, a(i,:)=a(i,:)-a(i,2)*a(2,:);end;
end;a
a =

1.00000 0.00000 -0.25000 1.00000 0.25000 0.25000 0.00000 0.00000
-0.00000 1.00000 -0.37500 1.00000 0.37500 -0.12500 -0.00000 -0.00000
0.00000 0.00000 -0.87500 -1.00000 -1.12500 -0.62500 1.00000 0.00000
0.00000 0.00000 1.12500 1.00000 -0.12500 -0.62500 0.00000 1.00000

>> a(3,:)=a(3,:)/a(3,3)
a =

1.00000 0.00000 -0.25000 1.00000 0.25000 0.25000 0.00000 0.00000
-0.00000 1.00000 -0.37500 1.00000 0.37500 -0.12500 -0.00000 -0.00000
-0.00000 -0.00000 1.00000 1.14286 1.28571 0.71429 -1.14286 -0.00000
0.00000 0.00000 1.12500 1.00000 -0.12500 -0.62500 0.00000 1.00000

>> for i = 1:4; if i~=3,a(i,:)=a(i,:)-a(i,3)*a(3,:);end;
end;a
a =

1.00000 0.00000 0.00000 1.28571 0.57143 0.42857 -0.28571 0.00000
-0.00000 1.00000 0.00000 1.42857 0.85714 0.14286 -0.42857 -0.00000
-0.00000 -0.00000 1.00000 1.14286 1.28571 0.71429 -1.14286 -0.00000
0.00000 0.00000 0.00000 -0.28571 -1.57143 -1.42857 1.28571 1.00000

>> a(4,:)=a(4,:)/a(4,4)
a =

1.00000 0.00000 0.00000 1.28571 0.57143 0.42857 -0.28571 0.00000
0.00000 1.00000 0.00000 1.42857 0.85714 0.14286 -0.42857 0.00000
-0.00000 -0.00000 1.00000 1.14286 1.28571 0.71429 -1.14286 -0.00000
-0.00000 -0.00000 -0.00000 1.00000 5.50000 5.00000 -4.50000 -3.50000

>> for i =1:4; if i~= 4,a(i,:)=a(i,:)-a(i,4)*a(4,:);end;
end;a
a =

1.00000 0.00000 0.00000 0.00000 -6.50000 -6.00000 5.50000 4.50000
0.00000 1.00000 0.00000 0.00000 -7.00000 -7.00000 6.00000 5.00000
0.00000 0.00000 1.00000 0.00000 -5.00000 -5.00000 4.00000 4.00000
-0.00000 -0.00000 -0.00000 1.00000 5.50000 5.00000 -4.50000 -3.50000

>> A_odwr = a(:,5:8)
A_odwr =

-6.5000 -6.0000 5.5000 4.5000
-7.0000 -7.0000 6.0000 5.0000
-5.0000 -5.0000 4.0000 4.0000
5.5000 5.0000 -4.5000 -3.5000

Sprawdzenie:
>> A*A_odwr
ans =

1.00000 0.00000 0.00000 0.00000
0.00000 1.00000 0.00000 -0.00000
-0.00000 0.00000 1.00000 -0.00000
0.00000 0.00000 0.00000 1.00000


strony: 1

Prawo do pisania przysługuje tylko zalogowanym użytkownikom. Zaloguj się lub zarejestruj

© 2019 Mariusz Śliwiński      o serwisie | kontakt   drukuj