?

Average Accuracy: 100.0% → 100.0%
Time: 12.6s
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
Accuracy52.6%
Cost3442
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ t_2 := y \cdot \left(t - x\right)\\ \mathbf{if}\;y - z \leq -2 \cdot 10^{+258}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y - z \leq -5 \cdot 10^{+174}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq -5 \cdot 10^{+154}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y - z \leq -0.04:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq 4 \cdot 10^{-131}:\\ \;\;\;\;x\\ \mathbf{elif}\;y - z \leq 4 \cdot 10^{-52}:\\ \;\;\;\;\left(y - z\right) \cdot t\\ \mathbf{elif}\;y - z \leq 5 \cdot 10^{-36}:\\ \;\;\;\;x\\ \mathbf{elif}\;y - z \leq 10^{+101} \lor \neg \left(y - z \leq 2 \cdot 10^{+125}\right) \land \left(y - z \leq 10^{+164} \lor \neg \left(y - z \leq 2 \cdot 10^{+195}\right) \land y - z \leq 2 \cdot 10^{+246}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Accuracy51.7%
Cost2922
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ t_2 := \left(y - z\right) \cdot t\\ \mathbf{if}\;y - z \leq -5 \cdot 10^{+174}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq -5 \cdot 10^{+154}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;y - z \leq -0.04:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq 4 \cdot 10^{-131}:\\ \;\;\;\;x\\ \mathbf{elif}\;y - z \leq 4 \cdot 10^{-52}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y - z \leq 5 \cdot 10^{-36}:\\ \;\;\;\;x\\ \mathbf{elif}\;y - z \leq 5 \cdot 10^{+94} \lor \neg \left(y - z \leq 10^{+182} \lor \neg \left(y - z \leq 2 \cdot 10^{+246}\right) \land y - z \leq 10^{+301}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Accuracy59.7%
Cost2922
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ t_2 := y \cdot \left(t - x\right)\\ \mathbf{if}\;y - z \leq -2 \cdot 10^{+258}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y - z \leq -5 \cdot 10^{+174}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq -5 \cdot 10^{+154}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y - z \leq -0.04:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq 5 \cdot 10^{-36}:\\ \;\;\;\;x + y \cdot t\\ \mathbf{elif}\;y - z \leq 10^{+101} \lor \neg \left(y - z \leq 2 \cdot 10^{+125}\right) \land \left(y - z \leq 10^{+164} \lor \neg \left(y - z \leq 2 \cdot 10^{+195}\right) \land y - z \leq 2 \cdot 10^{+246}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Accuracy49.3%
Cost2401
\[\begin{array}{l} t_1 := \left(y - z\right) \cdot t\\ \mathbf{if}\;y - z \leq -1 \cdot 10^{+174}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq -1 \cdot 10^{+154}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;y - z \leq -2 \cdot 10^{+100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq -2 \cdot 10^{+48}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;y - z \leq -0.04:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq 4 \cdot 10^{-131}:\\ \;\;\;\;x\\ \mathbf{elif}\;y - z \leq 10^{+182} \lor \neg \left(y - z \leq 2 \cdot 10^{+246}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 5
Accuracy38.4%
Cost1710
\[\begin{array}{l} t_1 := z \cdot \left(-t\right)\\ \mathbf{if}\;z \leq -8.8 \cdot 10^{+161}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq -4.3 \cdot 10^{-100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{-234}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.2 \cdot 10^{-272}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{-246}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-209}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{-12}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{+35} \lor \neg \left(z \leq 4.8 \cdot 10^{+113} \lor \neg \left(z \leq 8.4 \cdot 10^{+182}\right) \land z \leq 2.15 \cdot 10^{+247}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 6
Accuracy39.9%
Cost1180
\[\begin{array}{l} t_1 := y \cdot \left(-x\right)\\ \mathbf{if}\;y \leq -8.8 \cdot 10^{+144}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -3.3 \cdot 10^{-18}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq -1.5 \cdot 10^{-72}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -4 \cdot 10^{-96}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{-7}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 6.8 \cdot 10^{+177}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{+229}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y \cdot t\\ \end{array} \]
Alternative 7
Accuracy38.9%
Cost984
\[\begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{+20}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq -1.75 \cdot 10^{-233}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -3.9 \cdot 10^{-273}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-246}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 7 \cdot 10^{-207}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;z \leq 4100:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 8
Accuracy83.6%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1.25 \cdot 10^{+15} \lor \neg \left(z \leq 100\right):\\ \;\;\;\;z \cdot \left(x - t\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(t - x\right)\\ \end{array} \]
Alternative 9
Accuracy100.0%
Cost576
\[x + \left(y - z\right) \cdot \left(t - x\right) \]
Alternative 10
Accuracy40.1%
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -3.15 \cdot 10^{-18}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{-7}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot t\\ \end{array} \]
Alternative 11
Accuracy25.2%
Cost64
\[x \]

Error

Reproduce?

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