| Alternative 1 | |
|---|---|
| Accuracy | 99.6% |
| Cost | 13568 |

(FPCore (x y) :precision binary64 (* (* 3.0 (sqrt x)) (- (+ y (/ 1.0 (* x 9.0))) 1.0)))
(FPCore (x y) :precision binary64 (+ (pow (* x 9.0) -0.5) (* (+ y -1.0) (* 3.0 (sqrt x)))))
double code(double x, double y) {
return (3.0 * sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0);
}
double code(double x, double y) {
return pow((x * 9.0), -0.5) + ((y + -1.0) * (3.0 * sqrt(x)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (3.0d0 * sqrt(x)) * ((y + (1.0d0 / (x * 9.0d0))) - 1.0d0)
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 9.0d0) ** (-0.5d0)) + ((y + (-1.0d0)) * (3.0d0 * sqrt(x)))
end function
public static double code(double x, double y) {
return (3.0 * Math.sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0);
}
public static double code(double x, double y) {
return Math.pow((x * 9.0), -0.5) + ((y + -1.0) * (3.0 * Math.sqrt(x)));
}
def code(x, y): return (3.0 * math.sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0)
def code(x, y): return math.pow((x * 9.0), -0.5) + ((y + -1.0) * (3.0 * math.sqrt(x)))
function code(x, y) return Float64(Float64(3.0 * sqrt(x)) * Float64(Float64(y + Float64(1.0 / Float64(x * 9.0))) - 1.0)) end
function code(x, y) return Float64((Float64(x * 9.0) ^ -0.5) + Float64(Float64(y + -1.0) * Float64(3.0 * sqrt(x)))) end
function tmp = code(x, y) tmp = (3.0 * sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0); end
function tmp = code(x, y) tmp = ((x * 9.0) ^ -0.5) + ((y + -1.0) * (3.0 * sqrt(x))); end
code[x_, y_] := N[(N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[(N[(y + N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[Power[N[(x * 9.0), $MachinePrecision], -0.5], $MachinePrecision] + N[(N[(y + -1.0), $MachinePrecision] * N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(3 \cdot \sqrt{x}\right) \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)
{\left(x \cdot 9\right)}^{-0.5} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 99.4% |
|---|---|
| Target | 99.4% |
| Herbie | 99.6% |
Initial program 99.4%
Applied egg-rr99.4%
[Start]99.4% | \[ \left(3 \cdot \sqrt{x}\right) \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)
\] |
|---|---|
associate-/r* [=>]99.4% | \[ \left(3 \cdot \sqrt{x}\right) \cdot \left(\left(y + \color{blue}{\frac{\frac{1}{x}}{9}}\right) - 1\right)
\] |
+-commutative [=>]99.4% | \[ \left(3 \cdot \sqrt{x}\right) \cdot \left(\color{blue}{\left(\frac{\frac{1}{x}}{9} + y\right)} - 1\right)
\] |
associate-/r* [<=]99.4% | \[ \left(3 \cdot \sqrt{x}\right) \cdot \left(\left(\color{blue}{\frac{1}{x \cdot 9}} + y\right) - 1\right)
\] |
inv-pow [=>]99.4% | \[ \left(3 \cdot \sqrt{x}\right) \cdot \left(\left(\color{blue}{{\left(x \cdot 9\right)}^{-1}} + y\right) - 1\right)
\] |
*-commutative [=>]99.4% | \[ \left(3 \cdot \sqrt{x}\right) \cdot \left(\left({\color{blue}{\left(9 \cdot x\right)}}^{-1} + y\right) - 1\right)
\] |
unpow-prod-down [=>]99.4% | \[ \left(3 \cdot \sqrt{x}\right) \cdot \left(\left(\color{blue}{{9}^{-1} \cdot {x}^{-1}} + y\right) - 1\right)
\] |
metadata-eval [=>]99.4% | \[ \left(3 \cdot \sqrt{x}\right) \cdot \left(\left(\color{blue}{0.1111111111111111} \cdot {x}^{-1} + y\right) - 1\right)
\] |
inv-pow [<=]99.4% | \[ \left(3 \cdot \sqrt{x}\right) \cdot \left(\left(0.1111111111111111 \cdot \color{blue}{\frac{1}{x}} + y\right) - 1\right)
\] |
div-inv [<=]99.4% | \[ \left(3 \cdot \sqrt{x}\right) \cdot \left(\left(\color{blue}{\frac{0.1111111111111111}{x}} + y\right) - 1\right)
\] |
associate-+r- [<=]99.4% | \[ \left(3 \cdot \sqrt{x}\right) \cdot \color{blue}{\left(\frac{0.1111111111111111}{x} + \left(y - 1\right)\right)}
\] |
distribute-rgt-in [=>]99.4% | \[ \color{blue}{\frac{0.1111111111111111}{x} \cdot \left(3 \cdot \sqrt{x}\right) + \left(y - 1\right) \cdot \left(3 \cdot \sqrt{x}\right)}
\] |
sub-neg [=>]99.4% | \[ \frac{0.1111111111111111}{x} \cdot \left(3 \cdot \sqrt{x}\right) + \color{blue}{\left(y + \left(-1\right)\right)} \cdot \left(3 \cdot \sqrt{x}\right)
\] |
metadata-eval [=>]99.4% | \[ \frac{0.1111111111111111}{x} \cdot \left(3 \cdot \sqrt{x}\right) + \left(y + \color{blue}{-1}\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
Applied egg-rr99.5%
[Start]99.4% | \[ \frac{0.1111111111111111}{x} \cdot \left(3 \cdot \sqrt{x}\right) + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
|---|---|
*-commutative [=>]99.4% | \[ \color{blue}{\left(3 \cdot \sqrt{x}\right) \cdot \frac{0.1111111111111111}{x}} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
clear-num [=>]99.4% | \[ \left(3 \cdot \sqrt{x}\right) \cdot \color{blue}{\frac{1}{\frac{x}{0.1111111111111111}}} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
un-div-inv [=>]99.4% | \[ \color{blue}{\frac{3 \cdot \sqrt{x}}{\frac{x}{0.1111111111111111}}} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
add-sqr-sqrt [=>]99.3% | \[ \frac{\color{blue}{\sqrt{3 \cdot \sqrt{x}} \cdot \sqrt{3 \cdot \sqrt{x}}}}{\frac{x}{0.1111111111111111}} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
sqrt-unprod [=>]99.4% | \[ \frac{\color{blue}{\sqrt{\left(3 \cdot \sqrt{x}\right) \cdot \left(3 \cdot \sqrt{x}\right)}}}{\frac{x}{0.1111111111111111}} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
*-commutative [=>]99.4% | \[ \frac{\sqrt{\color{blue}{\left(\sqrt{x} \cdot 3\right)} \cdot \left(3 \cdot \sqrt{x}\right)}}{\frac{x}{0.1111111111111111}} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
*-commutative [=>]99.4% | \[ \frac{\sqrt{\left(\sqrt{x} \cdot 3\right) \cdot \color{blue}{\left(\sqrt{x} \cdot 3\right)}}}{\frac{x}{0.1111111111111111}} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
swap-sqr [=>]99.4% | \[ \frac{\sqrt{\color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right) \cdot \left(3 \cdot 3\right)}}}{\frac{x}{0.1111111111111111}} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
add-sqr-sqrt [<=]99.4% | \[ \frac{\sqrt{\color{blue}{x} \cdot \left(3 \cdot 3\right)}}{\frac{x}{0.1111111111111111}} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
metadata-eval [=>]99.4% | \[ \frac{\sqrt{x \cdot \color{blue}{9}}}{\frac{x}{0.1111111111111111}} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
div-inv [=>]99.5% | \[ \frac{\sqrt{x \cdot 9}}{\color{blue}{x \cdot \frac{1}{0.1111111111111111}}} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
metadata-eval [=>]99.5% | \[ \frac{\sqrt{x \cdot 9}}{x \cdot \color{blue}{9}} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
Applied egg-rr96.8%
[Start]99.5% | \[ \frac{\sqrt{x \cdot 9}}{x \cdot 9} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
|---|---|
expm1-log1p-u [=>]96.8% | \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{x \cdot 9}}{x \cdot 9}\right)\right)} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
expm1-udef [=>]96.8% | \[ \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\sqrt{x \cdot 9}}{x \cdot 9}\right)} - 1\right)} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
pow1/2 [=>]96.8% | \[ \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{{\left(x \cdot 9\right)}^{0.5}}}{x \cdot 9}\right)} - 1\right) + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
pow1 [=>]96.8% | \[ \left(e^{\mathsf{log1p}\left(\frac{{\left(x \cdot 9\right)}^{0.5}}{\color{blue}{{\left(x \cdot 9\right)}^{1}}}\right)} - 1\right) + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
pow-div [=>]96.8% | \[ \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(x \cdot 9\right)}^{\left(0.5 - 1\right)}}\right)} - 1\right) + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
metadata-eval [=>]96.8% | \[ \left(e^{\mathsf{log1p}\left({\left(x \cdot 9\right)}^{\color{blue}{-0.5}}\right)} - 1\right) + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
Simplified99.6%
[Start]96.8% | \[ \left(e^{\mathsf{log1p}\left({\left(x \cdot 9\right)}^{-0.5}\right)} - 1\right) + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
|---|---|
expm1-def [=>]96.8% | \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(x \cdot 9\right)}^{-0.5}\right)\right)} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
expm1-log1p [=>]99.6% | \[ \color{blue}{{\left(x \cdot 9\right)}^{-0.5}} + \left(y + -1\right) \cdot \left(3 \cdot \sqrt{x}\right)
\] |
Final simplification99.6%
| Alternative 1 | |
|---|---|
| Accuracy | 99.6% |
| Cost | 13568 |
| Alternative 2 | |
|---|---|
| Accuracy | 61.7% |
| Cost | 7380 |
| Alternative 3 | |
|---|---|
| Accuracy | 61.7% |
| Cost | 7380 |
| Alternative 4 | |
|---|---|
| Accuracy | 86.5% |
| Cost | 7112 |
| Alternative 5 | |
|---|---|
| Accuracy | 85.5% |
| Cost | 7108 |
| Alternative 6 | |
|---|---|
| Accuracy | 99.4% |
| Cost | 7104 |
| Alternative 7 | |
|---|---|
| Accuracy | 99.4% |
| Cost | 7104 |
| Alternative 8 | |
|---|---|
| Accuracy | 60.8% |
| Cost | 6985 |
| Alternative 9 | |
|---|---|
| Accuracy | 60.8% |
| Cost | 6985 |
| Alternative 10 | |
|---|---|
| Accuracy | 85.5% |
| Cost | 6980 |
| Alternative 11 | |
|---|---|
| Accuracy | 85.5% |
| Cost | 6980 |
| Alternative 12 | |
|---|---|
| Accuracy | 25.4% |
| Cost | 6592 |
herbie shell --seed 2023258
(FPCore (x y)
:name "Numeric.SpecFunctions:incompleteGamma from math-functions-0.1.5.2, B"
:precision binary64
:herbie-target
(* 3.0 (+ (* y (sqrt x)) (* (- (/ 1.0 (* x 9.0)) 1.0) (sqrt x))))
(* (* 3.0 (sqrt x)) (- (+ y (/ 1.0 (* x 9.0))) 1.0)))