-2

Is there any way of solving two linear equations simultaneously in python without the use of a module?? I want to solve these two equations but can't seem to find the approach .

                         a - b = 1
                         a + b = 5

Thanks in advance.

2 Answers2

1

Implement Gauss Jordan elimination. Its not a great way to do it, but for two equations a simple analytical solution will pop out.

SomeGuest
  • 11
  • 1
1

you will need linear algebra module such as numpy.

#e.g. 
import numpy as np

X = np.array([[1,-1], [1,1]])
y = np.array([1,5])
np.linalg.inv(X).dot(y)
Yonas Kassa
  • 3,362
  • 1
  • 18
  • 27