| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 19904 |
\[\mathsf{fma}\left(\mathsf{fma}\left(y, y, -2\right), -y \cdot y, 9 \cdot {x}^{4}\right)
\]

(FPCore (x y) :precision binary64 (- (* 9.0 (pow x 4.0)) (* (* y y) (- (* y y) 2.0))))
(FPCore (x y) :precision binary64 (fma (fma y y -2.0) (- (* y y)) (* 9.0 (pow x 4.0))))
double code(double x, double y) {
return (9.0 * pow(x, 4.0)) - ((y * y) * ((y * y) - 2.0));
}
double code(double x, double y) {
return fma(fma(y, y, -2.0), -(y * y), (9.0 * pow(x, 4.0)));
}
function code(x, y) return Float64(Float64(9.0 * (x ^ 4.0)) - Float64(Float64(y * y) * Float64(Float64(y * y) - 2.0))) end
function code(x, y) return fma(fma(y, y, -2.0), Float64(-Float64(y * y)), Float64(9.0 * (x ^ 4.0))) end
code[x_, y_] := N[(N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] - N[(N[(y * y), $MachinePrecision] * N[(N[(y * y), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[(y * y + -2.0), $MachinePrecision] * (-N[(y * y), $MachinePrecision]) + N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
9 \cdot {x}^{4} - \left(y \cdot y\right) \cdot \left(y \cdot y - 2\right)
\mathsf{fma}\left(\mathsf{fma}\left(y, y, -2\right), -y \cdot y, 9 \cdot {x}^{4}\right)
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Initial program 3.1%
Applied egg-rr100.0%
[Start]3.1% | \[ 9 \cdot {x}^{4} - \left(y \cdot y\right) \cdot \left(y \cdot y - 2\right)
\] |
|---|---|
sub-neg [=>]3.1% | \[ \color{blue}{9 \cdot {x}^{4} + \left(-\left(y \cdot y\right) \cdot \left(y \cdot y - 2\right)\right)}
\] |
+-commutative [=>]3.1% | \[ \color{blue}{\left(-\left(y \cdot y\right) \cdot \left(y \cdot y - 2\right)\right) + 9 \cdot {x}^{4}}
\] |
*-commutative [=>]3.1% | \[ \left(-\color{blue}{\left(y \cdot y - 2\right) \cdot \left(y \cdot y\right)}\right) + 9 \cdot {x}^{4}
\] |
distribute-rgt-neg-in [=>]3.1% | \[ \color{blue}{\left(y \cdot y - 2\right) \cdot \left(-y \cdot y\right)} + 9 \cdot {x}^{4}
\] |
fma-def [=>]100.0% | \[ \color{blue}{\mathsf{fma}\left(y \cdot y - 2, -y \cdot y, 9 \cdot {x}^{4}\right)}
\] |
fma-neg [=>]100.0% | \[ \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(y, y, -2\right)}, -y \cdot y, 9 \cdot {x}^{4}\right)
\] |
metadata-eval [=>]100.0% | \[ \mathsf{fma}\left(\mathsf{fma}\left(y, y, \color{blue}{-2}\right), -y \cdot y, 9 \cdot {x}^{4}\right)
\] |
distribute-rgt-neg-in [=>]100.0% | \[ \mathsf{fma}\left(\mathsf{fma}\left(y, y, -2\right), \color{blue}{y \cdot \left(-y\right)}, 9 \cdot {x}^{4}\right)
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 19904 |
| Alternative 2 | |
|---|---|
| Accuracy | 9.6% |
| Cost | 6656 |
| Alternative 3 | |
|---|---|
| Accuracy | 1.5% |
| Cost | 6592 |
herbie shell --seed 2023178
(FPCore (x y)
:name "From Rump in a 1983 paper, rewritten"
:precision binary64
:pre (and (== x 10864.0) (== y 18817.0))
(- (* 9.0 (pow x 4.0)) (* (* y y) (- (* y y) 2.0))))