# Thread: [SOLVED] what is an equation to find 2 variables simultaneously?

1. ## [SOLVED] what is an equation to find 2 variables simultaneously?

Ok so this is more for a program to do general solving of 2 variables with 2 equations.
I know how to solve simultaneously on paper but need to know how with one equation that can use variables.

eg. I want to solve for x and y when i have two equations:
x + 3y = 34
&
2x + 4y = 50
I can find that x=7 & y=9 on paper but I want to get this within a program
All I need to know is if:
*(in that example above a=1 b=3 c=34 d=2 e=4 f=50)

ax + by = c
dx + ey = f

.: x=
.: y=

what are the equations that x= and y= in terms of a, b, c, d, e, & f?

Note: I'm not trying to solve the example, I just thought it might help to visualize with an example.

2. Originally Posted by DarkReviver
Ok so this is more for a program to do general solving of 2 variables with 2 equations.
I know how to solve simultaneously on paper but need to know how with one equation that can use variables.

eg. I want to solve for x and y when i have two equations:
x + 3y = 34
&
2x + 4y = 50
I can find that x=7 & y=9 on paper but I want to get this within a program
All I need to know is if:
*(in that example above a=1 b=3 c=34 d=2 e=4 f=50)

ax + by = c
dx + ey = f

.: x=
.: y=

what are the equations that x= and y= in terms of a, b, c, d, e, & f?

Note: I'm not trying to solve the example, I just thought it might help to visualize with an example.
I'll change it just slightly for you and make your two equations look like:

$ax+by=e$
$cx+dy=f$

Solve for x using elimination:

$adx+bdy=de$ Multiply the first equation by d
$bcx+bdy=bf$ Multiply the second equation by b

Subtract these two equations:

$adx-bcx=de-bf$

Factor:

$(ad-bc)x=de-bf$

$\boxed{x=\frac{de-bf}{ad-bc}}$

Solving for y in the same way produces:

$\boxed{y=\frac{af-ce}{ad-bc}}$

3. Originally Posted by masters
$\boxed{x=\frac{de-bf}{ad-bc}}$

Solving for y in the same way produces:

$\boxed{y=\frac{af-ce}{ad-bc}}$
thanks that's perfect, and I can see how it made more sense to have the equation arranged the way you put it.