
(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 10 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 (* (sqrt (* x 9.0)) (+ (+ y (/ 1.0 (* x 9.0))) -1.0)))
double code(double x, double y) {
return sqrt((x * 9.0)) * ((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 = sqrt((x * 9.0d0)) * ((y + (1.0d0 / (x * 9.0d0))) + (-1.0d0))
end function
public static double code(double x, double y) {
return Math.sqrt((x * 9.0)) * ((y + (1.0 / (x * 9.0))) + -1.0);
}
def code(x, y): return math.sqrt((x * 9.0)) * ((y + (1.0 / (x * 9.0))) + -1.0)
function code(x, y) return Float64(sqrt(Float64(x * 9.0)) * Float64(Float64(y + Float64(1.0 / Float64(x * 9.0))) + -1.0)) end
function tmp = code(x, y) tmp = sqrt((x * 9.0)) * ((y + (1.0 / (x * 9.0))) + -1.0); end
code[x_, y_] := N[(N[Sqrt[N[(x * 9.0), $MachinePrecision]], $MachinePrecision] * N[(N[(y + N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x \cdot 9} \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) + -1\right)
\end{array}
Initial program 99.4%
expm1-log1p-u96.2%
expm1-udef51.4%
*-commutative51.4%
metadata-eval51.4%
sqrt-prod51.4%
Applied egg-rr51.4%
expm1-def96.3%
expm1-log1p99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y) :precision binary64 (* 3.0 (* (sqrt x) (+ (/ 0.1111111111111111 x) (- y 1.0)))))
double code(double x, double y) {
return 3.0 * (sqrt(x) * ((0.1111111111111111 / x) + (y - 1.0)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 3.0d0 * (sqrt(x) * ((0.1111111111111111d0 / x) + (y - 1.0d0)))
end function
public static double code(double x, double y) {
return 3.0 * (Math.sqrt(x) * ((0.1111111111111111 / x) + (y - 1.0)));
}
def code(x, y): return 3.0 * (math.sqrt(x) * ((0.1111111111111111 / x) + (y - 1.0)))
function code(x, y) return Float64(3.0 * Float64(sqrt(x) * Float64(Float64(0.1111111111111111 / x) + Float64(y - 1.0)))) end
function tmp = code(x, y) tmp = 3.0 * (sqrt(x) * ((0.1111111111111111 / x) + (y - 1.0))); end
code[x_, y_] := N[(3.0 * N[(N[Sqrt[x], $MachinePrecision] * N[(N[(0.1111111111111111 / x), $MachinePrecision] + N[(y - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
3 \cdot \left(\sqrt{x} \cdot \left(\frac{0.1111111111111111}{x} + \left(y - 1\right)\right)\right)
\end{array}
Initial program 99.4%
expm1-log1p-u96.2%
expm1-udef51.4%
*-commutative51.4%
metadata-eval51.4%
sqrt-prod51.4%
Applied egg-rr51.4%
expm1-def96.3%
expm1-log1p99.6%
Simplified99.6%
Taylor expanded in y around 0 99.1%
distribute-lft-out99.1%
sub-neg99.1%
associate-*r/99.5%
metadata-eval99.5%
metadata-eval99.5%
distribute-lft-in99.5%
+-commutative99.5%
associate-+l+99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x y) :precision binary64 (* (sqrt (* x 9.0)) (+ y (+ (/ 0.1111111111111111 x) -1.0))))
double code(double x, double y) {
return sqrt((x * 9.0)) * (y + ((0.1111111111111111 / x) + -1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt((x * 9.0d0)) * (y + ((0.1111111111111111d0 / x) + (-1.0d0)))
end function
public static double code(double x, double y) {
return Math.sqrt((x * 9.0)) * (y + ((0.1111111111111111 / x) + -1.0));
}
def code(x, y): return math.sqrt((x * 9.0)) * (y + ((0.1111111111111111 / x) + -1.0))
function code(x, y) return Float64(sqrt(Float64(x * 9.0)) * Float64(y + Float64(Float64(0.1111111111111111 / x) + -1.0))) end
function tmp = code(x, y) tmp = sqrt((x * 9.0)) * (y + ((0.1111111111111111 / x) + -1.0)); end
code[x_, y_] := N[(N[Sqrt[N[(x * 9.0), $MachinePrecision]], $MachinePrecision] * N[(y + N[(N[(0.1111111111111111 / x), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x \cdot 9} \cdot \left(y + \left(\frac{0.1111111111111111}{x} + -1\right)\right)
\end{array}
Initial program 99.4%
*-commutative99.4%
associate-*l*99.0%
+-commutative99.0%
associate--l+99.0%
*-commutative99.0%
associate-/r*99.1%
metadata-eval99.1%
sub-neg99.1%
metadata-eval99.1%
Simplified99.1%
associate-*r*99.4%
*-commutative99.4%
+-commutative99.4%
associate-+r+99.4%
+-commutative99.4%
distribute-lft-in99.4%
metadata-eval99.4%
sub-neg99.4%
clear-num99.4%
div-inv99.4%
metadata-eval99.4%
*-commutative99.4%
metadata-eval99.4%
sqrt-prod99.5%
*-commutative99.5%
metadata-eval99.5%
sqrt-prod99.6%
Applied egg-rr99.5%
+-commutative99.5%
distribute-lft-out99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y) :precision binary64 (* (sqrt x) (- (* y 3.0) 3.0)))
double code(double x, double y) {
return sqrt(x) * ((y * 3.0) - 3.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt(x) * ((y * 3.0d0) - 3.0d0)
end function
public static double code(double x, double y) {
return Math.sqrt(x) * ((y * 3.0) - 3.0);
}
def code(x, y): return math.sqrt(x) * ((y * 3.0) - 3.0)
function code(x, y) return Float64(sqrt(x) * Float64(Float64(y * 3.0) - 3.0)) end
function tmp = code(x, y) tmp = sqrt(x) * ((y * 3.0) - 3.0); end
code[x_, y_] := N[(N[Sqrt[x], $MachinePrecision] * N[(N[(y * 3.0), $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x} \cdot \left(y \cdot 3 - 3\right)
\end{array}
Initial program 99.4%
*-commutative99.4%
associate-*l*99.0%
associate--l+99.0%
distribute-lft-in99.0%
fma-def99.1%
sub-neg99.1%
+-commutative99.1%
distribute-lft-in99.1%
metadata-eval99.1%
metadata-eval99.1%
*-commutative99.1%
associate-/r*99.1%
associate-*r/99.1%
metadata-eval99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in x around inf 63.9%
Final simplification63.9%
(FPCore (x y) :precision binary64 (* (sqrt (* x 9.0)) (- y 1.0)))
double code(double x, double y) {
return sqrt((x * 9.0)) * (y - 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt((x * 9.0d0)) * (y - 1.0d0)
end function
public static double code(double x, double y) {
return Math.sqrt((x * 9.0)) * (y - 1.0);
}
def code(x, y): return math.sqrt((x * 9.0)) * (y - 1.0)
function code(x, y) return Float64(sqrt(Float64(x * 9.0)) * Float64(y - 1.0)) end
function tmp = code(x, y) tmp = sqrt((x * 9.0)) * (y - 1.0); end
code[x_, y_] := N[(N[Sqrt[N[(x * 9.0), $MachinePrecision]], $MachinePrecision] * N[(y - 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x \cdot 9} \cdot \left(y - 1\right)
\end{array}
Initial program 99.4%
expm1-log1p-u96.2%
expm1-udef51.4%
*-commutative51.4%
metadata-eval51.4%
sqrt-prod51.4%
Applied egg-rr51.4%
expm1-def96.3%
expm1-log1p99.6%
Simplified99.6%
Taylor expanded in y around inf 64.4%
Final simplification64.4%
(FPCore (x y) :precision binary64 (* 3.0 (* y (sqrt x))))
double code(double x, double y) {
return 3.0 * (y * sqrt(x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 3.0d0 * (y * sqrt(x))
end function
public static double code(double x, double y) {
return 3.0 * (y * Math.sqrt(x));
}
def code(x, y): return 3.0 * (y * math.sqrt(x))
function code(x, y) return Float64(3.0 * Float64(y * sqrt(x))) end
function tmp = code(x, y) tmp = 3.0 * (y * sqrt(x)); end
code[x_, y_] := N[(3.0 * N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
3 \cdot \left(y \cdot \sqrt{x}\right)
\end{array}
Initial program 99.4%
*-commutative99.4%
associate-*l*99.0%
+-commutative99.0%
associate--l+99.0%
*-commutative99.0%
associate-/r*99.1%
metadata-eval99.1%
sub-neg99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in y around inf 38.6%
Final simplification38.6%
(FPCore (x y) :precision binary64 (* y (* 3.0 (sqrt x))))
double code(double x, double y) {
return y * (3.0 * sqrt(x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y * (3.0d0 * sqrt(x))
end function
public static double code(double x, double y) {
return y * (3.0 * Math.sqrt(x));
}
def code(x, y): return y * (3.0 * math.sqrt(x))
function code(x, y) return Float64(y * Float64(3.0 * sqrt(x))) end
function tmp = code(x, y) tmp = y * (3.0 * sqrt(x)); end
code[x_, y_] := N[(y * N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(3 \cdot \sqrt{x}\right)
\end{array}
Initial program 99.4%
expm1-log1p-u96.2%
expm1-udef51.4%
*-commutative51.4%
metadata-eval51.4%
sqrt-prod51.4%
Applied egg-rr51.4%
expm1-def96.3%
expm1-log1p99.6%
Simplified99.6%
Taylor expanded in y around 0 99.1%
distribute-lft-out99.1%
sub-neg99.1%
associate-*r/99.5%
metadata-eval99.5%
metadata-eval99.5%
distribute-lft-in99.5%
+-commutative99.5%
associate-+l+99.5%
Simplified99.5%
Taylor expanded in y around inf 38.6%
associate-*r*38.5%
*-commutative38.5%
Simplified38.5%
Final simplification38.5%
(FPCore (x y) :precision binary64 (- (sqrt (* x 9.0))))
double code(double x, double y) {
return -sqrt((x * 9.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -sqrt((x * 9.0d0))
end function
public static double code(double x, double y) {
return -Math.sqrt((x * 9.0));
}
def code(x, y): return -math.sqrt((x * 9.0))
function code(x, y) return Float64(-sqrt(Float64(x * 9.0))) end
function tmp = code(x, y) tmp = -sqrt((x * 9.0)); end
code[x_, y_] := (-N[Sqrt[N[(x * 9.0), $MachinePrecision]], $MachinePrecision])
\begin{array}{l}
\\
-\sqrt{x \cdot 9}
\end{array}
Initial program 99.4%
*-commutative99.4%
associate-*l*99.0%
associate--l+99.0%
distribute-lft-in99.0%
fma-def99.1%
sub-neg99.1%
+-commutative99.1%
distribute-lft-in99.1%
metadata-eval99.1%
metadata-eval99.1%
*-commutative99.1%
associate-/r*99.1%
associate-*r/99.1%
metadata-eval99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in x around inf 63.9%
Taylor expanded in y around 0 27.8%
*-commutative27.8%
Simplified27.8%
*-commutative27.8%
metadata-eval27.8%
associate-*r*27.8%
mul-1-neg27.8%
*-commutative27.8%
metadata-eval27.8%
sqrt-prod27.8%
Applied egg-rr27.8%
Final simplification27.8%
(FPCore (x y) :precision binary64 (sqrt (* x 9.0)))
double code(double x, double y) {
return sqrt((x * 9.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt((x * 9.0d0))
end function
public static double code(double x, double y) {
return Math.sqrt((x * 9.0));
}
def code(x, y): return math.sqrt((x * 9.0))
function code(x, y) return sqrt(Float64(x * 9.0)) end
function tmp = code(x, y) tmp = sqrt((x * 9.0)); end
code[x_, y_] := N[Sqrt[N[(x * 9.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x \cdot 9}
\end{array}
Initial program 99.4%
*-commutative99.4%
associate-*l*99.0%
associate--l+99.0%
distribute-lft-in99.0%
fma-def99.1%
sub-neg99.1%
+-commutative99.1%
distribute-lft-in99.1%
metadata-eval99.1%
metadata-eval99.1%
*-commutative99.1%
associate-/r*99.1%
associate-*r/99.1%
metadata-eval99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in x around inf 63.9%
Taylor expanded in y around 0 27.8%
*-commutative27.8%
Simplified27.8%
expm1-log1p-u1.0%
expm1-udef1.2%
add-sqr-sqrt0.0%
sqrt-unprod2.5%
swap-sqr2.5%
add-sqr-sqrt2.5%
metadata-eval2.5%
Applied egg-rr2.5%
expm1-def3.2%
expm1-log1p3.2%
Simplified3.2%
Final simplification3.2%
(FPCore (x y) :precision binary64 (* (sqrt x) -3.0))
double code(double x, double y) {
return sqrt(x) * -3.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt(x) * (-3.0d0)
end function
public static double code(double x, double y) {
return Math.sqrt(x) * -3.0;
}
def code(x, y): return math.sqrt(x) * -3.0
function code(x, y) return Float64(sqrt(x) * -3.0) end
function tmp = code(x, y) tmp = sqrt(x) * -3.0; end
code[x_, y_] := N[(N[Sqrt[x], $MachinePrecision] * -3.0), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x} \cdot -3
\end{array}
Initial program 99.4%
*-commutative99.4%
associate-*l*99.0%
associate--l+99.0%
distribute-lft-in99.0%
fma-def99.1%
sub-neg99.1%
+-commutative99.1%
distribute-lft-in99.1%
metadata-eval99.1%
metadata-eval99.1%
*-commutative99.1%
associate-/r*99.1%
associate-*r/99.1%
metadata-eval99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in x around inf 63.9%
Taylor expanded in y around 0 27.8%
*-commutative27.8%
Simplified27.8%
Final simplification27.8%
(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 2024033
(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)))