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 system
Here is a new puzzle that you will have to solve.
Assume that in a farm:
The triple of the number of hens plus the double of the number of rabbits is 38.
The quadruple of the number of hens minus the number of rabbits is 14.
Then, by the end of the test, you will answer the questions:
How many hens are there in the farm?
How many rabbits are there in the farm?
Find a system of 2 linear equation of 2 real variables that is equivalent to the puzzle, denoting:
\( x\) the number of hens in the farm,
and \( y\) the number of rabbits in the farm.
Solve the system obtained by the method of substitution/elimination.
Make exact calculations with fractions from end to end.
Tips: Distribute the factor \( 4\) and then multiply both members of the equality by \( 3\) . 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: \( 4x-y=4x+(-1)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.
Update the following script next page to define and solve the matrix equation \( AX=B\) , with \( A=\begin{bmatrix}3&2\ 4&-1\end{bmatrix}\) and \( B=\begin{bmatrix}38\ 14\end{bmatrix}\) .
Do it in a script in Anaconda and Spyder named ‘LinearSystem.py’ for instance, in order to test your program!
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'
'''