
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
public static double code(double x) {
return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
def code(x): return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
function code(x) return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) end
function tmp = code(x) tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))); end
code[x_] := N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
public static double code(double x) {
return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
def code(x): return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
function code(x) return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) end
function tmp = code(x) tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))); end
code[x_] := N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 2e-23)
(/
(+
(fma (pow x -2.5) -0.25 (* (pow x -0.5) 0.5))
(- (* (pow x -2.5) 0.5) (* (pow x -0.5) (/ 0.375 x))))
x)
(/ (/ (- (+ 1.0 x) x) (+ (sqrt x) t_0)) (sqrt (* x (+ 1.0 x)))))))
double code(double x) {
double t_0 = sqrt((1.0 + x));
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 2e-23) {
tmp = (fma(pow(x, -2.5), -0.25, (pow(x, -0.5) * 0.5)) + ((pow(x, -2.5) * 0.5) - (pow(x, -0.5) * (0.375 / x)))) / x;
} else {
tmp = (((1.0 + x) - x) / (sqrt(x) + t_0)) / sqrt((x * (1.0 + x)));
}
return tmp;
}
function code(x) t_0 = sqrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / t_0)) <= 2e-23) tmp = Float64(Float64(fma((x ^ -2.5), -0.25, Float64((x ^ -0.5) * 0.5)) + Float64(Float64((x ^ -2.5) * 0.5) - Float64((x ^ -0.5) * Float64(0.375 / x)))) / x); else tmp = Float64(Float64(Float64(Float64(1.0 + x) - x) / Float64(sqrt(x) + t_0)) / sqrt(Float64(x * Float64(1.0 + x)))); end return tmp end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 2e-23], N[(N[(N[(N[Power[x, -2.5], $MachinePrecision] * -0.25 + N[(N[Power[x, -0.5], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[x, -2.5], $MachinePrecision] * 0.5), $MachinePrecision] - N[(N[Power[x, -0.5], $MachinePrecision] * N[(0.375 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(N[(1.0 + x), $MachinePrecision] - x), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t\_0} \leq 2 \cdot 10^{-23}:\\
\;\;\;\;\frac{\mathsf{fma}\left({x}^{-2.5}, -0.25, {x}^{-0.5} \cdot 0.5\right) + \left({x}^{-2.5} \cdot 0.5 - {x}^{-0.5} \cdot \frac{0.375}{x}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(1 + x\right) - x}{\sqrt{x} + t\_0}}{\sqrt{x \cdot \left(1 + x\right)}}\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) < 1.99999999999999992e-23Initial program 36.7%
Taylor expanded in x around inf 79.8%
Taylor expanded in x around inf 99.6%
Simplified99.6%
associate-+l-99.6%
sqrt-pow199.6%
metadata-eval99.6%
pow1/299.6%
inv-pow99.6%
pow-pow99.7%
metadata-eval99.7%
associate-/l*99.7%
pow1/299.7%
inv-pow99.7%
pow-pow99.7%
metadata-eval99.7%
sqrt-pow199.7%
metadata-eval99.7%
Applied egg-rr99.7%
if 1.99999999999999992e-23 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) Initial program 60.7%
frac-sub61.6%
*-rgt-identity61.6%
*-un-lft-identity61.6%
+-commutative61.6%
sqrt-unprod61.6%
+-commutative61.6%
Applied egg-rr61.6%
flip--82.8%
add-sqr-sqrt85.2%
+-commutative85.2%
add-sqr-sqrt99.3%
+-commutative99.3%
Applied egg-rr99.3%
Final simplification99.6%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (/ 1.0 x))) (t_1 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_1)) 2e-23)
(/ (- (* 0.5 t_0) (/ (* 0.375 t_0) x)) x)
(/ (/ (- (+ 1.0 x) x) (+ (sqrt x) t_1)) (sqrt (* x (+ 1.0 x)))))))
double code(double x) {
double t_0 = sqrt((1.0 / x));
double t_1 = sqrt((1.0 + x));
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / t_1)) <= 2e-23) {
tmp = ((0.5 * t_0) - ((0.375 * t_0) / x)) / x;
} else {
tmp = (((1.0 + x) - x) / (sqrt(x) + t_1)) / sqrt((x * (1.0 + x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((1.0d0 / x))
t_1 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_1)) <= 2d-23) then
tmp = ((0.5d0 * t_0) - ((0.375d0 * t_0) / x)) / x
else
tmp = (((1.0d0 + x) - x) / (sqrt(x) + t_1)) / sqrt((x * (1.0d0 + x)))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((1.0 / x));
double t_1 = Math.sqrt((1.0 + x));
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / t_1)) <= 2e-23) {
tmp = ((0.5 * t_0) - ((0.375 * t_0) / x)) / x;
} else {
tmp = (((1.0 + x) - x) / (Math.sqrt(x) + t_1)) / Math.sqrt((x * (1.0 + x)));
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 / x)) t_1 = math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_1)) <= 2e-23: tmp = ((0.5 * t_0) - ((0.375 * t_0) / x)) / x else: tmp = (((1.0 + x) - x) / (math.sqrt(x) + t_1)) / math.sqrt((x * (1.0 + x))) return tmp
function code(x) t_0 = sqrt(Float64(1.0 / x)) t_1 = sqrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / t_1)) <= 2e-23) tmp = Float64(Float64(Float64(0.5 * t_0) - Float64(Float64(0.375 * t_0) / x)) / x); else tmp = Float64(Float64(Float64(Float64(1.0 + x) - x) / Float64(sqrt(x) + t_1)) / sqrt(Float64(x * Float64(1.0 + x)))); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((1.0 / x)); t_1 = sqrt((1.0 + x)); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / t_1)) <= 2e-23) tmp = ((0.5 * t_0) - ((0.375 * t_0) / x)) / x; else tmp = (((1.0 + x) - x) / (sqrt(x) + t_1)) / sqrt((x * (1.0 + x))); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], 2e-23], N[(N[(N[(0.5 * t$95$0), $MachinePrecision] - N[(N[(0.375 * t$95$0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(N[(1.0 + x), $MachinePrecision] - x), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{x}}\\
t_1 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t\_1} \leq 2 \cdot 10^{-23}:\\
\;\;\;\;\frac{0.5 \cdot t\_0 - \frac{0.375 \cdot t\_0}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(1 + x\right) - x}{\sqrt{x} + t\_1}}{\sqrt{x \cdot \left(1 + x\right)}}\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) < 1.99999999999999992e-23Initial program 36.7%
Taylor expanded in x around inf 79.8%
Taylor expanded in x around inf 99.6%
+-commutative99.6%
mul-1-neg99.6%
unsub-neg99.6%
*-commutative99.6%
distribute-rgt-out99.6%
metadata-eval99.6%
Simplified99.6%
if 1.99999999999999992e-23 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) Initial program 60.7%
frac-sub61.6%
*-rgt-identity61.6%
*-un-lft-identity61.6%
+-commutative61.6%
sqrt-unprod61.6%
+-commutative61.6%
Applied egg-rr61.6%
flip--82.8%
add-sqr-sqrt85.2%
+-commutative85.2%
add-sqr-sqrt99.3%
+-commutative99.3%
Applied egg-rr99.3%
Final simplification99.6%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 2e-13) (/ (* 0.5 (sqrt (/ 1.0 x))) x) (- (pow x -0.5) (pow (+ 1.0 x) -0.5))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 2e-13) {
tmp = (0.5 * sqrt((1.0 / x))) / x;
} else {
tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((1.0d0 + x)))) <= 2d-13) then
tmp = (0.5d0 * sqrt((1.0d0 / x))) / x
else
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / Math.sqrt((1.0 + x)))) <= 2e-13) {
tmp = (0.5 * Math.sqrt((1.0 / x))) / x;
} else {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 2e-13: tmp = (0.5 * math.sqrt((1.0 / x))) / x else: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 2e-13) tmp = Float64(Float64(0.5 * sqrt(Float64(1.0 / x))) / x); else tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 2e-13) tmp = (0.5 * sqrt((1.0 / x))) / x; else tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e-13], N[(N[(0.5 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 2 \cdot 10^{-13}:\\
\;\;\;\;\frac{0.5 \cdot \sqrt{\frac{1}{x}}}{x}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) < 2.0000000000000001e-13Initial program 36.7%
Taylor expanded in x around inf 80.6%
Taylor expanded in x around inf 99.6%
Simplified99.6%
Taylor expanded in x around inf 98.9%
if 2.0000000000000001e-13 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) Initial program 81.4%
sub-neg81.4%
inv-pow81.4%
sqrt-pow281.0%
metadata-eval81.0%
distribute-neg-frac81.0%
metadata-eval81.0%
+-commutative81.0%
Applied egg-rr81.0%
*-rgt-identity81.0%
cancel-sign-sub81.0%
distribute-lft-neg-in81.0%
*-rgt-identity81.0%
distribute-neg-frac81.0%
metadata-eval81.0%
unpow1/281.0%
exp-to-pow77.9%
log1p-undefine77.9%
*-commutative77.9%
exp-neg79.1%
*-commutative79.1%
distribute-rgt-neg-in79.1%
log1p-undefine79.1%
metadata-eval79.1%
exp-to-pow82.0%
Simplified82.0%
Final simplification98.1%
(FPCore (x) :precision binary64 (let* ((t_0 (sqrt (/ 1.0 x)))) (/ (- (* 0.5 t_0) (/ (* 0.375 t_0) x)) x)))
double code(double x) {
double t_0 = sqrt((1.0 / x));
return ((0.5 * t_0) - ((0.375 * t_0) / x)) / x;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sqrt((1.0d0 / x))
code = ((0.5d0 * t_0) - ((0.375d0 * t_0) / x)) / x
end function
public static double code(double x) {
double t_0 = Math.sqrt((1.0 / x));
return ((0.5 * t_0) - ((0.375 * t_0) / x)) / x;
}
def code(x): t_0 = math.sqrt((1.0 / x)) return ((0.5 * t_0) - ((0.375 * t_0) / x)) / x
function code(x) t_0 = sqrt(Float64(1.0 / x)) return Float64(Float64(Float64(0.5 * t_0) - Float64(Float64(0.375 * t_0) / x)) / x) end
function tmp = code(x) t_0 = sqrt((1.0 / x)); tmp = ((0.5 * t_0) - ((0.375 * t_0) / x)) / x; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(0.5 * t$95$0), $MachinePrecision] - N[(N[(0.375 * t$95$0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{x}}\\
\frac{0.5 \cdot t\_0 - \frac{0.375 \cdot t\_0}{x}}{x}
\end{array}
\end{array}
Initial program 38.6%
Taylor expanded in x around inf 79.8%
Taylor expanded in x around inf 97.8%
+-commutative97.8%
mul-1-neg97.8%
unsub-neg97.8%
*-commutative97.8%
distribute-rgt-out97.8%
metadata-eval97.8%
Simplified97.8%
Final simplification97.8%
(FPCore (x) :precision binary64 (if (<= x 8.5e+122) (pow x -0.5) 0.0))
double code(double x) {
double tmp;
if (x <= 8.5e+122) {
tmp = pow(x, -0.5);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 8.5d+122) then
tmp = x ** (-0.5d0)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 8.5e+122) {
tmp = Math.pow(x, -0.5);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 8.5e+122: tmp = math.pow(x, -0.5) else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= 8.5e+122) tmp = x ^ -0.5; else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 8.5e+122) tmp = x ^ -0.5; else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 8.5e+122], N[Power[x, -0.5], $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.5 \cdot 10^{+122}:\\
\;\;\;\;{x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 8.50000000000000003e122Initial program 15.8%
Taylor expanded in x around 0 7.9%
pow1/27.9%
inv-pow7.9%
pow-pow7.9%
metadata-eval7.9%
*-un-lft-identity7.9%
Applied egg-rr7.9%
*-lft-identity7.9%
Simplified7.9%
if 8.50000000000000003e122 < x Initial program 54.0%
Applied egg-rr4.5%
fma-undefine4.5%
+-commutative4.5%
fma-undefine19.0%
distribute-lft-neg-out19.0%
*-commutative19.0%
distribute-lft-neg-out19.0%
fma-undefine4.5%
associate-*r/4.5%
*-rgt-identity4.5%
Simplified4.5%
Taylor expanded in x around inf 54.0%
distribute-rgt1-in54.0%
metadata-eval54.0%
mul0-lft54.0%
Simplified54.0%
(FPCore (x) :precision binary64 (/ (* 0.5 (sqrt (/ 1.0 x))) x))
double code(double x) {
return (0.5 * sqrt((1.0 / x))) / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (0.5d0 * sqrt((1.0d0 / x))) / x
end function
public static double code(double x) {
return (0.5 * Math.sqrt((1.0 / x))) / x;
}
def code(x): return (0.5 * math.sqrt((1.0 / x))) / x
function code(x) return Float64(Float64(0.5 * sqrt(Float64(1.0 / x))) / x) end
function tmp = code(x) tmp = (0.5 * sqrt((1.0 / x))) / x; end
code[x_] := N[(N[(0.5 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5 \cdot \sqrt{\frac{1}{x}}}{x}
\end{array}
Initial program 38.6%
Taylor expanded in x around inf 79.8%
Taylor expanded in x around inf 98.0%
Simplified98.0%
Taylor expanded in x around inf 96.3%
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 38.6%
Applied egg-rr9.8%
fma-undefine9.8%
+-commutative9.8%
fma-undefine18.3%
distribute-lft-neg-out18.3%
*-commutative18.3%
distribute-lft-neg-out18.3%
fma-undefine9.8%
associate-*r/9.8%
*-rgt-identity9.8%
Simplified9.8%
Taylor expanded in x around inf 33.8%
distribute-rgt1-in33.8%
metadata-eval33.8%
mul0-lft33.8%
Simplified33.8%
(FPCore (x) :precision binary64 (/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0))))))
double code(double x) {
return 1.0 / (((x + 1.0) * sqrt(x)) + (x * sqrt((x + 1.0))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (((x + 1.0d0) * sqrt(x)) + (x * sqrt((x + 1.0d0))))
end function
public static double code(double x) {
return 1.0 / (((x + 1.0) * Math.sqrt(x)) + (x * Math.sqrt((x + 1.0))));
}
def code(x): return 1.0 / (((x + 1.0) * math.sqrt(x)) + (x * math.sqrt((x + 1.0))))
function code(x) return Float64(1.0 / Float64(Float64(Float64(x + 1.0) * sqrt(x)) + Float64(x * sqrt(Float64(x + 1.0))))) end
function tmp = code(x) tmp = 1.0 / (((x + 1.0) * sqrt(x)) + (x * sqrt((x + 1.0)))); end
code[x_] := N[(1.0 / N[(N[(N[(x + 1.0), $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(x * N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}
\end{array}
herbie shell --seed 2024136
(FPCore (x)
:name "2isqrt (example 3.6)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:alt
(! :herbie-platform default (/ 1 (+ (* (+ x 1) (sqrt x)) (* x (sqrt (+ x 1))))))
(- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))