LaTex2Web logo

LaTeX2Web, a web authoring and publishing system

If you see this, something is wrong

Collapse and expand sections

To get acquainted with the document, the best thing to do is to select the "Collapse all sections" item from the "View" menu. This will leave visible only the titles of the top-level sections.

Clicking on a section title toggles the visibility of the section content. If you have collapsed all of the sections, this will let you discover the document progressively, from the top-level sections to the lower-level ones.

Cross-references and related material

Generally speaking, anything that is blue is clickable.

Clicking on a reference link (like an equation number, for instance) will display the reference as close as possible, without breaking the layout. Clicking on the displayed content or on the reference link hides the content. This is recursive: if the content includes a reference, clicking on it will have the same effect. These "links" are not necessarily numbers, as it is possible in LaTeX2Web to use full text for a reference.

Clicking on a bibliographical reference (i.e., a number within brackets) will display the reference.

Speech bubbles indicate a footnote. Click on the bubble to reveal the footnote (there is no page in a web document, so footnotes are placed inside the text flow). Acronyms work the same way as footnotes, except that you have the acronym instead of the speech bubble.

Discussions

By default, discussions are open in a document. Click on the discussion button below to reveal the discussion thread. However, you must be registered to participate in the discussion.

If a thread has been initialized, you can reply to it. Any modification to any comment, or a reply to it, in the discussion is signified by email to the owner of the document and to the author of the comment.

Table of contents

First published on Monday, Jan 6, 2025 and last modified on Monday, Jan 6, 2025 by Fabienne Chaplais.

Linear Algebra in the Euclidian Space: Section 3 test Corrected
2022

Fabienne Chaplais Mathedu SAS

Keywords: Linear Systems

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

\paragraph{} 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.1.1 Solution

The first equation is equivalent to the linear equation in \( x\) :

\[\begin{equation} 4x=-11-2y \end{equation}\]

(2)

Its solution depends on \( y\) and is:

\( x=\frac{-11-2y}{4}= -\frac{11}{4} -\frac{y}{2} \) .

Consequently, the solution of the first equation in \( x\) is:

\[\begin{equation} x= -\frac{11}{4} -\frac{1}{2}y \end{equation}\]

(3)

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.2.1 Solution

In the second equation, we eliminate \( x\) by replacing it by its value given by the equation 3.

The second equation is thus equivalent to:

\[\begin{equation} 3\left(-\frac{11}{4} -\frac{1}{2}y\right) -5y=-\frac{23}{2} \end{equation}\]

(4)

If we distribute the factor \( 3\) , we obtain:

\[\begin{equation} -\frac{33}{4} -\frac{3}{2}y -5y=-\frac{23}{2} \end{equation}\]

(5)

If we multiply both members of the equality by \( 3\) , we obtain:

\[\begin{equation} -33-6y-20y=-46 \end{equation}\]

(6)

The equation 6 is equivalent to the affine equation in \( y\) :

\[\begin{equation} 26y+33=46 \end{equation}\]

(7)

Its solution is: \( y=\frac{46-33}{26}=\frac{13}{26}=\frac{1}{2} \) .

Consequently, the solution of the system 1 in \( y\) is:

\[\begin{equation} y=\frac{1}{2} \end{equation}\]

(8)

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

1.3.1 Solution

In the equation 3, we eliminate \( y\) by replacing it by its value \( 10\) .

The equation 3 is thus equivalent to:

\[\begin{equation} x=-\frac{11}{4}-\frac{1}{2}\times\frac{1}{2} \end{equation}\]

(9)

If we continue the calculation, we obtain: \( x=-\frac{11}{4}-\frac{1}{4}=-\frac{12}{4}=-3 \) .

Consequently, the solution of the system 1 in \( x\) is

\[\begin{equation} x=-3 \end{equation}\]

(10)

1.4 Give the solution of the linear system

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

The solution of the linear system is the couple of real numbers is \( (x,y)=(-3,\frac{1}{2})\) .

This is because a solution must be \( (-3,\frac{1}{2})\) , and \( (x,y)=(-3,\frac{1}{2})\) is a solution as:

  1. \( 4x+2y=4\times(-3)+2\times\frac{1}{2}=-12+1=-11\) ,

  2. and \( 3x-5y=3\times(-3)-5\times\frac{1}{2}=-9-\frac{5}{2}=\frac{-18-5}{2}=-\frac{23}{2}\) .

2 The Matrix View

2.1 The linear system as a matrix equation

\paragraph{} 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.1.1 Solution

We define the column vectors: \( X=\begin{bmatrix}x\ y\end{bmatrix}\) and \( B=\begin{bmatrix}-11\ ­\frac{23}{2}\end{bmatrix}\) , as well as the square matrix: \( A=\begin{bmatrix}4&2\ 3&-5\end{bmatrix}\) .

2.1.2 Multiply the square matrix \( A\) by the column vector \( X\)

2.1.2.1 Solution

The product \( AX\) of the matrix \( A\) and the column vector \( X\) is equal to:

\[\begin{equation} AX=\begin{bmatrix}4&2\\ 3&-5\end{bmatrix} \begin{bmatrix}x\\ y\end{bmatrix} =\begin{bmatrix}4x+2y\\ 3x-5y\end{bmatrix} \end{equation}\]

(11)

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

2.1.3.1 Solution

The elements of the column vector \( AX\) are the first members of the linear system:

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

Moreover, the elements of the column vector \( B\) are the second membre of that system.

Consequently, the linear system above is equivalent to the matrix equation \( AX=B\) .

2.2 Invert the Matrix \( A\)

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

2.2.1.1 Solution

The determinant of the matrix \( A=\begin{bmatrix}4&2\ 3&-5\end{bmatrix}\) is:

\(\det(A)=4\times (-5) - 3\times 2 = -20-6 = -26 \).

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\) .

\( AA\) is equal to:

\[\begin{equation} AA=\begin{bmatrix}-5&-2\\ -3&4\end{bmatrix} \end{equation}\]

(12)

Section 2.2.2.1

The inverse of the matrix \( A\) is the product of the inverse of \( \det(A)\) and \( AA\) :

\[\begin{equation} A^{-1}=\frac{1}{-26}\begin{bmatrix}-5&-2\\ -3&4\end{bmatrix} \end{equation}\]

(13)

Let’s enter the factor \( \frac{1}{5}\) in the matrix \( AA\) element by element:

\[\begin{equation} A^{-1}= \begin{bmatrix} \frac{-5}{-26}&\frac{-2}{-26}\\ \\ \frac{-3}{-26}&\frac{4}{-26} \end{bmatrix} \end{equation}\]

(14)

so that:

\[\begin{equation} A^{-1}= \begin{bmatrix} \frac{5}{26}&\frac{1}{13}\\ \\ \frac{3}{26}&-\frac{2}{13} \end{bmatrix} \end{equation}\]

(15)

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.1.1 Solution

Let’s multiply the matrix \( A^{-1}\) by the column vector \( B\) :

\( A^{-1}B= \begin{bmatrix} \frac{5}{26}&\frac{1}{13}\  \  \frac{3}{26}&-\frac{2}{13} \end{bmatrix} \begin{bmatrix} -11\ -\frac{23}{2} \end{bmatrix}= \begin{bmatrix} \frac{5}{26}\times(-11)+ \frac{1}{13}\times\left(-\frac{23}{2}\right)\  \  \frac{3}{26}\times(-11) - \frac{2}{13}\times\left(-\frac{23}{2}\right) \end{bmatrix} \)

Let’s calculate further, we obtain: \( A^{-1}B= \begin{bmatrix} \frac{-55 -23}{26}\  \  \frac{-33+46}{26} \end{bmatrix}= \begin{bmatrix} \frac{78}{26}\  \  \frac{13}{26} \end{bmatrix}= \begin{bmatrix} -3\  \frac{1}{2} \end{bmatrix} \)

2.3.2 Deduce the matrix way to solve the system

The solution of the matrix eqution \( AX=B\) is the column vector \( A^{-1}B\) .

Consequently, the solution of the system of linear equations:

\( \left\{ \begin{matrix} 4x&+&2y&&=&-3\  3x&-&5y&&=&-\frac{23}{2} \end{matrix} \right. \)

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

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.1 IMPORTANT

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

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

3.3 Solution

Here is the updated script:

from numpy import *
from numpy.linalg import * 

X0=array([-3,1/2])
print('X0=',X0)

'''
It is a line vector 
'''

A=array([[4,2],[3,-5]])
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 
(-3,1/2). Note that -11.5=-23/2.
```

B=array([-11,-23/2])
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' 
'''

I am normally hidden by the status bar