?

Average Error: 0.5 → 0.1
Time: 19.3s
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.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.1

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

    [Start]0.5

    \[ \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
Error14.0
Cost1364
\[\begin{array}{l} t_1 := \left(x - y\right) \cdot \frac{60}{z - t}\\ t_2 := a \cdot 120 + \frac{60}{\frac{z}{x - y}}\\ \mathbf{if}\;z \leq -1.75 \cdot 10^{+15}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.9 \cdot 10^{-77}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{-301}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{x}{t}\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{-19}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{y}{z - t}\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{+41}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error20.6
Cost1236
\[\begin{array}{l} t_1 := \left(x - y\right) \cdot \frac{60}{z - t}\\ t_2 := a \cdot 120 + -60 \cdot \frac{y}{z}\\ t_3 := a \cdot 120 + -60 \cdot \frac{x}{t}\\ \mathbf{if}\;z \leq -9 \cdot 10^{+105}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-77}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{-153}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-137}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+42}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error20.6
Cost1236
\[\begin{array}{l} t_1 := \left(x - y\right) \cdot \frac{60}{z - t}\\ t_2 := a \cdot 120 + -60 \cdot \frac{y}{z}\\ \mathbf{if}\;z \leq -1.75 \cdot 10^{+106}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-77}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{-301}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{x}{t}\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-77}:\\ \;\;\;\;a \cdot 120 + 60 \cdot \frac{y}{t}\\ \mathbf{elif}\;z \leq 8 \cdot 10^{+41}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error20.6
Cost1236
\[\begin{array}{l} t_1 := \left(x - y\right) \cdot \frac{60}{z - t}\\ \mathbf{if}\;z \leq -2.5 \cdot 10^{+107}:\\ \;\;\;\;a \cdot 120 + y \cdot \frac{-60}{z}\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-77}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{-301}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{x}{t}\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-77}:\\ \;\;\;\;a \cdot 120 + 60 \cdot \frac{y}{t}\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{+41}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{y}{z}\\ \end{array} \]
Alternative 5
Error20.0
Cost1236
\[\begin{array}{l} t_1 := \left(x - y\right) \cdot \frac{60}{z - t}\\ t_2 := a \cdot 120 + \frac{60}{\frac{z}{x}}\\ \mathbf{if}\;z \leq -1 \cdot 10^{+79}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.9 \cdot 10^{-77}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{-301}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{x}{t}\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-80}:\\ \;\;\;\;a \cdot 120 + 60 \cdot \frac{y}{t}\\ \mathbf{elif}\;z \leq 2.85 \cdot 10^{+41}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error18.6
Cost1236
\[\begin{array}{l} t_1 := \left(x - y\right) \cdot \frac{60}{z - t}\\ t_2 := a \cdot 120 + \frac{60}{\frac{z}{x}}\\ \mathbf{if}\;z \leq -5.1 \cdot 10^{+79}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-77}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{-301}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{x}{t}\\ \mathbf{elif}\;z \leq 9.2 \cdot 10^{-19}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{y}{z - t}\\ \mathbf{elif}\;z \leq 3.7 \cdot 10^{+42}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error27.5
Cost976
\[\begin{array}{l} t_1 := 60 \cdot \frac{x}{z - t}\\ \mathbf{if}\;x \leq -3.9 \cdot 10^{+70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{-112}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-140}:\\ \;\;\;\;-60 \cdot \frac{y}{z - t}\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{+142}:\\ \;\;\;\;a \cdot 120\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error27.5
Cost976
\[\begin{array}{l} t_1 := 60 \cdot \frac{x}{z - t}\\ \mathbf{if}\;x \leq -3.9 \cdot 10^{+70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-112}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-140}:\\ \;\;\;\;y \cdot \frac{-60}{z - t}\\ \mathbf{elif}\;x \leq 9.6 \cdot 10^{+145}:\\ \;\;\;\;a \cdot 120\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error7.2
Cost969
\[\begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-67} \lor \neg \left(x \leq 7.2 \cdot 10^{-16}\right):\\ \;\;\;\;\frac{60}{\frac{z - t}{x}} + a \cdot 120\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{y}{z - t}\\ \end{array} \]
Alternative 10
Error32.4
Cost848
\[\begin{array}{l} \mathbf{if}\;z \leq -1.06 \cdot 10^{+78}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;z \leq -9.8 \cdot 10^{-33}:\\ \;\;\;\;-60 \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{-19}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{+41}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 11
Error33.2
Cost848
\[\begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{+105}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;z \leq -2.55 \cdot 10^{-55}:\\ \;\;\;\;60 \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{-19}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{+41}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 12
Error33.2
Cost848
\[\begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{+105}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;z \leq -2.55 \cdot 10^{-55}:\\ \;\;\;\;\frac{60}{\frac{z}{x}}\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{-19}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{+41}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 13
Error15.1
Cost841
\[\begin{array}{l} \mathbf{if}\;a \leq -7.5 \cdot 10^{+27} \lor \neg \left(a \leq 1.1 \cdot 10^{-35}\right):\\ \;\;\;\;a \cdot 120\\ \mathbf{else}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{60}{z - t}\\ \end{array} \]
Alternative 14
Error0.2
Cost832
\[\frac{60}{\frac{z - t}{x - y}} + a \cdot 120 \]
Alternative 15
Error26.8
Cost712
\[\begin{array}{l} \mathbf{if}\;a \leq -3.3 \cdot 10^{-84}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 1.35 \cdot 10^{-287}:\\ \;\;\;\;-60 \cdot \frac{y}{z - t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 16
Error30.6
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq 6 \cdot 10^{-19}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{+41}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 17
Error29.6
Cost192
\[a \cdot 120 \]

Error

Reproduce?

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