
(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
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 2e-7)
(/
(*
(+ 1.0 (- x x))
(/ 1.0 (+ 0.5 (- (+ x (/ 0.0625 (pow x 2.0))) (/ 0.125 x)))))
(+ (sqrt x) t_0))
(- (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-7) {
tmp = ((1.0 + (x - x)) * (1.0 / (0.5 + ((x + (0.0625 / pow(x, 2.0))) - (0.125 / x))))) / (sqrt(x) + t_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) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 2d-7) then
tmp = ((1.0d0 + (x - x)) * (1.0d0 / (0.5d0 + ((x + (0.0625d0 / (x ** 2.0d0))) - (0.125d0 / x))))) / (sqrt(x) + t_0)
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-7) {
tmp = ((1.0 + (x - x)) * (1.0 / (0.5 + ((x + (0.0625 / Math.pow(x, 2.0))) - (0.125 / x))))) / (Math.sqrt(x) + t_0);
} 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-7: tmp = ((1.0 + (x - x)) * (1.0 / (0.5 + ((x + (0.0625 / math.pow(x, 2.0))) - (0.125 / x))))) / (math.sqrt(x) + t_0) 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-7) tmp = Float64(Float64(Float64(1.0 + Float64(x - x)) * Float64(1.0 / Float64(0.5 + Float64(Float64(x + Float64(0.0625 / (x ^ 2.0))) - Float64(0.125 / x))))) / Float64(sqrt(x) + t_0)); 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-7) tmp = ((1.0 + (x - x)) * (1.0 / (0.5 + ((x + (0.0625 / (x ^ 2.0))) - (0.125 / x))))) / (sqrt(x) + t_0); 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-7], N[(N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(0.5 + N[(N[(x + N[(0.0625 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] + t$95$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}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\frac{\left(1 + \left(x - x\right)\right) \cdot \frac{1}{0.5 + \left(\left(x + \frac{0.0625}{{x}^{2}}\right) - \frac{0.125}{x}\right)}}{\sqrt{x} + t_0}\\
\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)))) < 1.9999999999999999e-7Initial program 45.0%
frac-sub45.1%
div-inv45.1%
*-un-lft-identity45.1%
*-rgt-identity45.1%
flip--46.2%
metadata-eval46.2%
frac-times46.2%
associate-*l/46.2%
Applied egg-rr83.1%
Taylor expanded in x around inf 99.6%
associate--l+99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*r/99.6%
metadata-eval99.6%
Simplified99.6%
if 1.9999999999999999e-7 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.6%
expm1-log1p-u99.6%
expm1-udef99.6%
associate--r-99.6%
pow1/299.6%
pow-flip99.9%
metadata-eval99.9%
pow1/299.9%
pow-flip99.9%
+-commutative99.9%
metadata-eval99.9%
Applied egg-rr99.9%
associate-+l-99.9%
expm1-def99.9%
expm1-log1p99.9%
Simplified99.9%
Final simplification99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 2e-7)
(/
(* (+ 1.0 (- x x)) (/ 1.0 (+ x (+ 0.5 (/ -0.125 x)))))
(+ (sqrt x) t_0))
(- (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-7) {
tmp = ((1.0 + (x - x)) * (1.0 / (x + (0.5 + (-0.125 / x))))) / (sqrt(x) + t_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) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 2d-7) then
tmp = ((1.0d0 + (x - x)) * (1.0d0 / (x + (0.5d0 + ((-0.125d0) / x))))) / (sqrt(x) + t_0)
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-7) {
tmp = ((1.0 + (x - x)) * (1.0 / (x + (0.5 + (-0.125 / x))))) / (Math.sqrt(x) + t_0);
} 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-7: tmp = ((1.0 + (x - x)) * (1.0 / (x + (0.5 + (-0.125 / x))))) / (math.sqrt(x) + t_0) 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-7) tmp = Float64(Float64(Float64(1.0 + Float64(x - x)) * Float64(1.0 / Float64(x + Float64(0.5 + Float64(-0.125 / x))))) / Float64(sqrt(x) + t_0)); 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-7) tmp = ((1.0 + (x - x)) * (1.0 / (x + (0.5 + (-0.125 / x))))) / (sqrt(x) + t_0); 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-7], N[(N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(x + N[(0.5 + N[(-0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] + t$95$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}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\frac{\left(1 + \left(x - x\right)\right) \cdot \frac{1}{x + \left(0.5 + \frac{-0.125}{x}\right)}}{\sqrt{x} + t_0}\\
\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)))) < 1.9999999999999999e-7Initial program 45.0%
frac-sub45.1%
div-inv45.1%
*-un-lft-identity45.1%
*-rgt-identity45.1%
flip--46.2%
metadata-eval46.2%
frac-times46.2%
associate-*l/46.2%
Applied egg-rr83.1%
Taylor expanded in x around inf 99.6%
cancel-sign-sub-inv99.6%
+-commutative99.6%
associate-+l+99.6%
associate-*r/99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
if 1.9999999999999999e-7 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.6%
expm1-log1p-u99.6%
expm1-udef99.6%
associate--r-99.6%
pow1/299.6%
pow-flip99.9%
metadata-eval99.9%
pow1/299.9%
pow-flip99.9%
+-commutative99.9%
metadata-eval99.9%
Applied egg-rr99.9%
associate-+l-99.9%
expm1-def99.9%
expm1-log1p99.9%
Simplified99.9%
Final simplification99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 1e-14)
(/ (* (+ 1.0 (- x x)) (/ 1.0 (+ x 0.5))) (+ (sqrt x) t_0))
(- (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)) <= 1e-14) {
tmp = ((1.0 + (x - x)) * (1.0 / (x + 0.5))) / (sqrt(x) + t_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) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 1d-14) then
tmp = ((1.0d0 + (x - x)) * (1.0d0 / (x + 0.5d0))) / (sqrt(x) + t_0)
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)) <= 1e-14) {
tmp = ((1.0 + (x - x)) * (1.0 / (x + 0.5))) / (Math.sqrt(x) + t_0);
} 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)) <= 1e-14: tmp = ((1.0 + (x - x)) * (1.0 / (x + 0.5))) / (math.sqrt(x) + t_0) 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)) <= 1e-14) tmp = Float64(Float64(Float64(1.0 + Float64(x - x)) * Float64(1.0 / Float64(x + 0.5))) / Float64(sqrt(x) + t_0)); 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)) <= 1e-14) tmp = ((1.0 + (x - x)) * (1.0 / (x + 0.5))) / (sqrt(x) + t_0); 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], 1e-14], N[(N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] + t$95$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}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 10^{-14}:\\
\;\;\;\;\frac{\left(1 + \left(x - x\right)\right) \cdot \frac{1}{x + 0.5}}{\sqrt{x} + t_0}\\
\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)))) < 9.99999999999999999e-15Initial program 44.7%
frac-sub44.8%
div-inv44.8%
*-un-lft-identity44.8%
*-rgt-identity44.8%
flip--45.8%
metadata-eval45.8%
frac-times45.8%
associate-*l/45.8%
Applied egg-rr82.9%
Taylor expanded in x around inf 99.7%
+-commutative99.7%
Simplified99.7%
if 9.99999999999999999e-15 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.4%
expm1-log1p-u99.4%
expm1-udef99.3%
associate--r-99.3%
pow1/299.3%
pow-flip99.7%
metadata-eval99.7%
pow1/299.7%
pow-flip99.7%
+-commutative99.7%
metadata-eval99.7%
Applied egg-rr99.7%
associate-+l-99.7%
expm1-def99.8%
expm1-log1p99.8%
Simplified99.8%
Final simplification99.7%
(FPCore (x) :precision binary64 (/ (* (+ 1.0 (- x x)) (* (pow (+ 1.0 x) -0.5) (pow x -0.5))) (+ (sqrt x) (sqrt (+ 1.0 x)))))
double code(double x) {
return ((1.0 + (x - x)) * (pow((1.0 + x), -0.5) * pow(x, -0.5))) / (sqrt(x) + sqrt((1.0 + x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 + (x - x)) * (((1.0d0 + x) ** (-0.5d0)) * (x ** (-0.5d0)))) / (sqrt(x) + sqrt((1.0d0 + x)))
end function
public static double code(double x) {
return ((1.0 + (x - x)) * (Math.pow((1.0 + x), -0.5) * Math.pow(x, -0.5))) / (Math.sqrt(x) + Math.sqrt((1.0 + x)));
}
def code(x): return ((1.0 + (x - x)) * (math.pow((1.0 + x), -0.5) * math.pow(x, -0.5))) / (math.sqrt(x) + math.sqrt((1.0 + x)))
function code(x) return Float64(Float64(Float64(1.0 + Float64(x - x)) * Float64((Float64(1.0 + x) ^ -0.5) * (x ^ -0.5))) / Float64(sqrt(x) + sqrt(Float64(1.0 + x)))) end
function tmp = code(x) tmp = ((1.0 + (x - x)) * (((1.0 + x) ^ -0.5) * (x ^ -0.5))) / (sqrt(x) + sqrt((1.0 + x))); end
code[x_] := N[(N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] * N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \left(x - x\right)\right) \cdot \left({\left(1 + x\right)}^{-0.5} \cdot {x}^{-0.5}\right)}{\sqrt{x} + \sqrt{1 + x}}
\end{array}
Initial program 74.9%
frac-sub74.9%
div-inv74.9%
*-un-lft-identity74.9%
*-rgt-identity74.9%
flip--75.4%
metadata-eval75.4%
frac-times75.4%
associate-*l/75.4%
Applied egg-rr92.1%
metadata-eval92.1%
*-un-lft-identity92.1%
unpow292.1%
distribute-rgt-out92.1%
sqrt-unprod99.5%
frac-times99.5%
+-commutative99.5%
*-commutative99.5%
+-commutative99.5%
pow1/299.5%
pow-flip99.5%
+-commutative99.5%
metadata-eval99.5%
pow1/299.5%
pow-flip99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x) :precision binary64 (/ 1.0 (* (+ (sqrt x) (sqrt (+ 1.0 x))) (hypot x (sqrt x)))))
double code(double x) {
return 1.0 / ((sqrt(x) + sqrt((1.0 + x))) * hypot(x, sqrt(x)));
}
public static double code(double x) {
return 1.0 / ((Math.sqrt(x) + Math.sqrt((1.0 + x))) * Math.hypot(x, Math.sqrt(x)));
}
def code(x): return 1.0 / ((math.sqrt(x) + math.sqrt((1.0 + x))) * math.hypot(x, math.sqrt(x)))
function code(x) return Float64(1.0 / Float64(Float64(sqrt(x) + sqrt(Float64(1.0 + x))) * hypot(x, sqrt(x)))) end
function tmp = code(x) tmp = 1.0 / ((sqrt(x) + sqrt((1.0 + x))) * hypot(x, sqrt(x))); end
code[x_] := N[(1.0 / N[(N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[x ^ 2 + N[Sqrt[x], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\left(\sqrt{x} + \sqrt{1 + x}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)}
\end{array}
Initial program 74.9%
frac-sub74.9%
div-inv74.9%
*-un-lft-identity74.9%
*-rgt-identity74.9%
flip--75.4%
metadata-eval75.4%
frac-times75.4%
associate-*l/75.4%
Applied egg-rr92.1%
expm1-log1p-u88.4%
expm1-udef70.7%
Applied egg-rr70.7%
expm1-def95.1%
expm1-log1p98.8%
*-commutative98.8%
Simplified98.8%
Final simplification98.8%
(FPCore (x) :precision binary64 (/ (/ 1.0 (+ (sqrt x) (sqrt (+ 1.0 x)))) (hypot x (sqrt x))))
double code(double x) {
return (1.0 / (sqrt(x) + sqrt((1.0 + x)))) / hypot(x, sqrt(x));
}
public static double code(double x) {
return (1.0 / (Math.sqrt(x) + Math.sqrt((1.0 + x)))) / Math.hypot(x, Math.sqrt(x));
}
def code(x): return (1.0 / (math.sqrt(x) + math.sqrt((1.0 + x)))) / math.hypot(x, math.sqrt(x))
function code(x) return Float64(Float64(1.0 / Float64(sqrt(x) + sqrt(Float64(1.0 + x)))) / hypot(x, sqrt(x))) end
function tmp = code(x) tmp = (1.0 / (sqrt(x) + sqrt((1.0 + x)))) / hypot(x, sqrt(x)); end
code[x_] := N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[x ^ 2 + N[Sqrt[x], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}{\mathsf{hypot}\left(x, \sqrt{x}\right)}
\end{array}
Initial program 74.9%
frac-sub74.9%
div-inv74.9%
*-un-lft-identity74.9%
*-rgt-identity74.9%
flip--75.4%
metadata-eval75.4%
frac-times75.4%
associate-*l/75.4%
Applied egg-rr92.1%
expm1-log1p-u88.4%
expm1-udef70.7%
Applied egg-rr70.7%
expm1-def95.1%
expm1-log1p98.8%
associate-/r*99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x) :precision binary64 (if (<= x 5e+90) (/ (/ (/ 1.0 x) (+ 1.0 x)) (+ (pow (+ 1.0 x) -0.5) (pow x -0.5))) (/ (/ 1.0 (+ (sqrt x) (sqrt (+ 1.0 x)))) x)))
double code(double x) {
double tmp;
if (x <= 5e+90) {
tmp = ((1.0 / x) / (1.0 + x)) / (pow((1.0 + x), -0.5) + pow(x, -0.5));
} else {
tmp = (1.0 / (sqrt(x) + sqrt((1.0 + x)))) / x;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 5d+90) then
tmp = ((1.0d0 / x) / (1.0d0 + x)) / (((1.0d0 + x) ** (-0.5d0)) + (x ** (-0.5d0)))
else
tmp = (1.0d0 / (sqrt(x) + sqrt((1.0d0 + x)))) / x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 5e+90) {
tmp = ((1.0 / x) / (1.0 + x)) / (Math.pow((1.0 + x), -0.5) + Math.pow(x, -0.5));
} else {
tmp = (1.0 / (Math.sqrt(x) + Math.sqrt((1.0 + x)))) / x;
}
return tmp;
}
def code(x): tmp = 0 if x <= 5e+90: tmp = ((1.0 / x) / (1.0 + x)) / (math.pow((1.0 + x), -0.5) + math.pow(x, -0.5)) else: tmp = (1.0 / (math.sqrt(x) + math.sqrt((1.0 + x)))) / x return tmp
function code(x) tmp = 0.0 if (x <= 5e+90) tmp = Float64(Float64(Float64(1.0 / x) / Float64(1.0 + x)) / Float64((Float64(1.0 + x) ^ -0.5) + (x ^ -0.5))); else tmp = Float64(Float64(1.0 / Float64(sqrt(x) + sqrt(Float64(1.0 + x)))) / x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 5e+90) tmp = ((1.0 / x) / (1.0 + x)) / (((1.0 + x) ^ -0.5) + (x ^ -0.5)); else tmp = (1.0 / (sqrt(x) + sqrt((1.0 + x)))) / x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 5e+90], N[(N[(N[(1.0 / x), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] + N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + 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^{+90}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{1 + x}}{{\left(1 + x\right)}^{-0.5} + {x}^{-0.5}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}{x}\\
\end{array}
\end{array}
if x < 5.0000000000000004e90Initial program 86.0%
add-sqr-sqrt85.5%
sqrt-unprod86.0%
frac-times85.9%
metadata-eval85.9%
add-sqr-sqrt86.2%
Applied egg-rr86.2%
Applied egg-rr85.8%
+-commutative85.8%
frac-sub87.1%
associate-/r*87.1%
*-un-lft-identity87.1%
*-rgt-identity87.1%
associate-+r-99.2%
+-inverses99.2%
metadata-eval99.2%
+-commutative99.2%
Applied egg-rr99.2%
if 5.0000000000000004e90 < x Initial program 54.3%
frac-sub54.3%
div-inv54.3%
*-un-lft-identity54.3%
*-rgt-identity54.3%
flip--54.3%
metadata-eval54.3%
frac-times54.3%
associate-*l/54.3%
Applied egg-rr78.3%
expm1-log1p-u78.3%
expm1-udef54.3%
Applied egg-rr54.3%
expm1-def97.5%
expm1-log1p97.5%
associate-/r*99.8%
Simplified99.8%
Taylor expanded in x around inf 99.8%
Final simplification99.4%
(FPCore (x) :precision binary64 (if (<= x 65000000.0) (- (pow x -0.5) (pow (+ 1.0 x) -0.5)) (/ (/ 1.0 (+ (sqrt x) (sqrt (+ 1.0 x)))) x)))
double code(double x) {
double tmp;
if (x <= 65000000.0) {
tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
} else {
tmp = (1.0 / (sqrt(x) + sqrt((1.0 + x)))) / x;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 65000000.0d0) then
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
else
tmp = (1.0d0 / (sqrt(x) + sqrt((1.0d0 + x)))) / x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 65000000.0) {
tmp = 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;
}
return tmp;
}
def code(x): tmp = 0 if x <= 65000000.0: tmp = 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 return tmp
function code(x) tmp = 0.0 if (x <= 65000000.0) tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); else tmp = Float64(Float64(1.0 / Float64(sqrt(x) + sqrt(Float64(1.0 + x)))) / x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 65000000.0) tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); else tmp = (1.0 / (sqrt(x) + sqrt((1.0 + x)))) / x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 65000000.0], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 65000000:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}{x}\\
\end{array}
\end{array}
if x < 6.5e7Initial program 99.4%
expm1-log1p-u99.4%
expm1-udef99.3%
associate--r-99.3%
pow1/299.3%
pow-flip99.7%
metadata-eval99.7%
pow1/299.7%
pow-flip99.7%
+-commutative99.7%
metadata-eval99.7%
Applied egg-rr99.7%
associate-+l-99.7%
expm1-def99.8%
expm1-log1p99.8%
Simplified99.8%
if 6.5e7 < x Initial program 44.7%
frac-sub44.8%
div-inv44.8%
*-un-lft-identity44.8%
*-rgt-identity44.8%
flip--45.8%
metadata-eval45.8%
frac-times45.8%
associate-*l/45.8%
Applied egg-rr82.9%
expm1-log1p-u82.9%
expm1-udef43.9%
Applied egg-rr43.9%
expm1-def97.9%
expm1-log1p97.9%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in x around inf 98.8%
Final simplification99.4%
(FPCore (x) :precision binary64 (if (<= x 100000000.0) (- (pow x -0.5) (pow (+ 1.0 x) -0.5)) (/ 0.5 (pow x 1.5))))
double code(double x) {
double tmp;
if (x <= 100000000.0) {
tmp = pow(x, -0.5) - pow((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 <= 100000000.0d0) then
tmp = (x ** (-0.5d0)) - ((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 <= 100000000.0) {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
} else {
tmp = 0.5 / Math.pow(x, 1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 100000000.0: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) else: tmp = 0.5 / math.pow(x, 1.5) return tmp
function code(x) tmp = 0.0 if (x <= 100000000.0) tmp = Float64((x ^ -0.5) - (Float64(1.0 + 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 <= 100000000.0) tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); else tmp = 0.5 / (x ^ 1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 100000000.0], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(0.5 / N[Power[x, 1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 100000000:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{{x}^{1.5}}\\
\end{array}
\end{array}
if x < 1e8Initial program 99.4%
expm1-log1p-u99.4%
expm1-udef99.3%
associate--r-99.3%
pow1/299.3%
pow-flip99.7%
metadata-eval99.7%
pow1/299.7%
pow-flip99.7%
+-commutative99.7%
metadata-eval99.7%
Applied egg-rr99.7%
associate-+l-99.7%
expm1-def99.8%
expm1-log1p99.8%
Simplified99.8%
if 1e8 < x Initial program 44.7%
flip--44.8%
clear-num44.8%
*-un-lft-identity44.8%
associate-/l*44.8%
flip--44.7%
pow1/244.7%
pow-flip35.2%
metadata-eval35.2%
pow1/235.2%
pow-flip44.8%
+-commutative44.8%
metadata-eval44.8%
Applied egg-rr44.8%
Taylor expanded in x around inf 64.8%
expm1-log1p-u64.8%
expm1-udef43.9%
associate-/r*43.9%
metadata-eval43.9%
sqrt-pow143.9%
metadata-eval43.9%
Applied egg-rr43.9%
Simplified97.0%
Final simplification98.5%
(FPCore (x) :precision binary64 (if (<= x 1.0) (+ (pow x -0.5) (+ -1.0 (* x 0.5))) (/ 0.5 (pow x 1.5))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = pow(x, -0.5) + (-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.0d0) then
tmp = (x ** (-0.5d0)) + ((-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.0) {
tmp = Math.pow(x, -0.5) + (-1.0 + (x * 0.5));
} 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) + (-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.0) tmp = Float64((x ^ -0.5) + 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.0) tmp = (x ^ -0.5) + (-1.0 + (x * 0.5)); else tmp = 0.5 / (x ^ 1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 / N[Power[x, 1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;{x}^{-0.5} + \left(-1 + x \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{{x}^{1.5}}\\
\end{array}
\end{array}
if x < 1Initial program 99.6%
add-sqr-sqrt99.1%
sqrt-unprod99.6%
frac-times99.5%
metadata-eval99.5%
add-sqr-sqrt99.7%
Applied egg-rr99.7%
Taylor expanded in x around 0 99.2%
associate--r+99.2%
cancel-sign-sub-inv99.2%
sub-neg99.2%
associate-+l+99.2%
inv-pow99.2%
metadata-eval99.2%
sqrt-pow199.5%
metadata-eval99.5%
metadata-eval99.5%
metadata-eval99.5%
metadata-eval99.5%
Applied egg-rr99.5%
if 1 < x Initial program 45.4%
flip--45.5%
clear-num45.5%
*-un-lft-identity45.5%
associate-/l*45.5%
flip--45.4%
pow1/245.4%
pow-flip36.1%
metadata-eval36.1%
pow1/236.1%
pow-flip45.5%
+-commutative45.5%
metadata-eval45.5%
Applied egg-rr45.5%
Taylor expanded in x around inf 64.2%
expm1-log1p-u64.2%
expm1-udef43.8%
associate-/r*43.8%
metadata-eval43.8%
sqrt-pow143.8%
metadata-eval43.8%
Applied egg-rr43.8%
Simplified95.9%
Final simplification97.8%
(FPCore (x) :precision binary64 (if (<= x 1.0) (+ (pow x -0.5) -1.0) (/ 0.0 x)))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = 0.0 / x;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.0d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = 0.0d0 / x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = 0.0 / x;
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = math.pow(x, -0.5) + -1.0 else: tmp = 0.0 / x return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(0.0 / x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = (x ^ -0.5) + -1.0; else tmp = 0.0 / x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(0.0 / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{x}\\
\end{array}
\end{array}
if x < 1Initial program 99.6%
Taylor expanded in x around 0 98.6%
expm1-log1p-u91.7%
expm1-udef91.7%
pow1/291.7%
pow-flip91.7%
metadata-eval91.7%
Applied egg-rr91.7%
expm1-def91.7%
expm1-log1p99.0%
Simplified99.0%
if 1 < x Initial program 45.4%
frac-sub45.5%
div-inv45.5%
*-un-lft-identity45.5%
*-rgt-identity45.5%
flip--46.7%
metadata-eval46.7%
frac-times46.7%
associate-*l/46.7%
Applied egg-rr83.2%
Taylor expanded in x around inf 97.7%
Taylor expanded in x around 0 8.0%
Simplified42.6%
Final simplification73.2%
(FPCore (x) :precision binary64 (if (<= x 0.66) (+ (pow x -0.5) -1.0) (/ 0.5 (pow x 1.5))))
double code(double x) {
double tmp;
if (x <= 0.66) {
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.66d0) 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.66) {
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.66: 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.66) 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.66) tmp = (x ^ -0.5) + -1.0; else tmp = 0.5 / (x ^ 1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.66], 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.66:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{{x}^{1.5}}\\
\end{array}
\end{array}
if x < 0.660000000000000031Initial program 99.6%
Taylor expanded in x around 0 98.6%
expm1-log1p-u91.7%
expm1-udef91.7%
pow1/291.7%
pow-flip91.7%
metadata-eval91.7%
Applied egg-rr91.7%
expm1-def91.7%
expm1-log1p99.0%
Simplified99.0%
if 0.660000000000000031 < x Initial program 45.4%
flip--45.5%
clear-num45.5%
*-un-lft-identity45.5%
associate-/l*45.5%
flip--45.4%
pow1/245.4%
pow-flip36.1%
metadata-eval36.1%
pow1/236.1%
pow-flip45.5%
+-commutative45.5%
metadata-eval45.5%
Applied egg-rr45.5%
Taylor expanded in x around inf 64.2%
expm1-log1p-u64.2%
expm1-udef43.8%
associate-/r*43.8%
metadata-eval43.8%
sqrt-pow143.8%
metadata-eval43.8%
Applied egg-rr43.8%
Simplified95.9%
Final simplification97.6%
(FPCore (x) :precision binary64 (if (<= x 4.7e+153) (/ 1.0 x) (/ 0.0 x)))
double code(double x) {
double tmp;
if (x <= 4.7e+153) {
tmp = 1.0 / x;
} else {
tmp = 0.0 / x;
}
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
else
tmp = 0.0d0 / x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 4.7e+153) {
tmp = 1.0 / x;
} else {
tmp = 0.0 / x;
}
return tmp;
}
def code(x): tmp = 0 if x <= 4.7e+153: tmp = 1.0 / x else: tmp = 0.0 / x return tmp
function code(x) tmp = 0.0 if (x <= 4.7e+153) tmp = Float64(1.0 / x); else tmp = Float64(0.0 / x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 4.7e+153) tmp = 1.0 / x; else tmp = 0.0 / x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 4.7e+153], N[(1.0 / x), $MachinePrecision], N[(0.0 / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.7 \cdot 10^{+153}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{x}\\
\end{array}
\end{array}
if x < 4.69999999999999968e153Initial program 76.2%
frac-sub76.3%
div-inv76.3%
*-un-lft-identity76.3%
*-rgt-identity76.3%
flip--77.0%
metadata-eval77.0%
frac-times77.0%
associate-*l/77.0%
Applied egg-rr99.6%
Taylor expanded in x around inf 30.1%
Taylor expanded in x around 0 7.2%
if 4.69999999999999968e153 < x Initial program 71.1%
frac-sub71.1%
div-inv71.1%
*-un-lft-identity71.1%
*-rgt-identity71.1%
flip--71.1%
metadata-eval71.1%
frac-times71.1%
associate-*l/71.1%
Applied egg-rr71.1%
Taylor expanded in x around inf 99.8%
Taylor expanded in x around 0 7.6%
Simplified71.1%
Final simplification23.9%
(FPCore (x) :precision binary64 (/ 0.0 x))
double code(double x) {
return 0.0 / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0 / x
end function
public static double code(double x) {
return 0.0 / x;
}
def code(x): return 0.0 / x
function code(x) return Float64(0.0 / x) end
function tmp = code(x) tmp = 0.0 / x; end
code[x_] := N[(0.0 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{0}{x}
\end{array}
Initial program 74.9%
frac-sub74.9%
div-inv74.9%
*-un-lft-identity74.9%
*-rgt-identity74.9%
flip--75.4%
metadata-eval75.4%
frac-times75.4%
associate-*l/75.4%
Applied egg-rr92.1%
Taylor expanded in x around inf 48.3%
Taylor expanded in x around 0 7.3%
Simplified20.9%
Final simplification20.9%
(FPCore (x) :precision binary64 -1.0)
double code(double x) {
return -1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = -1.0d0
end function
public static double code(double x) {
return -1.0;
}
def code(x): return -1.0
function code(x) return -1.0 end
function tmp = code(x) tmp = -1.0; end
code[x_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 74.9%
Taylor expanded in x around 0 54.8%
Taylor expanded in x around inf 1.9%
Final simplification1.9%
(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 2023336
(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)))))