
(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 11 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 (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 2e-9)
(* (+ (/ 0.5 x) (+ (/ 0.3125 (pow x 3.0)) (/ -0.375 (* x x)))) (pow x -0.5))
(fma
(- 0.0 (pow (+ 1.0 x) -0.3333333333333333))
(cbrt (pow (+ 1.0 x) -0.5))
(pow x -0.5))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 2e-9) {
tmp = ((0.5 / x) + ((0.3125 / pow(x, 3.0)) + (-0.375 / (x * x)))) * pow(x, -0.5);
} else {
tmp = fma((0.0 - pow((1.0 + x), -0.3333333333333333)), cbrt(pow((1.0 + x), -0.5)), pow(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-9) tmp = Float64(Float64(Float64(0.5 / x) + Float64(Float64(0.3125 / (x ^ 3.0)) + Float64(-0.375 / Float64(x * x)))) * (x ^ -0.5)); else tmp = fma(Float64(0.0 - (Float64(1.0 + x) ^ -0.3333333333333333)), cbrt((Float64(1.0 + x) ^ -0.5)), (x ^ -0.5)); end return 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-9], N[(N[(N[(0.5 / x), $MachinePrecision] + N[(N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(0.0 - N[Power[N[(1.0 + x), $MachinePrecision], -0.3333333333333333], $MachinePrecision]), $MachinePrecision] * N[Power[N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision], 1/3], $MachinePrecision] + N[Power[x, -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^{-9}:\\
\;\;\;\;\left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} + \frac{-0.375}{x \cdot x}\right)\right) \cdot {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0 - {\left(1 + x\right)}^{-0.3333333333333333}, \sqrt[3]{{\left(1 + x\right)}^{-0.5}}, {x}^{-0.5}\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 2.00000000000000012e-9Initial program 38.2%
frac-sub38.3%
div-inv38.3%
*-un-lft-identity38.3%
+-commutative38.3%
*-rgt-identity38.3%
metadata-eval38.3%
frac-times38.3%
un-div-inv38.3%
pow1/238.3%
pow-flip38.3%
metadata-eval38.3%
+-commutative38.3%
Applied egg-rr38.3%
associate-*r/38.3%
*-rgt-identity38.3%
times-frac38.3%
div-sub38.3%
*-inverses38.3%
unpow138.3%
sqr-pow38.3%
metadata-eval38.3%
exp-to-pow6.1%
metadata-eval6.1%
exp-to-pow6.0%
hypot-1-def6.0%
exp-to-pow38.3%
unpow1/238.3%
/-rgt-identity38.3%
Simplified38.3%
clear-num38.3%
inv-pow38.3%
hypot-1-def38.2%
add-sqr-sqrt38.2%
sqrt-undiv38.3%
Applied egg-rr38.3%
unpow-138.3%
Simplified38.3%
Taylor expanded in x around inf 99.7%
sub-neg99.7%
+-commutative99.7%
associate-+l+99.7%
associate-*r/99.7%
metadata-eval99.7%
associate-*r/99.7%
metadata-eval99.7%
associate-*r/99.7%
metadata-eval99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
unpow299.7%
Simplified99.7%
if 2.00000000000000012e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.4%
sub-neg99.4%
+-commutative99.4%
add-cube-cbrt99.4%
distribute-lft-neg-in99.4%
fma-def99.4%
Applied egg-rr99.9%
pow1/399.9%
inv-pow99.9%
pow-pow99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification99.8%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 2e-9) (* (+ (/ 0.5 x) (+ (/ 0.3125 (pow x 3.0)) (/ -0.375 (* x x)))) (pow x -0.5)) (* (pow x -0.5) (- 1.0 (sqrt (/ x (+ 1.0 x)))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 2e-9) {
tmp = ((0.5 / x) + ((0.3125 / pow(x, 3.0)) + (-0.375 / (x * x)))) * pow(x, -0.5);
} else {
tmp = pow(x, -0.5) * (1.0 - sqrt((x / (1.0 + x))));
}
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-9) then
tmp = ((0.5d0 / x) + ((0.3125d0 / (x ** 3.0d0)) + ((-0.375d0) / (x * x)))) * (x ** (-0.5d0))
else
tmp = (x ** (-0.5d0)) * (1.0d0 - sqrt((x / (1.0d0 + x))))
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-9) {
tmp = ((0.5 / x) + ((0.3125 / Math.pow(x, 3.0)) + (-0.375 / (x * x)))) * Math.pow(x, -0.5);
} else {
tmp = Math.pow(x, -0.5) * (1.0 - Math.sqrt((x / (1.0 + x))));
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 2e-9: tmp = ((0.5 / x) + ((0.3125 / math.pow(x, 3.0)) + (-0.375 / (x * x)))) * math.pow(x, -0.5) else: tmp = math.pow(x, -0.5) * (1.0 - math.sqrt((x / (1.0 + x)))) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 2e-9) tmp = Float64(Float64(Float64(0.5 / x) + Float64(Float64(0.3125 / (x ^ 3.0)) + Float64(-0.375 / Float64(x * x)))) * (x ^ -0.5)); else tmp = Float64((x ^ -0.5) * Float64(1.0 - sqrt(Float64(x / Float64(1.0 + x))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 2e-9) tmp = ((0.5 / x) + ((0.3125 / (x ^ 3.0)) + (-0.375 / (x * x)))) * (x ^ -0.5); else tmp = (x ^ -0.5) * (1.0 - sqrt((x / (1.0 + x)))); 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-9], N[(N[(N[(0.5 / x), $MachinePrecision] + N[(N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(1.0 - N[Sqrt[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} + \frac{-0.375}{x \cdot x}\right)\right) \cdot {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(1 - \sqrt{\frac{x}{1 + x}}\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 2.00000000000000012e-9Initial program 38.2%
frac-sub38.3%
div-inv38.3%
*-un-lft-identity38.3%
+-commutative38.3%
*-rgt-identity38.3%
metadata-eval38.3%
frac-times38.3%
un-div-inv38.3%
pow1/238.3%
pow-flip38.3%
metadata-eval38.3%
+-commutative38.3%
Applied egg-rr38.3%
associate-*r/38.3%
*-rgt-identity38.3%
times-frac38.3%
div-sub38.3%
*-inverses38.3%
unpow138.3%
sqr-pow38.3%
metadata-eval38.3%
exp-to-pow6.1%
metadata-eval6.1%
exp-to-pow6.0%
hypot-1-def6.0%
exp-to-pow38.3%
unpow1/238.3%
/-rgt-identity38.3%
Simplified38.3%
clear-num38.3%
inv-pow38.3%
hypot-1-def38.2%
add-sqr-sqrt38.2%
sqrt-undiv38.3%
Applied egg-rr38.3%
unpow-138.3%
Simplified38.3%
Taylor expanded in x around inf 99.7%
sub-neg99.7%
+-commutative99.7%
associate-+l+99.7%
associate-*r/99.7%
metadata-eval99.7%
associate-*r/99.7%
metadata-eval99.7%
associate-*r/99.7%
metadata-eval99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
unpow299.7%
Simplified99.7%
if 2.00000000000000012e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.4%
frac-sub99.4%
div-inv99.4%
*-un-lft-identity99.4%
+-commutative99.4%
*-rgt-identity99.4%
metadata-eval99.4%
frac-times99.4%
un-div-inv99.4%
pow1/299.4%
pow-flip99.9%
metadata-eval99.9%
+-commutative99.9%
Applied egg-rr99.9%
associate-*r/99.9%
*-rgt-identity99.9%
times-frac99.9%
div-sub99.9%
*-inverses99.9%
unpow199.9%
sqr-pow99.9%
metadata-eval99.9%
exp-to-pow99.9%
metadata-eval99.9%
exp-to-pow99.9%
hypot-1-def99.9%
exp-to-pow99.9%
unpow1/299.9%
/-rgt-identity99.9%
Simplified99.9%
expm1-log1p-u92.2%
expm1-udef92.1%
hypot-1-def92.1%
add-sqr-sqrt92.1%
sqrt-undiv92.1%
Applied egg-rr92.1%
expm1-def92.2%
expm1-log1p99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.8%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 2e-9) (* (pow x -0.5) (- (/ 0.5 x) (/ 0.375 (* x x)))) (* (pow x -0.5) (- 1.0 (sqrt (/ x (+ 1.0 x)))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 2e-9) {
tmp = pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
} else {
tmp = pow(x, -0.5) * (1.0 - sqrt((x / (1.0 + x))));
}
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-9) then
tmp = (x ** (-0.5d0)) * ((0.5d0 / x) - (0.375d0 / (x * x)))
else
tmp = (x ** (-0.5d0)) * (1.0d0 - sqrt((x / (1.0d0 + x))))
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-9) {
tmp = Math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
} else {
tmp = Math.pow(x, -0.5) * (1.0 - Math.sqrt((x / (1.0 + x))));
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 2e-9: tmp = math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x))) else: tmp = math.pow(x, -0.5) * (1.0 - math.sqrt((x / (1.0 + x)))) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 2e-9) tmp = Float64((x ^ -0.5) * Float64(Float64(0.5 / x) - Float64(0.375 / Float64(x * x)))); else tmp = Float64((x ^ -0.5) * Float64(1.0 - sqrt(Float64(x / Float64(1.0 + x))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 2e-9) tmp = (x ^ -0.5) * ((0.5 / x) - (0.375 / (x * x))); else tmp = (x ^ -0.5) * (1.0 - sqrt((x / (1.0 + x)))); 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-9], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(0.5 / x), $MachinePrecision] - N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(1.0 - N[Sqrt[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} - \frac{0.375}{x \cdot x}\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(1 - \sqrt{\frac{x}{1 + x}}\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 2.00000000000000012e-9Initial program 38.2%
frac-sub38.3%
div-inv38.3%
*-un-lft-identity38.3%
+-commutative38.3%
*-rgt-identity38.3%
metadata-eval38.3%
frac-times38.3%
un-div-inv38.3%
pow1/238.3%
pow-flip38.3%
metadata-eval38.3%
+-commutative38.3%
Applied egg-rr38.3%
associate-*r/38.3%
*-rgt-identity38.3%
times-frac38.3%
div-sub38.3%
*-inverses38.3%
unpow138.3%
sqr-pow38.3%
metadata-eval38.3%
exp-to-pow6.1%
metadata-eval6.1%
exp-to-pow6.0%
hypot-1-def6.0%
exp-to-pow38.3%
unpow1/238.3%
/-rgt-identity38.3%
Simplified38.3%
clear-num38.3%
inv-pow38.3%
hypot-1-def38.2%
add-sqr-sqrt38.2%
sqrt-undiv38.3%
Applied egg-rr38.3%
unpow-138.3%
Simplified38.3%
Taylor expanded in x around inf 99.5%
associate-*r/99.5%
metadata-eval99.5%
associate-*r/99.5%
metadata-eval99.5%
unpow299.5%
Simplified99.5%
if 2.00000000000000012e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.4%
frac-sub99.4%
div-inv99.4%
*-un-lft-identity99.4%
+-commutative99.4%
*-rgt-identity99.4%
metadata-eval99.4%
frac-times99.4%
un-div-inv99.4%
pow1/299.4%
pow-flip99.9%
metadata-eval99.9%
+-commutative99.9%
Applied egg-rr99.9%
associate-*r/99.9%
*-rgt-identity99.9%
times-frac99.9%
div-sub99.9%
*-inverses99.9%
unpow199.9%
sqr-pow99.9%
metadata-eval99.9%
exp-to-pow99.9%
metadata-eval99.9%
exp-to-pow99.9%
hypot-1-def99.9%
exp-to-pow99.9%
unpow1/299.9%
/-rgt-identity99.9%
Simplified99.9%
expm1-log1p-u92.2%
expm1-udef92.1%
hypot-1-def92.1%
add-sqr-sqrt92.1%
sqrt-undiv92.1%
Applied egg-rr92.1%
expm1-def92.2%
expm1-log1p99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.7%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 2e-9) (* (pow x -0.5) (- (/ 0.5 x) (/ 0.375 (* x x)))) (- (pow x -0.5) (pow (+ 1.0 x) -0.5))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 2e-9) {
tmp = pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
} else {
tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((1.0d0 + x)))) <= 2d-9) then
tmp = (x ** (-0.5d0)) * ((0.5d0 / x) - (0.375d0 / (x * x)))
else
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / Math.sqrt((1.0 + x)))) <= 2e-9) {
tmp = Math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
} else {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 2e-9: tmp = math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x))) else: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 2e-9) tmp = Float64((x ^ -0.5) * Float64(Float64(0.5 / x) - Float64(0.375 / Float64(x * x)))); else tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 2e-9) tmp = (x ^ -0.5) * ((0.5 / x) - (0.375 / (x * x))); else tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e-9], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(0.5 / x), $MachinePrecision] - N[(0.375 / N[(x * 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^{-9}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} - \frac{0.375}{x \cdot x}\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 2.00000000000000012e-9Initial program 38.2%
frac-sub38.3%
div-inv38.3%
*-un-lft-identity38.3%
+-commutative38.3%
*-rgt-identity38.3%
metadata-eval38.3%
frac-times38.3%
un-div-inv38.3%
pow1/238.3%
pow-flip38.3%
metadata-eval38.3%
+-commutative38.3%
Applied egg-rr38.3%
associate-*r/38.3%
*-rgt-identity38.3%
times-frac38.3%
div-sub38.3%
*-inverses38.3%
unpow138.3%
sqr-pow38.3%
metadata-eval38.3%
exp-to-pow6.1%
metadata-eval6.1%
exp-to-pow6.0%
hypot-1-def6.0%
exp-to-pow38.3%
unpow1/238.3%
/-rgt-identity38.3%
Simplified38.3%
clear-num38.3%
inv-pow38.3%
hypot-1-def38.2%
add-sqr-sqrt38.2%
sqrt-undiv38.3%
Applied egg-rr38.3%
unpow-138.3%
Simplified38.3%
Taylor expanded in x around inf 99.5%
associate-*r/99.5%
metadata-eval99.5%
associate-*r/99.5%
metadata-eval99.5%
unpow299.5%
Simplified99.5%
if 2.00000000000000012e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.4%
*-un-lft-identity99.4%
clear-num99.4%
associate-/r/99.4%
prod-diff99.4%
*-un-lft-identity99.4%
fma-neg99.4%
*-un-lft-identity99.4%
inv-pow99.4%
sqrt-pow299.9%
metadata-eval99.9%
pow1/299.9%
pow-flip99.9%
+-commutative99.9%
metadata-eval99.9%
Applied egg-rr99.9%
fma-udef99.9%
neg-mul-199.9%
rem-log-exp99.9%
log-rec99.9%
+-commutative99.9%
log-rec99.9%
rem-log-exp99.9%
sub-neg99.9%
+-inverses99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.7%
(FPCore (x) :precision binary64 (if (<= x 1.42) (+ (pow x -0.5) (/ -1.0 (+ 1.0 (* x 0.5)))) (* (pow x -0.5) (- (/ 0.5 x) (/ 0.375 (* x x))))))
double code(double x) {
double tmp;
if (x <= 1.42) {
tmp = pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5)));
} else {
tmp = pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.42d0) then
tmp = (x ** (-0.5d0)) + ((-1.0d0) / (1.0d0 + (x * 0.5d0)))
else
tmp = (x ** (-0.5d0)) * ((0.5d0 / x) - (0.375d0 / (x * x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.42) {
tmp = Math.pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5)));
} else {
tmp = Math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.42: tmp = math.pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5))) else: tmp = math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x))) return tmp
function code(x) tmp = 0.0 if (x <= 1.42) tmp = Float64((x ^ -0.5) + Float64(-1.0 / Float64(1.0 + Float64(x * 0.5)))); else tmp = Float64((x ^ -0.5) * Float64(Float64(0.5 / x) - Float64(0.375 / Float64(x * x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.42) tmp = (x ^ -0.5) + (-1.0 / (1.0 + (x * 0.5))); else tmp = (x ^ -0.5) * ((0.5 / x) - (0.375 / (x * x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.42], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 / N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(0.5 / x), $MachinePrecision] - N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.42:\\
\;\;\;\;{x}^{-0.5} + \frac{-1}{1 + x \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} - \frac{0.375}{x \cdot x}\right)\\
\end{array}
\end{array}
if x < 1.4199999999999999Initial program 99.5%
Taylor expanded in x around 0 99.0%
*-commutative99.0%
Simplified99.0%
add-log-exp4.0%
*-un-lft-identity4.0%
log-prod4.0%
metadata-eval4.0%
add-log-exp99.0%
pow1/299.0%
pow-flip99.5%
metadata-eval99.5%
Applied egg-rr99.5%
+-lft-identity99.5%
Simplified99.5%
if 1.4199999999999999 < x Initial program 39.2%
frac-sub39.3%
div-inv39.3%
*-un-lft-identity39.3%
+-commutative39.3%
*-rgt-identity39.3%
metadata-eval39.3%
frac-times39.3%
un-div-inv39.3%
pow1/239.3%
pow-flip39.3%
metadata-eval39.3%
+-commutative39.3%
Applied egg-rr39.3%
associate-*r/39.3%
*-rgt-identity39.3%
times-frac39.3%
div-sub39.3%
*-inverses39.3%
unpow139.3%
sqr-pow39.3%
metadata-eval39.3%
exp-to-pow7.7%
metadata-eval7.7%
exp-to-pow7.6%
hypot-1-def7.6%
exp-to-pow39.3%
unpow1/239.3%
/-rgt-identity39.3%
Simplified39.3%
clear-num39.3%
inv-pow39.3%
hypot-1-def39.3%
add-sqr-sqrt39.3%
sqrt-undiv39.3%
Applied egg-rr39.3%
unpow-139.3%
Simplified39.3%
Taylor expanded in x around inf 98.3%
associate-*r/98.3%
metadata-eval98.3%
associate-*r/98.3%
metadata-eval98.3%
unpow298.3%
Simplified98.3%
Final simplification99.0%
(FPCore (x) :precision binary64 (if (<= x 1.7) (+ (pow x -0.5) (/ -1.0 (+ 1.0 (* x 0.5)))) (* 0.5 (pow x -1.5))))
double code(double x) {
double tmp;
if (x <= 1.7) {
tmp = pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5)));
} else {
tmp = 0.5 * pow(x, -1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.7d0) then
tmp = (x ** (-0.5d0)) + ((-1.0d0) / (1.0d0 + (x * 0.5d0)))
else
tmp = 0.5d0 * (x ** (-1.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.7) {
tmp = Math.pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5)));
} else {
tmp = 0.5 * Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.7: tmp = math.pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5))) else: tmp = 0.5 * math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 1.7) tmp = Float64((x ^ -0.5) + Float64(-1.0 / Float64(1.0 + Float64(x * 0.5)))); else tmp = Float64(0.5 * (x ^ -1.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.7) tmp = (x ^ -0.5) + (-1.0 / (1.0 + (x * 0.5))); else tmp = 0.5 * (x ^ -1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.7], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 / N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.7:\\
\;\;\;\;{x}^{-0.5} + \frac{-1}{1 + x \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\end{array}
if x < 1.69999999999999996Initial program 99.5%
Taylor expanded in x around 0 99.0%
*-commutative99.0%
Simplified99.0%
add-log-exp4.0%
*-un-lft-identity4.0%
log-prod4.0%
metadata-eval4.0%
add-log-exp99.0%
pow1/299.0%
pow-flip99.5%
metadata-eval99.5%
Applied egg-rr99.5%
+-lft-identity99.5%
Simplified99.5%
if 1.69999999999999996 < x Initial program 39.2%
flip--39.3%
div-inv39.3%
frac-times25.8%
metadata-eval25.8%
add-sqr-sqrt23.6%
frac-times21.4%
metadata-eval21.4%
add-sqr-sqrt39.5%
+-commutative39.5%
pow1/239.5%
pow-flip39.5%
metadata-eval39.5%
inv-pow39.5%
sqrt-pow239.5%
+-commutative39.5%
metadata-eval39.5%
Applied egg-rr39.5%
frac-sub40.4%
*-un-lft-identity40.4%
Applied egg-rr40.4%
*-rgt-identity40.4%
associate--l+84.2%
+-inverses84.2%
metadata-eval84.2%
distribute-lft-in84.2%
*-rgt-identity84.2%
Simplified84.2%
Taylor expanded in x around inf 60.9%
unpow-160.9%
exp-to-pow58.8%
*-commutative58.8%
log-pow59.2%
associate-*r*59.2%
metadata-eval59.2%
*-commutative59.2%
exp-to-pow61.5%
metadata-eval61.5%
pow-sqr61.6%
rem-sqrt-square97.5%
rem-square-sqrt97.0%
fabs-sqr97.0%
rem-square-sqrt97.5%
Simplified97.5%
Final simplification98.6%
(FPCore (x) :precision binary64 (if (<= x 1.0) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (* 0.5 (pow x -1.5))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = 0.5 * pow(x, -1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.0d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = 0.5d0 * (x ** (-1.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = 0.5 * Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = 0.5 * math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); else tmp = Float64(0.5 * (x ^ -1.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = 0.5 * (x ^ -1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\end{array}
if x < 1Initial program 99.5%
inv-pow99.5%
pow1/299.5%
pow-pow100.0%
add-exp-log92.1%
pow-exp92.1%
metadata-eval92.1%
Applied egg-rr92.1%
Taylor expanded in x around 0 99.5%
if 1 < x Initial program 39.2%
flip--39.3%
div-inv39.3%
frac-times25.8%
metadata-eval25.8%
add-sqr-sqrt23.6%
frac-times21.4%
metadata-eval21.4%
add-sqr-sqrt39.5%
+-commutative39.5%
pow1/239.5%
pow-flip39.5%
metadata-eval39.5%
inv-pow39.5%
sqrt-pow239.5%
+-commutative39.5%
metadata-eval39.5%
Applied egg-rr39.5%
frac-sub40.4%
*-un-lft-identity40.4%
Applied egg-rr40.4%
*-rgt-identity40.4%
associate--l+84.2%
+-inverses84.2%
metadata-eval84.2%
distribute-lft-in84.2%
*-rgt-identity84.2%
Simplified84.2%
Taylor expanded in x around inf 60.9%
unpow-160.9%
exp-to-pow58.8%
*-commutative58.8%
log-pow59.2%
associate-*r*59.2%
metadata-eval59.2%
*-commutative59.2%
exp-to-pow61.5%
metadata-eval61.5%
pow-sqr61.6%
rem-sqrt-square97.5%
rem-square-sqrt97.0%
fabs-sqr97.0%
rem-square-sqrt97.5%
Simplified97.5%
Final simplification98.6%
(FPCore (x) :precision binary64 (if (<= x 0.5) (pow x -0.5) (* 0.5 (pow x -1.5))))
double code(double x) {
double tmp;
if (x <= 0.5) {
tmp = pow(x, -0.5);
} else {
tmp = 0.5 * pow(x, -1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.5d0) then
tmp = x ** (-0.5d0)
else
tmp = 0.5d0 * (x ** (-1.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.5) {
tmp = Math.pow(x, -0.5);
} else {
tmp = 0.5 * Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.5: tmp = math.pow(x, -0.5) else: tmp = 0.5 * math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 0.5) tmp = x ^ -0.5; else tmp = Float64(0.5 * (x ^ -1.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.5) tmp = x ^ -0.5; else tmp = 0.5 * (x ^ -1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.5], N[Power[x, -0.5], $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.5:\\
\;\;\;\;{x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\end{array}
if x < 0.5Initial program 99.5%
inv-pow99.5%
pow1/299.5%
pow-pow100.0%
add-exp-log92.1%
pow-exp92.1%
metadata-eval92.1%
Applied egg-rr92.1%
Taylor expanded in x around inf 97.3%
pow1/297.3%
inv-pow97.3%
pow-pow97.5%
metadata-eval97.5%
expm1-log1p-u89.9%
expm1-udef89.9%
Applied egg-rr89.9%
expm1-def89.9%
expm1-log1p97.5%
Simplified97.5%
if 0.5 < x Initial program 39.8%
flip--39.9%
div-inv39.9%
frac-times26.4%
metadata-eval26.4%
add-sqr-sqrt24.3%
frac-times22.1%
metadata-eval22.1%
add-sqr-sqrt40.0%
+-commutative40.0%
pow1/240.0%
pow-flip40.0%
metadata-eval40.0%
inv-pow40.0%
sqrt-pow240.0%
+-commutative40.0%
metadata-eval40.0%
Applied egg-rr40.0%
frac-sub40.9%
*-un-lft-identity40.9%
Applied egg-rr40.9%
*-rgt-identity40.9%
associate--l+84.3%
+-inverses84.3%
metadata-eval84.3%
distribute-lft-in84.3%
*-rgt-identity84.3%
Simplified84.3%
Taylor expanded in x around inf 60.5%
unpow-160.5%
exp-to-pow58.4%
*-commutative58.4%
log-pow58.9%
associate-*r*58.9%
metadata-eval58.9%
*-commutative58.9%
exp-to-pow61.1%
metadata-eval61.1%
pow-sqr61.2%
rem-sqrt-square96.7%
rem-square-sqrt96.3%
fabs-sqr96.3%
rem-square-sqrt96.7%
Simplified96.7%
Final simplification97.2%
(FPCore (x) :precision binary64 (if (<= x 0.68) (+ (pow x -0.5) -1.0) (* 0.5 (pow x -1.5))))
double code(double x) {
double tmp;
if (x <= 0.68) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = 0.5 * pow(x, -1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.68d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = 0.5d0 * (x ** (-1.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.68) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = 0.5 * Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.68: tmp = math.pow(x, -0.5) + -1.0 else: tmp = 0.5 * math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 0.68) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(0.5 * (x ^ -1.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.68) tmp = (x ^ -0.5) + -1.0; else tmp = 0.5 * (x ^ -1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.68], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\end{array}
if x < 0.680000000000000049Initial program 99.5%
inv-pow99.5%
pow1/299.5%
pow-pow100.0%
add-exp-log92.1%
pow-exp92.1%
metadata-eval92.1%
Applied egg-rr92.1%
Taylor expanded in x around 0 99.4%
if 0.680000000000000049 < x Initial program 39.2%
flip--39.3%
div-inv39.3%
frac-times25.8%
metadata-eval25.8%
add-sqr-sqrt23.6%
frac-times21.4%
metadata-eval21.4%
add-sqr-sqrt39.5%
+-commutative39.5%
pow1/239.5%
pow-flip39.5%
metadata-eval39.5%
inv-pow39.5%
sqrt-pow239.5%
+-commutative39.5%
metadata-eval39.5%
Applied egg-rr39.5%
frac-sub40.4%
*-un-lft-identity40.4%
Applied egg-rr40.4%
*-rgt-identity40.4%
associate--l+84.2%
+-inverses84.2%
metadata-eval84.2%
distribute-lft-in84.2%
*-rgt-identity84.2%
Simplified84.2%
Taylor expanded in x around inf 60.9%
unpow-160.9%
exp-to-pow58.8%
*-commutative58.8%
log-pow59.2%
associate-*r*59.2%
metadata-eval59.2%
*-commutative59.2%
exp-to-pow61.5%
metadata-eval61.5%
pow-sqr61.6%
rem-sqrt-square97.5%
rem-square-sqrt97.0%
fabs-sqr97.0%
rem-square-sqrt97.5%
Simplified97.5%
Final simplification98.6%
(FPCore (x) :precision binary64 (pow x -0.5))
double code(double x) {
return pow(x, -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x ** (-0.5d0)
end function
public static double code(double x) {
return Math.pow(x, -0.5);
}
def code(x): return math.pow(x, -0.5)
function code(x) return x ^ -0.5 end
function tmp = code(x) tmp = x ^ -0.5; end
code[x_] := N[Power[x, -0.5], $MachinePrecision]
\begin{array}{l}
\\
{x}^{-0.5}
\end{array}
Initial program 74.1%
inv-pow74.1%
pow1/274.1%
pow-pow70.9%
add-exp-log56.4%
pow-exp56.4%
metadata-eval56.4%
Applied egg-rr56.4%
Taylor expanded in x around inf 58.2%
pow1/258.2%
inv-pow58.2%
pow-pow58.4%
metadata-eval58.4%
expm1-log1p-u54.0%
expm1-udef67.1%
Applied egg-rr67.1%
expm1-def54.0%
expm1-log1p58.4%
Simplified58.4%
Final simplification58.4%
(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 74.1%
Taylor expanded in x around 0 58.3%
Taylor expanded in x around inf 1.8%
Final simplification1.8%
(FPCore (x) :precision binary64 (/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0))))))
double code(double x) {
return 1.0 / (((x + 1.0) * sqrt(x)) + (x * sqrt((x + 1.0))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (((x + 1.0d0) * sqrt(x)) + (x * sqrt((x + 1.0d0))))
end function
public static double code(double x) {
return 1.0 / (((x + 1.0) * Math.sqrt(x)) + (x * Math.sqrt((x + 1.0))));
}
def code(x): return 1.0 / (((x + 1.0) * math.sqrt(x)) + (x * math.sqrt((x + 1.0))))
function code(x) return Float64(1.0 / Float64(Float64(Float64(x + 1.0) * sqrt(x)) + Float64(x * sqrt(Float64(x + 1.0))))) end
function tmp = code(x) tmp = 1.0 / (((x + 1.0) * sqrt(x)) + (x * sqrt((x + 1.0)))); end
code[x_] := N[(1.0 / N[(N[(N[(x + 1.0), $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(x * N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}
\end{array}
herbie shell --seed 2023275
(FPCore (x)
:name "2isqrt (example 3.6)"
:precision binary64
:herbie-target
(/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))
(- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))