| Alternative 1 | |
|---|---|
| Error | 3.1% |
| Cost | 585 |
\[\begin{array}{l}
\mathbf{if}\;x \leq -4 \lor \neg \left(x \leq 2.1\right):\\
\;\;\;\;\left(x \cdot x\right) \cdot -0.12\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\]
(FPCore (x) :precision binary64 (- 1.0 (* x (+ 0.253 (* x 0.12)))))
(FPCore (x) :precision binary64 (- 1.0 (* x (fma x 0.12 0.253))))
double code(double x) {
return 1.0 - (x * (0.253 + (x * 0.12)));
}
double code(double x) {
return 1.0 - (x * fma(x, 0.12, 0.253));
}
function code(x) return Float64(1.0 - Float64(x * Float64(0.253 + Float64(x * 0.12)))) end
function code(x) return Float64(1.0 - Float64(x * fma(x, 0.12, 0.253))) end
code[x_] := N[(1.0 - N[(x * N[(0.253 + N[(x * 0.12), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(1.0 - N[(x * N[(x * 0.12 + 0.253), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 - x \cdot \left(0.253 + x \cdot 0.12\right)
1 - x \cdot \mathsf{fma}\left(x, 0.12, 0.253\right)
Initial program 0.17
Simplified0.16
[Start]0.17 | \[ 1 - x \cdot \left(0.253 + x \cdot 0.12\right)
\] |
|---|---|
distribute-lft-in [=>]0.17 | \[ 1 - \color{blue}{\left(x \cdot 0.253 + x \cdot \left(x \cdot 0.12\right)\right)}
\] |
+-commutative [=>]0.17 | \[ 1 - \color{blue}{\left(x \cdot \left(x \cdot 0.12\right) + x \cdot 0.253\right)}
\] |
*-commutative [<=]0.17 | \[ 1 - \left(\color{blue}{\left(x \cdot 0.12\right) \cdot x} + x \cdot 0.253\right)
\] |
cancel-sign-sub [<=]0.17 | \[ 1 - \color{blue}{\left(\left(x \cdot 0.12\right) \cdot x - \left(-x\right) \cdot 0.253\right)}
\] |
*-commutative [<=]0.17 | \[ 1 - \left(\left(x \cdot 0.12\right) \cdot x - \color{blue}{0.253 \cdot \left(-x\right)}\right)
\] |
*-commutative [=>]0.17 | \[ 1 - \left(\left(x \cdot 0.12\right) \cdot x - \color{blue}{\left(-x\right) \cdot 0.253}\right)
\] |
cancel-sign-sub [=>]0.17 | \[ 1 - \color{blue}{\left(\left(x \cdot 0.12\right) \cdot x + x \cdot 0.253\right)}
\] |
*-commutative [=>]0.17 | \[ 1 - \left(\color{blue}{x \cdot \left(x \cdot 0.12\right)} + x \cdot 0.253\right)
\] |
distribute-lft-in [<=]0.17 | \[ 1 - \color{blue}{x \cdot \left(x \cdot 0.12 + 0.253\right)}
\] |
fma-def [=>]0.16 | \[ 1 - x \cdot \color{blue}{\mathsf{fma}\left(x, 0.12, 0.253\right)}
\] |
Final simplification0.16
| Alternative 1 | |
|---|---|
| Error | 3.1% |
| Cost | 585 |
| Alternative 2 | |
|---|---|
| Error | 2.39% |
| Cost | 585 |
| Alternative 3 | |
|---|---|
| Error | 0.17% |
| Cost | 576 |
| Alternative 4 | |
|---|---|
| Error | 3.11% |
| Cost | 448 |
| Alternative 5 | |
|---|---|
| Error | 33.96% |
| Cost | 64 |
herbie shell --seed 2023090
(FPCore (x)
:name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, A"
:precision binary64
(- 1.0 (* x (+ 0.253 (* x 0.12)))))