
(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 13 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)) 0.0)
(/ (+ (/ (* (pow x -0.5) -0.625) x) (* -0.5 (pow x -0.5))) (- x))
(/ (/ 1.0 (+ (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)) <= 0.0) {
tmp = (((pow(x, -0.5) * -0.625) / x) + (-0.5 * pow(x, -0.5))) / -x;
} else {
tmp = (1.0 / (sqrt(x) + t_0)) / sqrt((x * (1.0 + x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 0.0d0) then
tmp = ((((x ** (-0.5d0)) * (-0.625d0)) / x) + ((-0.5d0) * (x ** (-0.5d0)))) / -x
else
tmp = (1.0d0 / (sqrt(x) + t_0)) / 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 tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 0.0) {
tmp = (((Math.pow(x, -0.5) * -0.625) / x) + (-0.5 * Math.pow(x, -0.5))) / -x;
} else {
tmp = (1.0 / (Math.sqrt(x) + t_0)) / Math.sqrt((x * (1.0 + x)));
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 0.0: tmp = (((math.pow(x, -0.5) * -0.625) / x) + (-0.5 * math.pow(x, -0.5))) / -x else: tmp = (1.0 / (math.sqrt(x) + t_0)) / math.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)) <= 0.0) tmp = Float64(Float64(Float64(Float64((x ^ -0.5) * -0.625) / x) + Float64(-0.5 * (x ^ -0.5))) / Float64(-x)); else tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) / sqrt(Float64(x * Float64(1.0 + x)))); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((1.0 + x)); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 0.0) tmp = ((((x ^ -0.5) * -0.625) / x) + (-0.5 * (x ^ -0.5))) / -x; else tmp = (1.0 / (sqrt(x) + t_0)) / sqrt((x * (1.0 + x))); end tmp_2 = 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], 0.0], N[(N[(N[(N[(N[Power[x, -0.5], $MachinePrecision] * -0.625), $MachinePrecision] / x), $MachinePrecision] + N[(-0.5 * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-x)), $MachinePrecision], N[(N[(1.0 / 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 0:\\
\;\;\;\;\frac{\frac{{x}^{-0.5} \cdot -0.625}{x} + -0.5 \cdot {x}^{-0.5}}{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\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))))) < 0.0Initial program 41.8%
Taylor expanded in x around inf 83.4%
Taylor expanded in x around -inf 0.0%
mul-1-neg0.0%
distribute-neg-frac20.0%
Simplified99.8%
if 0.0 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) Initial program 72.4%
frac-sub74.5%
*-un-lft-identity74.5%
+-commutative74.5%
*-rgt-identity74.5%
sqrt-unprod74.4%
+-commutative74.4%
Applied egg-rr74.4%
flip--79.2%
add-sqr-sqrt86.8%
add-sqr-sqrt99.3%
Applied egg-rr99.3%
associate--l+99.3%
+-inverses99.3%
metadata-eval99.3%
+-commutative99.3%
Simplified99.3%
Final simplification99.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 2e-14)
(/ (/ 1.0 (+ (sqrt x) t_0)) (* x (+ 1.0 (/ 0.5 x))))
(/ (- t_0 (sqrt x)) (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-14) {
tmp = (1.0 / (sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x)));
} else {
tmp = (t_0 - sqrt(x)) / sqrt((x * (1.0 + x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 2d-14) then
tmp = (1.0d0 / (sqrt(x) + t_0)) / (x * (1.0d0 + (0.5d0 / x)))
else
tmp = (t_0 - sqrt(x)) / 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 tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 2e-14) {
tmp = (1.0 / (Math.sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x)));
} else {
tmp = (t_0 - Math.sqrt(x)) / Math.sqrt((x * (1.0 + x)));
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 2e-14: tmp = (1.0 / (math.sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x))) else: tmp = (t_0 - math.sqrt(x)) / math.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-14) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) / Float64(x * Float64(1.0 + Float64(0.5 / x)))); else tmp = Float64(Float64(t_0 - sqrt(x)) / sqrt(Float64(x * Float64(1.0 + x)))); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((1.0 + x)); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 2e-14) tmp = (1.0 / (sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x))); else tmp = (t_0 - sqrt(x)) / sqrt((x * (1.0 + x))); end tmp_2 = 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-14], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[(x * N[(1.0 + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - N[Sqrt[x], $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^{-14}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + t\_0}}{x \cdot \left(1 + \frac{0.5}{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - \sqrt{x}}{\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))))) < 2e-14Initial program 41.8%
frac-sub41.9%
*-un-lft-identity41.9%
+-commutative41.9%
*-rgt-identity41.9%
sqrt-unprod41.9%
+-commutative41.9%
Applied egg-rr41.9%
flip--42.0%
add-sqr-sqrt42.3%
add-sqr-sqrt43.0%
Applied egg-rr43.0%
associate--l+83.7%
+-inverses83.7%
metadata-eval83.7%
+-commutative83.7%
Simplified83.7%
Taylor expanded in x around inf 99.7%
associate-*r/99.7%
metadata-eval99.7%
Simplified99.7%
if 2e-14 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) Initial program 88.7%
frac-sub90.7%
*-un-lft-identity90.7%
+-commutative90.7%
*-rgt-identity90.7%
sqrt-unprod90.6%
+-commutative90.6%
Applied egg-rr90.6%
Final simplification99.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 2e-14)
(/ (/ 1.0 (+ (sqrt x) t_0)) (* x (+ 1.0 (/ 0.5 x))))
(/ (- 1.0 (/ (sqrt x) t_0)) (sqrt x)))))
double code(double x) {
double t_0 = sqrt((1.0 + x));
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 2e-14) {
tmp = (1.0 / (sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x)));
} else {
tmp = (1.0 - (sqrt(x) / t_0)) / sqrt(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 2d-14) then
tmp = (1.0d0 / (sqrt(x) + t_0)) / (x * (1.0d0 + (0.5d0 / x)))
else
tmp = (1.0d0 - (sqrt(x) / t_0)) / sqrt(x)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((1.0 + x));
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 2e-14) {
tmp = (1.0 / (Math.sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x)));
} else {
tmp = (1.0 - (Math.sqrt(x) / t_0)) / Math.sqrt(x);
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 2e-14: tmp = (1.0 / (math.sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x))) else: tmp = (1.0 - (math.sqrt(x) / t_0)) / math.sqrt(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-14) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) / Float64(x * Float64(1.0 + Float64(0.5 / x)))); else tmp = Float64(Float64(1.0 - Float64(sqrt(x) / t_0)) / sqrt(x)); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((1.0 + x)); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 2e-14) tmp = (1.0 / (sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x))); else tmp = (1.0 - (sqrt(x) / t_0)) / sqrt(x); end tmp_2 = 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-14], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[(x * N[(1.0 + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[Sqrt[x], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[x], $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^{-14}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + t\_0}}{x \cdot \left(1 + \frac{0.5}{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \frac{\sqrt{x}}{t\_0}}{\sqrt{x}}\\
\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))))) < 2e-14Initial program 41.8%
frac-sub41.9%
*-un-lft-identity41.9%
+-commutative41.9%
*-rgt-identity41.9%
sqrt-unprod41.9%
+-commutative41.9%
Applied egg-rr41.9%
flip--42.0%
add-sqr-sqrt42.3%
add-sqr-sqrt43.0%
Applied egg-rr43.0%
associate--l+83.7%
+-inverses83.7%
metadata-eval83.7%
+-commutative83.7%
Simplified83.7%
Taylor expanded in x around inf 99.7%
associate-*r/99.7%
metadata-eval99.7%
Simplified99.7%
if 2e-14 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) Initial program 88.7%
frac-sub90.7%
*-un-lft-identity90.7%
+-commutative90.7%
*-rgt-identity90.7%
sqrt-unprod90.6%
+-commutative90.6%
Applied egg-rr90.6%
add-sqr-sqrt90.3%
sqrt-prod90.4%
times-frac90.6%
Applied egg-rr90.6%
associate-*l/90.4%
associate-*r/90.4%
rem-square-sqrt90.5%
div-sub90.5%
*-inverses90.5%
+-commutative90.5%
Simplified90.5%
Final simplification99.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 2e-14)
(/ (/ 1.0 (+ (sqrt x) t_0)) (* x (+ 1.0 (/ 0.5 x))))
(/
1.0
(/
(+ (pow x -0.5) (pow (+ 1.0 x) -0.5))
(+ (/ 1.0 x) (/ 1.0 (- -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-14) {
tmp = (1.0 / (sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x)));
} else {
tmp = 1.0 / ((pow(x, -0.5) + pow((1.0 + x), -0.5)) / ((1.0 / x) + (1.0 / (-1.0 - x))));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 2d-14) then
tmp = (1.0d0 / (sqrt(x) + t_0)) / (x * (1.0d0 + (0.5d0 / x)))
else
tmp = 1.0d0 / (((x ** (-0.5d0)) + ((1.0d0 + x) ** (-0.5d0))) / ((1.0d0 / x) + (1.0d0 / ((-1.0d0) - x))))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((1.0 + x));
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 2e-14) {
tmp = (1.0 / (Math.sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x)));
} else {
tmp = 1.0 / ((Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5)) / ((1.0 / x) + (1.0 / (-1.0 - x))));
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 2e-14: tmp = (1.0 / (math.sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x))) else: tmp = 1.0 / ((math.pow(x, -0.5) + math.pow((1.0 + x), -0.5)) / ((1.0 / x) + (1.0 / (-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-14) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) / Float64(x * Float64(1.0 + Float64(0.5 / x)))); else tmp = Float64(1.0 / Float64(Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5)) / Float64(Float64(1.0 / x) + Float64(1.0 / Float64(-1.0 - x))))); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((1.0 + x)); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 2e-14) tmp = (1.0 / (sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x))); else tmp = 1.0 / (((x ^ -0.5) + ((1.0 + x) ^ -0.5)) / ((1.0 / x) + (1.0 / (-1.0 - x)))); end tmp_2 = 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-14], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[(x * N[(1.0 + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / x), $MachinePrecision] + N[(1.0 / N[(-1.0 - x), $MachinePrecision]), $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^{-14}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + t\_0}}{x \cdot \left(1 + \frac{0.5}{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}{\frac{1}{x} + \frac{1}{-1 - x}}}\\
\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))))) < 2e-14Initial program 41.8%
frac-sub41.9%
*-un-lft-identity41.9%
+-commutative41.9%
*-rgt-identity41.9%
sqrt-unprod41.9%
+-commutative41.9%
Applied egg-rr41.9%
flip--42.0%
add-sqr-sqrt42.3%
add-sqr-sqrt43.0%
Applied egg-rr43.0%
associate--l+83.7%
+-inverses83.7%
metadata-eval83.7%
+-commutative83.7%
Simplified83.7%
Taylor expanded in x around inf 99.7%
associate-*r/99.7%
metadata-eval99.7%
Simplified99.7%
if 2e-14 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) Initial program 88.7%
flip--88.7%
clear-num88.7%
inv-pow88.7%
sqrt-pow288.7%
metadata-eval88.7%
pow1/288.7%
pow-flip88.7%
+-commutative88.7%
metadata-eval88.7%
frac-times90.2%
metadata-eval90.2%
add-sqr-sqrt90.2%
frac-times90.1%
metadata-eval90.1%
add-sqr-sqrt90.1%
Applied egg-rr90.1%
Final simplification99.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 2e-14)
(/ (/ 1.0 (+ (sqrt x) t_0)) (* x (+ 1.0 (/ 0.5 x))))
(/
(+ (/ 1.0 x) (/ 1.0 (- -1.0 x)))
(+ (pow x -0.5) (pow (+ 1.0 x) -0.5))))))
double code(double x) {
double t_0 = sqrt((1.0 + x));
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 2e-14) {
tmp = (1.0 / (sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x)));
} else {
tmp = ((1.0 / x) + (1.0 / (-1.0 - x))) / (pow(x, -0.5) + pow((1.0 + x), -0.5));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 2d-14) then
tmp = (1.0d0 / (sqrt(x) + t_0)) / (x * (1.0d0 + (0.5d0 / x)))
else
tmp = ((1.0d0 / x) + (1.0d0 / ((-1.0d0) - x))) / ((x ** (-0.5d0)) + ((1.0d0 + x) ** (-0.5d0)))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((1.0 + x));
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 2e-14) {
tmp = (1.0 / (Math.sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x)));
} else {
tmp = ((1.0 / x) + (1.0 / (-1.0 - x))) / (Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5));
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 2e-14: tmp = (1.0 / (math.sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x))) else: tmp = ((1.0 / x) + (1.0 / (-1.0 - x))) / (math.pow(x, -0.5) + math.pow((1.0 + x), -0.5)) 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-14) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) / Float64(x * Float64(1.0 + Float64(0.5 / x)))); else tmp = Float64(Float64(Float64(1.0 / x) + Float64(1.0 / Float64(-1.0 - x))) / Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5))); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((1.0 + x)); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 2e-14) tmp = (1.0 / (sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x))); else tmp = ((1.0 / x) + (1.0 / (-1.0 - x))) / ((x ^ -0.5) + ((1.0 + x) ^ -0.5)); end tmp_2 = 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-14], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[(x * N[(1.0 + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] + N[(1.0 / 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}
\\
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t\_0} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + t\_0}}{x \cdot \left(1 + \frac{0.5}{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} + \frac{1}{-1 - x}}{{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))))) < 2e-14Initial program 41.8%
frac-sub41.9%
*-un-lft-identity41.9%
+-commutative41.9%
*-rgt-identity41.9%
sqrt-unprod41.9%
+-commutative41.9%
Applied egg-rr41.9%
flip--42.0%
add-sqr-sqrt42.3%
add-sqr-sqrt43.0%
Applied egg-rr43.0%
associate--l+83.7%
+-inverses83.7%
metadata-eval83.7%
+-commutative83.7%
Simplified83.7%
Taylor expanded in x around inf 99.7%
associate-*r/99.7%
metadata-eval99.7%
Simplified99.7%
if 2e-14 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) Initial program 88.7%
flip--88.7%
div-inv88.7%
frac-times90.1%
metadata-eval90.1%
add-sqr-sqrt90.0%
frac-times90.1%
metadata-eval90.1%
add-sqr-sqrt90.1%
+-commutative90.1%
inv-pow90.1%
sqrt-pow290.1%
metadata-eval90.1%
pow1/290.1%
pow-flip90.1%
+-commutative90.1%
metadata-eval90.1%
Applied egg-rr90.1%
associate-*r/90.1%
*-rgt-identity90.1%
Simplified90.1%
Final simplification99.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 2e-14)
(/ (/ 1.0 (+ (sqrt x) t_0)) (* x (+ 1.0 (/ 0.5 x))))
(- (pow x -0.5) (pow (+ 1.0 x) -0.5)))))
double code(double x) {
double t_0 = sqrt((1.0 + x));
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 2e-14) {
tmp = (1.0 / (sqrt(x) + t_0)) / (x * (1.0 + (0.5 / 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) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 2d-14) then
tmp = (1.0d0 / (sqrt(x) + t_0)) / (x * (1.0d0 + (0.5d0 / x)))
else
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((1.0 + x));
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 2e-14) {
tmp = (1.0 / (Math.sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x)));
} else {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 2e-14: tmp = (1.0 / (math.sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x))) else: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) 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-14) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) / Float64(x * Float64(1.0 + Float64(0.5 / x)))); else tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((1.0 + x)); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 2e-14) tmp = (1.0 / (sqrt(x) + t_0)) / (x * (1.0 + (0.5 / x))); else tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); end tmp_2 = 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-14], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[(x * N[(1.0 + N[(0.5 / 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}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t\_0} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + t\_0}}{x \cdot \left(1 + \frac{0.5}{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))))) < 2e-14Initial program 41.8%
frac-sub41.9%
*-un-lft-identity41.9%
+-commutative41.9%
*-rgt-identity41.9%
sqrt-unprod41.9%
+-commutative41.9%
Applied egg-rr41.9%
flip--42.0%
add-sqr-sqrt42.3%
add-sqr-sqrt43.0%
Applied egg-rr43.0%
associate--l+83.7%
+-inverses83.7%
metadata-eval83.7%
+-commutative83.7%
Simplified83.7%
Taylor expanded in x around inf 99.7%
associate-*r/99.7%
metadata-eval99.7%
Simplified99.7%
if 2e-14 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) Initial program 88.7%
sub-neg88.7%
inv-pow88.7%
sqrt-pow289.4%
metadata-eval89.4%
distribute-neg-frac89.4%
metadata-eval89.4%
+-commutative89.4%
Applied egg-rr89.4%
*-rgt-identity89.4%
cancel-sign-sub89.4%
distribute-lft-neg-in89.4%
*-rgt-identity89.4%
distribute-neg-frac89.4%
metadata-eval89.4%
unpow1/289.4%
exp-to-pow87.9%
log1p-undefine87.9%
*-commutative87.9%
exp-neg87.2%
*-commutative87.2%
distribute-rgt-neg-in87.2%
log1p-undefine87.2%
metadata-eval87.2%
exp-to-pow89.8%
Simplified89.8%
Final simplification99.3%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 2e-14) (/ (* 0.5 (sqrt (/ 1.0 x))) (* x (+ 1.0 (/ 0.5 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-14) {
tmp = (0.5 * sqrt((1.0 / x))) / (x * (1.0 + (0.5 / 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-14) then
tmp = (0.5d0 * sqrt((1.0d0 / x))) / (x * (1.0d0 + (0.5d0 / 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-14) {
tmp = (0.5 * Math.sqrt((1.0 / x))) / (x * (1.0 + (0.5 / 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-14: tmp = (0.5 * math.sqrt((1.0 / x))) / (x * (1.0 + (0.5 / 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-14) tmp = Float64(Float64(0.5 * sqrt(Float64(1.0 / x))) / Float64(x * Float64(1.0 + Float64(0.5 / 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-14) tmp = (0.5 * sqrt((1.0 / x))) / (x * (1.0 + (0.5 / 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-14], N[(N[(0.5 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(x * N[(1.0 + N[(0.5 / 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 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{0.5 \cdot \sqrt{\frac{1}{x}}}{x \cdot \left(1 + \frac{0.5}{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))))) < 2e-14Initial program 41.8%
frac-sub41.9%
*-un-lft-identity41.9%
+-commutative41.9%
*-rgt-identity41.9%
sqrt-unprod41.9%
+-commutative41.9%
Applied egg-rr41.9%
Taylor expanded in x around inf 83.3%
*-commutative83.3%
Simplified83.3%
Taylor expanded in x around inf 99.3%
associate-*r/99.7%
metadata-eval99.7%
Simplified99.3%
if 2e-14 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) Initial program 88.7%
sub-neg88.7%
inv-pow88.7%
sqrt-pow289.4%
metadata-eval89.4%
distribute-neg-frac89.4%
metadata-eval89.4%
+-commutative89.4%
Applied egg-rr89.4%
*-rgt-identity89.4%
cancel-sign-sub89.4%
distribute-lft-neg-in89.4%
*-rgt-identity89.4%
distribute-neg-frac89.4%
metadata-eval89.4%
unpow1/289.4%
exp-to-pow87.9%
log1p-undefine87.9%
*-commutative87.9%
exp-neg87.2%
*-commutative87.2%
distribute-rgt-neg-in87.2%
log1p-undefine87.2%
metadata-eval87.2%
exp-to-pow89.8%
Simplified89.8%
Final simplification99.0%
(FPCore (x) :precision binary64 (/ 1.0 (* (hypot (sqrt x) x) (+ (sqrt x) (sqrt (+ 1.0 x))))))
double code(double x) {
return 1.0 / (hypot(sqrt(x), x) * (sqrt(x) + sqrt((1.0 + x))));
}
public static double code(double x) {
return 1.0 / (Math.hypot(Math.sqrt(x), x) * (Math.sqrt(x) + Math.sqrt((1.0 + x))));
}
def code(x): return 1.0 / (math.hypot(math.sqrt(x), x) * (math.sqrt(x) + math.sqrt((1.0 + x))))
function code(x) return Float64(1.0 / Float64(hypot(sqrt(x), x) * Float64(sqrt(x) + sqrt(Float64(1.0 + x))))) end
function tmp = code(x) tmp = 1.0 / (hypot(sqrt(x), x) * (sqrt(x) + sqrt((1.0 + x)))); end
code[x_] := N[(1.0 / N[(N[Sqrt[N[Sqrt[x], $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision] * N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\mathsf{hypot}\left(\sqrt{x}, x\right) \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)}
\end{array}
Initial program 43.5%
frac-sub43.6%
*-un-lft-identity43.6%
+-commutative43.6%
*-rgt-identity43.6%
sqrt-unprod43.6%
+-commutative43.6%
Applied egg-rr43.6%
flip--43.8%
add-sqr-sqrt44.3%
add-sqr-sqrt44.9%
Applied egg-rr44.9%
associate--l+84.2%
+-inverses84.2%
metadata-eval84.2%
+-commutative84.2%
Simplified84.2%
*-un-lft-identity84.2%
associate-/l/84.3%
associate-/r*84.3%
distribute-rgt-in84.3%
*-un-lft-identity84.3%
add-sqr-sqrt84.3%
hypot-define99.7%
+-commutative99.7%
Applied egg-rr99.7%
*-lft-identity99.7%
associate-/r*98.5%
+-commutative98.5%
Simplified98.5%
(FPCore (x) :precision binary64 (/ (* 0.5 (sqrt (/ 1.0 x))) (* x (+ 1.0 (/ 0.5 x)))))
double code(double x) {
return (0.5 * sqrt((1.0 / x))) / (x * (1.0 + (0.5 / x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (0.5d0 * sqrt((1.0d0 / x))) / (x * (1.0d0 + (0.5d0 / x)))
end function
public static double code(double x) {
return (0.5 * Math.sqrt((1.0 / x))) / (x * (1.0 + (0.5 / x)));
}
def code(x): return (0.5 * math.sqrt((1.0 / x))) / (x * (1.0 + (0.5 / x)))
function code(x) return Float64(Float64(0.5 * sqrt(Float64(1.0 / x))) / Float64(x * Float64(1.0 + Float64(0.5 / x)))) end
function tmp = code(x) tmp = (0.5 * sqrt((1.0 / x))) / (x * (1.0 + (0.5 / x))); end
code[x_] := N[(N[(0.5 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(x * N[(1.0 + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5 \cdot \sqrt{\frac{1}{x}}}{x \cdot \left(1 + \frac{0.5}{x}\right)}
\end{array}
Initial program 43.5%
frac-sub43.6%
*-un-lft-identity43.6%
+-commutative43.6%
*-rgt-identity43.6%
sqrt-unprod43.6%
+-commutative43.6%
Applied egg-rr43.6%
Taylor expanded in x around inf 81.5%
*-commutative81.5%
Simplified81.5%
Taylor expanded in x around inf 96.9%
associate-*r/97.7%
metadata-eval97.7%
Simplified96.9%
Final simplification96.9%
(FPCore (x) :precision binary64 (/ (/ 0.5 x) (sqrt (+ 1.0 x))))
double code(double x) {
return (0.5 / x) / sqrt((1.0 + x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (0.5d0 / x) / sqrt((1.0d0 + x))
end function
public static double code(double x) {
return (0.5 / x) / Math.sqrt((1.0 + x));
}
def code(x): return (0.5 / x) / math.sqrt((1.0 + x))
function code(x) return Float64(Float64(0.5 / x) / sqrt(Float64(1.0 + x))) end
function tmp = code(x) tmp = (0.5 / x) / sqrt((1.0 + x)); end
code[x_] := N[(N[(0.5 / x), $MachinePrecision] / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{0.5}{x}}{\sqrt{1 + x}}
\end{array}
Initial program 43.5%
frac-sub43.6%
*-un-lft-identity43.6%
+-commutative43.6%
*-rgt-identity43.6%
sqrt-unprod43.6%
+-commutative43.6%
Applied egg-rr43.6%
Taylor expanded in x around inf 81.5%
*-commutative81.5%
Simplified81.5%
*-un-lft-identity81.5%
sqrt-prod96.6%
times-frac96.6%
un-div-inv96.6%
metadata-eval96.6%
sqrt-div96.6%
add-sqr-sqrt96.8%
+-commutative96.8%
Applied egg-rr96.8%
*-lft-identity96.8%
associate-*r/96.9%
associate-*l/96.9%
metadata-eval96.9%
+-commutative96.9%
Simplified96.9%
(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 43.5%
frac-sub43.6%
*-un-lft-identity43.6%
+-commutative43.6%
*-rgt-identity43.6%
sqrt-unprod43.6%
+-commutative43.6%
Applied egg-rr43.6%
Taylor expanded in x around inf 81.5%
*-commutative81.5%
Simplified81.5%
Taylor expanded in x around inf 96.8%
Final simplification96.8%
(FPCore (x) :precision binary64 (if (<= x 6.4e+153) (/ 0.5 x) 0.0))
double code(double x) {
double tmp;
if (x <= 6.4e+153) {
tmp = 0.5 / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 6.4d+153) then
tmp = 0.5d0 / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 6.4e+153) {
tmp = 0.5 / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 6.4e+153: tmp = 0.5 / x else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= 6.4e+153) tmp = Float64(0.5 / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 6.4e+153) tmp = 0.5 / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 6.4e+153], N[(0.5 / x), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.4 \cdot 10^{+153}:\\
\;\;\;\;\frac{0.5}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 6.4000000000000003e153Initial program 12.5%
frac-sub12.7%
*-un-lft-identity12.7%
+-commutative12.7%
*-rgt-identity12.7%
sqrt-unprod12.7%
+-commutative12.7%
Applied egg-rr12.7%
Taylor expanded in x around inf 93.6%
*-commutative93.6%
Simplified93.6%
Taylor expanded in x around 0 8.6%
if 6.4000000000000003e153 < x Initial program 70.8%
sub-neg70.8%
+-commutative70.8%
add-cube-cbrt15.6%
distribute-lft-neg-in15.6%
fma-define4.5%
Applied egg-rr4.5%
Taylor expanded in x around inf 70.8%
distribute-rgt1-in70.8%
metadata-eval70.8%
mul0-lft70.8%
Simplified70.8%
(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.5%
sub-neg43.5%
+-commutative43.5%
add-cube-cbrt14.5%
distribute-lft-neg-in14.5%
fma-define8.6%
Applied egg-rr8.9%
Taylor expanded in x around inf 39.7%
distribute-rgt1-in39.7%
metadata-eval39.7%
mul0-lft39.7%
Simplified39.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 2024119
(FPCore (x)
:name "2isqrt (example 3.6)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:alt
(/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))
(- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))