?

Average Accuracy: 100.0% → 100.0%
Time: 14.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?

Bogosity?

Bogosity

Target

Original100.0%
Target96.3%
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
Accuracy37.5%
Cost1444
\[\begin{array}{l} t_1 := z \cdot \left(-t\right)\\ t_2 := y \cdot \left(-x\right)\\ \mathbf{if}\;z \leq -1.75 \cdot 10^{+251}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{+210}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq -1.5 \cdot 10^{+151}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -95000000000:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{-100}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{-256}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4.3 \cdot 10^{-103}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;z \leq 9.2 \cdot 10^{-64}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-32}:\\ \;\;\;\;y \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Accuracy56.3%
Cost1361
\[\begin{array}{l} t_1 := \left(y - z\right) \cdot t\\ \mathbf{if}\;y - z \leq -1 \cdot 10^{-20}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq 2 \cdot 10^{-35}:\\ \;\;\;\;x\\ \mathbf{elif}\;y - z \leq 5 \cdot 10^{+126} \lor \neg \left(y - z \leq 2 \cdot 10^{+151}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \end{array} \]
Alternative 3
Accuracy58.3%
Cost1112
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ t_2 := \left(y - z\right) \cdot t\\ \mathbf{if}\;z \leq -22500000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{-97}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-154}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -2.8 \cdot 10^{-261}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-205}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 0.082:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Accuracy58.4%
Cost1112
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ t_2 := \left(y - z\right) \cdot t\\ \mathbf{if}\;z \leq -22000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.05 \cdot 10^{-98}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{-155}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{elif}\;z \leq -4.4 \cdot 10^{-261}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{-205}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 0.082:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Accuracy36.9%
Cost1048
\[\begin{array}{l} t_1 := z \cdot \left(-t\right)\\ \mathbf{if}\;z \leq -2.15 \cdot 10^{+251}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.7 \cdot 10^{+209}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{+146}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{-256}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4.3 \cdot 10^{-103}:\\ \;\;\;\;y \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Accuracy67.3%
Cost848
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ t_2 := x \cdot \left(1 - y\right)\\ \mathbf{if}\;z \leq -85000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{-203}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 2.7 \cdot 10^{-122}:\\ \;\;\;\;\left(y - z\right) \cdot t\\ \mathbf{elif}\;z \leq 1.16 \cdot 10^{-14}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Accuracy73.8%
Cost844
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -85000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.35 \cdot 10^{-150}:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \mathbf{elif}\;z \leq 22000000:\\ \;\;\;\;x + \left(y - z\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Accuracy68.1%
Cost716
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -85000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{-254}:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \mathbf{elif}\;z \leq 102:\\ \;\;\;\;y \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Accuracy70.5%
Cost716
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -85000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.55 \cdot 10^{-150}:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \mathbf{elif}\;z \leq 4.9 \cdot 10^{-22}:\\ \;\;\;\;x + y \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Accuracy84.2%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -85000000000 \lor \neg \left(z \leq 2500\right):\\ \;\;\;\;z \cdot \left(x - t\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(t - x\right)\\ \end{array} \]
Alternative 11
Accuracy84.6%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -2.6 \cdot 10^{-6} \lor \neg \left(z \leq 2000000\right):\\ \;\;\;\;x + z \cdot \left(x - t\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(t - x\right)\\ \end{array} \]
Alternative 12
Accuracy37.0%
Cost588
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{-256}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 0.0062:\\ \;\;\;\;y \cdot t\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 13
Accuracy100.0%
Cost576
\[x + \left(y - z\right) \cdot \left(t - x\right) \]
Alternative 14
Accuracy38.7%
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -4.2 \cdot 10^{-15}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-30}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot t\\ \end{array} \]
Alternative 15
Accuracy18.3%
Cost64
\[x \]

Error

Reproduce?

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