?

Average Accuracy: 100.0% → 100.0%
Time: 13.8s
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
Accuracy35.5%
Cost1444
\[\begin{array}{l} t_1 := z \cdot \left(-t\right)\\ t_2 := y \cdot \left(-x\right)\\ \mathbf{if}\;y \leq -1.45 \cdot 10^{+38}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -4.5 \cdot 10^{-56}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{-74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -9 \cdot 10^{-129}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq -1.6 \cdot 10^{-202}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -4 \cdot 10^{-264}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;y \leq 3.25 \cdot 10^{-143}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{-87}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{-6}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Accuracy63.9%
Cost1112
\[\begin{array}{l} t_1 := y \cdot \left(t - x\right)\\ t_2 := x \cdot \left(z + 1\right)\\ \mathbf{if}\;y \leq -8.5 \cdot 10^{-22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.3 \cdot 10^{-54}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -2.4 \cdot 10^{-130}:\\ \;\;\;\;\left(y - z\right) \cdot t\\ \mathbf{elif}\;y \leq 1.72 \cdot 10^{-143}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{-92}:\\ \;\;\;\;z \cdot \left(x - t\right)\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{-7}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Accuracy67.7%
Cost980
\[\begin{array}{l} t_1 := y \cdot \left(t - x\right)\\ t_2 := x \cdot \left(z + 1\right)\\ \mathbf{if}\;y \leq -8.2 \cdot 10^{-22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.06 \cdot 10^{-53}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -9 \cdot 10^{-130}:\\ \;\;\;\;\left(y - z\right) \cdot t\\ \mathbf{elif}\;y \leq -2.3 \cdot 10^{-263}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 720:\\ \;\;\;\;x - z \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Accuracy76.5%
Cost976
\[\begin{array}{l} t_1 := y \cdot \left(t - x\right)\\ t_2 := x + \left(y - z\right) \cdot t\\ \mathbf{if}\;y \leq -6500000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.4 \cdot 10^{-162}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -1.2 \cdot 10^{-264}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{elif}\;y \leq 18000:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Accuracy37.9%
Cost852
\[\begin{array}{l} \mathbf{if}\;z \leq -3.6 \cdot 10^{+25}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq -9.2 \cdot 10^{-234}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.22 \cdot 10^{-261}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-115}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 0.00038:\\ \;\;\;\;y \cdot t\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 6
Accuracy54.7%
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -5.4 \cdot 10^{+77}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -5.8 \cdot 10^{-60}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;x \leq 8.8 \cdot 10^{-123}:\\ \;\;\;\;\left(y - z\right) \cdot t\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{+169}:\\ \;\;\;\;z \cdot \left(x - t\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Accuracy60.6%
Cost848
\[\begin{array}{l} t_1 := x \cdot \left(z + 1\right)\\ \mathbf{if}\;x \leq -6.5 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.25 \cdot 10^{-60}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-125}:\\ \;\;\;\;\left(y - z\right) \cdot t\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{+39}:\\ \;\;\;\;z \cdot \left(x - t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Accuracy83.5%
Cost844
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -35000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-71}:\\ \;\;\;\;x + y \cdot \left(t - x\right)\\ \mathbf{elif}\;z \leq 0.00022:\\ \;\;\;\;x + \left(y - z\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Accuracy84.2%
Cost844
\[\begin{array}{l} t_1 := x + z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -8.9 \cdot 10^{-10}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 8.8 \cdot 10^{-65}:\\ \;\;\;\;x + y \cdot \left(t - x\right)\\ \mathbf{elif}\;z \leq 0.00036:\\ \;\;\;\;x + \left(y - z\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Accuracy35.8%
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{-82}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-292}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-82}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{+169}:\\ \;\;\;\;z \cdot x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Accuracy53.4%
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{+78}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -5.5 \cdot 10^{-60}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{-31}:\\ \;\;\;\;\left(y - z\right) \cdot t\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{+169}:\\ \;\;\;\;z \cdot x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Accuracy100.0%
Cost576
\[x + \left(y - z\right) \cdot \left(t - x\right) \]
Alternative 13
Accuracy38.4%
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -9 \cdot 10^{-129}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq 1.28 \cdot 10^{-6}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot t\\ \end{array} \]
Alternative 14
Accuracy25.3%
Cost64
\[x \]

Error

Reproduce?

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