?

Average Accuracy: 99.4% → 99.8%
Time: 28.0s
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

Original99.4%
Target99.8%
Herbie99.8%
\[\frac{60}{\frac{z - t}{x - y}} + a \cdot 120 \]

Derivation?

  1. Initial program 99.7%

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

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

    [Start]99.7

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

    +-commutative [=>]99.7

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

    fma-def [=>]99.8

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

    associate-*l/ [<=]99.9

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

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

Alternatives

Alternative 1
Accuracy99.8%
Cost7104
\[\mathsf{fma}\left(60, \frac{x - y}{z - t}, a \cdot 120\right) \]
Alternative 2
Accuracy50.4%
Cost2528
\[\begin{array}{l} t_1 := \frac{x - y}{t \cdot -0.016666666666666666}\\ t_2 := 60 \cdot \frac{x}{z - t}\\ \mathbf{if}\;z - t \leq 2 \cdot 10^{+117}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;z - t \leq 10^{+50}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z - t \leq 2 \cdot 10^{+18}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;z - t \leq 5 \cdot 10^{-29}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z - t \leq 2 \cdot 10^{-87}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z - t \leq 4 \cdot 10^{-29}:\\ \;\;\;\;60 \cdot \frac{x - y}{z}\\ \mathbf{elif}\;z - t \leq 2 \cdot 10^{+55}:\\ \;\;\;\;\frac{-60}{\frac{z - t}{y}}\\ \mathbf{elif}\;z - t \leq 2 \cdot 10^{+60}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 3
Accuracy50.4%
Cost2268
\[\begin{array}{l} t_1 := \frac{x - y}{t \cdot -0.016666666666666666}\\ \mathbf{if}\;z - t \leq 2 \cdot 10^{+117}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;z - t \leq 10^{+50}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z - t \leq 500000:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{x}{t}\\ \mathbf{elif}\;z - t \leq 2 \cdot 10^{-87}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z - t \leq 4 \cdot 10^{-29}:\\ \;\;\;\;60 \cdot \frac{x - y}{z}\\ \mathbf{elif}\;z - t \leq 2 \cdot 10^{+55}:\\ \;\;\;\;\frac{-60}{\frac{z - t}{y}}\\ \mathbf{elif}\;z - t \leq 2 \cdot 10^{+60}:\\ \;\;\;\;60 \cdot \frac{x}{z - t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 4
Accuracy54.9%
Cost1500
\[\begin{array}{l} t_1 := \frac{x - y}{t \cdot -0.016666666666666666}\\ t_2 := a \cdot 120 + -60 \cdot \frac{x}{t}\\ t_3 := a \cdot 120 + -60 \cdot \frac{y}{z}\\ \mathbf{if}\;z \leq 1.4 \cdot 10^{+34}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-96}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-119}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{-137}:\\ \;\;\;\;60 \cdot \frac{x - y}{z}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-249}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{-287}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{-29}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 5
Accuracy50.4%
Cost1372
\[\begin{array}{l} t_1 := 60 \cdot \frac{x}{z - t}\\ t_2 := -60 \cdot \frac{y}{z - t}\\ \mathbf{if}\;a \leq 7 \cdot 10^{-25}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 5.5 \cdot 10^{-150}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 1.7 \cdot 10^{-293}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.9 \cdot 10^{-240}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 4.5 \cdot 10^{-184}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.5 \cdot 10^{-165}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 1.9 \cdot 10^{-38}:\\ \;\;\;\;60 \cdot \frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 6
Accuracy50.4%
Cost1372
\[\begin{array}{l} t_1 := 60 \cdot \frac{x}{z - t}\\ t_2 := -60 \cdot \frac{y}{z - t}\\ \mathbf{if}\;a \leq 1.22 \cdot 10^{-19}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 8.8 \cdot 10^{-150}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 3 \cdot 10^{-294}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.8 \cdot 10^{-241}:\\ \;\;\;\;y \cdot \frac{-60}{z - t}\\ \mathbf{elif}\;a \leq 6.6 \cdot 10^{-184}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 7.5 \cdot 10^{-168}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 1.9 \cdot 10^{-33}:\\ \;\;\;\;60 \cdot \frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 7
Accuracy55.0%
Cost1368
\[\begin{array}{l} t_1 := a \cdot 120 + 60 \cdot \frac{x}{z}\\ t_2 := a \cdot 120 + -60 \cdot \frac{x}{t}\\ \mathbf{if}\;z \leq 1.9 \cdot 10^{+42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-160}:\\ \;\;\;\;a \cdot 120 + 60 \cdot \frac{y}{t}\\ \mathbf{elif}\;z \leq 7.4 \cdot 10^{-249}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{-287}:\\ \;\;\;\;\frac{x - y}{t \cdot -0.016666666666666666}\\ \mathbf{elif}\;z \leq 7.8 \cdot 10^{-29}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{+133}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Accuracy50.4%
Cost1240
\[\begin{array}{l} \mathbf{if}\;a \leq 1.3 \cdot 10^{-20}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 2.3 \cdot 10^{-149}:\\ \;\;\;\;-60 \cdot \frac{y}{z - t}\\ \mathbf{elif}\;a \leq 3.9 \cdot 10^{-293}:\\ \;\;\;\;60 \cdot \frac{x}{z - t}\\ \mathbf{elif}\;a \leq 1.7 \cdot 10^{-239}:\\ \;\;\;\;y \cdot \frac{-60}{z - t}\\ \mathbf{elif}\;a \leq 3.6 \cdot 10^{-184}:\\ \;\;\;\;\frac{60}{z - t} \cdot x\\ \mathbf{elif}\;a \leq 1.06 \cdot 10^{-38}:\\ \;\;\;\;60 \cdot \frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 9
Accuracy54.9%
Cost1236
\[\begin{array}{l} t_1 := a \cdot 120 + -60 \cdot \frac{x}{t}\\ t_2 := a \cdot 120 + 60 \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq 2.05 \cdot 10^{+52}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{-249}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-287}:\\ \;\;\;\;\frac{x - y}{t \cdot -0.016666666666666666}\\ \mathbf{elif}\;z \leq 5.1 \cdot 10^{-29}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.8 \cdot 10^{+133}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 10
Accuracy50.3%
Cost1228
\[\begin{array}{l} \mathbf{if}\;z - t \leq 500000:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;z - t \leq 2 \cdot 10^{-216}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{elif}\;z - t \leq 2 \cdot 10^{+55}:\\ \;\;\;\;-60 \cdot \frac{y}{z - t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 11
Accuracy75.3%
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot 120 \leq 5 \cdot 10^{-23} \lor \neg \left(a \cdot 120 \leq 5 \cdot 10^{-109}\right):\\ \;\;\;\;\frac{60}{z - t} \cdot x + a \cdot 120\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{\frac{z - t}{60}}\\ \end{array} \]
Alternative 12
Accuracy50.4%
Cost1108
\[\begin{array}{l} t_1 := 60 \cdot \frac{x}{z - t}\\ t_2 := -60 \cdot \frac{y}{z - t}\\ \mathbf{if}\;a \leq 2.65 \cdot 10^{-22}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 1.9 \cdot 10^{-149}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 6.5 \cdot 10^{-293}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.2 \cdot 10^{-238}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 1.02 \cdot 10^{-38}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 13
Accuracy56.0%
Cost1096
\[\begin{array}{l} \mathbf{if}\;a \cdot 120 \leq 5 \cdot 10^{-23}:\\ \;\;\;\;a \cdot 120 + -60 \cdot \frac{y}{z}\\ \mathbf{elif}\;a \cdot 120 \leq 50000:\\ \;\;\;\;\frac{x - y}{\frac{z - t}{60}}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 14
Accuracy75.3%
Cost969
\[\begin{array}{l} \mathbf{if}\;x \leq 5.5 \cdot 10^{+48} \lor \neg \left(x \leq 4.6 \cdot 10^{-50}\right):\\ \;\;\;\;\frac{60}{z - t} \cdot x + a \cdot 120\\ \mathbf{else}:\\ \;\;\;\;\frac{-60}{\frac{z - t}{y}} + a \cdot 120\\ \end{array} \]
Alternative 15
Accuracy75.3%
Cost968
\[\begin{array}{l} \mathbf{if}\;x \leq 6.7 \cdot 10^{+47}:\\ \;\;\;\;\frac{60}{\frac{z - t}{x}} + a \cdot 120\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-51}:\\ \;\;\;\;\frac{-60}{\frac{z - t}{y}} + a \cdot 120\\ \mathbf{else}:\\ \;\;\;\;\frac{60}{z - t} \cdot x + a \cdot 120\\ \end{array} \]
Alternative 16
Accuracy50.4%
Cost848
\[\begin{array}{l} \mathbf{if}\;a \leq 6.6 \cdot 10^{-77}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 4.4 \cdot 10^{-153}:\\ \;\;\;\;60 \cdot \frac{y}{t}\\ \mathbf{elif}\;a \leq 6 \cdot 10^{-306}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{elif}\;a \leq 9.5 \cdot 10^{-80}:\\ \;\;\;\;60 \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 17
Accuracy50.4%
Cost848
\[\begin{array}{l} \mathbf{if}\;a \leq 5.6 \cdot 10^{-77}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 2.85 \cdot 10^{-153}:\\ \;\;\;\;60 \cdot \frac{y}{t}\\ \mathbf{elif}\;a \leq 4.3 \cdot 10^{-305}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{elif}\;a \leq 1.86 \cdot 10^{-78}:\\ \;\;\;\;\frac{60}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 18
Accuracy99.8%
Cost832
\[\frac{60}{\frac{z - t}{x - y}} + a \cdot 120 \]
Alternative 19
Accuracy50.4%
Cost716
\[\begin{array}{l} \mathbf{if}\;a \leq 1.85 \cdot 10^{-153}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 1.52 \cdot 10^{-292}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{elif}\;a \leq 5 \cdot 10^{-244}:\\ \;\;\;\;-60 \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 20
Accuracy49.9%
Cost716
\[\begin{array}{l} \mathbf{if}\;a \leq 1.75 \cdot 10^{-153}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 5.8 \cdot 10^{-302}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{elif}\;a \leq 3.3 \cdot 10^{-80}:\\ \;\;\;\;60 \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 21
Accuracy50.4%
Cost584
\[\begin{array}{l} \mathbf{if}\;a \leq 2.6 \cdot 10^{-153}:\\ \;\;\;\;a \cdot 120\\ \mathbf{elif}\;a \leq 6.2 \cdot 10^{-267}:\\ \;\;\;\;-60 \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;a \cdot 120\\ \end{array} \]
Alternative 22
Accuracy50.4%
Cost192
\[a \cdot 120 \]

Error

Reproduce?

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