LaTex2Web logo

Documents Live, a web authoring and publishing system

If you see this, something is wrong

Table of contents

First published on Monday, Jan 6, 2025 and last modified on Monday, Jan 6, 2025

Linear Algebra in the Euclidian Space: Section 3 test
2022

Fabienne Chaplais Mathedu SAS

Keywords: Linear Systems

1 Solve a \( 2\times 2\) System

Solve the following system by the method of substitution/elimination.

\[\begin{equation} \left\{ \begin{matrix} 4x&+&2y&=&-11\\ 3x&-&5y&=&-\frac{23}{2} \end{matrix} \right. \end{equation}\]

(1)

Make exact calculations with fractions from end to end.

1.1 Solve the first Equation in \( x\)

1.2 Replace \( x\) by its Value in the Second Equation

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.

1.3 Replace y by its value in in the equation giving \( x\) as a function of \( y\)

1.4 Give the solution of the linear system

The solution is a couple \( (x,y)\) . In particular, check the solution.

2 The Matrix View

2.1 The linear system as a matrix equation

Find a matrix equation \( AX=B\) equivalent to the system.

2.1.1 Define relevant column vectors \( X\) and \( B\) , and square matrix \( A\)

TIP: \( 3x-5y=3x+(-5)y\) .

2.1.2 Deduce that the system is equivalent to the matrix vector \( AX=B\)

2.2 Invert the Matrix \( A\)

2.2.1 Calculate the determinant of the matrix \( A\)

2.2.2 Calculate the inverse of the matrix \( A\)

Let the result as fractions of positive integers of their opposite.

TIP: Define a matrix \( AA\) the following way:

  1. The diagonal elements of \( A\) are exchanged to obtain the diagonal elements of \( AA\) .

  2. The anti-diagonal elements of \( A\) are opposed to obtain the anti-diagonal elements of \( AA\) .

2.3 Solve the system the matrix way

2.3.1 Multiply the matrix \( A^{-1}\) by the column vector \( B\) .

Calculate with fractions from end to end, but don’t hesitate to use the calculator to help you.

2.3.2 Deduce the matrix way to solve the system

is the couple \( (x,y)=(-3,\frac{1}{2})\) of elements of the column vector \( A^{-1}B\) .

3 Solve the matrix Equation in Python

3.1 TIPS

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.

3.2 IMPORTANT

Do it in a script, in order to test your program!

3.3 SCRIPT

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' 
'''