I'm trying to find the intersection of lines $y=a_1x+b_1$ and $y=a_2x+b_2$ using
numpy.linalg.solve(). What I can't get my head around is how to correctly make $A$ a square matrix for
solve() to work. I'm familiar with solving linear equation systems, but there's something here I don't get.
What I'd like to do is:
def meeting_lines(a1, b1, a2, b2): a = np.array([[a1], [a2]]) b = np.array([b1, b2]) return np.linalg.solve(a, b) def main(): a1=1 b1=4 a2=3 b2=2 y, x = meeting_lines(a1, b1, a2, b2)
Where I expect $y=-3$ and $x=1$. However, this fails with
numpy.linalg.LinAlgError: Last 2 dimensions of the array must be square.
Thank you very much for your help, trying to figure this out has messed up my day already!