| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 448 |
\[\frac{x}{\frac{6}{x}} + -0.5
\]

(FPCore (x) :precision binary64 (/ (- (* x x) 3.0) 6.0))
(FPCore (x) :precision binary64 (+ (/ x (/ 6.0 x)) -0.5))
double code(double x) {
return ((x * x) - 3.0) / 6.0;
}
double code(double x) {
return (x / (6.0 / x)) + -0.5;
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x * x) - 3.0d0) / 6.0d0
end function
real(8) function code(x)
real(8), intent (in) :: x
code = (x / (6.0d0 / x)) + (-0.5d0)
end function
public static double code(double x) {
return ((x * x) - 3.0) / 6.0;
}
public static double code(double x) {
return (x / (6.0 / x)) + -0.5;
}
def code(x): return ((x * x) - 3.0) / 6.0
def code(x): return (x / (6.0 / x)) + -0.5
function code(x) return Float64(Float64(Float64(x * x) - 3.0) / 6.0) end
function code(x) return Float64(Float64(x / Float64(6.0 / x)) + -0.5) end
function tmp = code(x) tmp = ((x * x) - 3.0) / 6.0; end
function tmp = code(x) tmp = (x / (6.0 / x)) + -0.5; end
code[x_] := N[(N[(N[(x * x), $MachinePrecision] - 3.0), $MachinePrecision] / 6.0), $MachinePrecision]
code[x_] := N[(N[(x / N[(6.0 / x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision]
\frac{x \cdot x - 3}{6}
\frac{x}{\frac{6}{x}} + -0.5
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
Initial program 99.9%
Applied egg-rr99.8%
[Start]99.9% | \[ \frac{x \cdot x - 3}{6}
\] |
|---|---|
clear-num [=>]99.8% | \[ \color{blue}{\frac{1}{\frac{6}{x \cdot x - 3}}}
\] |
inv-pow [=>]99.8% | \[ \color{blue}{{\left(\frac{6}{x \cdot x - 3}\right)}^{-1}}
\] |
fma-neg [=>]99.8% | \[ {\left(\frac{6}{\color{blue}{\mathsf{fma}\left(x, x, -3\right)}}\right)}^{-1}
\] |
metadata-eval [=>]99.8% | \[ {\left(\frac{6}{\mathsf{fma}\left(x, x, \color{blue}{-3}\right)}\right)}^{-1}
\] |
Applied egg-rr99.9%
[Start]99.8% | \[ {\left(\frac{6}{\mathsf{fma}\left(x, x, -3\right)}\right)}^{-1}
\] |
|---|---|
unpow-1 [=>]99.8% | \[ \color{blue}{\frac{1}{\frac{6}{\mathsf{fma}\left(x, x, -3\right)}}}
\] |
associate-/r/ [=>]99.8% | \[ \color{blue}{\frac{1}{6} \cdot \mathsf{fma}\left(x, x, -3\right)}
\] |
metadata-eval [=>]99.8% | \[ \color{blue}{0.16666666666666666} \cdot \mathsf{fma}\left(x, x, -3\right)
\] |
fma-udef [=>]99.8% | \[ 0.16666666666666666 \cdot \color{blue}{\left(x \cdot x + -3\right)}
\] |
distribute-rgt-in [=>]99.8% | \[ \color{blue}{\left(x \cdot x\right) \cdot 0.16666666666666666 + -3 \cdot 0.16666666666666666}
\] |
associate-*l* [=>]99.9% | \[ \color{blue}{x \cdot \left(x \cdot 0.16666666666666666\right)} + -3 \cdot 0.16666666666666666
\] |
metadata-eval [=>]99.9% | \[ x \cdot \left(x \cdot 0.16666666666666666\right) + \color{blue}{-0.5}
\] |
Applied egg-rr99.9%
[Start]99.9% | \[ x \cdot \left(x \cdot 0.16666666666666666\right) + -0.5
\] |
|---|---|
associate-*r* [=>]99.8% | \[ \color{blue}{\left(x \cdot x\right) \cdot 0.16666666666666666} + -0.5
\] |
metadata-eval [<=]99.8% | \[ \left(x \cdot x\right) \cdot \color{blue}{\frac{1}{6}} + -0.5
\] |
div-inv [<=]99.9% | \[ \color{blue}{\frac{x \cdot x}{6}} + -0.5
\] |
associate-/l* [=>]99.9% | \[ \color{blue}{\frac{x}{\frac{6}{x}}} + -0.5
\] |
Final simplification99.9%
| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 448 |
| Alternative 2 | |
|---|---|
| Accuracy | 98.8% |
| Cost | 580 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.8% |
| Cost | 580 |
| Alternative 4 | |
|---|---|
| Accuracy | 98.8% |
| Cost | 580 |
| Alternative 5 | |
|---|---|
| Accuracy | 98.8% |
| Cost | 580 |
| Alternative 6 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 448 |
| Alternative 7 | |
|---|---|
| Accuracy | 49.8% |
| Cost | 64 |
herbie shell --seed 2023165
(FPCore (x)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, H"
:precision binary64
(/ (- (* x x) 3.0) 6.0))