| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 704 |

(FPCore (x) :precision binary64 (- 1.0 (* x (+ 0.253 (* x 0.12)))))
(FPCore (x) :precision binary64 (+ 1.0 (- (* x (* x -0.12)) (* 0.253 x))))
double code(double x) {
return 1.0 - (x * (0.253 + (x * 0.12)));
}
double code(double x) {
return 1.0 + ((x * (x * -0.12)) - (0.253 * x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 - (x * (0.253d0 + (x * 0.12d0)))
end function
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 + ((x * (x * (-0.12d0))) - (0.253d0 * x))
end function
public static double code(double x) {
return 1.0 - (x * (0.253 + (x * 0.12)));
}
public static double code(double x) {
return 1.0 + ((x * (x * -0.12)) - (0.253 * x));
}
def code(x): return 1.0 - (x * (0.253 + (x * 0.12)))
def code(x): return 1.0 + ((x * (x * -0.12)) - (0.253 * x))
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(Float64(x * Float64(x * -0.12)) - Float64(0.253 * x))) end
function tmp = code(x) tmp = 1.0 - (x * (0.253 + (x * 0.12))); end
function tmp = code(x) tmp = 1.0 + ((x * (x * -0.12)) - (0.253 * x)); 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[(N[(x * N[(x * -0.12), $MachinePrecision]), $MachinePrecision] - N[(0.253 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 - x \cdot \left(0.253 + x \cdot 0.12\right)
1 + \left(x \cdot \left(x \cdot -0.12\right) - 0.253 \cdot x\right)
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
Initial program 99.9%
Applied egg-rr99.9%
[Start]99.9% | \[ 1 - x \cdot \left(0.253 + x \cdot 0.12\right)
\] |
|---|---|
+-commutative [=>]99.9% | \[ 1 - x \cdot \color{blue}{\left(x \cdot 0.12 + 0.253\right)}
\] |
distribute-rgt-in [=>]99.9% | \[ 1 - \color{blue}{\left(\left(x \cdot 0.12\right) \cdot x + 0.253 \cdot x\right)}
\] |
fma-def [=>]99.9% | \[ 1 - \color{blue}{\mathsf{fma}\left(x \cdot 0.12, x, 0.253 \cdot x\right)}
\] |
*-commutative [=>]99.9% | \[ 1 - \mathsf{fma}\left(x \cdot 0.12, x, \color{blue}{x \cdot 0.253}\right)
\] |
Applied egg-rr66.2%
[Start]99.9% | \[ 1 - \mathsf{fma}\left(x \cdot 0.12, x, x \cdot 0.253\right)
\] |
|---|---|
fma-udef [=>]99.9% | \[ 1 - \color{blue}{\left(\left(x \cdot 0.12\right) \cdot x + x \cdot 0.253\right)}
\] |
*-commutative [=>]99.9% | \[ 1 - \left(\color{blue}{\left(0.12 \cdot x\right)} \cdot x + x \cdot 0.253\right)
\] |
associate-*r* [<=]99.8% | \[ 1 - \left(\color{blue}{0.12 \cdot \left(x \cdot x\right)} + x \cdot 0.253\right)
\] |
+-commutative [<=]99.8% | \[ 1 - \color{blue}{\left(x \cdot 0.253 + 0.12 \cdot \left(x \cdot x\right)\right)}
\] |
*-commutative [=>]99.8% | \[ 1 - \left(\color{blue}{0.253 \cdot x} + 0.12 \cdot \left(x \cdot x\right)\right)
\] |
associate-*r* [=>]99.9% | \[ 1 - \left(0.253 \cdot x + \color{blue}{\left(0.12 \cdot x\right) \cdot x}\right)
\] |
*-commutative [<=]99.9% | \[ 1 - \left(0.253 \cdot x + \color{blue}{\left(x \cdot 0.12\right)} \cdot x\right)
\] |
distribute-rgt-out [=>]99.9% | \[ 1 - \color{blue}{x \cdot \left(0.253 + x \cdot 0.12\right)}
\] |
*-commutative [=>]99.9% | \[ 1 - x \cdot \left(0.253 + \color{blue}{0.12 \cdot x}\right)
\] |
metadata-eval [<=]99.9% | \[ 1 - x \cdot \left(0.253 + \color{blue}{\left(--0.12\right)} \cdot x\right)
\] |
cancel-sign-sub-inv [<=]99.9% | \[ 1 - x \cdot \color{blue}{\left(0.253 - -0.12 \cdot x\right)}
\] |
add-sqr-sqrt [=>]51.0% | \[ 1 - x \cdot \left(0.253 - \color{blue}{\sqrt{-0.12 \cdot x} \cdot \sqrt{-0.12 \cdot x}}\right)
\] |
sqrt-unprod [=>]76.7% | \[ 1 - x \cdot \left(0.253 - \color{blue}{\sqrt{\left(-0.12 \cdot x\right) \cdot \left(-0.12 \cdot x\right)}}\right)
\] |
swap-sqr [=>]76.7% | \[ 1 - x \cdot \left(0.253 - \sqrt{\color{blue}{\left(-0.12 \cdot -0.12\right) \cdot \left(x \cdot x\right)}}\right)
\] |
metadata-eval [=>]76.7% | \[ 1 - x \cdot \left(0.253 - \sqrt{\color{blue}{0.0144} \cdot \left(x \cdot x\right)}\right)
\] |
*-commutative [<=]76.7% | \[ 1 - x \cdot \left(0.253 - \sqrt{\color{blue}{\left(x \cdot x\right) \cdot 0.0144}}\right)
\] |
metadata-eval [<=]76.7% | \[ 1 - x \cdot \left(0.253 - \sqrt{\left(x \cdot x\right) \cdot \color{blue}{\left(0.12 \cdot 0.12\right)}}\right)
\] |
swap-sqr [<=]76.7% | \[ 1 - x \cdot \left(0.253 - \sqrt{\color{blue}{\left(x \cdot 0.12\right) \cdot \left(x \cdot 0.12\right)}}\right)
\] |
sqrt-unprod [<=]25.6% | \[ 1 - x \cdot \left(0.253 - \color{blue}{\sqrt{x \cdot 0.12} \cdot \sqrt{x \cdot 0.12}}\right)
\] |
add-sqr-sqrt [<=]53.7% | \[ 1 - x \cdot \left(0.253 - \color{blue}{x \cdot 0.12}\right)
\] |
distribute-rgt-out-- [<=]53.7% | \[ 1 - \color{blue}{\left(0.253 \cdot x - \left(x \cdot 0.12\right) \cdot x\right)}
\] |
*-commutative [<=]53.7% | \[ 1 - \left(\color{blue}{x \cdot 0.253} - \left(x \cdot 0.12\right) \cdot x\right)
\] |
add-log-exp [=>]54.2% | \[ 1 - \left(\color{blue}{\log \left(e^{x \cdot 0.253}\right)} - \left(x \cdot 0.12\right) \cdot x\right)
\] |
Simplified99.9%
[Start]66.2% | \[ 1 - \log \left(\frac{{\left(e^{x}\right)}^{0.253}}{{\left({\left(e^{-0.12}\right)}^{x}\right)}^{x}}\right)
\] |
|---|---|
log-div [=>]66.2% | \[ 1 - \color{blue}{\left(\log \left({\left(e^{x}\right)}^{0.253}\right) - \log \left({\left({\left(e^{-0.12}\right)}^{x}\right)}^{x}\right)\right)}
\] |
log-pow [=>]66.2% | \[ 1 - \left(\color{blue}{0.253 \cdot \log \left(e^{x}\right)} - \log \left({\left({\left(e^{-0.12}\right)}^{x}\right)}^{x}\right)\right)
\] |
fma-neg [=>]66.2% | \[ 1 - \color{blue}{\mathsf{fma}\left(0.253, \log \left(e^{x}\right), -\log \left({\left({\left(e^{-0.12}\right)}^{x}\right)}^{x}\right)\right)}
\] |
rem-log-exp [=>]76.4% | \[ 1 - \mathsf{fma}\left(0.253, \color{blue}{x}, -\log \left({\left({\left(e^{-0.12}\right)}^{x}\right)}^{x}\right)\right)
\] |
log-pow [=>]76.4% | \[ 1 - \mathsf{fma}\left(0.253, x, -\color{blue}{x \cdot \log \left({\left(e^{-0.12}\right)}^{x}\right)}\right)
\] |
log-pow [=>]99.4% | \[ 1 - \mathsf{fma}\left(0.253, x, -x \cdot \color{blue}{\left(x \cdot \log \left(e^{-0.12}\right)\right)}\right)
\] |
rem-log-exp [=>]99.9% | \[ 1 - \mathsf{fma}\left(0.253, x, -x \cdot \left(x \cdot \color{blue}{-0.12}\right)\right)
\] |
metadata-eval [<=]99.9% | \[ 1 - \mathsf{fma}\left(0.253, x, -x \cdot \left(x \cdot \color{blue}{\left(-0.12\right)}\right)\right)
\] |
distribute-rgt-neg-in [<=]99.9% | \[ 1 - \mathsf{fma}\left(0.253, x, -x \cdot \color{blue}{\left(-x \cdot 0.12\right)}\right)
\] |
distribute-rgt-neg-out [=>]99.9% | \[ 1 - \mathsf{fma}\left(0.253, x, -\color{blue}{\left(-x \cdot \left(x \cdot 0.12\right)\right)}\right)
\] |
associate-*r* [=>]99.8% | \[ 1 - \mathsf{fma}\left(0.253, x, -\left(-\color{blue}{\left(x \cdot x\right) \cdot 0.12}\right)\right)
\] |
*-commutative [<=]99.8% | \[ 1 - \mathsf{fma}\left(0.253, x, -\left(-\color{blue}{0.12 \cdot \left(x \cdot x\right)}\right)\right)
\] |
fma-neg [<=]99.8% | \[ 1 - \color{blue}{\left(0.253 \cdot x - \left(-0.12 \cdot \left(x \cdot x\right)\right)\right)}
\] |
distribute-lft-neg-in [=>]99.8% | \[ 1 - \left(0.253 \cdot x - \color{blue}{\left(-0.12\right) \cdot \left(x \cdot x\right)}\right)
\] |
metadata-eval [=>]99.8% | \[ 1 - \left(0.253 \cdot x - \color{blue}{-0.12} \cdot \left(x \cdot x\right)\right)
\] |
*-commutative [=>]99.8% | \[ 1 - \left(0.253 \cdot x - \color{blue}{\left(x \cdot x\right) \cdot -0.12}\right)
\] |
associate-*r* [<=]99.9% | \[ 1 - \left(0.253 \cdot x - \color{blue}{x \cdot \left(x \cdot -0.12\right)}\right)
\] |
Final simplification99.9%
| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 704 |
| Alternative 2 | |
|---|---|
| Accuracy | 59.0% |
| Cost | 585 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.3% |
| Cost | 585 |
| Alternative 4 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 576 |
| Alternative 5 | |
|---|---|
| Accuracy | 97.8% |
| Cost | 448 |
| Alternative 6 | |
|---|---|
| Accuracy | 97.8% |
| Cost | 448 |
| Alternative 7 | |
|---|---|
| Accuracy | 10.5% |
| Cost | 64 |
herbie shell --seed 2023165
(FPCore (x)
:name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, A"
:precision binary64
(- 1.0 (* x (+ 0.253 (* x 0.12)))))