Average Error: 0.0 → 0.0
Time: 6.8s
Precision: binary64
Cost: 6720
\[x + y \cdot \left(z + x\right) \]
\[\mathsf{fma}\left(y, z + x, x\right) \]
(FPCore (x y z) :precision binary64 (+ x (* y (+ z x))))
(FPCore (x y z) :precision binary64 (fma y (+ z x) x))
double code(double x, double y, double z) {
	return x + (y * (z + x));
}
double code(double x, double y, double z) {
	return fma(y, (z + x), x);
}
function code(x, y, z)
	return Float64(x + Float64(y * Float64(z + x)))
end
function code(x, y, z)
	return fma(y, Float64(z + x), x)
end
code[x_, y_, z_] := N[(x + N[(y * N[(z + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(y * N[(z + x), $MachinePrecision] + x), $MachinePrecision]
x + y \cdot \left(z + x\right)
\mathsf{fma}\left(y, z + x, x\right)

Error

Derivation

  1. Initial program 0.0

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

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

Alternatives

Alternative 1
Error26.4
Cost2172
\[\begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+113}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq -1.75 \cdot 10^{+76}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -0.032:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq -2.2 \cdot 10^{-99}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -6.8 \cdot 10^{-136}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-190}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.16 \cdot 10^{-153}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{-120}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-97}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 1.36 \cdot 10^{-36}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 460000000000:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 8.8 \cdot 10^{+26}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{+66}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 7.4 \cdot 10^{+96}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{+182}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 2
Error14.6
Cost1376
\[\begin{array}{l} t_0 := \left(z + x\right) \cdot y\\ \mathbf{if}\;y \leq -0.0135:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -2.2 \cdot 10^{-99}:\\ \;\;\;\;\left(1 + y\right) \cdot x\\ \mathbf{elif}\;y \leq -6.8 \cdot 10^{-136}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-190}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.16 \cdot 10^{-153}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-121}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-97}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.75 \cdot 10^{-36}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error14.6
Cost1376
\[\begin{array}{l} t_0 := \left(z + x\right) \cdot y\\ \mathbf{if}\;y \leq -0.032:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -2.4 \cdot 10^{-99}:\\ \;\;\;\;y \cdot x + x\\ \mathbf{elif}\;y \leq -6.8 \cdot 10^{-136}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-190}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.16 \cdot 10^{-153}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{-120}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-97}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{-36}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error18.9
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{+89}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(1 + y\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 5
Error0.0
Cost576
\[\left(x + y \cdot z\right) + y \cdot x \]
Alternative 6
Error24.5
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -0.032:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 7
Error0.0
Cost448
\[x + y \cdot \left(z + x\right) \]
Alternative 8
Error34.9
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (x y z)
  :name "Main:bigenough2 from A"
  :precision binary64
  (+ x (* y (+ z x))))