In [2]:
from sympy import *
from IPython.display import display
init_printing(use_latex='mathjax')
In [5]:
A=Matrix([[1,3,5,0,0,3],[0,0,2,1,2,1],[2,6,12,1,2,7]])
display(A)
$$\left[\begin{matrix}1 & 3 & 5 & 0 & 0 & 3\\0 & 0 & 2 & 1 & 2 & 1\\2 & 6 & 12 & 1 & 2 & 7\end{matrix}\right]$$
In [6]:
A.rref()
Out[6]:
$$\left ( \left[\begin{matrix}1 & 3 & 0 & - \frac{5}{2} & -5 & \frac{1}{2}\\0 & 0 & 1 & \frac{1}{2} & 1 & \frac{1}{2}\\0 & 0 & 0 & 0 & 0 & 0\end{matrix}\right], \quad \left [ 0, \quad 2\right ]\right )$$
In [8]:
B=Matrix(A) #a copy of A
B[2,5]+= 1 #indices start at 0
display(B)
$$\left[\begin{matrix}1 & 3 & 5 & 0 & 0 & 3\\0 & 0 & 2 & 1 & 2 & 1\\2 & 6 & 12 & 1 & 2 & 8\end{matrix}\right]$$
In [11]:
B.rref()
Out[11]:
$$\left ( \left[\begin{matrix}1 & 3 & 0 & - \frac{5}{2} & -5 & 0\\0 & 0 & 1 & \frac{1}{2} & 1 & 0\\0 & 0 & 0 & 0 & 0 & 1\end{matrix}\right], \quad \left [ 0, \quad 2, \quad 5\right ]\right )$$
In [9]:
C=Matrix(A) #a copy of A
C[2,2]= 8 #indices start at 0
display(C)
$$\left[\begin{matrix}1 & 3 & 5 & 0 & 0 & 3\\0 & 0 & 2 & 1 & 2 & 1\\2 & 6 & 8 & 1 & 2 & 7\end{matrix}\right]$$
In [10]:
C.rref()
Out[10]:
$$\left ( \left[\begin{matrix}1 & 3 & 0 & 0 & 0 & 3\\0 & 0 & 1 & 0 & 0 & 0\\0 & 0 & 0 & 1 & 2 & 1\end{matrix}\right], \quad \left [ 0, \quad 2, \quad 3\right ]\right )$$
In []: