If you see this, something is wrong
First published on Monday, Jan 6, 2025 and last modified on Monday, Jan 6, 2025
Mathedu SAS
Linear Systems
Solve the following system by the method of substitution/elimination.
(1)
Make exact calculations with fractions from end to end.
Tips: Distribute the factor \( 2\) and then multiply both members of the equality by \( 4\) . Don’t hesitate to use the calculator, but only to help fraction computations.
The solution is a couple \( (x,y)\) . In particular, check the solution.
Find a matrix equation \( AX=B\) equivalent to the system.
TIP: \( 3x-5y=3x+(-5)y\) .
Let the result as fractions of positive integers of their opposite.
TIP: Define a matrix \( AA\) the following way:
The diagonal elements of \( A\) are exchanged to obtain the diagonal elements of \( AA\) .
The anti-diagonal elements of \( A\) are opposed to obtain the anti-diagonal elements of \( AA\) .
Calculate with fractions from end to end, but don’t hesitate to use the calculator to help you.
is the couple \( (x,y)=(-3,\frac{1}{2})\) of elements of the column vector \( A^{-1}B\) .
In Python, the fractions may be entered as divisions (1/2 for \( \frac{1}{2}\) ), and are displayed as (approximate) decimal numbers. Moreover, the solution \( (x,y)=(-3,0.5)\) may be approximated as well because of roundoff errors.
Do it in a script, in order to test your program!
Update the following script ‘LinearSystem.py’ to define and solve the matrix equation \( AX=B\) , with \( A=\begin{bmatrix}4&2\ 3&-5\end{bmatrix}\) and \( B=\begin{bmatrix}-11\ -\frac{23}{2}\end{bmatrix}\) .
from numpy import *
from numpy.linalg import *
X0=array([43,3])
print('X0=',X0)
'''
It is a line vector
'''
A=array([[2,1],[1,3]])
print('A=\n',A)
'''
It is a matrix with 2 rows and 2 columns
'''
B0=A@X0
'''
The column vector B0' is the product of the matrix A and the column vector
X0'
'''
print('B0=',B0)
```
We have reconstructed the system of two linear equations and two
variables equivalent to the matric equation AX=B, with the solution (43,3).
```
B=array([89,52])
InvA=inv(A)
print('The inverse of A is\n',InvA)
X=InvA@B
'''
The column vector X' is the product of the inverse of A and the column
vector B'
'''
print('X=',X)
'''
The column vector X' is the solution of the matrix equation AX'=B'
'''