
(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 -6.8e+74) t_1 (if (<= y 6.5e+92) (- 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 <= -6.8e+74) {
tmp = t_1;
} else if (y <= 6.5e+92) {
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 <= (-6.8d+74)) then
tmp = t_1
else if (y <= 6.5d+92) 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 <= -6.8e+74) {
tmp = t_1;
} else if (y <= 6.5e+92) {
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 <= -6.8e+74: tmp = t_1 elif y <= 6.5e+92: 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 <= -6.8e+74) tmp = t_1; elseif (y <= 6.5e+92) 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 <= -6.8e+74) tmp = t_1; elseif (y <= 6.5e+92) 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, -6.8e+74], t$95$1, If[LessEqual[y, 6.5e+92], 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 -6.8 \cdot 10^{+74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{+92}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -6.7999999999999998e74 or 6.49999999999999999e92 < y Initial program 99.5%
Taylor expanded in x around 0
Applied rewrites91.6%
if -6.7999999999999998e74 < y < 6.49999999999999999e92Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites93.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (* x 9.0) (/ y (* 3.0 (sqrt x))))))
(if (<= y -7.5e+118)
t_0
(if (<= y 1.2e+98) (- 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 <= -7.5e+118) {
tmp = t_0;
} else if (y <= 1.2e+98) {
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 <= (-7.5d+118)) then
tmp = t_0
else if (y <= 1.2d+98) 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 <= -7.5e+118) {
tmp = t_0;
} else if (y <= 1.2e+98) {
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 <= -7.5e+118: tmp = t_0 elif y <= 1.2e+98: 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 <= -7.5e+118) tmp = t_0; elseif (y <= 1.2e+98) 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 <= -7.5e+118) tmp = t_0; elseif (y <= 1.2e+98) 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, -7.5e+118], t$95$0, If[LessEqual[y, 1.2e+98], 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 -7.5 \cdot 10^{+118}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{+98}:\\
\;\;\;\;1 - \frac{1}{x \cdot 9}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -7.50000000000000003e118 or 1.1999999999999999e98 < y Initial program 99.6%
Taylor expanded in x around 0
Applied rewrites71.6%
if -7.50000000000000003e118 < y < 1.1999999999999999e98Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites90.1%
(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 rewrites62.2%
(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 rewrites62.2%
Taylor expanded in x around 0
Applied rewrites3.0%
Taylor expanded in x around inf
Applied rewrites3.5%
(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 rewrites62.2%
Taylor expanded in x around 0
Applied rewrites3.0%
(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 2024321
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, D"
:precision binary64
:pre (TRUE)
:alt
(! :herbie-platform default (- (- 1 (/ (/ 1 x) 9)) (/ y (* 3 (sqrt x)))))
(- (- 1.0 (/ 1.0 (* x 9.0))) (/ y (* 3.0 (sqrt x)))))