```python
from IPython.display import display, Markdown, Latex
import linear_systems as ls 
import numpy as np
```

Using KVL in 3 meshes we have the relations:- 
$$
\begin{align}
-10+10I_1+20+10(I_1-I_2)-10I_1  = 0 \\
-20 +10(I_2-I_1) + 30I_2+10(I_2-I_3) = 0 \\
-10 -20I_3-10(I_3-I_2)= 0
\end{align}
$$
In matrix form we have the following relation 
$$
\begin{pmatrix}
4 & -1 & 0 \\
-1 & 5 & -1 \\
0 & 1 & -3 \\
\end{pmatrix}
\begin{pmatrix}
I_1 \\
I_2\\
I_3 \\
\end{pmatrix}
=
\begin{pmatrix}
-1 \\
2\\
1 \\
\end{pmatrix}
$$
$$

\left[\begin{array}{ccc|c}
4 & -1 & 0 &-1 \\
-1 & 5 & -1 &2\\
0 & 1 & -3& 1 \\
\end{array}\right]
$$


Using Gaussian elimination we have, 


```python
A = np.array(
    [[4,-1,0],
    [-1,5,-1],
    [0,1,-3]] , dtype=float
)
b = np.array([-1,2,1])
loc= "electric_circuit.md"
(aug,steps) = ls.gauss_elim(A,b,loc)
aug = ls.gauss_jordan(aug)
display(Latex(steps))
display(Latex(ls.matrixp(aug)))
print(np.linalg.solve(A,b))
```

    Consistent system, unique solution, 3 3 3




$$\left[\begin{array}{ccc|c}
4 & -1 & 0 & -1\\
-1 & 5 & -1 & 2\\
0 & 1 & -3 & 1\\
\end{array}\right]$$

$$\left[\begin{array}{ccc|c}
1 & -0.25 & 0 & -0.25\\
-1 & 5 & -1 & 2\\
0 & 1 & -3 & 1\\
\end{array}\right]$$

$$\left[\begin{array}{ccc|c}
1 & -0.25 & 0 & -0.25\\
0 & 4.75 & -1 & 1.75\\
0 & 1 & -3 & 1\\
\end{array}\right]$$

$$\left[\begin{array}{ccc|c}
1 & -0.25 & 0 & -0.25\\
0 & 4.75 & -1 & 1.75\\
0 & 1 & -3 & 1\\
\end{array}\right]$$

$$\left[\begin{array}{ccc|c}
1 & -0.25 & 0 & -0.25\\
0 & 1 & -0.211 & 0.368\\
0 & 1 & -3 & 1\\
\end{array}\right]$$

$$\left[\begin{array}{ccc|c}
1 & -0.25 & 0 & -0.25\\
0 & 1 & -0.211 & 0.368\\
0 & 0 & -2.79 & 0.632\\
\end{array}\right]$$

$$\left[\begin{array}{ccc|c}
1 & -0.25 & 0 & -0.25\\
0 & 1 & -0.211 & 0.368\\
0 & 0 & -2.79 & 0.632\\
\end{array}\right]$$

$$\left[\begin{array}{ccc|c}
1 & -0.25 & 0 & -0.25\\
0 & 1 & -0.211 & 0.368\\
-0 & -0 & 1 & -0.226\\
\end{array}\right]$$





$$\left[\begin{array}{ccc|c}
1 & 0 & 0 & -0.17\\
0 & 1 & 0 & 0.321\\
-0 & -0 & 1 & -0.226\\
\end{array}\right]$$



    [-0.16981132  0.32075472 -0.22641509]



```python
A = np.array(
    [[4,1,1],
    [-1,2,2],
    [0,3,3]] , dtype=float
)
b = np.array([-1,2,1])
loc= "electric_circuit.md"
(aug,steps) = ls.gauss_elim(A,b,loc)
aug = ls.gauss_jordan(aug)
display(Latex(steps))
display(Latex(ls.matrixp(aug)))
print(np.linalg.solve(A,b))
```


```python
A = np.array(
    [[1,2],
    [1,1],
    [2,2]] , dtype=float
)
b = np.array([7,2,4])
(aug,steps) = ls.gauss_elim(A,b,loc)
aug = ls.gauss_jordan(aug)
display(Latex(steps))
display(Latex(ls.matrixp(aug)))
print(np.linalg.solve(A,b))
```

0a9871cc08b6022dbc1fb24741ebea3b660db518
ipynb
Jupyter Notebook
linear_system/electric_circuits.ipynb
plancky/mathematical_physics_II
c912dca1a58c218ddb06dc6cbca021b03a703540
CC0-1.0
linear_system/electric_circuits.ipynb
plancky/mathematical_physics_II
c912dca1a58c218ddb06dc6cbca021b03a703540
CC0-1.0
linear_system/electric_circuits.ipynb
plancky/mathematical_physics_II
c912dca1a58c218ddb06dc6cbca021b03a703540
CC0-1.0
Qwen/Qwen-72B
1. YES
2. YES