
(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 15 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 (if (<= x 5e+16) (/ (/ 1.0 (+ (pow x -0.5) (pow (+ 1.0 x) -0.5))) (fma x x x)) (/ (+ (* -0.5 (sqrt (/ 1.0 (pow x 3.0)))) (* 0.5 (sqrt (/ 1.0 x)))) x)))
double code(double x) {
double tmp;
if (x <= 5e+16) {
tmp = (1.0 / (pow(x, -0.5) + pow((1.0 + x), -0.5))) / fma(x, x, x);
} else {
tmp = ((-0.5 * sqrt((1.0 / pow(x, 3.0)))) + (0.5 * sqrt((1.0 / x)))) / x;
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 5e+16) tmp = Float64(Float64(1.0 / Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5))) / fma(x, x, x)); else tmp = Float64(Float64(Float64(-0.5 * sqrt(Float64(1.0 / (x ^ 3.0)))) + Float64(0.5 * sqrt(Float64(1.0 / x)))) / x); end return tmp end
code[x_] := If[LessEqual[x, 5e+16], N[(N[(1.0 / N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * x + x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-0.5 * N[Sqrt[N[(1.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+16}:\\
\;\;\;\;\frac{\frac{1}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}}{\mathsf{fma}\left(x, x, x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot \sqrt{\frac{1}{{x}^{3}}} + 0.5 \cdot \sqrt{\frac{1}{x}}}{x}\\
\end{array}
\end{array}
if x < 5e16Initial program 57.8%
flip--57.7%
frac-times56.7%
metadata-eval56.7%
add-sqr-sqrt57.3%
frac-times59.2%
metadata-eval59.2%
add-sqr-sqrt60.3%
+-commutative60.3%
inv-pow60.3%
sqrt-pow260.3%
metadata-eval60.3%
inv-pow60.3%
sqrt-pow260.3%
+-commutative60.3%
metadata-eval60.3%
Applied egg-rr60.3%
frac-sub95.2%
*-un-lft-identity95.2%
distribute-rgt-in95.0%
*-un-lft-identity95.0%
pow295.0%
Applied egg-rr95.0%
*-rgt-identity95.0%
associate--l+99.3%
+-inverses99.3%
metadata-eval99.3%
+-commutative99.3%
unpow299.3%
fma-define99.4%
Simplified99.4%
div-inv99.4%
add-sqr-sqrt99.2%
associate-*l*99.4%
sqrt-div99.4%
metadata-eval99.4%
fma-undefine99.3%
add-sqr-sqrt99.3%
hypot-define99.6%
sqrt-div99.5%
metadata-eval99.5%
fma-undefine99.5%
add-sqr-sqrt99.5%
hypot-define99.4%
Applied egg-rr99.4%
associate-*l/99.4%
*-un-lft-identity99.4%
frac-times99.3%
*-un-lft-identity99.3%
hypot-undefine99.5%
add-sqr-sqrt99.5%
hypot-undefine99.2%
add-sqr-sqrt99.2%
add-sqr-sqrt99.5%
fma-undefine99.7%
Applied egg-rr99.7%
if 5e16 < x Initial program 42.2%
flip--42.2%
frac-times20.9%
metadata-eval20.9%
add-sqr-sqrt20.4%
frac-times25.2%
metadata-eval25.2%
add-sqr-sqrt42.2%
+-commutative42.2%
inv-pow42.2%
sqrt-pow242.2%
metadata-eval42.2%
inv-pow42.2%
sqrt-pow242.2%
+-commutative42.2%
metadata-eval42.2%
Applied egg-rr42.2%
Taylor expanded in x around inf 42.2%
*-commutative42.2%
unpow1/242.2%
rem-exp-log42.2%
exp-neg42.2%
exp-prod42.2%
distribute-lft-neg-out42.2%
distribute-rgt-neg-in42.2%
metadata-eval42.2%
exp-to-pow42.2%
Simplified42.2%
Taylor expanded in x around inf 99.8%
(FPCore (x) :precision binary64 (let* ((t_0 (/ 1.0 (hypot x (sqrt x))))) (* t_0 (* t_0 (/ 1.0 (+ (pow x -0.5) (pow (+ 1.0 x) -0.5)))))))
double code(double x) {
double t_0 = 1.0 / hypot(x, sqrt(x));
return t_0 * (t_0 * (1.0 / (pow(x, -0.5) + pow((1.0 + x), -0.5))));
}
public static double code(double x) {
double t_0 = 1.0 / Math.hypot(x, Math.sqrt(x));
return t_0 * (t_0 * (1.0 / (Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5))));
}
def code(x): t_0 = 1.0 / math.hypot(x, math.sqrt(x)) return t_0 * (t_0 * (1.0 / (math.pow(x, -0.5) + math.pow((1.0 + x), -0.5))))
function code(x) t_0 = Float64(1.0 / hypot(x, sqrt(x))) return Float64(t_0 * Float64(t_0 * Float64(1.0 / Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5))))) end
function tmp = code(x) t_0 = 1.0 / hypot(x, sqrt(x)); tmp = t_0 * (t_0 * (1.0 / ((x ^ -0.5) + ((1.0 + x) ^ -0.5)))); end
code[x_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[x ^ 2 + N[Sqrt[x], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * N[(t$95$0 * N[(1.0 / N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}\\
t\_0 \cdot \left(t\_0 \cdot \frac{1}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}\right)
\end{array}
\end{array}
Initial program 43.6%
flip--43.6%
frac-times24.1%
metadata-eval24.1%
add-sqr-sqrt23.7%
frac-times28.2%
metadata-eval28.2%
add-sqr-sqrt43.8%
+-commutative43.8%
inv-pow43.8%
sqrt-pow243.8%
metadata-eval43.8%
inv-pow43.8%
sqrt-pow243.8%
+-commutative43.8%
metadata-eval43.8%
Applied egg-rr43.8%
frac-sub46.9%
*-un-lft-identity46.9%
distribute-rgt-in46.9%
*-un-lft-identity46.9%
pow246.9%
Applied egg-rr46.9%
*-rgt-identity46.9%
associate--l+86.2%
+-inverses86.2%
metadata-eval86.2%
+-commutative86.2%
unpow286.2%
fma-define86.2%
Simplified86.2%
div-inv86.2%
add-sqr-sqrt86.1%
associate-*l*86.1%
sqrt-div86.1%
metadata-eval86.1%
fma-undefine86.1%
add-sqr-sqrt86.1%
hypot-define86.1%
sqrt-div86.1%
metadata-eval86.1%
fma-undefine86.1%
add-sqr-sqrt86.1%
hypot-define99.4%
Applied egg-rr99.4%
(FPCore (x) :precision binary64 (let* ((t_0 (/ 1.0 (hypot x (sqrt x))))) (* t_0 (/ t_0 (+ (pow x -0.5) (pow (+ 1.0 x) -0.5))))))
double code(double x) {
double t_0 = 1.0 / hypot(x, sqrt(x));
return t_0 * (t_0 / (pow(x, -0.5) + pow((1.0 + x), -0.5)));
}
public static double code(double x) {
double t_0 = 1.0 / Math.hypot(x, Math.sqrt(x));
return t_0 * (t_0 / (Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5)));
}
def code(x): t_0 = 1.0 / math.hypot(x, math.sqrt(x)) return t_0 * (t_0 / (math.pow(x, -0.5) + math.pow((1.0 + x), -0.5)))
function code(x) t_0 = Float64(1.0 / hypot(x, sqrt(x))) return Float64(t_0 * Float64(t_0 / Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5)))) end
function tmp = code(x) t_0 = 1.0 / hypot(x, sqrt(x)); tmp = t_0 * (t_0 / ((x ^ -0.5) + ((1.0 + x) ^ -0.5))); end
code[x_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[x ^ 2 + N[Sqrt[x], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * N[(t$95$0 / N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}\\
t\_0 \cdot \frac{t\_0}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}
\end{array}
\end{array}
Initial program 43.6%
flip--43.6%
frac-times24.1%
metadata-eval24.1%
add-sqr-sqrt23.7%
frac-times28.2%
metadata-eval28.2%
add-sqr-sqrt43.8%
+-commutative43.8%
inv-pow43.8%
sqrt-pow243.8%
metadata-eval43.8%
inv-pow43.8%
sqrt-pow243.8%
+-commutative43.8%
metadata-eval43.8%
Applied egg-rr43.8%
frac-sub46.9%
*-un-lft-identity46.9%
distribute-rgt-in46.9%
*-un-lft-identity46.9%
pow246.9%
Applied egg-rr46.9%
*-rgt-identity46.9%
associate--l+86.2%
+-inverses86.2%
metadata-eval86.2%
+-commutative86.2%
unpow286.2%
fma-define86.2%
Simplified86.2%
add-sqr-sqrt86.1%
associate-/l*86.1%
sqrt-div86.2%
metadata-eval86.2%
fma-undefine86.1%
add-sqr-sqrt86.1%
hypot-define86.2%
sqrt-div86.1%
metadata-eval86.1%
fma-undefine86.1%
add-sqr-sqrt86.1%
hypot-define99.4%
Applied egg-rr99.4%
(FPCore (x) :precision binary64 (pow (/ (/ 1.0 (hypot x (sqrt x))) (hypot (pow x -0.25) (pow (+ 1.0 x) -0.25))) 2.0))
double code(double x) {
return pow(((1.0 / hypot(x, sqrt(x))) / hypot(pow(x, -0.25), pow((1.0 + x), -0.25))), 2.0);
}
public static double code(double x) {
return Math.pow(((1.0 / Math.hypot(x, Math.sqrt(x))) / Math.hypot(Math.pow(x, -0.25), Math.pow((1.0 + x), -0.25))), 2.0);
}
def code(x): return math.pow(((1.0 / math.hypot(x, math.sqrt(x))) / math.hypot(math.pow(x, -0.25), math.pow((1.0 + x), -0.25))), 2.0)
function code(x) return Float64(Float64(1.0 / hypot(x, sqrt(x))) / hypot((x ^ -0.25), (Float64(1.0 + x) ^ -0.25))) ^ 2.0 end
function tmp = code(x) tmp = ((1.0 / hypot(x, sqrt(x))) / hypot((x ^ -0.25), ((1.0 + x) ^ -0.25))) ^ 2.0; end
code[x_] := N[Power[N[(N[(1.0 / N[Sqrt[x ^ 2 + N[Sqrt[x], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[Power[x, -0.25], $MachinePrecision] ^ 2 + N[Power[N[(1.0 + x), $MachinePrecision], -0.25], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(\frac{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}}{\mathsf{hypot}\left({x}^{-0.25}, {\left(1 + x\right)}^{-0.25}\right)}\right)}^{2}
\end{array}
Initial program 43.6%
flip--43.6%
frac-times24.1%
metadata-eval24.1%
add-sqr-sqrt23.7%
frac-times28.2%
metadata-eval28.2%
add-sqr-sqrt43.8%
+-commutative43.8%
inv-pow43.8%
sqrt-pow243.8%
metadata-eval43.8%
inv-pow43.8%
sqrt-pow243.8%
+-commutative43.8%
metadata-eval43.8%
Applied egg-rr43.8%
frac-sub46.9%
*-un-lft-identity46.9%
distribute-rgt-in46.9%
*-un-lft-identity46.9%
pow246.9%
Applied egg-rr46.9%
*-rgt-identity46.9%
associate--l+86.2%
+-inverses86.2%
metadata-eval86.2%
+-commutative86.2%
unpow286.2%
fma-define86.2%
Simplified86.2%
add-sqr-sqrt86.0%
add-sqr-sqrt86.0%
times-frac86.0%
Applied egg-rr99.2%
unpow299.2%
Simplified99.2%
(FPCore (x) :precision binary64 (pow (/ 1.0 (* (hypot x (sqrt x)) (hypot (pow x -0.25) (pow (+ 1.0 x) -0.25)))) 2.0))
double code(double x) {
return pow((1.0 / (hypot(x, sqrt(x)) * hypot(pow(x, -0.25), pow((1.0 + x), -0.25)))), 2.0);
}
public static double code(double x) {
return Math.pow((1.0 / (Math.hypot(x, Math.sqrt(x)) * Math.hypot(Math.pow(x, -0.25), Math.pow((1.0 + x), -0.25)))), 2.0);
}
def code(x): return math.pow((1.0 / (math.hypot(x, math.sqrt(x)) * math.hypot(math.pow(x, -0.25), math.pow((1.0 + x), -0.25)))), 2.0)
function code(x) return Float64(1.0 / Float64(hypot(x, sqrt(x)) * hypot((x ^ -0.25), (Float64(1.0 + x) ^ -0.25)))) ^ 2.0 end
function tmp = code(x) tmp = (1.0 / (hypot(x, sqrt(x)) * hypot((x ^ -0.25), ((1.0 + x) ^ -0.25)))) ^ 2.0; end
code[x_] := N[Power[N[(1.0 / N[(N[Sqrt[x ^ 2 + N[Sqrt[x], $MachinePrecision] ^ 2], $MachinePrecision] * N[Sqrt[N[Power[x, -0.25], $MachinePrecision] ^ 2 + N[Power[N[(1.0 + x), $MachinePrecision], -0.25], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right) \cdot \mathsf{hypot}\left({x}^{-0.25}, {\left(1 + x\right)}^{-0.25}\right)}\right)}^{2}
\end{array}
Initial program 43.6%
flip--43.6%
frac-times24.1%
metadata-eval24.1%
add-sqr-sqrt23.7%
frac-times28.2%
metadata-eval28.2%
add-sqr-sqrt43.8%
+-commutative43.8%
inv-pow43.8%
sqrt-pow243.8%
metadata-eval43.8%
inv-pow43.8%
sqrt-pow243.8%
+-commutative43.8%
metadata-eval43.8%
Applied egg-rr43.8%
frac-sub46.9%
*-un-lft-identity46.9%
distribute-rgt-in46.9%
*-un-lft-identity46.9%
pow246.9%
Applied egg-rr46.9%
*-rgt-identity46.9%
associate--l+86.2%
+-inverses86.2%
metadata-eval86.2%
+-commutative86.2%
unpow286.2%
fma-define86.2%
Simplified86.2%
add-sqr-sqrt86.0%
add-sqr-sqrt86.0%
times-frac86.0%
Applied egg-rr99.2%
unpow299.2%
associate-/l/99.1%
*-commutative99.1%
Simplified99.1%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 1e-13) (/ (* (pow x -0.5) 0.5) (sqrt (* x (+ 1.0 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)))) <= 1e-13) {
tmp = (pow(x, -0.5) * 0.5) / sqrt((x * (1.0 + 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)))) <= 1d-13) then
tmp = ((x ** (-0.5d0)) * 0.5d0) / sqrt((x * (1.0d0 + 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)))) <= 1e-13) {
tmp = (Math.pow(x, -0.5) * 0.5) / Math.sqrt((x * (1.0 + 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)))) <= 1e-13: tmp = (math.pow(x, -0.5) * 0.5) / math.sqrt((x * (1.0 + 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)))) <= 1e-13) tmp = Float64(Float64((x ^ -0.5) * 0.5) / sqrt(Float64(x * Float64(1.0 + 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)))) <= 1e-13) tmp = ((x ^ -0.5) * 0.5) / sqrt((x * (1.0 + 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], 1e-13], N[(N[(N[Power[x, -0.5], $MachinePrecision] * 0.5), $MachinePrecision] / N[Sqrt[N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $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 10^{-13}:\\
\;\;\;\;\frac{{x}^{-0.5} \cdot 0.5}{\sqrt{x \cdot \left(1 + x\right)}}\\
\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))))) < 1e-13Initial program 41.8%
frac-sub41.8%
*-rgt-identity41.8%
*-un-lft-identity41.8%
+-commutative41.8%
sqrt-unprod41.8%
+-commutative41.8%
Applied egg-rr41.8%
Taylor expanded in x around inf 85.0%
*-commutative85.0%
unpow1/285.0%
rem-exp-log82.2%
exp-neg82.2%
exp-prod82.2%
distribute-lft-neg-out82.2%
distribute-rgt-neg-in82.2%
metadata-eval82.2%
exp-to-pow85.0%
Simplified85.0%
if 1e-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 83.9%
sub-neg83.9%
inv-pow83.9%
sqrt-pow284.8%
metadata-eval84.8%
distribute-neg-frac84.8%
metadata-eval84.8%
+-commutative84.8%
Applied egg-rr84.8%
*-rgt-identity84.8%
cancel-sign-sub84.8%
distribute-lft-neg-in84.8%
*-rgt-identity84.8%
distribute-neg-frac84.8%
metadata-eval84.8%
unpow1/284.8%
exp-to-pow82.6%
log1p-undefine82.6%
*-commutative82.6%
exp-neg82.7%
*-commutative82.7%
distribute-rgt-neg-in82.7%
log1p-undefine82.7%
metadata-eval82.7%
exp-to-pow85.1%
Simplified85.1%
Final simplification85.0%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 1e-13) (/ (/ 1.0 (* x (+ 1.0 x))) (* (pow x -0.5) 2.0)) (- (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)))) <= 1e-13) {
tmp = (1.0 / (x * (1.0 + x))) / (pow(x, -0.5) * 2.0);
} 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)))) <= 1d-13) then
tmp = (1.0d0 / (x * (1.0d0 + x))) / ((x ** (-0.5d0)) * 2.0d0)
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)))) <= 1e-13) {
tmp = (1.0 / (x * (1.0 + x))) / (Math.pow(x, -0.5) * 2.0);
} 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)))) <= 1e-13: tmp = (1.0 / (x * (1.0 + x))) / (math.pow(x, -0.5) * 2.0) 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)))) <= 1e-13) tmp = Float64(Float64(1.0 / Float64(x * Float64(1.0 + x))) / Float64((x ^ -0.5) * 2.0)); 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)))) <= 1e-13) tmp = (1.0 / (x * (1.0 + x))) / ((x ^ -0.5) * 2.0); 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], 1e-13], N[(N[(1.0 / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, -0.5], $MachinePrecision] * 2.0), $MachinePrecision]), $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 10^{-13}:\\
\;\;\;\;\frac{\frac{1}{x \cdot \left(1 + x\right)}}{{x}^{-0.5} \cdot 2}\\
\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))))) < 1e-13Initial program 41.8%
flip--41.8%
frac-times21.5%
metadata-eval21.5%
add-sqr-sqrt21.0%
frac-times25.7%
metadata-eval25.7%
add-sqr-sqrt41.9%
+-commutative41.9%
inv-pow41.9%
sqrt-pow241.9%
metadata-eval41.9%
inv-pow41.9%
sqrt-pow241.9%
+-commutative41.9%
metadata-eval41.9%
Applied egg-rr41.9%
frac-sub44.6%
*-un-lft-identity44.6%
distribute-rgt-in44.6%
*-un-lft-identity44.6%
pow244.6%
Applied egg-rr44.6%
*-rgt-identity44.6%
associate--l+85.6%
+-inverses85.6%
metadata-eval85.6%
+-commutative85.6%
unpow285.6%
fma-define85.6%
Simplified85.6%
Taylor expanded in x around inf 84.9%
*-commutative41.9%
unpow1/241.9%
rem-exp-log41.9%
exp-neg41.9%
exp-prod41.9%
distribute-lft-neg-out41.9%
distribute-rgt-neg-in41.9%
metadata-eval41.9%
exp-to-pow41.9%
Simplified84.9%
fma-undefine85.6%
distribute-lft1-in85.6%
+-commutative85.6%
Applied egg-rr84.9%
if 1e-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 83.9%
sub-neg83.9%
inv-pow83.9%
sqrt-pow284.8%
metadata-eval84.8%
distribute-neg-frac84.8%
metadata-eval84.8%
+-commutative84.8%
Applied egg-rr84.8%
*-rgt-identity84.8%
cancel-sign-sub84.8%
distribute-lft-neg-in84.8%
*-rgt-identity84.8%
distribute-neg-frac84.8%
metadata-eval84.8%
unpow1/284.8%
exp-to-pow82.6%
log1p-undefine82.6%
*-commutative82.6%
exp-neg82.7%
*-commutative82.7%
distribute-rgt-neg-in82.7%
log1p-undefine82.7%
metadata-eval82.7%
exp-to-pow85.1%
Simplified85.1%
Final simplification84.9%
(FPCore (x) :precision binary64 (/ 1.0 (* (+ (sqrt x) (sqrt (+ 1.0 x))) (hypot (sqrt x) x))))
double code(double x) {
return 1.0 / ((sqrt(x) + sqrt((1.0 + x))) * hypot(sqrt(x), x));
}
public static double code(double x) {
return 1.0 / ((Math.sqrt(x) + Math.sqrt((1.0 + x))) * Math.hypot(Math.sqrt(x), x));
}
def code(x): return 1.0 / ((math.sqrt(x) + math.sqrt((1.0 + x))) * math.hypot(math.sqrt(x), x))
function code(x) return Float64(1.0 / Float64(Float64(sqrt(x) + sqrt(Float64(1.0 + x))) * hypot(sqrt(x), x))) end
function tmp = code(x) tmp = 1.0 / ((sqrt(x) + sqrt((1.0 + x))) * hypot(sqrt(x), x)); end
code[x_] := N[(1.0 / N[(N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[Sqrt[x], $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\left(\sqrt{x} + \sqrt{1 + x}\right) \cdot \mathsf{hypot}\left(\sqrt{x}, x\right)}
\end{array}
Initial program 43.6%
frac-sub43.7%
*-rgt-identity43.7%
*-un-lft-identity43.7%
+-commutative43.7%
sqrt-unprod43.7%
+-commutative43.7%
Applied egg-rr43.7%
flip--44.8%
add-sqr-sqrt45.2%
add-sqr-sqrt46.9%
add-sqr-sqrt46.9%
hypot-1-def46.9%
Applied egg-rr46.9%
associate--l+86.2%
+-inverses86.2%
metadata-eval86.2%
+-commutative86.2%
hypot-undefine86.2%
metadata-eval86.2%
rem-square-sqrt86.2%
Simplified86.2%
*-un-lft-identity86.2%
associate-/l/86.2%
distribute-rgt-in86.2%
*-un-lft-identity86.2%
add-sqr-sqrt86.2%
hypot-define98.8%
Applied egg-rr98.8%
*-lft-identity98.8%
*-commutative98.8%
Simplified98.8%
(FPCore (x) :precision binary64 (if (<= x 5e+99) (/ (/ 1.0 (* x (+ 1.0 x))) (+ (pow x -0.5) (pow (+ 1.0 x) -0.5))) (/ (/ 1.0 (+ (sqrt x) (sqrt (+ 1.0 x)))) (* x (+ 1.0 (/ 0.5 x))))))
double code(double x) {
double tmp;
if (x <= 5e+99) {
tmp = (1.0 / (x * (1.0 + x))) / (pow(x, -0.5) + pow((1.0 + x), -0.5));
} else {
tmp = (1.0 / (sqrt(x) + sqrt((1.0 + x)))) / (x * (1.0 + (0.5 / x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 5d+99) then
tmp = (1.0d0 / (x * (1.0d0 + x))) / ((x ** (-0.5d0)) + ((1.0d0 + x) ** (-0.5d0)))
else
tmp = (1.0d0 / (sqrt(x) + sqrt((1.0d0 + x)))) / (x * (1.0d0 + (0.5d0 / x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 5e+99) {
tmp = (1.0 / (x * (1.0 + x))) / (Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5));
} else {
tmp = (1.0 / (Math.sqrt(x) + Math.sqrt((1.0 + x)))) / (x * (1.0 + (0.5 / x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 5e+99: tmp = (1.0 / (x * (1.0 + x))) / (math.pow(x, -0.5) + math.pow((1.0 + x), -0.5)) else: tmp = (1.0 / (math.sqrt(x) + math.sqrt((1.0 + x)))) / (x * (1.0 + (0.5 / x))) return tmp
function code(x) tmp = 0.0 if (x <= 5e+99) tmp = Float64(Float64(1.0 / Float64(x * Float64(1.0 + x))) / Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5))); else tmp = Float64(Float64(1.0 / Float64(sqrt(x) + sqrt(Float64(1.0 + x)))) / Float64(x * Float64(1.0 + Float64(0.5 / x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 5e+99) tmp = (1.0 / (x * (1.0 + x))) / ((x ^ -0.5) + ((1.0 + x) ^ -0.5)); else tmp = (1.0 / (sqrt(x) + sqrt((1.0 + x)))) / (x * (1.0 + (0.5 / x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 5e+99], N[(N[(1.0 / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * N[(1.0 + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+99}:\\
\;\;\;\;\frac{\frac{1}{x \cdot \left(1 + x\right)}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}{x \cdot \left(1 + \frac{0.5}{x}\right)}\\
\end{array}
\end{array}
if x < 5.00000000000000008e99Initial program 17.7%
flip--17.7%
frac-times18.3%
metadata-eval18.3%
add-sqr-sqrt18.3%
frac-times18.2%
metadata-eval18.2%
add-sqr-sqrt18.4%
+-commutative18.4%
inv-pow18.4%
sqrt-pow218.4%
metadata-eval18.4%
inv-pow18.4%
sqrt-pow218.4%
+-commutative18.4%
metadata-eval18.4%
Applied egg-rr18.4%
frac-sub27.3%
*-un-lft-identity27.3%
distribute-rgt-in27.2%
*-un-lft-identity27.2%
pow227.2%
Applied egg-rr27.2%
*-rgt-identity27.2%
associate--l+99.4%
+-inverses99.4%
metadata-eval99.4%
+-commutative99.4%
unpow299.4%
fma-define99.4%
Simplified99.4%
fma-undefine99.4%
distribute-lft1-in99.4%
+-commutative99.4%
Applied egg-rr99.4%
if 5.00000000000000008e99 < x Initial program 57.6%
frac-sub57.6%
*-rgt-identity57.6%
*-un-lft-identity57.6%
+-commutative57.6%
sqrt-unprod57.6%
+-commutative57.6%
Applied egg-rr57.6%
flip--57.6%
add-sqr-sqrt57.4%
add-sqr-sqrt57.6%
add-sqr-sqrt57.6%
hypot-1-def57.6%
Applied egg-rr57.6%
associate--l+79.2%
+-inverses79.2%
metadata-eval79.2%
+-commutative79.2%
hypot-undefine79.2%
metadata-eval79.2%
rem-square-sqrt79.2%
Simplified79.2%
Taylor expanded in x around inf 99.8%
associate-*r/99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.7%
(FPCore (x) :precision binary64 (/ (/ 1.0 (* x (+ 1.0 x))) (+ (pow x -0.5) (pow (+ 1.0 x) -0.5))))
double code(double x) {
return (1.0 / (x * (1.0 + x))) / (pow(x, -0.5) + pow((1.0 + x), -0.5));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (x * (1.0d0 + x))) / ((x ** (-0.5d0)) + ((1.0d0 + x) ** (-0.5d0)))
end function
public static double code(double x) {
return (1.0 / (x * (1.0 + x))) / (Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5));
}
def code(x): return (1.0 / (x * (1.0 + x))) / (math.pow(x, -0.5) + math.pow((1.0 + x), -0.5))
function code(x) return Float64(Float64(1.0 / Float64(x * Float64(1.0 + x))) / Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5))) end
function tmp = code(x) tmp = (1.0 / (x * (1.0 + x))) / ((x ^ -0.5) + ((1.0 + x) ^ -0.5)); end
code[x_] := N[(N[(1.0 / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x \cdot \left(1 + x\right)}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}
\end{array}
Initial program 43.6%
flip--43.6%
frac-times24.1%
metadata-eval24.1%
add-sqr-sqrt23.7%
frac-times28.2%
metadata-eval28.2%
add-sqr-sqrt43.8%
+-commutative43.8%
inv-pow43.8%
sqrt-pow243.8%
metadata-eval43.8%
inv-pow43.8%
sqrt-pow243.8%
+-commutative43.8%
metadata-eval43.8%
Applied egg-rr43.8%
frac-sub46.9%
*-un-lft-identity46.9%
distribute-rgt-in46.9%
*-un-lft-identity46.9%
pow246.9%
Applied egg-rr46.9%
*-rgt-identity46.9%
associate--l+86.2%
+-inverses86.2%
metadata-eval86.2%
+-commutative86.2%
unpow286.2%
fma-define86.2%
Simplified86.2%
fma-undefine86.2%
distribute-lft1-in86.2%
+-commutative86.2%
Applied egg-rr86.2%
Final simplification86.2%
(FPCore (x) :precision binary64 (if (<= x 4.7e+153) (/ (/ 1.0 x) (+ 1.0 (pow x -0.5))) 0.0))
double code(double x) {
double tmp;
if (x <= 4.7e+153) {
tmp = (1.0 / x) / (1.0 + 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 <= 4.7d+153) then
tmp = (1.0d0 / x) / (1.0d0 + (x ** (-0.5d0)))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 4.7e+153) {
tmp = (1.0 / x) / (1.0 + Math.pow(x, -0.5));
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 4.7e+153: tmp = (1.0 / x) / (1.0 + math.pow(x, -0.5)) else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= 4.7e+153) tmp = Float64(Float64(1.0 / x) / Float64(1.0 + (x ^ -0.5))); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 4.7e+153) tmp = (1.0 / x) / (1.0 + (x ^ -0.5)); else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 4.7e+153], N[(N[(1.0 / x), $MachinePrecision] / N[(1.0 + N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.7 \cdot 10^{+153}:\\
\;\;\;\;\frac{\frac{1}{x}}{1 + {x}^{-0.5}}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 4.69999999999999968e153Initial program 14.1%
flip--14.1%
frac-times14.4%
metadata-eval14.4%
add-sqr-sqrt14.3%
frac-times14.3%
metadata-eval14.3%
add-sqr-sqrt14.6%
+-commutative14.6%
inv-pow14.6%
sqrt-pow214.6%
metadata-eval14.6%
inv-pow14.6%
sqrt-pow214.6%
+-commutative14.6%
metadata-eval14.6%
Applied egg-rr14.6%
Taylor expanded in x around 0 7.4%
Taylor expanded in x around 0 8.9%
if 4.69999999999999968e153 < x Initial program 72.6%
inv-pow72.6%
add-cube-cbrt26.4%
unpow-prod-down23.9%
fmm-def4.4%
cbrt-prod4.4%
add-sqr-sqrt4.4%
distribute-neg-frac4.4%
metadata-eval4.4%
+-commutative4.4%
Applied egg-rr4.4%
Taylor expanded in x around inf 72.6%
distribute-rgt1-in72.6%
metadata-eval72.6%
mul0-lft72.6%
Simplified72.6%
Final simplification41.0%
(FPCore (x) :precision binary64 (/ (/ 1.0 (* x (+ 1.0 x))) (* (pow x -0.5) 2.0)))
double code(double x) {
return (1.0 / (x * (1.0 + x))) / (pow(x, -0.5) * 2.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (x * (1.0d0 + x))) / ((x ** (-0.5d0)) * 2.0d0)
end function
public static double code(double x) {
return (1.0 / (x * (1.0 + x))) / (Math.pow(x, -0.5) * 2.0);
}
def code(x): return (1.0 / (x * (1.0 + x))) / (math.pow(x, -0.5) * 2.0)
function code(x) return Float64(Float64(1.0 / Float64(x * Float64(1.0 + x))) / Float64((x ^ -0.5) * 2.0)) end
function tmp = code(x) tmp = (1.0 / (x * (1.0 + x))) / ((x ^ -0.5) * 2.0); end
code[x_] := N[(N[(1.0 / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, -0.5], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x \cdot \left(1 + x\right)}}{{x}^{-0.5} \cdot 2}
\end{array}
Initial program 43.6%
flip--43.6%
frac-times24.1%
metadata-eval24.1%
add-sqr-sqrt23.7%
frac-times28.2%
metadata-eval28.2%
add-sqr-sqrt43.8%
+-commutative43.8%
inv-pow43.8%
sqrt-pow243.8%
metadata-eval43.8%
inv-pow43.8%
sqrt-pow243.8%
+-commutative43.8%
metadata-eval43.8%
Applied egg-rr43.8%
frac-sub46.9%
*-un-lft-identity46.9%
distribute-rgt-in46.9%
*-un-lft-identity46.9%
pow246.9%
Applied egg-rr46.9%
*-rgt-identity46.9%
associate--l+86.2%
+-inverses86.2%
metadata-eval86.2%
+-commutative86.2%
unpow286.2%
fma-define86.2%
Simplified86.2%
Taylor expanded in x around inf 82.9%
*-commutative41.8%
unpow1/241.8%
rem-exp-log41.8%
exp-neg41.8%
exp-prod41.8%
distribute-lft-neg-out41.8%
distribute-rgt-neg-in41.8%
metadata-eval41.8%
exp-to-pow41.8%
Simplified82.9%
fma-undefine86.2%
distribute-lft1-in86.2%
+-commutative86.2%
Applied egg-rr82.9%
Final simplification82.9%
(FPCore (x) :precision binary64 (if (<= x 1.12e+123) (* 0.5 (sqrt (/ 1.0 x))) 0.0))
double code(double x) {
double tmp;
if (x <= 1.12e+123) {
tmp = 0.5 * sqrt((1.0 / x));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.12d+123) then
tmp = 0.5d0 * sqrt((1.0d0 / x))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.12e+123) {
tmp = 0.5 * Math.sqrt((1.0 / x));
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.12e+123: tmp = 0.5 * math.sqrt((1.0 / x)) else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= 1.12e+123) tmp = Float64(0.5 * sqrt(Float64(1.0 / x))); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.12e+123) tmp = 0.5 * sqrt((1.0 / x)); else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.12e+123], N[(0.5 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.12 \cdot 10^{+123}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.12e123Initial program 15.8%
flip--15.8%
frac-times16.2%
metadata-eval16.2%
add-sqr-sqrt16.2%
frac-times16.1%
metadata-eval16.1%
add-sqr-sqrt16.3%
+-commutative16.3%
inv-pow16.3%
sqrt-pow216.3%
metadata-eval16.3%
inv-pow16.3%
sqrt-pow216.3%
+-commutative16.3%
metadata-eval16.3%
Applied egg-rr16.3%
Taylor expanded in x around 0 7.9%
Taylor expanded in x around inf 7.9%
*-commutative7.9%
Simplified7.9%
if 1.12e123 < x Initial program 63.2%
inv-pow63.2%
add-cube-cbrt23.3%
unpow-prod-down21.1%
fmm-def4.3%
cbrt-prod4.3%
add-sqr-sqrt4.4%
distribute-neg-frac4.4%
metadata-eval4.4%
+-commutative4.4%
Applied egg-rr4.4%
Taylor expanded in x around inf 63.2%
distribute-rgt1-in63.2%
metadata-eval63.2%
mul0-lft63.2%
Simplified63.2%
Final simplification40.3%
(FPCore (x) :precision binary64 (if (<= x 8.2e+122) (pow x -0.5) 0.0))
double code(double x) {
double tmp;
if (x <= 8.2e+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.2d+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.2e+122) {
tmp = Math.pow(x, -0.5);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 8.2e+122: tmp = math.pow(x, -0.5) else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= 8.2e+122) tmp = x ^ -0.5; else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 8.2e+122) tmp = x ^ -0.5; else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 8.2e+122], N[Power[x, -0.5], $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.2 \cdot 10^{+122}:\\
\;\;\;\;{x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 8.2000000000000004e122Initial program 15.8%
flip--15.8%
frac-times16.2%
metadata-eval16.2%
add-sqr-sqrt16.2%
frac-times16.1%
metadata-eval16.1%
add-sqr-sqrt16.3%
+-commutative16.3%
inv-pow16.3%
sqrt-pow216.3%
metadata-eval16.3%
inv-pow16.3%
sqrt-pow216.3%
+-commutative16.3%
metadata-eval16.3%
Applied egg-rr16.3%
Taylor expanded in x around 0 7.8%
unpow1/27.8%
rem-exp-log7.8%
exp-neg7.8%
exp-prod7.8%
distribute-lft-neg-out7.8%
distribute-rgt-neg-in7.8%
metadata-eval7.8%
exp-to-pow7.8%
Simplified7.8%
if 8.2000000000000004e122 < x Initial program 63.2%
inv-pow63.2%
add-cube-cbrt23.3%
unpow-prod-down21.1%
fmm-def4.3%
cbrt-prod4.3%
add-sqr-sqrt4.4%
distribute-neg-frac4.4%
metadata-eval4.4%
+-commutative4.4%
Applied egg-rr4.4%
Taylor expanded in x around inf 63.2%
distribute-rgt1-in63.2%
metadata-eval63.2%
mul0-lft63.2%
Simplified63.2%
(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 43.6%
inv-pow43.6%
add-cube-cbrt20.0%
unpow-prod-down18.8%
fmm-def9.0%
cbrt-prod8.9%
add-sqr-sqrt9.1%
distribute-neg-frac9.1%
metadata-eval9.1%
+-commutative9.1%
Applied egg-rr9.1%
Taylor expanded in x around inf 38.7%
distribute-rgt1-in38.7%
metadata-eval38.7%
mul0-lft38.7%
Simplified38.7%
(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 2024152
(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)))))