Use `fabs()` instead of `abs()`

`abs()` is only for integers, so it's a bad idea to use it with doubles.
Use a threshold for checking double equality.
Round final result to a number of decimal places

This hides some slight precision errors, like "sin(pi)" not displaying
exactly zero.