SHARE
TWEET

4x4 Gauss Solution

royryando Jul 31st, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. A=input("Enter the element of matrix "); //should be [1,6,1,-1;0,2,-1,1;1,-3,-2,-2;0,4,-1,1]
  2. B=input("Enter the result of matrix "); // should be [14;10;-10;18]
  3. disp(A)
  4.  
  5. I=eye(4,4);
  6.  
  7. U=A;
  8.  
  9. U(2,:)=-2*U(1,:)+U(2,:)
  10.  
  11. E1=I;
  12. E1(2,:)=-2*E1(1,:)+E1(2,:);
  13.  
  14. U(2,:)=U(2,:)/-11;
  15.  
  16. E2=I;
  17. E2(2,:)=E2(2,:)/-11;
  18.  
  19. U(3,:)=U(2,:)+U(3,:);
  20.  
  21. E3=I;
  22. E3(3,:)=E3(2,:)+E3(3,:);
  23.  
  24. U(3,:)=U(3,:)/3;
  25.  
  26. E4=I;
  27. E4(3,:)=E4(3,:)/3;
  28.  
  29. U(4,:)=U(4,:)/3;
  30.  
  31. E5=I;
  32. E5($,:)=E5(4,:)/3;
  33.  
  34. L=inv(E1)*inv(E2)*inv(E3)*inv(E4)*inv(E5);
  35.  
  36. U(4,:)=U(4,:)/3;
  37.  
  38. y=inv(L)*B;
  39. disp("Solusi persamaam Ly = b")
  40. disp(y)
  41.  
  42. x=inv(U)*y;
  43. disp("Solusi persamaan Ux = y")
  44. disp(x)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top