| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 960 |
\[1 + \frac{x \cdot \left(x \cdot 0.0144\right) - 0.064009}{\frac{0.253}{x} + -0.12}
\]

(FPCore (x) :precision binary64 (- 1.0 (* x (+ 0.253 (* x 0.12)))))
(FPCore (x) :precision binary64 (+ 1.0 (/ (- (* x (* x 0.0144)) 0.064009) (+ (/ 0.253 x) -0.12))))
double code(double x) {
return 1.0 - (x * (0.253 + (x * 0.12)));
}
double code(double x) {
return 1.0 + (((x * (x * 0.0144)) - 0.064009) / ((0.253 / x) + -0.12));
}
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.0144d0)) - 0.064009d0) / ((0.253d0 / x) + (-0.12d0)))
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.0144)) - 0.064009) / ((0.253 / x) + -0.12));
}
def code(x): return 1.0 - (x * (0.253 + (x * 0.12)))
def code(x): return 1.0 + (((x * (x * 0.0144)) - 0.064009) / ((0.253 / x) + -0.12))
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(Float64(x * Float64(x * 0.0144)) - 0.064009) / Float64(Float64(0.253 / x) + -0.12))) 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.0144)) - 0.064009) / ((0.253 / x) + -0.12)); 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[(N[(x * N[(x * 0.0144), $MachinePrecision]), $MachinePrecision] - 0.064009), $MachinePrecision] / N[(N[(0.253 / x), $MachinePrecision] + -0.12), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 - x \cdot \left(0.253 + x \cdot 0.12\right)
1 + \frac{x \cdot \left(x \cdot 0.0144\right) - 0.064009}{\frac{0.253}{x} + -0.12}
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
Initial program 99.9%
Applied egg-rr91.6%
[Start]99.9% | \[ 1 - x \cdot \left(0.253 + x \cdot 0.12\right)
\] |
|---|---|
flip-+ [=>]99.8% | \[ 1 - x \cdot \color{blue}{\frac{0.253 \cdot 0.253 - \left(x \cdot 0.12\right) \cdot \left(x \cdot 0.12\right)}{0.253 - x \cdot 0.12}}
\] |
associate-*r/ [=>]91.6% | \[ 1 - \color{blue}{\frac{x \cdot \left(0.253 \cdot 0.253 - \left(x \cdot 0.12\right) \cdot \left(x \cdot 0.12\right)\right)}{0.253 - x \cdot 0.12}}
\] |
metadata-eval [=>]91.6% | \[ 1 - \frac{x \cdot \left(\color{blue}{0.064009} - \left(x \cdot 0.12\right) \cdot \left(x \cdot 0.12\right)\right)}{0.253 - x \cdot 0.12}
\] |
swap-sqr [=>]91.6% | \[ 1 - \frac{x \cdot \left(0.064009 - \color{blue}{\left(x \cdot x\right) \cdot \left(0.12 \cdot 0.12\right)}\right)}{0.253 - x \cdot 0.12}
\] |
metadata-eval [=>]91.6% | \[ 1 - \frac{x \cdot \left(0.064009 - \left(x \cdot x\right) \cdot \color{blue}{0.0144}\right)}{0.253 - x \cdot 0.12}
\] |
*-commutative [=>]91.6% | \[ 1 - \frac{x \cdot \left(0.064009 - \left(x \cdot x\right) \cdot 0.0144\right)}{0.253 - \color{blue}{0.12 \cdot x}}
\] |
cancel-sign-sub-inv [=>]91.6% | \[ 1 - \frac{x \cdot \left(0.064009 - \left(x \cdot x\right) \cdot 0.0144\right)}{\color{blue}{0.253 + \left(-0.12\right) \cdot x}}
\] |
metadata-eval [=>]91.6% | \[ 1 - \frac{x \cdot \left(0.064009 - \left(x \cdot x\right) \cdot 0.0144\right)}{0.253 + \color{blue}{-0.12} \cdot x}
\] |
Simplified99.8%
[Start]91.6% | \[ 1 - \frac{x \cdot \left(0.064009 - \left(x \cdot x\right) \cdot 0.0144\right)}{0.253 + -0.12 \cdot x}
\] |
|---|---|
*-commutative [<=]91.6% | \[ 1 - \frac{\color{blue}{\left(0.064009 - \left(x \cdot x\right) \cdot 0.0144\right) \cdot x}}{0.253 + -0.12 \cdot x}
\] |
associate-/l* [=>]99.8% | \[ 1 - \color{blue}{\frac{0.064009 - \left(x \cdot x\right) \cdot 0.0144}{\frac{0.253 + -0.12 \cdot x}{x}}}
\] |
associate-*l* [=>]99.8% | \[ 1 - \frac{0.064009 - \color{blue}{x \cdot \left(x \cdot 0.0144\right)}}{\frac{0.253 + -0.12 \cdot x}{x}}
\] |
*-commutative [=>]99.8% | \[ 1 - \frac{0.064009 - x \cdot \left(x \cdot 0.0144\right)}{\frac{0.253 + \color{blue}{x \cdot -0.12}}{x}}
\] |
Taylor expanded in x around 0 99.9%
Simplified99.9%
[Start]99.9% | \[ 1 - \frac{0.064009 - x \cdot \left(x \cdot 0.0144\right)}{0.253 \cdot \frac{1}{x} - 0.12}
\] |
|---|---|
sub-neg [=>]99.9% | \[ 1 - \frac{0.064009 - x \cdot \left(x \cdot 0.0144\right)}{\color{blue}{0.253 \cdot \frac{1}{x} + \left(-0.12\right)}}
\] |
associate-*r/ [=>]99.9% | \[ 1 - \frac{0.064009 - x \cdot \left(x \cdot 0.0144\right)}{\color{blue}{\frac{0.253 \cdot 1}{x}} + \left(-0.12\right)}
\] |
metadata-eval [=>]99.9% | \[ 1 - \frac{0.064009 - x \cdot \left(x \cdot 0.0144\right)}{\frac{\color{blue}{0.253}}{x} + \left(-0.12\right)}
\] |
metadata-eval [=>]99.9% | \[ 1 - \frac{0.064009 - x \cdot \left(x \cdot 0.0144\right)}{\frac{0.253}{x} + \color{blue}{-0.12}}
\] |
Final simplification99.9%
| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 960 |
| Alternative 2 | |
|---|---|
| Accuracy | 59.3% |
| Cost | 585 |
| Alternative 3 | |
|---|---|
| Accuracy | 59.4% |
| Cost | 584 |
| Alternative 4 | |
|---|---|
| Accuracy | 98.1% |
| Cost | 584 |
| Alternative 5 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 576 |
| Alternative 6 | |
|---|---|
| Accuracy | 97.6% |
| Cost | 448 |
| Alternative 7 | |
|---|---|
| Accuracy | 10.4% |
| Cost | 64 |
herbie shell --seed 2023263
(FPCore (x)
:name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, A"
:precision binary64
(- 1.0 (* x (+ 0.253 (* x 0.12)))))