Average Error: 0.4 → 0.1
Time: 5.5s
Precision: binary64
\[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120 \]
\[\mathsf{fma}\left(a, 120, \left(x - y\right) \cdot \frac{60}{z - t}\right) \]
\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120
\mathsf{fma}\left(a, 120, \left(x - y\right) \cdot \frac{60}{z - t}\right)
(FPCore (x y z t a)
 :precision binary64
 (+ (/ (* 60.0 (- x y)) (- z t)) (* a 120.0)))
(FPCore (x y z t a)
 :precision binary64
 (fma a 120.0 (* (- x y) (/ 60.0 (- z t)))))
double code(double x, double y, double z, double t, double a) {
	return ((60.0 * (x - y)) / (z - t)) + (a * 120.0);
}
double code(double x, double y, double z, double t, double a) {
	return fma(a, 120.0, ((x - y) * (60.0 / (z - t))));
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original0.4
Target0.2
Herbie0.1
\[\frac{60}{\frac{z - t}{x - y}} + a \cdot 120 \]

Derivation

  1. Initial program 0.4

    \[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120 \]
  2. Simplified0.4

    \[\leadsto \color{blue}{\mathsf{fma}\left(a, 120, \frac{60 \cdot \left(x - y\right)}{z - t}\right)} \]
  3. Applied associate-/l*_binary640.1

    \[\leadsto \mathsf{fma}\left(a, 120, \color{blue}{\frac{60}{\frac{z - t}{x - y}}}\right) \]
  4. Taylor expanded in x around 0 0.1

    \[\leadsto \mathsf{fma}\left(a, 120, \color{blue}{60 \cdot \frac{x}{z - t} - 60 \cdot \frac{y}{z - t}}\right) \]
  5. Simplified0.1

    \[\leadsto \mathsf{fma}\left(a, 120, \color{blue}{\left(x - y\right) \cdot \frac{60}{z - t}}\right) \]
  6. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(a, 120, \left(x - y\right) \cdot \frac{60}{z - t}\right) \]

Reproduce

herbie shell --seed 2022081 
(FPCore (x y z t a)
  :name "Data.Colour.RGB:hslsv from colour-2.3.3, B"
  :precision binary64

  :herbie-target
  (+ (/ 60.0 (/ (- z t) (- x y))) (* a 120.0))

  (+ (/ (* 60.0 (- x y)) (- z t)) (* a 120.0)))