?

Average Error: 0.0 → 0.0
Time: 1.4min
Precision: binary64
Cost: 6848

?

\[x + \left(y - z\right) \cdot \left(t - x\right) \]
\[\mathsf{fma}\left(t - x, y - z, x\right) \]
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
(FPCore (x y z t) :precision binary64 (fma (- t x) (- y z) 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((t - x), (y - z), 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(t - x), Float64(y - z), 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[(t - x), $MachinePrecision] * N[(y - z), $MachinePrecision] + x), $MachinePrecision]
x + \left(y - z\right) \cdot \left(t - x\right)
\mathsf{fma}\left(t - x, y - z, x\right)

Error?

Target

Original0.0
Target0.0
Herbie0.0
\[x + \left(t \cdot \left(y - z\right) + \left(-x\right) \cdot \left(y - z\right)\right) \]

Derivation?

  1. Initial program 0.0

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

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

Alternatives

Alternative 1
Error28.2
Cost1880
\[\begin{array}{l} t_1 := t \cdot \left(y - z\right)\\ t_2 := y \cdot \left(t - x\right)\\ \mathbf{if}\;y - z \leq -4 \cdot 10^{+224}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq -5 \cdot 10^{+127}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y - z \leq -1 \cdot 10^{+71}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq -1 \cdot 10^{+29}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y - z \leq -4 \cdot 10^{-58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq 5 \cdot 10^{-42}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error24.5
Cost1640
\[\begin{array}{l} t_1 := \left(x - t\right) \cdot z\\ t_2 := y \cdot \left(t - x\right)\\ t_3 := \left(1 + z\right) \cdot x\\ \mathbf{if}\;y \leq -4.8 \cdot 10^{-58}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -8 \cdot 10^{-152}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -5.2 \cdot 10^{-214}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.15 \cdot 10^{-298}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-260}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4 \cdot 10^{-133}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{-101}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{-12}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{+126}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{+181}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error24.0
Cost1640
\[\begin{array}{l} t_1 := \left(x - t\right) \cdot z\\ t_2 := y \cdot \left(t - x\right)\\ t_3 := \left(1 + z\right) \cdot x\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -6.8 \cdot 10^{-118}:\\ \;\;\;\;y \cdot t + x\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-216}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.76 \cdot 10^{-298}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 6.4 \cdot 10^{-260}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{-134}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-101}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{-15}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{+126}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{+181}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error23.9
Cost1640
\[\begin{array}{l} t_1 := \left(1 + z\right) \cdot x\\ t_2 := \left(x - t\right) \cdot z\\ t_3 := y \cdot \left(t - x\right)\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -7.3 \cdot 10^{-118}:\\ \;\;\;\;y \cdot t + x\\ \mathbf{elif}\;y \leq -5.2 \cdot 10^{-217}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 10^{-298}:\\ \;\;\;\;z \cdot x + x\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{-257}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{-133}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.36 \cdot 10^{-101}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{-13}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{+126}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{+181}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 5
Error38.4
Cost1444
\[\begin{array}{l} t_1 := -z \cdot t\\ t_2 := -y \cdot x\\ \mathbf{if}\;y \leq -3 \cdot 10^{+66}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq -1.7 \cdot 10^{+40}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -4.8 \cdot 10^{-58}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq 1.36 \cdot 10^{-300}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.32 \cdot 10^{-261}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-132}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-102}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{-36}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{+55}:\\ \;\;\;\;y \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error28.6
Cost1360
\[\begin{array}{l} t_1 := t \cdot \left(y - z\right)\\ \mathbf{if}\;y - z \leq -2 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq -5 \cdot 10^{+40}:\\ \;\;\;\;-y \cdot x\\ \mathbf{elif}\;y - z \leq -4 \cdot 10^{-58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq 5 \cdot 10^{-42}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error22.9
Cost1112
\[\begin{array}{l} t_1 := t \cdot \left(y - z\right)\\ t_2 := y \cdot \left(t - x\right)\\ t_3 := \left(1 + z\right) \cdot x\\ \mathbf{if}\;y \leq -4.8 \cdot 10^{-58}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -2.5 \cdot 10^{-185}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -1.15 \cdot 10^{-211}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-132}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{-100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.15 \cdot 10^{-7}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error37.9
Cost916
\[\begin{array}{l} t_1 := -y \cdot x\\ \mathbf{if}\;y \leq -2.3 \cdot 10^{+66}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq -4.6 \cdot 10^{+40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -4.8 \cdot 10^{-58}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-35}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+56}:\\ \;\;\;\;y \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error20.4
Cost848
\[\begin{array}{l} t_1 := y \cdot \left(t - x\right)\\ \mathbf{if}\;y \leq -4.8 \cdot 10^{-58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{-35}:\\ \;\;\;\;x + \left(-z \cdot t\right)\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{+126}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{+181}:\\ \;\;\;\;\left(x - t\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error13.5
Cost848
\[\begin{array}{l} t_1 := \left(x - t\right) \cdot z\\ t_2 := y \cdot \left(t - x\right)\\ \mathbf{if}\;y \leq -4.8 \cdot 10^{-58}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 62000000000:\\ \;\;\;\;x + t_1\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{+126}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{+181}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 11
Error12.3
Cost848
\[\begin{array}{l} t_1 := \left(x - t\right) \cdot z\\ t_2 := y \cdot \left(t - x\right)\\ \mathbf{if}\;y \leq -4.8 \cdot 10^{-58}:\\ \;\;\;\;t_2 + x\\ \mathbf{elif}\;y \leq 51000000000:\\ \;\;\;\;x + t_1\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{+126}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{+181}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 12
Error0.0
Cost576
\[x + \left(y - z\right) \cdot \left(t - x\right) \]
Alternative 13
Error37.7
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -4.7 \cdot 10^{-58}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{-35}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot t\\ \end{array} \]
Alternative 14
Error47.0
Cost64
\[x \]

Error

Reproduce?

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