?

Average Accuracy: 99.9% → 99.9%
Time: 9.3s
Precision: binary64
Cost: 6976

?

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

Error?

Derivation?

  1. Initial program 99.9%

    \[\left(x \cdot y + z\right) \cdot y + t \]
  2. Applied egg-rr66.6%

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

    [Start]99.9

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

    *-commutative [=>]99.9

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

    flip-+ [=>]71.7

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

    associate-*r/ [=>]66.6

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

    pow2 [=>]66.6

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

    fma-neg [=>]66.6

    \[ \frac{y \cdot \left({\left(x \cdot y\right)}^{2} - z \cdot z\right)}{\color{blue}{\mathsf{fma}\left(x, y, -z\right)}} + t \]
  3. Simplified70.7%

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

    [Start]66.6

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

    associate-*l/ [<=]70.7

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

    fma-neg [<=]70.7

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

    *-commutative [<=]70.7

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

    *-commutative [<=]70.7

    \[ \frac{y}{y \cdot x - z} \cdot \left({\color{blue}{\left(y \cdot x\right)}}^{2} - z \cdot z\right) + t \]
  4. Taylor expanded in y around 0 93.2%

    \[\leadsto \color{blue}{\left(y \cdot z + {y}^{2} \cdot x\right)} + t \]
  5. Simplified99.9%

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

    [Start]93.2

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

    fma-def [=>]93.2

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

    unpow2 [=>]93.2

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

    associate-*r* [<=]99.9

    \[ \mathsf{fma}\left(y, z, \color{blue}{y \cdot \left(y \cdot x\right)}\right) + t \]
  6. Final simplification99.9%

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

Alternatives

Alternative 1
Accuracy58.8%
Cost1244
\[\begin{array}{l} t_1 := y \cdot \left(y \cdot x\right)\\ \mathbf{if}\;t \leq -4000000000:\\ \;\;\;\;t\\ \mathbf{elif}\;t \leq -9.8 \cdot 10^{-146}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;t \leq -3.7 \cdot 10^{-200}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.9 \cdot 10^{-242}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;t \leq 2.5 \cdot 10^{-197}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.05 \cdot 10^{-147}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;t \leq 2.25 \cdot 10^{-125}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 2
Accuracy78.3%
Cost850
\[\begin{array}{l} \mathbf{if}\;t \leq -3 \cdot 10^{-184} \lor \neg \left(t \leq -1.1 \cdot 10^{-198}\right) \land \left(t \leq 1.6 \cdot 10^{-223} \lor \neg \left(t \leq 2.5 \cdot 10^{-197}\right)\right):\\ \;\;\;\;t + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(y \cdot x\right)\\ \end{array} \]
Alternative 3
Accuracy92.0%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -8.5 \cdot 10^{+60} \lor \neg \left(z \leq 2.1 \cdot 10^{-20}\right):\\ \;\;\;\;t + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(y \cdot x\right) + t\\ \end{array} \]
Alternative 4
Accuracy99.9%
Cost576
\[t + y \cdot \left(z + y \cdot x\right) \]
Alternative 5
Accuracy59.5%
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{+208}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{+134}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 6
Accuracy53.5%
Cost64
\[t \]

Error

Reproduce?

herbie shell --seed 2023133 
(FPCore (x y z t)
  :name "Language.Haskell.HsColour.ColourHighlight:unbase from hscolour-1.23"
  :precision binary64
  (+ (* (+ (* x y) z) y) t))