
(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 12 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 (* (+ (/ 0.0625 (pow x 3.0)) (- (/ 0.5 x) (+ (/ 0.125 (pow x 2.0)) (/ 0.0390625 (pow x 4.0))))) (pow (+ x 1.0) -0.5)))
double code(double x) {
return ((0.0625 / pow(x, 3.0)) + ((0.5 / x) - ((0.125 / pow(x, 2.0)) + (0.0390625 / pow(x, 4.0))))) * pow((x + 1.0), -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((0.0625d0 / (x ** 3.0d0)) + ((0.5d0 / x) - ((0.125d0 / (x ** 2.0d0)) + (0.0390625d0 / (x ** 4.0d0))))) * ((x + 1.0d0) ** (-0.5d0))
end function
public static double code(double x) {
return ((0.0625 / Math.pow(x, 3.0)) + ((0.5 / x) - ((0.125 / Math.pow(x, 2.0)) + (0.0390625 / Math.pow(x, 4.0))))) * Math.pow((x + 1.0), -0.5);
}
def code(x): return ((0.0625 / math.pow(x, 3.0)) + ((0.5 / x) - ((0.125 / math.pow(x, 2.0)) + (0.0390625 / math.pow(x, 4.0))))) * math.pow((x + 1.0), -0.5)
function code(x) return Float64(Float64(Float64(0.0625 / (x ^ 3.0)) + Float64(Float64(0.5 / x) - Float64(Float64(0.125 / (x ^ 2.0)) + Float64(0.0390625 / (x ^ 4.0))))) * (Float64(x + 1.0) ^ -0.5)) end
function tmp = code(x) tmp = ((0.0625 / (x ^ 3.0)) + ((0.5 / x) - ((0.125 / (x ^ 2.0)) + (0.0390625 / (x ^ 4.0))))) * ((x + 1.0) ^ -0.5); end
code[x_] := N[(N[(N[(0.0625 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.5 / x), $MachinePrecision] - N[(N[(0.125 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(0.0390625 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{0.0625}{{x}^{3}} + \left(\frac{0.5}{x} - \left(\frac{0.125}{{x}^{2}} + \frac{0.0390625}{{x}^{4}}\right)\right)\right) \cdot {\left(x + 1\right)}^{-0.5}
\end{array}
Initial program 40.9%
frac-sub40.9%
div-inv40.9%
*-un-lft-identity40.9%
+-commutative40.9%
*-rgt-identity40.9%
metadata-eval40.9%
frac-times40.9%
associate-*l/41.0%
inv-pow41.0%
*-un-lft-identity41.0%
sqrt-pow240.9%
+-commutative40.9%
metadata-eval40.9%
Applied egg-rr40.9%
associate-*r/40.9%
*-rgt-identity40.9%
times-frac40.9%
div-sub40.9%
sub-neg40.9%
*-inverses40.9%
metadata-eval40.9%
Simplified40.9%
Taylor expanded in x around inf 98.9%
associate--l+98.9%
associate-*r/98.9%
metadata-eval98.9%
associate-*r/98.9%
metadata-eval98.9%
+-commutative98.9%
associate-*r/98.9%
metadata-eval98.9%
associate-*r/98.9%
metadata-eval98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (x) :precision binary64 (* (pow (+ x 1.0) -0.5) (- (+ (/ 0.0625 (pow x 3.0)) (/ 0.5 x)) (/ 0.125 (pow x 2.0)))))
double code(double x) {
return pow((x + 1.0), -0.5) * (((0.0625 / pow(x, 3.0)) + (0.5 / x)) - (0.125 / pow(x, 2.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x + 1.0d0) ** (-0.5d0)) * (((0.0625d0 / (x ** 3.0d0)) + (0.5d0 / x)) - (0.125d0 / (x ** 2.0d0)))
end function
public static double code(double x) {
return Math.pow((x + 1.0), -0.5) * (((0.0625 / Math.pow(x, 3.0)) + (0.5 / x)) - (0.125 / Math.pow(x, 2.0)));
}
def code(x): return math.pow((x + 1.0), -0.5) * (((0.0625 / math.pow(x, 3.0)) + (0.5 / x)) - (0.125 / math.pow(x, 2.0)))
function code(x) return Float64((Float64(x + 1.0) ^ -0.5) * Float64(Float64(Float64(0.0625 / (x ^ 3.0)) + Float64(0.5 / x)) - Float64(0.125 / (x ^ 2.0)))) end
function tmp = code(x) tmp = ((x + 1.0) ^ -0.5) * (((0.0625 / (x ^ 3.0)) + (0.5 / x)) - (0.125 / (x ^ 2.0))); end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision] * N[(N[(N[(0.0625 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(0.5 / x), $MachinePrecision]), $MachinePrecision] - N[(0.125 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{-0.5} \cdot \left(\left(\frac{0.0625}{{x}^{3}} + \frac{0.5}{x}\right) - \frac{0.125}{{x}^{2}}\right)
\end{array}
Initial program 40.9%
frac-sub40.9%
div-inv40.9%
*-un-lft-identity40.9%
+-commutative40.9%
*-rgt-identity40.9%
metadata-eval40.9%
frac-times40.9%
associate-*l/41.0%
inv-pow41.0%
*-un-lft-identity41.0%
sqrt-pow240.9%
+-commutative40.9%
metadata-eval40.9%
Applied egg-rr40.9%
associate-*r/40.9%
*-rgt-identity40.9%
times-frac40.9%
div-sub40.9%
sub-neg40.9%
*-inverses40.9%
metadata-eval40.9%
Simplified40.9%
Taylor expanded in x around inf 98.7%
+-commutative98.7%
associate-*r/98.7%
metadata-eval98.7%
associate-*r/98.7%
metadata-eval98.7%
associate-*r/98.7%
metadata-eval98.7%
Simplified98.7%
Final simplification98.7%
(FPCore (x) :precision binary64 (/ (/ (+ (* 0.125 (pow x -2.0)) (/ -0.5 x)) (sqrt (+ x 1.0))) -1.0))
double code(double x) {
return (((0.125 * pow(x, -2.0)) + (-0.5 / x)) / sqrt((x + 1.0))) / -1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (((0.125d0 * (x ** (-2.0d0))) + ((-0.5d0) / x)) / sqrt((x + 1.0d0))) / (-1.0d0)
end function
public static double code(double x) {
return (((0.125 * Math.pow(x, -2.0)) + (-0.5 / x)) / Math.sqrt((x + 1.0))) / -1.0;
}
def code(x): return (((0.125 * math.pow(x, -2.0)) + (-0.5 / x)) / math.sqrt((x + 1.0))) / -1.0
function code(x) return Float64(Float64(Float64(Float64(0.125 * (x ^ -2.0)) + Float64(-0.5 / x)) / sqrt(Float64(x + 1.0))) / -1.0) end
function tmp = code(x) tmp = (((0.125 * (x ^ -2.0)) + (-0.5 / x)) / sqrt((x + 1.0))) / -1.0; end
code[x_] := N[(N[(N[(N[(0.125 * N[Power[x, -2.0], $MachinePrecision]), $MachinePrecision] + N[(-0.5 / x), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / -1.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{0.125 \cdot {x}^{-2} + \frac{-0.5}{x}}{\sqrt{x + 1}}}{-1}
\end{array}
Initial program 40.9%
frac-sub40.9%
div-inv40.9%
*-un-lft-identity40.9%
+-commutative40.9%
*-rgt-identity40.9%
metadata-eval40.9%
frac-times40.9%
associate-*l/41.0%
inv-pow41.0%
*-un-lft-identity41.0%
sqrt-pow240.9%
+-commutative40.9%
metadata-eval40.9%
Applied egg-rr40.9%
associate-*r/40.9%
*-rgt-identity40.9%
times-frac40.9%
div-sub40.9%
sub-neg40.9%
*-inverses40.9%
metadata-eval40.9%
Simplified40.9%
Taylor expanded in x around inf 98.3%
associate-*r/98.3%
metadata-eval98.3%
associate-*r/98.3%
metadata-eval98.3%
Simplified98.3%
/-rgt-identity98.3%
frac-2neg98.3%
Applied egg-rr98.3%
distribute-neg-frac98.3%
+-commutative98.3%
distribute-neg-in98.3%
distribute-lft-neg-in98.3%
metadata-eval98.3%
distribute-neg-frac98.3%
metadata-eval98.3%
hypot-undefine98.2%
metadata-eval98.2%
rem-square-sqrt98.2%
+-commutative98.2%
Simplified98.2%
Final simplification98.2%
(FPCore (x) :precision binary64 (* (pow (+ x 1.0) -0.5) (- (/ 0.5 x) (/ 0.125 (pow x 2.0)))))
double code(double x) {
return pow((x + 1.0), -0.5) * ((0.5 / x) - (0.125 / pow(x, 2.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x + 1.0d0) ** (-0.5d0)) * ((0.5d0 / x) - (0.125d0 / (x ** 2.0d0)))
end function
public static double code(double x) {
return Math.pow((x + 1.0), -0.5) * ((0.5 / x) - (0.125 / Math.pow(x, 2.0)));
}
def code(x): return math.pow((x + 1.0), -0.5) * ((0.5 / x) - (0.125 / math.pow(x, 2.0)))
function code(x) return Float64((Float64(x + 1.0) ^ -0.5) * Float64(Float64(0.5 / x) - Float64(0.125 / (x ^ 2.0)))) end
function tmp = code(x) tmp = ((x + 1.0) ^ -0.5) * ((0.5 / x) - (0.125 / (x ^ 2.0))); end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision] * N[(N[(0.5 / x), $MachinePrecision] - N[(0.125 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{-0.5} \cdot \left(\frac{0.5}{x} - \frac{0.125}{{x}^{2}}\right)
\end{array}
Initial program 40.9%
frac-sub40.9%
div-inv40.9%
*-un-lft-identity40.9%
+-commutative40.9%
*-rgt-identity40.9%
metadata-eval40.9%
frac-times40.9%
associate-*l/41.0%
inv-pow41.0%
*-un-lft-identity41.0%
sqrt-pow240.9%
+-commutative40.9%
metadata-eval40.9%
Applied egg-rr40.9%
associate-*r/40.9%
*-rgt-identity40.9%
times-frac40.9%
div-sub40.9%
sub-neg40.9%
*-inverses40.9%
metadata-eval40.9%
Simplified40.9%
Taylor expanded in x around inf 98.3%
associate-*r/98.3%
metadata-eval98.3%
associate-*r/98.3%
metadata-eval98.3%
Simplified98.3%
Final simplification98.3%
(FPCore (x) :precision binary64 (if (<= x 6.5e+153) (/ 0.5 x) (/ -0.0390625 (pow x 4.0))))
double code(double x) {
double tmp;
if (x <= 6.5e+153) {
tmp = 0.5 / x;
} else {
tmp = -0.0390625 / pow(x, 4.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 6.5d+153) then
tmp = 0.5d0 / x
else
tmp = (-0.0390625d0) / (x ** 4.0d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 6.5e+153) {
tmp = 0.5 / x;
} else {
tmp = -0.0390625 / Math.pow(x, 4.0);
}
return tmp;
}
def code(x): tmp = 0 if x <= 6.5e+153: tmp = 0.5 / x else: tmp = -0.0390625 / math.pow(x, 4.0) return tmp
function code(x) tmp = 0.0 if (x <= 6.5e+153) tmp = Float64(0.5 / x); else tmp = Float64(-0.0390625 / (x ^ 4.0)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 6.5e+153) tmp = 0.5 / x; else tmp = -0.0390625 / (x ^ 4.0); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 6.5e+153], N[(0.5 / x), $MachinePrecision], N[(-0.0390625 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.5 \cdot 10^{+153}:\\
\;\;\;\;\frac{0.5}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.0390625}{{x}^{4}}\\
\end{array}
\end{array}
if x < 6.49999999999999972e153Initial program 11.8%
frac-sub11.8%
div-inv11.8%
*-un-lft-identity11.8%
+-commutative11.8%
*-rgt-identity11.8%
metadata-eval11.8%
frac-times11.8%
associate-*l/11.8%
inv-pow11.8%
*-un-lft-identity11.8%
sqrt-pow211.8%
+-commutative11.8%
metadata-eval11.8%
Applied egg-rr11.8%
associate-*r/11.8%
*-rgt-identity11.8%
times-frac11.8%
div-sub11.8%
sub-neg11.8%
*-inverses11.8%
metadata-eval11.8%
Simplified11.8%
Taylor expanded in x around inf 94.5%
Taylor expanded in x around 0 8.7%
if 6.49999999999999972e153 < x Initial program 71.0%
frac-sub71.0%
div-inv71.0%
*-un-lft-identity71.0%
+-commutative71.0%
*-rgt-identity71.0%
metadata-eval71.0%
frac-times71.0%
associate-*l/71.0%
inv-pow71.0%
*-un-lft-identity71.0%
sqrt-pow271.0%
+-commutative71.0%
metadata-eval71.0%
Applied egg-rr71.0%
associate-*r/71.0%
*-rgt-identity71.0%
times-frac71.0%
div-sub71.0%
sub-neg71.0%
*-inverses71.0%
metadata-eval71.0%
Simplified71.0%
Taylor expanded in x around inf 99.9%
associate--l+99.9%
associate-*r/99.9%
metadata-eval99.9%
associate-*r/99.9%
metadata-eval99.9%
+-commutative99.9%
associate-*r/99.9%
metadata-eval99.9%
associate-*r/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 71.0%
Final simplification39.3%
(FPCore (x) :precision binary64 (* (/ 0.5 x) (pow (+ x 1.0) -0.5)))
double code(double x) {
return (0.5 / x) * pow((x + 1.0), -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (0.5d0 / x) * ((x + 1.0d0) ** (-0.5d0))
end function
public static double code(double x) {
return (0.5 / x) * Math.pow((x + 1.0), -0.5);
}
def code(x): return (0.5 / x) * math.pow((x + 1.0), -0.5)
function code(x) return Float64(Float64(0.5 / x) * (Float64(x + 1.0) ^ -0.5)) end
function tmp = code(x) tmp = (0.5 / x) * ((x + 1.0) ^ -0.5); end
code[x_] := N[(N[(0.5 / x), $MachinePrecision] * N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5}{x} \cdot {\left(x + 1\right)}^{-0.5}
\end{array}
Initial program 40.9%
frac-sub40.9%
div-inv40.9%
*-un-lft-identity40.9%
+-commutative40.9%
*-rgt-identity40.9%
metadata-eval40.9%
frac-times40.9%
associate-*l/41.0%
inv-pow41.0%
*-un-lft-identity41.0%
sqrt-pow240.9%
+-commutative40.9%
metadata-eval40.9%
Applied egg-rr40.9%
associate-*r/40.9%
*-rgt-identity40.9%
times-frac40.9%
div-sub40.9%
sub-neg40.9%
*-inverses40.9%
metadata-eval40.9%
Simplified40.9%
Taylor expanded in x around inf 97.1%
frac-2neg97.1%
metadata-eval97.1%
frac-times97.2%
+-commutative97.2%
Applied egg-rr97.2%
times-frac97.1%
neg-mul-197.1%
associate-/r*97.1%
metadata-eval97.1%
/-rgt-identity97.1%
Simplified97.1%
Final simplification97.1%
(FPCore (x) :precision binary64 (/ (pow (+ x 1.0) -0.5) (* x 2.0)))
double code(double x) {
return pow((x + 1.0), -0.5) / (x * 2.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x + 1.0d0) ** (-0.5d0)) / (x * 2.0d0)
end function
public static double code(double x) {
return Math.pow((x + 1.0), -0.5) / (x * 2.0);
}
def code(x): return math.pow((x + 1.0), -0.5) / (x * 2.0)
function code(x) return Float64((Float64(x + 1.0) ^ -0.5) / Float64(x * 2.0)) end
function tmp = code(x) tmp = ((x + 1.0) ^ -0.5) / (x * 2.0); end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision] / N[(x * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(x + 1\right)}^{-0.5}}{x \cdot 2}
\end{array}
Initial program 40.9%
frac-sub40.9%
div-inv40.9%
*-un-lft-identity40.9%
+-commutative40.9%
*-rgt-identity40.9%
metadata-eval40.9%
frac-times40.9%
associate-*l/41.0%
inv-pow41.0%
*-un-lft-identity41.0%
sqrt-pow240.9%
+-commutative40.9%
metadata-eval40.9%
Applied egg-rr40.9%
associate-*r/40.9%
*-rgt-identity40.9%
times-frac40.9%
div-sub40.9%
sub-neg40.9%
*-inverses40.9%
metadata-eval40.9%
Simplified40.9%
Taylor expanded in x around inf 97.1%
/-rgt-identity97.1%
*-commutative97.1%
clear-num97.1%
un-div-inv97.2%
+-commutative97.2%
div-inv97.2%
metadata-eval97.2%
Applied egg-rr97.2%
Final simplification97.2%
(FPCore (x) :precision binary64 (/ 0.5 (* x (sqrt (+ x 1.0)))))
double code(double x) {
return 0.5 / (x * sqrt((x + 1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.5d0 / (x * sqrt((x + 1.0d0)))
end function
public static double code(double x) {
return 0.5 / (x * Math.sqrt((x + 1.0)));
}
def code(x): return 0.5 / (x * math.sqrt((x + 1.0)))
function code(x) return Float64(0.5 / Float64(x * sqrt(Float64(x + 1.0)))) end
function tmp = code(x) tmp = 0.5 / (x * sqrt((x + 1.0))); end
code[x_] := N[(0.5 / N[(x * N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5}{x \cdot \sqrt{x + 1}}
\end{array}
Initial program 40.9%
frac-sub40.9%
div-inv40.9%
*-un-lft-identity40.9%
+-commutative40.9%
*-rgt-identity40.9%
metadata-eval40.9%
frac-times40.9%
associate-*l/41.0%
inv-pow41.0%
*-un-lft-identity41.0%
sqrt-pow240.9%
+-commutative40.9%
metadata-eval40.9%
Applied egg-rr40.9%
associate-*r/40.9%
*-rgt-identity40.9%
times-frac40.9%
div-sub40.9%
sub-neg40.9%
*-inverses40.9%
metadata-eval40.9%
Simplified40.9%
Taylor expanded in x around inf 97.1%
frac-2neg97.1%
metadata-eval97.1%
frac-times97.2%
+-commutative97.2%
Applied egg-rr97.2%
*-rgt-identity97.2%
associate-/l*96.9%
Simplified96.9%
*-un-lft-identity96.9%
associate-/r/97.1%
metadata-eval97.1%
frac-2neg97.1%
metadata-eval97.1%
pow-flip97.0%
pow1/297.0%
un-div-inv97.0%
Applied egg-rr97.0%
*-lft-identity97.0%
associate-/r*96.8%
Simplified96.8%
Final simplification96.8%
(FPCore (x) :precision binary64 (/ (/ 0.5 x) (sqrt (+ x 1.0))))
double code(double x) {
return (0.5 / x) / sqrt((x + 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (0.5d0 / x) / sqrt((x + 1.0d0))
end function
public static double code(double x) {
return (0.5 / x) / Math.sqrt((x + 1.0));
}
def code(x): return (0.5 / x) / math.sqrt((x + 1.0))
function code(x) return Float64(Float64(0.5 / x) / sqrt(Float64(x + 1.0))) end
function tmp = code(x) tmp = (0.5 / x) / sqrt((x + 1.0)); end
code[x_] := N[(N[(0.5 / x), $MachinePrecision] / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{0.5}{x}}{\sqrt{x + 1}}
\end{array}
Initial program 40.9%
frac-sub40.9%
div-inv40.9%
*-un-lft-identity40.9%
+-commutative40.9%
*-rgt-identity40.9%
metadata-eval40.9%
frac-times40.9%
associate-*l/41.0%
inv-pow41.0%
*-un-lft-identity41.0%
sqrt-pow240.9%
+-commutative40.9%
metadata-eval40.9%
Applied egg-rr40.9%
associate-*r/40.9%
*-rgt-identity40.9%
times-frac40.9%
div-sub40.9%
sub-neg40.9%
*-inverses40.9%
metadata-eval40.9%
Simplified40.9%
Taylor expanded in x around inf 97.1%
clear-num97.0%
pow-flip97.0%
metadata-eval97.0%
pow1/297.0%
frac-times96.8%
metadata-eval96.8%
add-sqr-sqrt96.8%
hypot-1-def96.8%
Applied egg-rr96.8%
associate-/r*97.0%
hypot-undefine97.0%
metadata-eval97.0%
rem-square-sqrt97.0%
+-commutative97.0%
Simplified97.0%
Final simplification97.0%
(FPCore (x) :precision binary64 (/ 0.0625 (pow x 3.0)))
double code(double x) {
return 0.0625 / pow(x, 3.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0625d0 / (x ** 3.0d0)
end function
public static double code(double x) {
return 0.0625 / Math.pow(x, 3.0);
}
def code(x): return 0.0625 / math.pow(x, 3.0)
function code(x) return Float64(0.0625 / (x ^ 3.0)) end
function tmp = code(x) tmp = 0.0625 / (x ^ 3.0); end
code[x_] := N[(0.0625 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.0625}{{x}^{3}}
\end{array}
Initial program 40.9%
frac-sub40.9%
div-inv40.9%
*-un-lft-identity40.9%
+-commutative40.9%
*-rgt-identity40.9%
metadata-eval40.9%
frac-times40.9%
associate-*l/41.0%
inv-pow41.0%
*-un-lft-identity41.0%
sqrt-pow240.9%
+-commutative40.9%
metadata-eval40.9%
Applied egg-rr40.9%
associate-*r/40.9%
*-rgt-identity40.9%
times-frac40.9%
div-sub40.9%
sub-neg40.9%
*-inverses40.9%
metadata-eval40.9%
Simplified40.9%
Taylor expanded in x around inf 98.7%
+-commutative98.7%
associate-*r/98.7%
metadata-eval98.7%
associate-*r/98.7%
metadata-eval98.7%
associate-*r/98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in x around 0 38.2%
Final simplification38.2%
(FPCore (x) :precision binary64 (/ 0.5 x))
double code(double x) {
return 0.5 / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.5d0 / x
end function
public static double code(double x) {
return 0.5 / x;
}
def code(x): return 0.5 / x
function code(x) return Float64(0.5 / x) end
function tmp = code(x) tmp = 0.5 / x; end
code[x_] := N[(0.5 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5}{x}
\end{array}
Initial program 40.9%
frac-sub40.9%
div-inv40.9%
*-un-lft-identity40.9%
+-commutative40.9%
*-rgt-identity40.9%
metadata-eval40.9%
frac-times40.9%
associate-*l/41.0%
inv-pow41.0%
*-un-lft-identity41.0%
sqrt-pow240.9%
+-commutative40.9%
metadata-eval40.9%
Applied egg-rr40.9%
associate-*r/40.9%
*-rgt-identity40.9%
times-frac40.9%
div-sub40.9%
sub-neg40.9%
*-inverses40.9%
metadata-eval40.9%
Simplified40.9%
Taylor expanded in x around inf 97.1%
Taylor expanded in x around 0 7.9%
Final simplification7.9%
(FPCore (x) :precision binary64 -1.0)
double code(double x) {
return -1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = -1.0d0
end function
public static double code(double x) {
return -1.0;
}
def code(x): return -1.0
function code(x) return -1.0 end
function tmp = code(x) tmp = -1.0; end
code[x_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 40.9%
Taylor expanded in x around 0 2.5%
Taylor expanded in x around inf 2.5%
Final simplification2.5%
(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 2024044
(FPCore (x)
:name "2isqrt (example 3.6)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:herbie-target
(/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))
(- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))