Average Error: 15.3 → 6.5
Time: 1.4s
Precision: binary64
\[\frac{a \cdot b - c \cdot d}{a \cdot b}\]
\[\frac{b - \frac{c \cdot d}{a}}{b}\]
\frac{a \cdot b - c \cdot d}{a \cdot b}
\frac{b - \frac{c \cdot d}{a}}{b}
double code(double a, double b, double c, double d) {
	return ((double) (((double) (((double) (a * b)) - ((double) (c * d)))) / ((double) (a * b))));
}
double code(double a, double b, double c, double d) {
	return ((double) (((double) (b - ((double) (((double) (c * d)) / a)))) / b));
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 15.3

    \[\frac{a \cdot b - c \cdot d}{a \cdot b}\]
  2. Simplified6.5

    \[\leadsto \color{blue}{\frac{b - \frac{c \cdot d}{a}}{b}}\]
  3. Final simplification6.5

    \[\leadsto \frac{b - \frac{c \cdot d}{a}}{b}\]

Reproduce

herbie shell --seed 2020153 
(FPCore (a b c d)
  :name "(/ (- (* a b) (* c d)) (* a b))"
  :precision binary64
  (/ (- (* a b) (* c d)) (* a b)))