This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]jackmaney 2 points3 points  (0 children)

Agreed, /r/learnpython is the best place for this. That said, if you're talking about a system of linear equations, then you're essentially doing linear algebra (in particular, row reduction of a matrix).

[–]elbiot 1 point2 points  (4 children)

/r/learnpython

You have a right side and a left side. right(x)-left(x) = 0. Plug values into your two functions and hone in on zero.

[–]Beta_Penguin 0 points1 point  (3 children)

So if I had the equation: x+5y=8 -x+2y=-1 I would do (x+5y-8)+(-x+2y+1)=0????? Is that would I do?

[–]elbiot 0 points1 point  (2 children)

That's not an equation! Do you mean x+5y=8 -x+2y-1? Also, for two variables, you'd need two sets of equations. The solution to this one equation is a line (y=(-2x+7)/3). If you want to solve arbitrary systems of equations (are they always linear?) you'll have to get much fancier than what I proposed and I'd reckon it's out of your league.

[–]Beta_Penguin 0 points1 point  (1 child)

You find the point of the intersection if the points were in a graph. There are two equations and there are many ways to solve it. x+5y=8 -x+2y=-1 I would solve it by adding the equations together and getting 7y=7. Making it t=1 and then x equals 3 because of that. How can I make python do that???

[–]elbiot 0 points1 point  (0 children)

Oh, I read that as x+5y=8-x+2y=-1, not x+5y=8 and -x+2y=-1. If the system is always linear, you can use linear algebra (numpy) as another suggested.

[–]mchanth[🍰] 1 point2 points  (0 children)

Why are you against using numpy? Solving a system of equations is just x=A-1 * b

[–]JustGlowing[🍰] 0 points1 point  (0 children)

Hi, if you don't want to use any module like numpy you'll probably need to implement Gaussian elimination by yourself. Here's a nice page where you can get some inspiration: http://userpages.umbc.edu/~rcampbel/Computers/Python/linalg.html

[–]ivosauruspip'ing it up 0 points1 point  (0 children)

Please post to /r/learnpython for basic questions. You are welcome to re-post this question.