Average Error: 0.5 → 0.1
Time: 2.5s
Precision: 64
\[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120\]
\[\mathsf{fma}\left(120, a, \frac{x - y}{\frac{z}{60} - \frac{t}{60}}\right)\]
\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120
\mathsf{fma}\left(120, a, \frac{x - y}{\frac{z}{60} - \frac{t}{60}}\right)
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(120.0, a, ((x - y) / ((z / 60.0) - (t / 60.0))));
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 0.5

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(120, a, \frac{60 \cdot \left(x - y\right)}{z - t}\right)}\]
  3. Using strategy rm
  4. Applied *-commutative0.5

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

    \[\leadsto \mathsf{fma}\left(120, a, \color{blue}{\frac{x - y}{\frac{z - t}{60}}}\right)\]
  6. Using strategy rm
  7. Applied div-sub0.1

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

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

Reproduce

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

  :herbie-target
  (+ (/ 60 (/ (- z t) (- x y))) (* a 120))

  (+ (/ (* 60 (- x y)) (- z t)) (* a 120)))