Professional Documents
Culture Documents
SOLUTIONS OF LINEAR
EUATIONS IN TWO VARIABLES
USING PYTHON
Introduction To Python Programming
Name:-Adarsh Tiwari
Roll No:- 19120007
Semester- 5th
Sub :- Introduction To Python Programming
NIT Raipur
B-Tech
Abstract-
In this Paper we are going to discuss about solutions of linear equations by using
python. Linear equations are having all variables as degree 1 and mainly we study 2
types of linear equations i.e. linear equations in 2 variables and 3 variables. Solutions
of linear equations can be found out by making 3 matrix one of coefficients of
variables and other matrix is of variables and making it equal to matrix of constants
i.e. Ax = B for finding solutions. In python we use NumPy and linear algebra to solve
the matrix. So, in this way we find out solutions of linear equations using python.
Keywords- Linear Equations, python, Variables, matrix, cofficients, NumPy.
1.Introduction –
Linear Equations: - A equation having graph as a straight line is known as linear
Equation, also if degree of all variable is one is also known as linear equation.
Equations of this are ax+ by + c = 0, where “a” and “b” ≠ 0.
A linear Equations are of types: -
Linear Equations in 2 variables
Example: - 4x +5y =7
5x +2y = 8,
x/4 + y/6=7,
3x+ 2y -9 =0
& y= 3x + 8
Linear Equations in 3 variables
Example: - 4x +5y +3z=7
5x +2y + 6z= 8,
x/4 + y/4 + z/4 =7,
x+ y +z =9
Graph Of linear Equations: - Graph 2 – x/4 + y /8 =1
Graph 1 – 5x + 6y = 30
Graph 3 = 3x + 2y -9 = 0
Page 1 of 9
Graph 4 - y= 3x + 8
Graph 3 = 3x +2y -9 =0
Graph 1 – 3x + 5y +4z = 60
Page 2 of 9
Graph 2 - ((x)/ (4)) +((y)/ (4)) +((z)/ (4)) =7
Page 3 of 9
2.Solutions of Linear Equations: -
For 2 variables-
In 2 variables there are 2 or more equations are given we had to find out the point or
the value of x and y which satisfy all the given equations known as Solution of linear
equations.
In Graph where graphs intersect each other that point is known as solution of those
equations.
Example: - let Given Equations are 3x + 5y + 8 = 0
&6x + 5y + 20 =0
Page 4 of 9
For 3 Variables: - x + y + z = 28
& 4x + 5y + 3z = 60
We solve this matrix and whatever values comes is solutions of linear Equations .
Page 5 of 9
In 3 variables in the same way 3 matrix are formed and we solve it to get solutions of
matrix. Equations of 3 variables are 2x + y -3 =-4 ,4x-2y+z =9 ,3x + 5y -2z =5.
import numpy as np
A = np.array([[2,1,-3],[4,-2,1],[3,5,-2]])
b = np.array ([-4,9,5])
y=np.linalg.solve(A,b)
print(y)
Page 6 of 9
Code and Output: -
import numpy as np
A = np.array([[4,5,3],[5,2,6],[1,1,1]])
print (A)
ouput= [[4 5 3]
[5 2 6]
[1 1 1]]
import numpy as np
A = np.array([[4,5,3],[5,2,6],[1,1,1]])
b = np.array ([7,8,28])
y=np.linalg.solve(A,b)
print(y)
5.Conclusion-
Using python make it very easier to solve the system of linear Equations in 3
variables we use the format Ax=b. Programming make it very easy to solve these
heavy cumbersome linear equations and to get solutions very fast within seconds
while solving manually accuracy is also a problem but through this, we get very
accurate answers. Solution of Linear equations are used in various parts in Mathmatics
with the help of python you can get these solutions very easily.
6.Reference-
1. (2021) Youtube.com. Available at: https://www.youtube.com/watch?v=0WOY0LcLjUE
(Accessed: 22 October 2021).
2. (2021) Jusst.org. Available at: https://jusst.org/wp-content/uploads/2021/07/A-STUDY-OF-
SOLVING-SYSTEM-OF-LINEAR-EQUATION-USING-DIFFERENT-METHODS-AND-ITS-REAL-LIFE-
APPLICATIONS.pdf (Accessed: 22 October 2021).
3. (2021) Globaljournals.org. Available at: https://globaljournals.org/GJCST_Volume15/4-System-
of-Linear-Equations.pdf (Accessed: 22 October 2021).
4. How do you solve linear equations in three variables? (with example) (2021). Available at:
https://byjus.com/jee-questions/how-to-you-solve-linear-equations-in-three-variables/
(Accessed: 22 October 2021)
Page 7 of 9