Average Error: 0.4 → 0.1
Time: 18.8s
Precision: binary64
Cost: 7104
\[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120 \]
\[\mathsf{fma}\left(a, 120, \frac{60}{z - t} \cdot \left(x - y\right)\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 (* (/ 60.0 (- z t)) (- x y))))
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, ((60.0 / (z - t)) * (x - y)));
}
function code(x, y, z, t, a)
	return Float64(Float64(Float64(60.0 * Float64(x - y)) / Float64(z - t)) + Float64(a * 120.0))
end
function code(x, y, z, t, a)
	return fma(a, 120.0, Float64(Float64(60.0 / Float64(z - t)) * Float64(x - y)))
end
code[x_, y_, z_, t_, a_] := N[(N[(N[(60.0 * N[(x - y), $MachinePrecision]), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision] + N[(a * 120.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := N[(a * 120.0 + N[(N[(60.0 / N[(z - t), $MachinePrecision]), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120
\mathsf{fma}\left(a, 120, \frac{60}{z - t} \cdot \left(x - y\right)\right)

Error

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.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(a, 120, \frac{60}{z - t} \cdot \left(x - y\right)\right)} \]
    Proof
    (fma.f64 a 120 (*.f64 (/.f64 60 (-.f64 z t)) (-.f64 x y))): 0 points increase in error, 0 points decrease in error
    (fma.f64 a 120 (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 60 (-.f64 x y)) (-.f64 z t)))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 a 120) (/.f64 (*.f64 60 (-.f64 x y)) (-.f64 z t)))): 4 points increase in error, 0 points decrease in error
    (Rewrite<= +-commutative_binary64 (+.f64 (/.f64 (*.f64 60 (-.f64 x y)) (-.f64 z t)) (*.f64 a 120))): 0 points increase in error, 3 points decrease in error
  3. Final simplification0.1

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

Alternatives

Alternative 1
Error25.4
Cost1768
\[\begin{array}{l} t_1 := 60 \cdot \frac{x}{z - t}\\ t_2 := \left(x - y\right) \cdot \frac{60}{z}\\ t_3 := \frac{-60}{\frac{z - t}{y}}\\ \mathbf{if}\;a \leq -4.4 \cdot 10^{-34}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq -6.5 \cdot 10^{-178}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -1.22 \cdot 10^{-221}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 3.6 \cdot 10^{-308}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 3.1 \cdot 10^{-285}:\\ \;\;\;\;\frac{x - y}{\frac{t}{-60}}\\ \mathbf{elif}\;a \leq 1.15 \cdot 10^{-262}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 6.1 \cdot 10^{-227}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 2.9 \cdot 10^{-193}:\\ \;\;\;\;\frac{x}{\frac{z - t}{60}}\\ \mathbf{elif}\;a \leq 1.16 \cdot 10^{-156}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 1.3 \cdot 10^{-79}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 2
Error25.7
Cost1504
\[\begin{array}{l} t_1 := 60 \cdot \frac{x}{z - t}\\ t_2 := -60 \cdot \frac{y}{z - t}\\ \mathbf{if}\;a \leq -2.3 \cdot 10^{-31}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq -6 \cdot 10^{-178}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -4.6 \cdot 10^{-243}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq -7 \cdot 10^{-265}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.5 \cdot 10^{-227}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 1.65 \cdot 10^{-193}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.16 \cdot 10^{-156}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 8.2 \cdot 10^{-79}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 3
Error25.5
Cost1504
\[\begin{array}{l} t_1 := -60 \cdot \frac{y}{z - t}\\ t_2 := 60 \cdot \frac{x}{z - t}\\ \mathbf{if}\;a \leq -7.5 \cdot 10^{-28}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq -1.65 \cdot 10^{-178}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -1.34 \cdot 10^{-222}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq -3.1 \cdot 10^{-263}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{60}{z}\\ \mathbf{elif}\;a \leq 1.08 \cdot 10^{-226}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.15 \cdot 10^{-193}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 6.6 \cdot 10^{-156}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 4.5 \cdot 10^{-82}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 4
Error25.6
Cost1504
\[\begin{array}{l} t_1 := \frac{-60}{\frac{z - t}{y}}\\ t_2 := 60 \cdot \frac{x}{z - t}\\ \mathbf{if}\;a \leq -1.25 \cdot 10^{-21}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq -1.65 \cdot 10^{-178}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -2.6 \cdot 10^{-221}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq -6 \cdot 10^{-266}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{60}{z}\\ \mathbf{elif}\;a \leq 1.05 \cdot 10^{-227}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.8 \cdot 10^{-193}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 1.16 \cdot 10^{-156}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 5.6 \cdot 10^{-81}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 5
Error25.4
Cost1504
\[\begin{array}{l} t_1 := \frac{-60}{\frac{z - t}{y}}\\ t_2 := 60 \cdot \frac{x}{z - t}\\ \mathbf{if}\;a \leq -2.9 \cdot 10^{-35}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq -1.65 \cdot 10^{-178}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -2.45 \cdot 10^{-221}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq -1.85 \cdot 10^{-264}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{60}{z}\\ \mathbf{elif}\;a \leq 1.38 \cdot 10^{-224}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.7 \cdot 10^{-193}:\\ \;\;\;\;\frac{x}{\frac{z - t}{60}}\\ \mathbf{elif}\;a \leq 1.45 \cdot 10^{-156}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.6 \cdot 10^{-84}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 6
Error12.6
Cost1496
\[\begin{array}{l} t_1 := \frac{60}{z - t} \cdot \left(x - y\right)\\ t_2 := \frac{y}{\frac{z - t}{-60}} + a \cdot 120\\ \mathbf{if}\;t \leq -2.2 \cdot 10^{+151}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -3.3 \cdot 10^{+115}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -4.2 \cdot 10^{-118}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.6 \cdot 10^{-65}:\\ \;\;\;\;\frac{60}{\frac{z}{x - y}} + a \cdot 120\\ \mathbf{elif}\;t \leq 6.5 \cdot 10^{-14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 17:\\ \;\;\;\;x \cdot \frac{60}{z} + a \cdot 120\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error12.7
Cost1496
\[\begin{array}{l} t_1 := \frac{60}{z - t} \cdot \left(x - y\right)\\ t_2 := \frac{y}{\frac{z - t}{-60}} + a \cdot 120\\ \mathbf{if}\;t \leq -2.2 \cdot 10^{+151}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -3.2 \cdot 10^{+115}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -2.7 \cdot 10^{-118}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 8.2 \cdot 10^{-66}:\\ \;\;\;\;\frac{60}{\frac{z}{x - y}} + a \cdot 120\\ \mathbf{elif}\;t \leq 6.2 \cdot 10^{-10}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 18:\\ \;\;\;\;x \cdot \frac{60}{z} + a \cdot 120\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot -60}{z - t} + a \cdot 120\\ \end{array} \]
Alternative 8
Error28.3
Cost1244
\[\begin{array}{l} t_1 := -60 \cdot \frac{x}{t}\\ t_2 := 60 \cdot \frac{x}{z}\\ \mathbf{if}\;a \leq -4.6 \cdot 10^{-243}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 3.3 \cdot 10^{-308}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 1.2 \cdot 10^{-285}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.9 \cdot 10^{-258}:\\ \;\;\;\;-60 \cdot \frac{y}{z}\\ \mathbf{elif}\;a \leq 1.85 \cdot 10^{-230}:\\ \;\;\;\;60 \cdot \frac{y}{t}\\ \mathbf{elif}\;a \leq 4.9 \cdot 10^{-211}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.1 \cdot 10^{-127}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 9
Error28.3
Cost1244
\[\begin{array}{l} t_1 := -60 \cdot \frac{x}{t}\\ t_2 := 60 \cdot \frac{x}{z}\\ \mathbf{if}\;a \leq -3.7 \cdot 10^{-243}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 3.5 \cdot 10^{-308}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 6.8 \cdot 10^{-286}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.02 \cdot 10^{-256}:\\ \;\;\;\;\frac{-60}{\frac{z}{y}}\\ \mathbf{elif}\;a \leq 1.85 \cdot 10^{-229}:\\ \;\;\;\;60 \cdot \frac{y}{t}\\ \mathbf{elif}\;a \leq 1.7 \cdot 10^{-213}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.1 \cdot 10^{-127}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 10
Error28.3
Cost1244
\[\begin{array}{l} t_1 := -60 \cdot \frac{x}{t}\\ \mathbf{if}\;a \leq -4.5 \cdot 10^{-243}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 3.3 \cdot 10^{-308}:\\ \;\;\;\;\frac{x}{z \cdot 0.016666666666666666}\\ \mathbf{elif}\;a \leq 3 \cdot 10^{-285}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 6.4 \cdot 10^{-258}:\\ \;\;\;\;\frac{-60}{\frac{z}{y}}\\ \mathbf{elif}\;a \leq 4.2 \cdot 10^{-229}:\\ \;\;\;\;60 \cdot \frac{y}{t}\\ \mathbf{elif}\;a \leq 2.1 \cdot 10^{-212}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.05 \cdot 10^{-127}:\\ \;\;\;\;60 \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 11
Error7.6
Cost1232
\[\begin{array}{l} t_1 := \frac{60 \cdot x}{z - t} + a \cdot 120\\ t_2 := \frac{y}{\frac{z - t}{-60}} + a \cdot 120\\ \mathbf{if}\;y \leq -1.45 \cdot 10^{+56}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 6 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.85 \cdot 10^{+58}:\\ \;\;\;\;\frac{y \cdot -60}{z - t} + a \cdot 120\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{+156}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 12
Error15.0
Cost1096
\[\begin{array}{l} \mathbf{if}\;a \cdot 120 \leq -4 \cdot 10^{-15}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \cdot 120 \leq 10^{+40}:\\ \;\;\;\;\frac{60}{z - t} \cdot \left(x - y\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 13
Error28.4
Cost848
\[\begin{array}{l} t_1 := 60 \cdot \frac{x}{z}\\ \mathbf{if}\;a \leq -4.4 \cdot 10^{-243}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq -1.95 \cdot 10^{-292}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 6 \cdot 10^{-227}:\\ \;\;\;\;-60 \cdot \frac{y}{z}\\ \mathbf{elif}\;a \leq 1.2 \cdot 10^{-127}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 14
Error0.2
Cost832
\[\frac{60}{\frac{z - t}{x - y}} + a \cdot 120 \]
Alternative 15
Error0.4
Cost832
\[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120 \]
Alternative 16
Error25.6
Cost712
\[\begin{array}{l} \mathbf{if}\;a \leq -2.6 \cdot 10^{-221}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 4 \cdot 10^{-129}:\\ \;\;\;\;-60 \cdot \frac{y}{z - t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 17
Error28.5
Cost584
\[\begin{array}{l} \mathbf{if}\;a \leq -4.2 \cdot 10^{-291}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 8.5 \cdot 10^{-155}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 18
Error28.5
Cost584
\[\begin{array}{l} \mathbf{if}\;a \leq -1.3 \cdot 10^{-222}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 2.05 \cdot 10^{-129}:\\ \;\;\;\;-60 \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 19
Error29.0
Cost192
\[a \cdot 120 \]

Error

Reproduce

herbie shell --seed 2022340 
(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)))