I wrote a simple short computer program to solve a pair of equations of the format ,
$y = a1 * x + b1$
$y = a2 * x + b2$ .
But , it outputs clearly wrong answers sometimes when $abs(a1)$ or $abs(a2)$ is very small ,but not zero. I analyze the problem as follows. When it computes $a1-a2$ for very small $a2$, the floating point function computes as $a1-a2 = a1$ . Is it possible and how do mathematicians safely solve these equations in their researches?
Thank you in advance.
For details, my algorithm follows.
- check $ a1 != a2 $ ;
- $0 = (a1-a2)x+(b1-b2)$;
- $x=-1*(b1-b2)/(a1-a2)$.