Mã:
Clear[n, A, B, X, x, i, j, k, temp];
n = Input["Nhap so phuong trinh"];
A = Table[Random[Integer, {-10, 10}], {i, n}, {j, n}];
B = Table[Random[Integer, {-10, 10}], {i, n}];
X  =  Table[x^i, {i, n}];
Print["Giai he phuong trinh AX = B bang phuong phap Gauss"];
Print[MatrixForm[A], MatrixForm[X], " = ", MatrixForm[B]];
Print["Qua trinh khu xuoi"];
For[i = 1, i < n, i++,
    	For[j = i + 1, j ≤ n, j++,
      		temp = -A[[i, i]]/A[[j, i]];
      			For[k = i, k ≤ n, k++,
        				A[[j, k]] = temp *A[[j, k]] + A[[i, k]];
        			];
      			B[[j]] = temp*B[[j]] + B[[i]];
      	];
    	Print[MatrixForm[A], MatrixForm[X], " = ", MatrixForm[B]];
    ];

Print["Qua trinh khu nguoc"];
For[i = n, i > 1, i--,
    	For[j = i - 1, j ≥ 1, j--,
      		temp = -A[[i, i]]/A[[j, i]];
      			For[k = i, k ≥ 1, k--,
        				A[[j, k]] = temp *A[[j, k]] + A[[i, k]];
        			];
      			B[[j]] = temp*B[[j]] + B[[i]];
      	];
    	Print[MatrixForm[A], MatrixForm[X], " = ", MatrixForm[B]];
    ];
(*Tim nghiem*)
temp = Table[B[[i]]/A[[i, i]], {i, n}];
Print["Nghiem ", MatrixForm[X], "=", MatrixForm[temp]];