
(FPCore (x y) :precision binary64 (* (* 3.0 (sqrt x)) (- (+ y (/ 1.0 (* x 9.0))) 1.0)))
double code(double x, double y) {
return (3.0 * sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0);
}
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
public static double code(double x, double y) {
return (3.0 * Math.sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0);
}
def code(x, y): return (3.0 * math.sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0)
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 tmp = code(x, y) tmp = (3.0 * sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0); 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]
\begin{array}{l}
\\
\left(3 \cdot \sqrt{x}\right) \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (* 3.0 (sqrt x)) (- (+ y (/ 1.0 (* x 9.0))) 1.0)))
double code(double x, double y) {
return (3.0 * sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0);
}
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
public static double code(double x, double y) {
return (3.0 * Math.sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0);
}
def code(x, y): return (3.0 * math.sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0)
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 tmp = code(x, y) tmp = (3.0 * sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0); 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]
\begin{array}{l}
\\
\left(3 \cdot \sqrt{x}\right) \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)
\end{array}
(FPCore (x y) :precision binary64 (* (* 3.0 (sqrt x)) (- (+ y (/ 1.0 (* x 9.0))) 1.0)))
double code(double x, double y) {
return (3.0 * sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0);
}
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
public static double code(double x, double y) {
return (3.0 * Math.sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0);
}
def code(x, y): return (3.0 * math.sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0)
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 tmp = code(x, y) tmp = (3.0 * sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0); 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]
\begin{array}{l}
\\
\left(3 \cdot \sqrt{x}\right) \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)
\end{array}
Initial program 99.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ 1.0 (* x 9.0))))
(if (<= x 0.00122)
(* (* 3.0 (sqrt x)) t_0)
(* (sqrt x) (- (+ y t_0) 1.0)))))
double code(double x, double y) {
double t_0 = 1.0 / (x * 9.0);
double tmp;
if (x <= 0.00122) {
tmp = (3.0 * sqrt(x)) * t_0;
} else {
tmp = sqrt(x) * ((y + t_0) - 1.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 = 1.0d0 / (x * 9.0d0)
if (x <= 0.00122d0) then
tmp = (3.0d0 * sqrt(x)) * t_0
else
tmp = sqrt(x) * ((y + t_0) - 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 / (x * 9.0);
double tmp;
if (x <= 0.00122) {
tmp = (3.0 * Math.sqrt(x)) * t_0;
} else {
tmp = Math.sqrt(x) * ((y + t_0) - 1.0);
}
return tmp;
}
def code(x, y): t_0 = 1.0 / (x * 9.0) tmp = 0 if x <= 0.00122: tmp = (3.0 * math.sqrt(x)) * t_0 else: tmp = math.sqrt(x) * ((y + t_0) - 1.0) return tmp
function code(x, y) t_0 = Float64(1.0 / Float64(x * 9.0)) tmp = 0.0 if (x <= 0.00122) tmp = Float64(Float64(3.0 * sqrt(x)) * t_0); else tmp = Float64(sqrt(x) * Float64(Float64(y + t_0) - 1.0)); end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 / (x * 9.0); tmp = 0.0; if (x <= 0.00122) tmp = (3.0 * sqrt(x)) * t_0; else tmp = sqrt(x) * ((y + t_0) - 1.0); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 0.00122], N[(N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Sqrt[x], $MachinePrecision] * N[(N[(y + t$95$0), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{x \cdot 9}\\
\mathbf{if}\;x \leq 0.00122:\\
\;\;\;\;\left(3 \cdot \sqrt{x}\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x} \cdot \left(\left(y + t\_0\right) - 1\right)\\
\end{array}
\end{array}
if x < 0.00121999999999999995Initial program 99.3%
Taylor expanded in x around 0
Applied rewrites73.7%
if 0.00121999999999999995 < x Initial program 99.6%
Taylor expanded in x around 0
Applied rewrites27.6%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ 1.0 (* x 9.0)))) (if (<= x 0.00122) (* (* 3.0 (sqrt x)) t_0) (* (sqrt x) (+ y t_0)))))
double code(double x, double y) {
double t_0 = 1.0 / (x * 9.0);
double tmp;
if (x <= 0.00122) {
tmp = (3.0 * sqrt(x)) * t_0;
} else {
tmp = sqrt(x) * (y + 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 = 1.0d0 / (x * 9.0d0)
if (x <= 0.00122d0) then
tmp = (3.0d0 * sqrt(x)) * t_0
else
tmp = sqrt(x) * (y + t_0)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 / (x * 9.0);
double tmp;
if (x <= 0.00122) {
tmp = (3.0 * Math.sqrt(x)) * t_0;
} else {
tmp = Math.sqrt(x) * (y + t_0);
}
return tmp;
}
def code(x, y): t_0 = 1.0 / (x * 9.0) tmp = 0 if x <= 0.00122: tmp = (3.0 * math.sqrt(x)) * t_0 else: tmp = math.sqrt(x) * (y + t_0) return tmp
function code(x, y) t_0 = Float64(1.0 / Float64(x * 9.0)) tmp = 0.0 if (x <= 0.00122) tmp = Float64(Float64(3.0 * sqrt(x)) * t_0); else tmp = Float64(sqrt(x) * Float64(y + t_0)); end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 / (x * 9.0); tmp = 0.0; if (x <= 0.00122) tmp = (3.0 * sqrt(x)) * t_0; else tmp = sqrt(x) * (y + t_0); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 0.00122], N[(N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Sqrt[x], $MachinePrecision] * N[(y + t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{x \cdot 9}\\
\mathbf{if}\;x \leq 0.00122:\\
\;\;\;\;\left(3 \cdot \sqrt{x}\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x} \cdot \left(y + t\_0\right)\\
\end{array}
\end{array}
if x < 0.00121999999999999995Initial program 99.3%
Taylor expanded in x around 0
Applied rewrites73.7%
if 0.00121999999999999995 < x Initial program 99.6%
Taylor expanded in x around 0
Applied rewrites53.3%
Taylor expanded in x around 0
Applied rewrites20.4%
(FPCore (x y) :precision binary64 (* 3.0 (* (sqrt x) (- (+ y (/ 1.0 (* x 9.0))) 1.0))))
double code(double x, double y) {
return 3.0 * (sqrt(x) * ((y + (1.0 / (x * 9.0))) - 1.0));
}
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
public static double code(double x, double y) {
return 3.0 * (Math.sqrt(x) * ((y + (1.0 / (x * 9.0))) - 1.0));
}
def code(x, y): return 3.0 * (math.sqrt(x) * ((y + (1.0 / (x * 9.0))) - 1.0))
function code(x, y) return Float64(3.0 * Float64(sqrt(x) * Float64(Float64(y + Float64(1.0 / Float64(x * 9.0))) - 1.0))) end
function tmp = code(x, y) tmp = 3.0 * (sqrt(x) * ((y + (1.0 / (x * 9.0))) - 1.0)); end
code[x_, y_] := N[(3.0 * N[(N[Sqrt[x], $MachinePrecision] * N[(N[(y + N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
3 \cdot \left(\sqrt{x} \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)\right)
\end{array}
Initial program 99.4%
Taylor expanded in x around 0
Applied rewrites3.4%
Taylor expanded in x around 0
Applied rewrites99.3%
(FPCore (x y) :precision binary64 (* (* 3.0 (sqrt x)) (+ y (/ 1.0 (* x 9.0)))))
double code(double x, double y) {
return (3.0 * sqrt(x)) * (y + (1.0 / (x * 9.0)));
}
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)))
end function
public static double code(double x, double y) {
return (3.0 * Math.sqrt(x)) * (y + (1.0 / (x * 9.0)));
}
def code(x, y): return (3.0 * math.sqrt(x)) * (y + (1.0 / (x * 9.0)))
function code(x, y) return Float64(Float64(3.0 * sqrt(x)) * Float64(y + Float64(1.0 / Float64(x * 9.0)))) end
function tmp = code(x, y) tmp = (3.0 * sqrt(x)) * (y + (1.0 / (x * 9.0))); end
code[x_, y_] := N[(N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[(y + N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 \cdot \sqrt{x}\right) \cdot \left(y + \frac{1}{x \cdot 9}\right)
\end{array}
Initial program 99.4%
Taylor expanded in x around 0
Applied rewrites76.0%
(FPCore (x y) :precision binary64 (* (sqrt x) (+ y (/ 1.0 (* x 9.0)))))
double code(double x, double y) {
return sqrt(x) * (y + (1.0 / (x * 9.0)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt(x) * (y + (1.0d0 / (x * 9.0d0)))
end function
public static double code(double x, double y) {
return Math.sqrt(x) * (y + (1.0 / (x * 9.0)));
}
def code(x, y): return math.sqrt(x) * (y + (1.0 / (x * 9.0)))
function code(x, y) return Float64(sqrt(x) * Float64(y + Float64(1.0 / Float64(x * 9.0)))) end
function tmp = code(x, y) tmp = sqrt(x) * (y + (1.0 / (x * 9.0))); end
code[x_, y_] := N[(N[Sqrt[x], $MachinePrecision] * N[(y + N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x} \cdot \left(y + \frac{1}{x \cdot 9}\right)
\end{array}
Initial program 99.4%
Taylor expanded in x around 0
Applied rewrites76.0%
Taylor expanded in x around 0
Applied rewrites19.0%
(FPCore (x y) :precision binary64 (* (sqrt x) (/ 1.0 (* x 9.0))))
double code(double x, double y) {
return sqrt(x) * (1.0 / (x * 9.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt(x) * (1.0d0 / (x * 9.0d0))
end function
public static double code(double x, double y) {
return Math.sqrt(x) * (1.0 / (x * 9.0));
}
def code(x, y): return math.sqrt(x) * (1.0 / (x * 9.0))
function code(x, y) return Float64(sqrt(x) * Float64(1.0 / Float64(x * 9.0))) end
function tmp = code(x, y) tmp = sqrt(x) * (1.0 / (x * 9.0)); end
code[x_, y_] := N[(N[Sqrt[x], $MachinePrecision] * N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x} \cdot \frac{1}{x \cdot 9}
\end{array}
Initial program 99.4%
Taylor expanded in x around 0
Applied rewrites38.7%
Taylor expanded in x around 0
Applied rewrites8.5%
(FPCore (x y) :precision binary64 (+ y (/ 1.0 (* x 9.0))))
double code(double x, double y) {
return y + (1.0 / (x * 9.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y + (1.0d0 / (x * 9.0d0))
end function
public static double code(double x, double y) {
return y + (1.0 / (x * 9.0));
}
def code(x, y): return y + (1.0 / (x * 9.0))
function code(x, y) return Float64(y + Float64(1.0 / Float64(x * 9.0))) end
function tmp = code(x, y) tmp = y + (1.0 / (x * 9.0)); end
code[x_, y_] := N[(y + N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y + \frac{1}{x \cdot 9}
\end{array}
Initial program 99.4%
Taylor expanded in x around 0
Applied rewrites3.4%
Taylor expanded in x around inf
Applied rewrites5.9%
(FPCore (x y) :precision binary64 (/ 1.0 (* x 9.0)))
double code(double x, double y) {
return 1.0 / (x * 9.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 / (x * 9.0d0)
end function
public static double code(double x, double y) {
return 1.0 / (x * 9.0);
}
def code(x, y): return 1.0 / (x * 9.0)
function code(x, y) return Float64(1.0 / Float64(x * 9.0)) end
function tmp = code(x, y) tmp = 1.0 / (x * 9.0); end
code[x_, y_] := N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot 9}
\end{array}
Initial program 99.4%
Taylor expanded in x around 0
Applied rewrites3.4%
Taylor expanded in x around inf
Applied rewrites5.9%
Taylor expanded in x around inf
Applied rewrites4.1%
(FPCore (x y) :precision binary64 (* 3.0 (sqrt x)))
double code(double x, double y) {
return 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)
end function
public static double code(double x, double y) {
return 3.0 * Math.sqrt(x);
}
def code(x, y): return 3.0 * math.sqrt(x)
function code(x, y) return Float64(3.0 * sqrt(x)) end
function tmp = code(x, y) tmp = 3.0 * sqrt(x); end
code[x_, y_] := N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
3 \cdot \sqrt{x}
\end{array}
Initial program 99.4%
Taylor expanded in x around 0
Applied rewrites3.4%
(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.4%
Taylor expanded in x around 0
Applied rewrites3.4%
Taylor expanded in x around 0
Applied rewrites3.4%
(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.4%
Taylor expanded in x around 0
Applied rewrites3.4%
Taylor expanded in x around inf
Applied rewrites5.9%
Taylor expanded in x around inf
Applied rewrites4.1%
Taylor expanded in x around 0
Applied rewrites3.1%
(FPCore (x y) :precision binary64 (* 3.0 (+ (* y (sqrt x)) (* (- (/ 1.0 (* x 9.0)) 1.0) (sqrt x)))))
double code(double x, double y) {
return 3.0 * ((y * sqrt(x)) + (((1.0 / (x * 9.0)) - 1.0) * sqrt(x)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 3.0d0 * ((y * sqrt(x)) + (((1.0d0 / (x * 9.0d0)) - 1.0d0) * sqrt(x)))
end function
public static double code(double x, double y) {
return 3.0 * ((y * Math.sqrt(x)) + (((1.0 / (x * 9.0)) - 1.0) * Math.sqrt(x)));
}
def code(x, y): return 3.0 * ((y * math.sqrt(x)) + (((1.0 / (x * 9.0)) - 1.0) * math.sqrt(x)))
function code(x, y) return Float64(3.0 * Float64(Float64(y * sqrt(x)) + Float64(Float64(Float64(1.0 / Float64(x * 9.0)) - 1.0) * sqrt(x)))) end
function tmp = code(x, y) tmp = 3.0 * ((y * sqrt(x)) + (((1.0 / (x * 9.0)) - 1.0) * sqrt(x))); end
code[x_, y_] := N[(3.0 * N[(N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
3 \cdot \left(y \cdot \sqrt{x} + \left(\frac{1}{x \cdot 9} - 1\right) \cdot \sqrt{x}\right)
\end{array}
herbie shell --seed 2024321
(FPCore (x y)
:name "Numeric.SpecFunctions:incompleteGamma from math-functions-0.1.5.2, B"
:precision binary64
:pre (TRUE)
:alt
(! :herbie-platform default (* 3 (+ (* y (sqrt x)) (* (- (/ 1 (* x 9)) 1) (sqrt x)))))
(* (* 3.0 (sqrt x)) (- (+ y (/ 1.0 (* x 9.0))) 1.0)))