
(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 6 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 (* 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}
Initial program 99.7%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ 1.0 (* x 9.0))) (t_1 (- t_0 (/ y (* 3.0 (sqrt x)))))) (if (<= y -5.3e+90) t_1 (if (<= y 1.45e+71) (- 1.0 t_0) t_1))))
double code(double x, double y) {
double t_0 = 1.0 / (x * 9.0);
double t_1 = t_0 - (y / (3.0 * sqrt(x)));
double tmp;
if (y <= -5.3e+90) {
tmp = t_1;
} else if (y <= 1.45e+71) {
tmp = 1.0 - t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 / (x * 9.0d0)
t_1 = t_0 - (y / (3.0d0 * sqrt(x)))
if (y <= (-5.3d+90)) then
tmp = t_1
else if (y <= 1.45d+71) then
tmp = 1.0d0 - t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 / (x * 9.0);
double t_1 = t_0 - (y / (3.0 * Math.sqrt(x)));
double tmp;
if (y <= -5.3e+90) {
tmp = t_1;
} else if (y <= 1.45e+71) {
tmp = 1.0 - t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = 1.0 / (x * 9.0) t_1 = t_0 - (y / (3.0 * math.sqrt(x))) tmp = 0 if y <= -5.3e+90: tmp = t_1 elif y <= 1.45e+71: tmp = 1.0 - t_0 else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(1.0 / Float64(x * 9.0)) t_1 = Float64(t_0 - Float64(y / Float64(3.0 * sqrt(x)))) tmp = 0.0 if (y <= -5.3e+90) tmp = t_1; elseif (y <= 1.45e+71) tmp = Float64(1.0 - t_0); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 / (x * 9.0); t_1 = t_0 - (y / (3.0 * sqrt(x))); tmp = 0.0; if (y <= -5.3e+90) tmp = t_1; elseif (y <= 1.45e+71) tmp = 1.0 - t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[(y / N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.3e+90], t$95$1, If[LessEqual[y, 1.45e+71], N[(1.0 - t$95$0), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{x \cdot 9}\\
t_1 := t\_0 - \frac{y}{3 \cdot \sqrt{x}}\\
\mathbf{if}\;y \leq -5.3 \cdot 10^{+90}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{+71}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -5.29999999999999979e90 or 1.45000000000000004e71 < y Initial program 99.6%
Taylor expanded in x around 0
Applied rewrites91.7%
if -5.29999999999999979e90 < y < 1.45000000000000004e71Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites95.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (* x 9.0) (/ y (* 3.0 (sqrt x))))))
(if (<= y -1.05e+91)
t_0
(if (<= y 4.8e+72) (- 1.0 (/ 1.0 (* x 9.0))) t_0))))
double code(double x, double y) {
double t_0 = (x * 9.0) - (y / (3.0 * sqrt(x)));
double tmp;
if (y <= -1.05e+91) {
tmp = t_0;
} else if (y <= 4.8e+72) {
tmp = 1.0 - (1.0 / (x * 9.0));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x * 9.0d0) - (y / (3.0d0 * sqrt(x)))
if (y <= (-1.05d+91)) then
tmp = t_0
else if (y <= 4.8d+72) then
tmp = 1.0d0 - (1.0d0 / (x * 9.0d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x * 9.0) - (y / (3.0 * Math.sqrt(x)));
double tmp;
if (y <= -1.05e+91) {
tmp = t_0;
} else if (y <= 4.8e+72) {
tmp = 1.0 - (1.0 / (x * 9.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x * 9.0) - (y / (3.0 * math.sqrt(x))) tmp = 0 if y <= -1.05e+91: tmp = t_0 elif y <= 4.8e+72: tmp = 1.0 - (1.0 / (x * 9.0)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x * 9.0) - Float64(y / Float64(3.0 * sqrt(x)))) tmp = 0.0 if (y <= -1.05e+91) tmp = t_0; elseif (y <= 4.8e+72) tmp = Float64(1.0 - Float64(1.0 / Float64(x * 9.0))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x * 9.0) - (y / (3.0 * sqrt(x))); tmp = 0.0; if (y <= -1.05e+91) tmp = t_0; elseif (y <= 4.8e+72) tmp = 1.0 - (1.0 / (x * 9.0)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * 9.0), $MachinePrecision] - N[(y / N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.05e+91], t$95$0, If[LessEqual[y, 4.8e+72], N[(1.0 - N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot 9 - \frac{y}{3 \cdot \sqrt{x}}\\
\mathbf{if}\;y \leq -1.05 \cdot 10^{+91}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+72}:\\
\;\;\;\;1 - \frac{1}{x \cdot 9}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.05000000000000004e91 or 4.8000000000000002e72 < y Initial program 99.6%
Taylor expanded in x around 0
Applied rewrites69.1%
if -1.05000000000000004e91 < y < 4.8000000000000002e72Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites95.8%
(FPCore (x y) :precision binary64 (- 1.0 (/ 1.0 (* x 9.0))))
double code(double x, double y) {
return 1.0 - (1.0 / (x * 9.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - (1.0d0 / (x * 9.0d0))
end function
public static double code(double x, double y) {
return 1.0 - (1.0 / (x * 9.0));
}
def code(x, y): return 1.0 - (1.0 / (x * 9.0))
function code(x, y) return Float64(1.0 - Float64(1.0 / Float64(x * 9.0))) end
function tmp = code(x, y) tmp = 1.0 - (1.0 / (x * 9.0)); end
code[x_, y_] := N[(1.0 - N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{1}{x \cdot 9}
\end{array}
Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites65.1%
(FPCore (x y) :precision binary64 (sqrt x))
double code(double x, double y) {
return sqrt(x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt(x)
end function
public static double code(double x, double y) {
return Math.sqrt(x);
}
def code(x, y): return math.sqrt(x)
function code(x, y) return sqrt(x) end
function tmp = code(x, y) tmp = sqrt(x); end
code[x_, y_] := N[Sqrt[x], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x}
\end{array}
Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites65.1%
Taylor expanded in x around 0
Applied rewrites3.2%
Taylor expanded in x around inf
Applied rewrites3.6%
(FPCore (x y) :precision binary64 (* x 9.0))
double code(double x, double y) {
return x * 9.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * 9.0d0
end function
public static double code(double x, double y) {
return x * 9.0;
}
def code(x, y): return x * 9.0
function code(x, y) return Float64(x * 9.0) end
function tmp = code(x, y) tmp = x * 9.0; end
code[x_, y_] := N[(x * 9.0), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 9
\end{array}
Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites65.1%
Taylor expanded in x around 0
Applied rewrites3.2%
(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 2024313
(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)))))