Average Error: 0.4 → 0.1
Time: 23.2s
Precision: binary64
Cost: 7104
\[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120 \]
\[\mathsf{fma}\left(60, \frac{x - y}{z - t}, a \cdot 120\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 60.0 (/ (- x y) (- z t)) (* a 120.0)))
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(60.0, ((x - y) / (z - t)), (a * 120.0));
}
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(60.0, Float64(Float64(x - y) / Float64(z - t)), Float64(a * 120.0))
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[(60.0 * N[(N[(x - y), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision] + N[(a * 120.0), $MachinePrecision]), $MachinePrecision]
\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120
\mathsf{fma}\left(60, \frac{x - y}{z - t}, a \cdot 120\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(60, \frac{x - y}{z - t}, a \cdot 120\right)} \]
    Proof

    [Start]0.4

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

    associate-*r/ [<=]0.2

    \[ \color{blue}{60 \cdot \frac{x - y}{z - t}} + a \cdot 120 \]

    fma-def [=>]0.1

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

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

Alternatives

Alternative 1
Error21.8
Cost2028
\[\begin{array}{l} t_1 := a \cdot 120 + -60 \cdot \frac{x}{t}\\ t_2 := \left(x - y\right) \cdot \frac{60}{z - t}\\ t_3 := a \cdot 120 + -60 \cdot \frac{y}{z}\\ t_4 := 60 \cdot \frac{x - y}{z - t}\\ t_5 := a \cdot 120 + 60 \cdot \frac{x}{z}\\ \mathbf{if}\;t \leq -4.2 \cdot 10^{+137}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -7.2 \cdot 10^{-13}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq -2.15 \cdot 10^{-32}:\\ \;\;\;\;a \cdot 120 + 60 \cdot \frac{y}{t}\\ \mathbf{elif}\;t \leq -7.6 \cdot 10^{-55}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t \leq -1.4 \cdot 10^{-90}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -2.06 \cdot 10^{-165}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -1.06 \cdot 10^{-243}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 6 \cdot 10^{-187}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 5 \cdot 10^{-108}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq 8.6 \cdot 10^{-54}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t \leq 3.8 \cdot 10^{+24}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error21.7
Cost2028
\[\begin{array}{l} t_1 := a \cdot 120 + -60 \cdot \frac{x}{t}\\ t_2 := \frac{60}{\frac{z - t}{x - y}}\\ t_3 := a \cdot 120 + -60 \cdot \frac{y}{z}\\ t_4 := 60 \cdot \frac{x - y}{z - t}\\ t_5 := a \cdot 120 + 60 \cdot \frac{x}{z}\\ \mathbf{if}\;t \leq -4.2 \cdot 10^{+137}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -4.35 \cdot 10^{-10}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq -5.4 \cdot 10^{-33}:\\ \;\;\;\;a \cdot 120 + 60 \cdot \frac{y}{t}\\ \mathbf{elif}\;t \leq -1.55 \cdot 10^{-55}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t \leq -4.3 \cdot 10^{-90}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -2.35 \cdot 10^{-165}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -1.9 \cdot 10^{-245}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.05 \cdot 10^{-186}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 1.1 \cdot 10^{-107}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq 3.3 \cdot 10^{-54}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t \leq 4.5 \cdot 10^{+22}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error21.8
Cost2028
\[\begin{array}{l} t_1 := a \cdot 120 + -60 \cdot \frac{x}{t}\\ t_2 := \frac{60}{\frac{z - t}{x - y}}\\ t_3 := a \cdot 120 + -60 \cdot \frac{y}{z}\\ t_4 := 60 \cdot \frac{x - y}{z - t}\\ t_5 := a \cdot 120 + 60 \cdot \frac{x}{z}\\ \mathbf{if}\;t \leq -1.15 \cdot 10^{+138}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -3.65 \cdot 10^{-9}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq -4 \cdot 10^{-35}:\\ \;\;\;\;a \cdot 120 + 60 \cdot \frac{y}{t}\\ \mathbf{elif}\;t \leq -2.25 \cdot 10^{-54}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t \leq -2.35 \cdot 10^{-90}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -1.55 \cdot 10^{-165}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -8.4 \cdot 10^{-244}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 4.3 \cdot 10^{-187}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 4.2 \cdot 10^{-108}:\\ \;\;\;\;\frac{x - y}{\left(z - t\right) \cdot 0.016666666666666666}\\ \mathbf{elif}\;t \leq 4 \cdot 10^{-54}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t \leq 1.65 \cdot 10^{+23}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error16.0
Cost1876
\[\begin{array}{l} t_1 := \frac{60}{\frac{z}{x - y}} + a \cdot 120\\ \mathbf{if}\;a \cdot 120 \leq -5 \cdot 10^{+91}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \cdot 120 \leq -2 \cdot 10^{-92}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot 120 \leq 2 \cdot 10^{-162}:\\ \;\;\;\;60 \cdot \frac{x - y}{z - t}\\ \mathbf{elif}\;a \cdot 120 \leq 10^{-67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot 120 \leq 10^{-6}:\\ \;\;\;\;\frac{60}{\frac{z - t}{x - y}}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 5
Error13.2
Cost1364
\[\begin{array}{l} t_1 := \frac{y \cdot -60}{z - t} + a \cdot 120\\ t_2 := \frac{60}{\frac{z}{x - y}} + a \cdot 120\\ \mathbf{if}\;z \leq -6.2 \cdot 10^{-22}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -5.4 \cdot 10^{-182}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-305}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{x}{t}\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{-56}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-13}:\\ \;\;\;\;\frac{x - y}{\left(z - t\right) \cdot 0.016666666666666666}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error16.1
Cost1106
\[\begin{array}{l} \mathbf{if}\;a \leq -1.85 \cdot 10^{+62} \lor \neg \left(a \leq -3.3 \cdot 10^{-9}\right) \land \left(a \leq -3.1 \cdot 10^{-79} \lor \neg \left(a \leq 1.66 \cdot 10^{-6}\right)\right):\\ \;\;\;\;a \cdot 120\\ \mathbf{else}:\\ \;\;\;\;60 \cdot \frac{x - y}{z - t}\\ \end{array} \]
Alternative 7
Error10.1
Cost1100
\[\begin{array}{l} t_1 := \frac{x - y}{\frac{t}{-60}} + a \cdot 120\\ \mathbf{if}\;t \leq -1.8 \cdot 10^{+101}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.3 \cdot 10^{-65}:\\ \;\;\;\;\frac{y \cdot -60}{z - t} + a \cdot 120\\ \mathbf{elif}\;t \leq 8.2 \cdot 10^{-37}:\\ \;\;\;\;\frac{60}{\frac{z}{x - y}} + a \cdot 120\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error10.1
Cost1100
\[\begin{array}{l} t_1 := \frac{x - y}{\frac{t}{-60}} + a \cdot 120\\ \mathbf{if}\;t \leq -9.5 \cdot 10^{+101}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.6 \cdot 10^{-65}:\\ \;\;\;\;\frac{y \cdot -60}{z - t} + a \cdot 120\\ \mathbf{elif}\;t \leq 3.6 \cdot 10^{-30}:\\ \;\;\;\;\frac{x - y}{\frac{z}{60}} + a \cdot 120\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error26.0
Cost976
\[\begin{array}{l} t_1 := -60 \cdot \frac{y}{z - t}\\ \mathbf{if}\;a \leq -8 \cdot 10^{-150}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 2.1 \cdot 10^{-271}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.12 \cdot 10^{-257}:\\ \;\;\;\;\frac{x \cdot -60}{t}\\ \mathbf{elif}\;a \leq 4 \cdot 10^{-165}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 10
Error15.1
Cost972
\[\begin{array}{l} \mathbf{if}\;a \leq -1.35 \cdot 10^{+67}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq -4.6 \cdot 10^{-34}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{y}{z}\\ \mathbf{elif}\;a \leq 0.00054:\\ \;\;\;\;60 \cdot \frac{x - y}{z - t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 11
Error26.0
Cost844
\[\begin{array}{l} \mathbf{if}\;a \leq -3.2 \cdot 10^{-119}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 1.5 \cdot 10^{-201}:\\ \;\;\;\;-60 \cdot \frac{x - y}{t}\\ \mathbf{elif}\;a \leq 3.8 \cdot 10^{-8}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{60}{z}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 12
Error26.0
Cost844
\[\begin{array}{l} \mathbf{if}\;a \leq -2.2 \cdot 10^{-119}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 1.25 \cdot 10^{-199}:\\ \;\;\;\;-60 \cdot \frac{x - y}{t}\\ \mathbf{elif}\;a \leq 3.7 \cdot 10^{-7}:\\ \;\;\;\;\frac{60}{\frac{z}{x - y}}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 13
Error26.0
Cost844
\[\begin{array}{l} \mathbf{if}\;a \leq -9.5 \cdot 10^{-119}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 2.95 \cdot 10^{-201}:\\ \;\;\;\;\frac{x - y}{\frac{t}{-60}}\\ \mathbf{elif}\;a \leq 1.1 \cdot 10^{-8}:\\ \;\;\;\;\frac{60}{\frac{z}{x - y}}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 14
Error0.2
Cost832
\[\frac{60}{\frac{z - t}{x - y}} + a \cdot 120 \]
Alternative 15
Error28.6
Cost716
\[\begin{array}{l} \mathbf{if}\;a \leq -1.18 \cdot 10^{-144}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq -4.5 \cdot 10^{-243}:\\ \;\;\;\;60 \cdot \frac{x}{z}\\ \mathbf{elif}\;a \leq 4 \cdot 10^{-215}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 16
Error29.1
Cost716
\[\begin{array}{l} \mathbf{if}\;a \leq -1.55 \cdot 10^{-177}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 5.6 \cdot 10^{-272}:\\ \;\;\;\;60 \cdot \frac{y}{t}\\ \mathbf{elif}\;a \leq 4 \cdot 10^{-213}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 17
Error29.1
Cost716
\[\begin{array}{l} \mathbf{if}\;a \leq -2.35 \cdot 10^{-176}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 5.6 \cdot 10^{-272}:\\ \;\;\;\;60 \cdot \frac{y}{t}\\ \mathbf{elif}\;a \leq 10^{-220}:\\ \;\;\;\;\frac{x}{t \cdot -0.016666666666666666}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 18
Error29.1
Cost716
\[\begin{array}{l} \mathbf{if}\;a \leq -2.1 \cdot 10^{-177}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 8 \cdot 10^{-272}:\\ \;\;\;\;60 \cdot \frac{y}{t}\\ \mathbf{elif}\;a \leq 2.1 \cdot 10^{-214}:\\ \;\;\;\;\frac{x}{\frac{t}{-60}}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 19
Error29.1
Cost716
\[\begin{array}{l} \mathbf{if}\;a \leq -1.8 \cdot 10^{-172}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 10^{-271}:\\ \;\;\;\;60 \cdot \frac{y}{t}\\ \mathbf{elif}\;a \leq 2.9 \cdot 10^{-220}:\\ \;\;\;\;\frac{x \cdot -60}{t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 20
Error26.1
Cost712
\[\begin{array}{l} \mathbf{if}\;a \leq -5.5 \cdot 10^{-119}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 3.5 \cdot 10^{-198}:\\ \;\;\;\;-60 \cdot \frac{x - y}{t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 21
Error28.8
Cost584
\[\begin{array}{l} \mathbf{if}\;a \leq -2 \cdot 10^{-120}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 3.4 \cdot 10^{-214}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 22
Error29.8
Cost192
\[a \cdot 120 \]

Error

Reproduce

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