
(FPCore (x y) :precision binary64 (- (- 1.0 (/ 1.0 (* x 9.0))) (/ y (* 3.0 (sqrt x)))))
double code(double x, double y) {
return (1.0 - (1.0 / (x * 9.0))) - (y / (3.0 * sqrt(x)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - (1.0d0 / (x * 9.0d0))) - (y / (3.0d0 * sqrt(x)))
end function
public static double code(double x, double y) {
return (1.0 - (1.0 / (x * 9.0))) - (y / (3.0 * Math.sqrt(x)));
}
def code(x, y): return (1.0 - (1.0 / (x * 9.0))) - (y / (3.0 * math.sqrt(x)))
function code(x, y) return Float64(Float64(1.0 - Float64(1.0 / Float64(x * 9.0))) - Float64(y / Float64(3.0 * sqrt(x)))) end
function tmp = code(x, y) tmp = (1.0 - (1.0 / (x * 9.0))) - (y / (3.0 * sqrt(x))); end
code[x_, y_] := N[(N[(1.0 - N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y / N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - \frac{1}{x \cdot 9}\right) - \frac{y}{3 \cdot \sqrt{x}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- (- 1.0 (/ 1.0 (* x 9.0))) (/ y (* 3.0 (sqrt x)))))
double code(double x, double y) {
return (1.0 - (1.0 / (x * 9.0))) - (y / (3.0 * sqrt(x)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - (1.0d0 / (x * 9.0d0))) - (y / (3.0d0 * sqrt(x)))
end function
public static double code(double x, double y) {
return (1.0 - (1.0 / (x * 9.0))) - (y / (3.0 * Math.sqrt(x)));
}
def code(x, y): return (1.0 - (1.0 / (x * 9.0))) - (y / (3.0 * math.sqrt(x)))
function code(x, y) return Float64(Float64(1.0 - Float64(1.0 / Float64(x * 9.0))) - Float64(y / Float64(3.0 * sqrt(x)))) end
function tmp = code(x, y) tmp = (1.0 - (1.0 / (x * 9.0))) - (y / (3.0 * sqrt(x))); end
code[x_, y_] := N[(N[(1.0 - N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y / N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - \frac{1}{x \cdot 9}\right) - \frac{y}{3 \cdot \sqrt{x}}
\end{array}
(FPCore (x y) :precision binary64 (- (- 1.0 (/ 1.0 (* 9.0 x))) (/ y (* (sqrt x) 3.0))))
double code(double x, double y) {
return (1.0 - (1.0 / (9.0 * x))) - (y / (sqrt(x) * 3.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - (1.0d0 / (9.0d0 * x))) - (y / (sqrt(x) * 3.0d0))
end function
public static double code(double x, double y) {
return (1.0 - (1.0 / (9.0 * x))) - (y / (Math.sqrt(x) * 3.0));
}
def code(x, y): return (1.0 - (1.0 / (9.0 * x))) - (y / (math.sqrt(x) * 3.0))
function code(x, y) return Float64(Float64(1.0 - Float64(1.0 / Float64(9.0 * x))) - Float64(y / Float64(sqrt(x) * 3.0))) end
function tmp = code(x, y) tmp = (1.0 - (1.0 / (9.0 * x))) - (y / (sqrt(x) * 3.0)); end
code[x_, y_] := N[(N[(1.0 - N[(1.0 / N[(9.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y / N[(N[Sqrt[x], $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - \frac{1}{9 \cdot x}\right) - \frac{y}{\sqrt{x} \cdot 3}
\end{array}
Initial program 99.7%
Final simplification99.7%
(FPCore (x y) :precision binary64 (if (<= (- (- 1.0 (/ 1.0 (* 9.0 x))) (/ y (* (sqrt x) 3.0))) -1000.0) (/ -0.1111111111111111 x) (- 1.0 (/ -0.1111111111111111 x))))
double code(double x, double y) {
double tmp;
if (((1.0 - (1.0 / (9.0 * x))) - (y / (sqrt(x) * 3.0))) <= -1000.0) {
tmp = -0.1111111111111111 / x;
} else {
tmp = 1.0 - (-0.1111111111111111 / x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (((1.0d0 - (1.0d0 / (9.0d0 * x))) - (y / (sqrt(x) * 3.0d0))) <= (-1000.0d0)) then
tmp = (-0.1111111111111111d0) / x
else
tmp = 1.0d0 - ((-0.1111111111111111d0) / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (((1.0 - (1.0 / (9.0 * x))) - (y / (Math.sqrt(x) * 3.0))) <= -1000.0) {
tmp = -0.1111111111111111 / x;
} else {
tmp = 1.0 - (-0.1111111111111111 / x);
}
return tmp;
}
def code(x, y): tmp = 0 if ((1.0 - (1.0 / (9.0 * x))) - (y / (math.sqrt(x) * 3.0))) <= -1000.0: tmp = -0.1111111111111111 / x else: tmp = 1.0 - (-0.1111111111111111 / x) return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(1.0 - Float64(1.0 / Float64(9.0 * x))) - Float64(y / Float64(sqrt(x) * 3.0))) <= -1000.0) tmp = Float64(-0.1111111111111111 / x); else tmp = Float64(1.0 - Float64(-0.1111111111111111 / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((1.0 - (1.0 / (9.0 * x))) - (y / (sqrt(x) * 3.0))) <= -1000.0) tmp = -0.1111111111111111 / x; else tmp = 1.0 - (-0.1111111111111111 / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[(1.0 - N[(1.0 / N[(9.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y / N[(N[Sqrt[x], $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1000.0], N[(-0.1111111111111111 / x), $MachinePrecision], N[(1.0 - N[(-0.1111111111111111 / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - \frac{1}{9 \cdot x}\right) - \frac{y}{\sqrt{x} \cdot 3} \leq -1000:\\
\;\;\;\;\frac{-0.1111111111111111}{x}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{-0.1111111111111111}{x}\\
\end{array}
\end{array}
if (-.f64 (-.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) (*.f64 x #s(literal 9 binary64)))) (/.f64 y (*.f64 #s(literal 3 binary64) (sqrt.f64 x)))) < -1e3Initial program 99.5%
Taylor expanded in y around 0
*-inversesN/A
associate-*r/N/A
metadata-evalN/A
div-subN/A
lower-/.f64N/A
lower--.f6461.8
Applied rewrites61.8%
Taylor expanded in x around 0
Applied rewrites61.5%
if -1e3 < (-.f64 (-.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) (*.f64 x #s(literal 9 binary64)))) (/.f64 y (*.f64 #s(literal 3 binary64) (sqrt.f64 x)))) Initial program 99.8%
Taylor expanded in y around 0
*-inversesN/A
associate-*r/N/A
metadata-evalN/A
div-subN/A
lower-/.f64N/A
lower--.f6462.8
Applied rewrites62.8%
Applied rewrites62.6%
Final simplification62.1%
(FPCore (x y) :precision binary64 (- (- 1.0 (/ (/ 1.0 x) 9.0)) (/ y (* 3.0 (sqrt x)))))
double code(double x, double y) {
return (1.0 - ((1.0 / x) / 9.0)) - (y / (3.0 * sqrt(x)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - ((1.0d0 / x) / 9.0d0)) - (y / (3.0d0 * sqrt(x)))
end function
public static double code(double x, double y) {
return (1.0 - ((1.0 / x) / 9.0)) - (y / (3.0 * Math.sqrt(x)));
}
def code(x, y): return (1.0 - ((1.0 / x) / 9.0)) - (y / (3.0 * math.sqrt(x)))
function code(x, y) return Float64(Float64(1.0 - Float64(Float64(1.0 / x) / 9.0)) - Float64(y / Float64(3.0 * sqrt(x)))) end
function tmp = code(x, y) tmp = (1.0 - ((1.0 / x) / 9.0)) - (y / (3.0 * sqrt(x))); end
code[x_, y_] := N[(N[(1.0 - N[(N[(1.0 / x), $MachinePrecision] / 9.0), $MachinePrecision]), $MachinePrecision] - N[(y / N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - \frac{\frac{1}{x}}{9}\right) - \frac{y}{3 \cdot \sqrt{x}}
\end{array}
herbie shell --seed 2024230
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, D"
:precision binary64
:alt
(! :herbie-platform default (- (- 1 (/ (/ 1 x) 9)) (/ y (* 3 (sqrt x)))))
(- (- 1.0 (/ 1.0 (* x 9.0))) (/ y (* 3.0 (sqrt x)))))