?

Average Accuracy: 100.0% → 100.0%
Time: 7.6s
Precision: binary64
Cost: 13248

?

\[\left(x + y\right) \cdot \left(z + 1\right) \]
\[x + \mathsf{fma}\left(z, y, \mathsf{fma}\left(z, x, y\right)\right) \]
(FPCore (x y z) :precision binary64 (* (+ x y) (+ z 1.0)))
(FPCore (x y z) :precision binary64 (+ x (fma z y (fma z x y))))
double code(double x, double y, double z) {
	return (x + y) * (z + 1.0);
}
double code(double x, double y, double z) {
	return x + fma(z, y, fma(z, x, y));
}
function code(x, y, z)
	return Float64(Float64(x + y) * Float64(z + 1.0))
end
function code(x, y, z)
	return Float64(x + fma(z, y, fma(z, x, y)))
end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x + N[(z * y + N[(z * x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(x + y\right) \cdot \left(z + 1\right)
x + \mathsf{fma}\left(z, y, \mathsf{fma}\left(z, x, y\right)\right)

Error?

Derivation?

  1. Initial program 100.0%

    \[\left(x + y\right) \cdot \left(z + 1\right) \]
  2. Applied egg-rr100.0%

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

    [Start]100.0

    \[ \left(x + y\right) \cdot \left(z + 1\right) \]

    distribute-rgt-in [=>]100.0

    \[ \color{blue}{z \cdot \left(x + y\right) + 1 \cdot \left(x + y\right)} \]

    *-un-lft-identity [<=]100.0

    \[ z \cdot \left(x + y\right) + \color{blue}{\left(x + y\right)} \]

    +-commutative [=>]100.0

    \[ z \cdot \left(x + y\right) + \color{blue}{\left(y + x\right)} \]

    associate-+r+ [=>]100.0

    \[ \color{blue}{\left(z \cdot \left(x + y\right) + y\right) + x} \]

    +-commutative [=>]100.0

    \[ \color{blue}{\left(y + z \cdot \left(x + y\right)\right)} + x \]

    *-commutative [=>]100.0

    \[ \left(y + \color{blue}{\left(x + y\right) \cdot z}\right) + x \]
  3. Applied egg-rr29.6%

    \[\leadsto \color{blue}{\frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - {\left(\left(x + y\right) \cdot z\right)}^{2} \cdot {\left(\left(x + y\right) \cdot z\right)}^{2}}{\left(y - \left(x + y\right) \cdot z\right) \cdot \left({\left(\left(x + y\right) \cdot z\right)}^{2} + y \cdot y\right)}} + x \]
    Proof

    [Start]100.0

    \[ \left(y + \left(x + y\right) \cdot z\right) + x \]

    flip-+ [=>]59.4

    \[ \color{blue}{\frac{y \cdot y - \left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)}{y - \left(x + y\right) \cdot z}} + x \]

    flip-- [=>]32.7

    \[ \frac{\color{blue}{\frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - \left(\left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)\right) \cdot \left(\left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)\right)}{y \cdot y + \left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)}}}{y - \left(x + y\right) \cdot z} + x \]

    associate-/l/ [=>]29.6

    \[ \color{blue}{\frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - \left(\left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)\right) \cdot \left(\left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)\right)}{\left(y - \left(x + y\right) \cdot z\right) \cdot \left(y \cdot y + \left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)\right)}} + x \]

    pow2 [=>]29.6

    \[ \frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - \color{blue}{{\left(\left(x + y\right) \cdot z\right)}^{2}} \cdot \left(\left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)\right)}{\left(y - \left(x + y\right) \cdot z\right) \cdot \left(y \cdot y + \left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)\right)} + x \]

    pow2 [=>]29.6

    \[ \frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - {\left(\left(x + y\right) \cdot z\right)}^{2} \cdot \color{blue}{{\left(\left(x + y\right) \cdot z\right)}^{2}}}{\left(y - \left(x + y\right) \cdot z\right) \cdot \left(y \cdot y + \left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)\right)} + x \]

    +-commutative [=>]29.6

    \[ \frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - {\left(\left(x + y\right) \cdot z\right)}^{2} \cdot {\left(\left(x + y\right) \cdot z\right)}^{2}}{\left(y - \left(x + y\right) \cdot z\right) \cdot \color{blue}{\left(\left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right) + y \cdot y\right)}} + x \]

    pow2 [=>]29.6

    \[ \frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - {\left(\left(x + y\right) \cdot z\right)}^{2} \cdot {\left(\left(x + y\right) \cdot z\right)}^{2}}{\left(y - \left(x + y\right) \cdot z\right) \cdot \left(\color{blue}{{\left(\left(x + y\right) \cdot z\right)}^{2}} + y \cdot y\right)} + x \]
  4. Applied egg-rr100.0%

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

    [Start]29.6

    \[ \frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - {\left(\left(x + y\right) \cdot z\right)}^{2} \cdot {\left(\left(x + y\right) \cdot z\right)}^{2}}{\left(y - \left(x + y\right) \cdot z\right) \cdot \left({\left(\left(x + y\right) \cdot z\right)}^{2} + y \cdot y\right)} + x \]

    *-commutative [=>]29.6

    \[ \frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - {\left(\left(x + y\right) \cdot z\right)}^{2} \cdot {\left(\left(x + y\right) \cdot z\right)}^{2}}{\color{blue}{\left({\left(\left(x + y\right) \cdot z\right)}^{2} + y \cdot y\right) \cdot \left(y - \left(x + y\right) \cdot z\right)}} + x \]

    associate-/r* [=>]32.7

    \[ \color{blue}{\frac{\frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - {\left(\left(x + y\right) \cdot z\right)}^{2} \cdot {\left(\left(x + y\right) \cdot z\right)}^{2}}{{\left(\left(x + y\right) \cdot z\right)}^{2} + y \cdot y}}{y - \left(x + y\right) \cdot z}} + x \]

    +-commutative [=>]32.7

    \[ \frac{\frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - {\left(\left(x + y\right) \cdot z\right)}^{2} \cdot {\left(\left(x + y\right) \cdot z\right)}^{2}}{\color{blue}{y \cdot y + {\left(\left(x + y\right) \cdot z\right)}^{2}}}}{y - \left(x + y\right) \cdot z} + x \]

    flip-- [<=]59.4

    \[ \frac{\color{blue}{y \cdot y - {\left(\left(x + y\right) \cdot z\right)}^{2}}}{y - \left(x + y\right) \cdot z} + x \]

    unpow2 [=>]59.4

    \[ \frac{y \cdot y - \color{blue}{\left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)}}{y - \left(x + y\right) \cdot z} + x \]

    flip-+ [<=]100.0

    \[ \color{blue}{\left(y + \left(x + y\right) \cdot z\right)} + x \]

    +-commutative [=>]100.0

    \[ \color{blue}{\left(\left(x + y\right) \cdot z + y\right)} + x \]

    *-commutative [=>]100.0

    \[ \left(\color{blue}{z \cdot \left(x + y\right)} + y\right) + x \]

    +-commutative [=>]100.0

    \[ \left(z \cdot \color{blue}{\left(y + x\right)} + y\right) + x \]

    distribute-rgt-in [=>]100.0

    \[ \left(\color{blue}{\left(y \cdot z + x \cdot z\right)} + y\right) + x \]

    associate-+l+ [=>]100.0

    \[ \color{blue}{\left(y \cdot z + \left(x \cdot z + y\right)\right)} + x \]
  5. Simplified100.0%

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

    [Start]100.0

    \[ \left(y \cdot z + \left(x \cdot z + y\right)\right) + x \]

    +-commutative [<=]100.0

    \[ \left(y \cdot z + \color{blue}{\left(y + x \cdot z\right)}\right) + x \]

    *-commutative [<=]100.0

    \[ \left(\color{blue}{z \cdot y} + \left(y + x \cdot z\right)\right) + x \]

    *-commutative [<=]100.0

    \[ \left(z \cdot y + \left(y + \color{blue}{z \cdot x}\right)\right) + x \]

    +-commutative [<=]100.0

    \[ \left(z \cdot y + \color{blue}{\left(z \cdot x + y\right)}\right) + x \]

    fma-def [=>]100.0

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

    fma-def [=>]100.0

    \[ \mathsf{fma}\left(z, y, \color{blue}{\mathsf{fma}\left(z, x, y\right)}\right) + x \]
  6. Final simplification100.0%

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

Alternatives

Alternative 1
Accuracy33.1%
Cost1380
\[\begin{array}{l} \mathbf{if}\;y \leq -4600000000000:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.5 \cdot 10^{-124}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;y \leq -2.45 \cdot 10^{-267}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.32 \cdot 10^{-169}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-47}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{-19}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 16000:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{+157}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 9.2 \cdot 10^{+222}:\\ \;\;\;\;z \cdot y\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 2
Accuracy49.0%
Cost720
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq -1.36 \cdot 10^{-162}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{-150}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 0.0034:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 3
Accuracy59.2%
Cost717
\[\begin{array}{l} \mathbf{if}\;x \leq -3 \cdot 10^{-60} \lor \neg \left(x \leq -1.95 \cdot 10^{-117}\right) \land x \leq -1.45 \cdot 10^{-196}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z + 1\right)\\ \end{array} \]
Alternative 4
Accuracy97.3%
Cost716
\[\begin{array}{l} t_0 := z \cdot \left(y + x\right)\\ \mathbf{if}\;z \leq -195000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.45 \cdot 10^{-14}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Accuracy97.3%
Cost716
\[\begin{array}{l} t_0 := z \cdot \left(y + x\right)\\ \mathbf{if}\;z \leq -3900000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.45 \cdot 10^{-14}:\\ \;\;\;\;x + z \cdot x\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Accuracy79.4%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -0.125 \lor \neg \left(z \leq 1.9 \cdot 10^{-27}\right):\\ \;\;\;\;y \cdot \left(z + 1\right)\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 7
Accuracy100.0%
Cost576
\[x + \left(y + z \cdot \left(y + x\right)\right) \]
Alternative 8
Accuracy79.4%
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq 55:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;z \cdot y\\ \end{array} \]
Alternative 9
Accuracy100.0%
Cost448
\[\left(y + x\right) \cdot \left(z + 1\right) \]
Alternative 10
Accuracy39.4%
Cost196
\[\begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{-56}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 11
Accuracy32.1%
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023137 
(FPCore (x y z)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, G"
  :precision binary64
  (* (+ x y) (+ z 1.0)))