Given the set of equations:
\( \begin{bmatrix} 5 & 0 & 0 \\ 0 & 10 & 0 \\ 0 & 0 & 15 \end{bmatrix} \times \left[ \begin{array}{c} x_1 \\ x_2 \\ x_3 \end{array} \right] = \left[ \begin{array}{c} 1 \\ 2 \\ 3 \end{array} \right] \)
Below is how to solve them using Sage:
1 2 3 4 |
sage: A = matrix([[5,0,0],[0,10,0],[0,0,15]]) sage: Y = vector([1,2,3]) sage: X = A.solve_right(Y) sage: X |
The output:
1 |
(1/5, 1/5, 1/5) |
In order to get the output as floating point numbers use the numerical_approx function:
1 |
sage: n(X, digits=4) |
The output:
1 |
(0.2000, 0.2000, 0.2000) |