Originally Posted by
JavaA123Chris
the form of ax+by=c and dx+ey=f
double x = (e * d - b * f) / (a * d - b * c);
double y = (a * f - e * c) / (a * d - b * c);
}
I know this is a little late. But your program works if the equations are of the form
ax+by=e
cx+dy=f
do a little math and we get
ax+by=e <=> ax=e-by <=> x=(e-by)/a
cx+dy=f <=> c((e-by)/a)+dy=f <=> ce-cby+ady=af <=> fa-ce=y(ad-bc) <=>
y=(af-ce)/(ad-bc)
x=(e-by)/a
x=(e-b((af-ce)/(ad-bc))/a <=> x=(e/a)+(b/a)((af-ce)/(ad-bc)) <=>
x=(e/a)((ad-bc)/(ad-bc))+(b/a)((af-ce)/(ad-bc)) <=>
x=(ade-bce)/(a(ad-bc))+(baf-bce)/(a(ad-bc)) <=>
x=(ade-bce+baf-bce)/(a(ad-bc)) <=> x=(ade+baf)/(a(ad-bc)) <=>
x=(de+bf)/(ad-bc)
ad-bc=/=0