title: Comparing mathematical expressions
body: <p>So here's my situation: I have two mathematical expressions which contains variables (x, y, z, etc). I have already compiled them to postfix using the <a href="http://en.wikipedia.org/wiki/Shunting-yard_algorithm" rel="nofollow">shunting yard algorithm</a> for execution and now I need a way to test if they're mathematical equal.</p>
  
  <p>Examples:</p>
  
  <pre><code>x+5==5+x
  x*2==x+x
  4/(x/2)==8/x
  </code></pre>
  
  <p>My initial thinking is to just throw a couple of thousand different random inputs and see if the evaluation result is the same.</p>
  
  <p>Problems I foresee with this approach: Precision problems, NaN-situations and possible overflows.</p>
  
  <p>All calculations are done with Java's double type.</p>
  
  <p>Any ideas? :)</p>
  
  <p>Edit: As this is for a casual game, the solution doesn't need to be perfect, only good enough!</p>