?

Average Error: 0.4 → 0.1
Time: 21.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

    [Start]0.4

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

    +-commutative [=>]0.4

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

    fma-def [=>]0.4

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

    associate-*l/ [<=]0.1

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

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

Alternatives

Alternative 1
Error0.2
Cost7104
\[\mathsf{fma}\left(60, \frac{x - y}{z - t}, a \cdot 120\right) \]
Alternative 2
Error25.7
Cost1236
\[\begin{array}{l} t_1 := a \cdot 120 + -60 \cdot \frac{x}{t}\\ \mathbf{if}\;z \leq -1.08 \cdot 10^{+88}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;z \leq -2.7 \cdot 10^{+44}:\\ \;\;\;\;\frac{y \cdot -60}{z - t}\\ \mathbf{elif}\;z \leq -4.3 \cdot 10^{-306}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-217}:\\ \;\;\;\;\frac{60}{t} \cdot \left(y - x\right)\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{+75}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 3
Error13.7
Cost1233
\[\begin{array}{l} \mathbf{if}\;x \leq -6.2 \cdot 10^{+172}:\\ \;\;\;\;\frac{60}{\frac{z - t}{x - y}}\\ \mathbf{elif}\;x \leq -1.1 \cdot 10^{+26} \lor \neg \left(x \leq -4.3 \cdot 10^{-18}\right) \land x \leq 2.05 \cdot 10^{+158}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{y}{z - t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{x}{t}\\ \end{array} \]
Alternative 4
Error13.3
Cost1233
\[\begin{array}{l} \mathbf{if}\;x \leq -5.6 \cdot 10^{+170}:\\ \;\;\;\;\frac{60}{\frac{z - t}{x - y}}\\ \mathbf{elif}\;x \leq -2.65 \cdot 10^{+42} \lor \neg \left(x \leq -3.4 \cdot 10^{-18}\right) \land x \leq 4.4 \cdot 10^{+142}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{y}{z - t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{x - y}{t}\\ \end{array} \]
Alternative 5
Error26.3
Cost1109
\[\begin{array}{l} \mathbf{if}\;a \leq -5.2 \cdot 10^{-111}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq -1.16 \cdot 10^{-143}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{elif}\;a \leq 2.7 \cdot 10^{-222} \lor \neg \left(a \leq 1.4 \cdot 10^{-100}\right) \land a \leq 3.7 \cdot 10^{-36}:\\ \;\;\;\;-60 \cdot \frac{y}{z - t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 6
Error20.9
Cost1104
\[\begin{array}{l} t_1 := a \cdot 120 + -60 \cdot \frac{x}{t}\\ t_2 := a \cdot 120 + -60 \cdot \frac{y}{z}\\ \mathbf{if}\;z \leq -1.6 \cdot 10^{-13}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -5.5 \cdot 10^{-306}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{-215}:\\ \;\;\;\;\frac{60}{t} \cdot \left(y - x\right)\\ \mathbf{elif}\;z \leq 320:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error21.0
Cost1104
\[\begin{array}{l} t_1 := a \cdot 120 + -60 \cdot \frac{x}{t}\\ t_2 := a \cdot 120 + \frac{y}{\frac{z}{-60}}\\ \mathbf{if}\;z \leq -1.12 \cdot 10^{-13}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -6 \cdot 10^{-305}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 10^{-210}:\\ \;\;\;\;\frac{60}{t} \cdot \left(y - x\right)\\ \mathbf{elif}\;z \leq 150:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error25.6
Cost977
\[\begin{array}{l} \mathbf{if}\;a \leq -2.4 \cdot 10^{-86}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 4.05 \cdot 10^{-150}:\\ \;\;\;\;-60 \cdot \frac{x - y}{t}\\ \mathbf{elif}\;a \leq 3.2 \cdot 10^{-99} \lor \neg \left(a \leq 3.3 \cdot 10^{-36}\right):\\ \;\;\;\;a \cdot 120\\ \mathbf{else}:\\ \;\;\;\;-60 \cdot \frac{y}{z - t}\\ \end{array} \]
Alternative 9
Error25.6
Cost976
\[\begin{array}{l} \mathbf{if}\;a \leq -4.2 \cdot 10^{-86}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 4.1 \cdot 10^{-150}:\\ \;\;\;\;\frac{60}{t} \cdot \left(y - x\right)\\ \mathbf{elif}\;a \leq 9.2 \cdot 10^{-99}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 3.3 \cdot 10^{-36}:\\ \;\;\;\;-60 \cdot \frac{y}{z - t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 10
Error7.1
Cost969
\[\begin{array}{l} \mathbf{if}\;x \leq -5.4 \cdot 10^{-42} \lor \neg \left(x \leq 2.1 \cdot 10^{+41}\right):\\ \;\;\;\;\frac{60 \cdot x}{z - t} + a \cdot 120\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{y}{z - t}\\ \end{array} \]
Alternative 11
Error15.0
Cost840
\[\begin{array}{l} \mathbf{if}\;a \leq -1.3 \cdot 10^{-30}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 4.3 \cdot 10^{-36}:\\ \;\;\;\;\frac{60}{\frac{z - t}{x - y}}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 12
Error0.2
Cost832
\[\frac{60}{\frac{z - t}{x - y}} + a \cdot 120 \]
Alternative 13
Error29.1
Cost716
\[\begin{array}{l} \mathbf{if}\;a \leq -5.8 \cdot 10^{-111}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq -1.95 \cdot 10^{-231}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{elif}\;a \leq 1.4 \cdot 10^{-247}:\\ \;\;\;\;60 \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 14
Error29.1
Cost716
\[\begin{array}{l} \mathbf{if}\;a \leq -6.3 \cdot 10^{-111}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq -7 \cdot 10^{-233}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{elif}\;a \leq 1.8 \cdot 10^{-245}:\\ \;\;\;\;y \cdot \frac{60}{t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 15
Error28.7
Cost584
\[\begin{array}{l} \mathbf{if}\;a \leq -5.3 \cdot 10^{-111}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 2.45 \cdot 10^{-226}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 16
Error29.1
Cost192
\[a \cdot 120 \]

Error

Reproduce?

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