We show here how to read a square matrix A
from a file
A.txt
and a vector b
from a file
b.txt
and print the solution x
to the equation
Ax = b
.

Here are the new features of the code:

numpy
package contains a linalg
subpackage. It is automatically loaded with numpy
, and it
can be accessed with np.linalg
. But with this command we
can access it with LA
instead and save typing.

np.linalg
. Here we access them with LA
. The
solve
member of the subpackage that we use here takes a
matrix and a vector and solves the linear system.
Try running the code to see the result.