Building and Solving Linear Equations

In this lesson, you will learn how to build and solve a system of linear equations in Python.

The linear algebra module of NumPy, linalg, provides a number of functionalities, including the ability to solve systems of linear equations. This is done using the matrix method.

Suppose we have the following system of linear equations:

2x+3y+z=172x+3y+z=17

3x+4y+2z=253x+4y+2z=25

x+yz=6x+y-z=6

We need to convert these to the form AX=bAX=b and solve the equation for XX.

[231342111][xyz]=[17256]\begin{bmatrix}2 & 3 & 1 \\3 & 4 & 2 \\1 & 1 & -1 \end{bmatrix} \begin{bmatrix}x \\y \\z \end{bmatrix} = \begin{bmatrix}17 \\25 \\6 \end{bmatrix}

Get hands-on with 1200+ tech skills courses.