| Alternative 1 | |
|---|---|
| Accuracy | 99.8% |
| Cost | 6976 |
\[\mathsf{fma}\left(x \cdot x, x \cdot -0.12900613773279798, x \cdot 0.954929658551372\right)
\]

(FPCore (x) :precision binary64 (- (* 0.954929658551372 x) (* 0.12900613773279798 (* (* x x) x))))
(FPCore (x) :precision binary64 (fma (* x x) (* x -0.12900613773279798) (* x 0.954929658551372)))
double code(double x) {
return (0.954929658551372 * x) - (0.12900613773279798 * ((x * x) * x));
}
double code(double x) {
return fma((x * x), (x * -0.12900613773279798), (x * 0.954929658551372));
}
function code(x) return Float64(Float64(0.954929658551372 * x) - Float64(0.12900613773279798 * Float64(Float64(x * x) * x))) end
function code(x) return fma(Float64(x * x), Float64(x * -0.12900613773279798), Float64(x * 0.954929658551372)) end
code[x_] := N[(N[(0.954929658551372 * x), $MachinePrecision] - N[(0.12900613773279798 * N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(x * x), $MachinePrecision] * N[(x * -0.12900613773279798), $MachinePrecision] + N[(x * 0.954929658551372), $MachinePrecision]), $MachinePrecision]
0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right)
\mathsf{fma}\left(x \cdot x, x \cdot -0.12900613773279798, x \cdot 0.954929658551372\right)
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Initial program 99.8%
Simplified99.7%
[Start]99.8% | \[ 0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right)
\] |
|---|---|
associate-*r* [=>]99.7% | \[ 0.954929658551372 \cdot x - \color{blue}{\left(0.12900613773279798 \cdot \left(x \cdot x\right)\right) \cdot x}
\] |
distribute-rgt-out-- [=>]99.7% | \[ \color{blue}{x \cdot \left(0.954929658551372 - 0.12900613773279798 \cdot \left(x \cdot x\right)\right)}
\] |
sub-neg [=>]99.7% | \[ x \cdot \color{blue}{\left(0.954929658551372 + \left(-0.12900613773279798 \cdot \left(x \cdot x\right)\right)\right)}
\] |
+-commutative [=>]99.7% | \[ x \cdot \color{blue}{\left(\left(-0.12900613773279798 \cdot \left(x \cdot x\right)\right) + 0.954929658551372\right)}
\] |
*-commutative [=>]99.7% | \[ x \cdot \left(\left(-\color{blue}{\left(x \cdot x\right) \cdot 0.12900613773279798}\right) + 0.954929658551372\right)
\] |
distribute-rgt-neg-in [=>]99.7% | \[ x \cdot \left(\color{blue}{\left(x \cdot x\right) \cdot \left(-0.12900613773279798\right)} + 0.954929658551372\right)
\] |
fma-def [=>]99.7% | \[ x \cdot \color{blue}{\mathsf{fma}\left(x \cdot x, -0.12900613773279798, 0.954929658551372\right)}
\] |
metadata-eval [=>]99.7% | \[ x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{-0.12900613773279798}, 0.954929658551372\right)
\] |
Applied egg-rr99.8%
[Start]99.7% | \[ x \cdot \mathsf{fma}\left(x \cdot x, -0.12900613773279798, 0.954929658551372\right)
\] |
|---|---|
fma-udef [=>]99.7% | \[ x \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot -0.12900613773279798 + 0.954929658551372\right)}
\] |
distribute-rgt-in [=>]99.7% | \[ \color{blue}{\left(\left(x \cdot x\right) \cdot -0.12900613773279798\right) \cdot x + 0.954929658551372 \cdot x}
\] |
*-commutative [=>]99.7% | \[ \color{blue}{\left(-0.12900613773279798 \cdot \left(x \cdot x\right)\right)} \cdot x + 0.954929658551372 \cdot x
\] |
associate-*r* [<=]99.8% | \[ \color{blue}{-0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right)} + 0.954929658551372 \cdot x
\] |
*-commutative [<=]99.8% | \[ \color{blue}{\left(\left(x \cdot x\right) \cdot x\right) \cdot -0.12900613773279798} + 0.954929658551372 \cdot x
\] |
associate-*l* [=>]99.8% | \[ \color{blue}{\left(x \cdot x\right) \cdot \left(x \cdot -0.12900613773279798\right)} + 0.954929658551372 \cdot x
\] |
fma-def [=>]99.8% | \[ \color{blue}{\mathsf{fma}\left(x \cdot x, x \cdot -0.12900613773279798, 0.954929658551372 \cdot x\right)}
\] |
*-commutative [=>]99.8% | \[ \mathsf{fma}\left(x \cdot x, x \cdot -0.12900613773279798, \color{blue}{x \cdot 0.954929658551372}\right)
\] |
Final simplification99.8%
| Alternative 1 | |
|---|---|
| Accuracy | 99.8% |
| Cost | 6976 |
| Alternative 2 | |
|---|---|
| Accuracy | 98.9% |
| Cost | 713 |
| Alternative 3 | |
|---|---|
| Accuracy | 99.8% |
| Cost | 704 |
| Alternative 4 | |
|---|---|
| Accuracy | 99.8% |
| Cost | 576 |
| Alternative 5 | |
|---|---|
| Accuracy | 5.1% |
| Cost | 192 |
| Alternative 6 | |
|---|---|
| Accuracy | 49.4% |
| Cost | 192 |
herbie shell --seed 2023271
(FPCore (x)
:name "Rosa's Benchmark"
:precision binary64
(- (* 0.954929658551372 x) (* 0.12900613773279798 (* (* x x) x))))