?

Average Accuracy: 100.0% → 100.0%
Time: 13.1s
Precision: binary64
Cost: 6848

?

\[x + \left(y - z\right) \cdot \left(t - x\right) \]
\[\mathsf{fma}\left(y - z, t - x, x\right) \]
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
(FPCore (x y z t) :precision binary64 (fma (- y z) (- t x) x))
double code(double x, double y, double z, double t) {
	return x + ((y - z) * (t - x));
}
double code(double x, double y, double z, double t) {
	return fma((y - z), (t - x), x);
}
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y - z) * Float64(t - x)))
end
function code(x, y, z, t)
	return fma(Float64(y - z), Float64(t - x), x)
end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision] + x), $MachinePrecision]
x + \left(y - z\right) \cdot \left(t - x\right)
\mathsf{fma}\left(y - z, t - x, x\right)

Error?

Target

Original100.0%
Target100.0%
Herbie100.0%
\[x + \left(t \cdot \left(y - z\right) + \left(-x\right) \cdot \left(y - z\right)\right) \]

Derivation?

  1. Initial program 100.0%

    \[x + \left(y - z\right) \cdot \left(t - x\right) \]
  2. Simplified100.0%

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

    [Start]100.0

    \[ x + \left(y - z\right) \cdot \left(t - x\right) \]

    +-commutative [=>]100.0

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

    fma-def [=>]100.0

    \[ \color{blue}{\mathsf{fma}\left(y - z, t - x, x\right)} \]
  3. Final simplification100.0%

    \[\leadsto \mathsf{fma}\left(y - z, t - x, x\right) \]

Alternatives

Alternative 1
Accuracy48.3%
Cost2401
\[\begin{array}{l} t_1 := \left(y - z\right) \cdot t\\ \mathbf{if}\;y - z \leq -1 \cdot 10^{+153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq -5 \cdot 10^{+115}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;y - z \leq -2 \cdot 10^{-16}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq 2 \cdot 10^{-166}:\\ \;\;\;\;x\\ \mathbf{elif}\;y - z \leq 10^{-49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq 5 \cdot 10^{-11}:\\ \;\;\;\;x\\ \mathbf{elif}\;y - z \leq 2 \cdot 10^{+54} \lor \neg \left(y - z \leq 3 \cdot 10^{+190}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \end{array} \]
Alternative 2
Accuracy56.5%
Cost1508
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ t_2 := \left(y - z\right) \cdot t\\ \mathbf{if}\;z \leq -350:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5.2 \cdot 10^{-112}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -3.4 \cdot 10^{-143}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.7 \cdot 10^{-169}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{-253}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-213}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{-108}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 5.8 \cdot 10^{-61}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-28}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Accuracy56.7%
Cost1508
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ t_2 := x \cdot \left(z + 1\right)\\ t_3 := \left(y - z\right) \cdot t\\ \mathbf{if}\;z \leq -2500:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.8 \cdot 10^{-112}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -1.6 \cdot 10^{-143}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.24 \cdot 10^{-169}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{-253}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 7.8 \cdot 10^{-212}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 3.25 \cdot 10^{-108}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.75 \cdot 10^{-59}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{-27}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Accuracy64.1%
Cost1244
\[\begin{array}{l} t_1 := x \cdot \left(1 - y\right)\\ t_2 := z \cdot \left(x - t\right)\\ t_3 := \left(y - z\right) \cdot t\\ \mathbf{if}\;z \leq -1620:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -9 \cdot 10^{-106}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-143}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{-169}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{-253}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-223}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-17}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Accuracy64.3%
Cost1244
\[\begin{array}{l} t_1 := x \cdot \left(1 - y\right)\\ t_2 := z \cdot \left(x - t\right)\\ t_3 := y \cdot \left(t - x\right)\\ \mathbf{if}\;z \leq -2.9 \cdot 10^{-5}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -6.5 \cdot 10^{-112}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -4.6 \cdot 10^{-144}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.1 \cdot 10^{-175}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{-255}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{-216}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{-16}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Accuracy38.7%
Cost1116
\[\begin{array}{l} \mathbf{if}\;z \leq -0.00088:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq -7.4 \cdot 10^{-112}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;z \leq -6 \cdot 10^{-144}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -9 \cdot 10^{-170}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;z \leq 5.6 \cdot 10^{-254}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{-223}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{-9}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 7
Accuracy100.0%
Cost832
\[\left(x + \left(y - z\right) \cdot t\right) + x \cdot \left(z - y\right) \]
Alternative 8
Accuracy71.2%
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -10200000000000 \lor \neg \left(t \leq 2.4 \cdot 10^{-64}\right):\\ \;\;\;\;\left(y - z\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\left(z + 1\right) - y\right)\\ \end{array} \]
Alternative 9
Accuracy83.5%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -2.95 \cdot 10^{-5} \lor \neg \left(z \leq 2.6 \cdot 10^{-16}\right):\\ \;\;\;\;z \cdot \left(x - t\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(t - x\right)\\ \end{array} \]
Alternative 10
Accuracy100.0%
Cost576
\[x + \left(y - z\right) \cdot \left(t - x\right) \]
Alternative 11
Accuracy36.6%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.4 \cdot 10^{-33}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{+29}:\\ \;\;\;\;y \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Accuracy26.1%
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023151 
(FPCore (x y z t)
  :name "Data.Metrics.Snapshot:quantile from metrics-0.3.0.2"
  :precision binary64

  :herbie-target
  (+ x (+ (* t (- y z)) (* (- x) (- y z))))

  (+ x (* (- y z) (- t x))))