
(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 (+ x 1.0))) (t_1 (+ t_0 (sqrt x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 0.0)
(/ (/ (+ 1.0 (- x x)) t_1) x)
(* (/ 1.0 t_1) (pow (+ x (* x x)) -0.5)))))
double code(double x) {
double t_0 = sqrt((x + 1.0));
double t_1 = t_0 + sqrt(x);
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 0.0) {
tmp = ((1.0 + (x - x)) / t_1) / x;
} else {
tmp = (1.0 / t_1) * pow((x + (x * x)), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((x + 1.0d0))
t_1 = t_0 + sqrt(x)
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 0.0d0) then
tmp = ((1.0d0 + (x - x)) / t_1) / x
else
tmp = (1.0d0 / t_1) * ((x + (x * x)) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((x + 1.0));
double t_1 = t_0 + Math.sqrt(x);
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 0.0) {
tmp = ((1.0 + (x - x)) / t_1) / x;
} else {
tmp = (1.0 / t_1) * Math.pow((x + (x * x)), -0.5);
}
return tmp;
}
def code(x): t_0 = math.sqrt((x + 1.0)) t_1 = t_0 + math.sqrt(x) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 0.0: tmp = ((1.0 + (x - x)) / t_1) / x else: tmp = (1.0 / t_1) * math.pow((x + (x * x)), -0.5) return tmp
function code(x) t_0 = sqrt(Float64(x + 1.0)) t_1 = Float64(t_0 + sqrt(x)) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / t_0)) <= 0.0) tmp = Float64(Float64(Float64(1.0 + Float64(x - x)) / t_1) / x); else tmp = Float64(Float64(1.0 / t_1) * (Float64(x + Float64(x * x)) ^ -0.5)); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((x + 1.0)); t_1 = t_0 + sqrt(x); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 0.0) tmp = ((1.0 + (x - x)) / t_1) / x; else tmp = (1.0 / t_1) * ((x + (x * x)) ^ -0.5); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 + N[Sqrt[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[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision] / x), $MachinePrecision], N[(N[(1.0 / t$95$1), $MachinePrecision] * N[Power[N[(x + N[(x * x), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{x + 1}\\
t_1 := t_0 + \sqrt{x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 0:\\
\;\;\;\;\frac{\frac{1 + \left(x - x\right)}{t_1}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_1} \cdot {\left(x + x \cdot x\right)}^{-0.5}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 0.0Initial program 38.2%
frac-sub38.2%
clear-num38.2%
sqrt-unprod38.2%
+-commutative38.2%
*-un-lft-identity38.2%
*-rgt-identity38.2%
+-commutative38.2%
Applied egg-rr38.2%
associate-/r/38.2%
Simplified38.2%
flip--38.2%
add-sqr-sqrt38.2%
+-commutative38.2%
add-sqr-sqrt38.2%
+-commutative38.2%
Applied egg-rr38.2%
Taylor expanded in x around inf 38.2%
expm1-log1p-u38.2%
expm1-udef38.2%
frac-times38.2%
*-un-lft-identity38.2%
associate--l+38.2%
+-commutative38.2%
Applied egg-rr38.2%
expm1-def38.2%
expm1-log1p38.2%
associate-/l/38.2%
associate-+r-38.2%
+-commutative38.2%
associate--l+99.7%
Simplified99.7%
if 0.0 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 96.2%
frac-sub96.3%
clear-num96.3%
sqrt-unprod96.3%
+-commutative96.3%
*-un-lft-identity96.3%
*-rgt-identity96.3%
+-commutative96.3%
Applied egg-rr96.3%
associate-/r/96.3%
Simplified96.3%
flip--98.1%
add-sqr-sqrt97.9%
+-commutative97.9%
add-sqr-sqrt99.4%
+-commutative99.4%
Applied egg-rr99.4%
Taylor expanded in x around 0 99.4%
pow1/299.4%
pow-flip99.9%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ x 1.0))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 2e-5)
(*
(/ 1.0 (+ t_0 (sqrt x)))
(/ 1.0 (- (+ 0.5 (+ x (/ 0.0625 (* x x)))) (/ 0.125 x))))
(- (pow x -0.5) (pow (+ x 1.0) -0.5)))))
double code(double x) {
double t_0 = sqrt((x + 1.0));
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 2e-5) {
tmp = (1.0 / (t_0 + sqrt(x))) * (1.0 / ((0.5 + (x + (0.0625 / (x * x)))) - (0.125 / x)));
} else {
tmp = pow(x, -0.5) - pow((x + 1.0), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((x + 1.0d0))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 2d-5) then
tmp = (1.0d0 / (t_0 + sqrt(x))) * (1.0d0 / ((0.5d0 + (x + (0.0625d0 / (x * x)))) - (0.125d0 / x)))
else
tmp = (x ** (-0.5d0)) - ((x + 1.0d0) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((x + 1.0));
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 2e-5) {
tmp = (1.0 / (t_0 + Math.sqrt(x))) * (1.0 / ((0.5 + (x + (0.0625 / (x * x)))) - (0.125 / x)));
} else {
tmp = Math.pow(x, -0.5) - Math.pow((x + 1.0), -0.5);
}
return tmp;
}
def code(x): t_0 = math.sqrt((x + 1.0)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 2e-5: tmp = (1.0 / (t_0 + math.sqrt(x))) * (1.0 / ((0.5 + (x + (0.0625 / (x * x)))) - (0.125 / x))) else: tmp = math.pow(x, -0.5) - math.pow((x + 1.0), -0.5) return tmp
function code(x) t_0 = sqrt(Float64(x + 1.0)) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / t_0)) <= 2e-5) tmp = Float64(Float64(1.0 / Float64(t_0 + sqrt(x))) * Float64(1.0 / Float64(Float64(0.5 + Float64(x + Float64(0.0625 / Float64(x * x)))) - Float64(0.125 / x)))); else tmp = Float64((x ^ -0.5) - (Float64(x + 1.0) ^ -0.5)); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((x + 1.0)); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 2e-5) tmp = (1.0 / (t_0 + sqrt(x))) * (1.0 / ((0.5 + (x + (0.0625 / (x * x)))) - (0.125 / x))); else tmp = (x ^ -0.5) - ((x + 1.0) ^ -0.5); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 2e-5], N[(N[(1.0 / N[(t$95$0 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(N[(0.5 + N[(x + N[(0.0625 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{x + 1}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{t_0 + \sqrt{x}} \cdot \frac{1}{\left(0.5 + \left(x + \frac{0.0625}{x \cdot x}\right)\right) - \frac{0.125}{x}}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 2.00000000000000016e-5Initial program 39.7%
frac-sub39.8%
clear-num39.8%
sqrt-unprod39.8%
+-commutative39.8%
*-un-lft-identity39.8%
*-rgt-identity39.8%
+-commutative39.8%
Applied egg-rr39.8%
associate-/r/39.8%
Simplified39.8%
flip--41.5%
add-sqr-sqrt41.3%
+-commutative41.3%
add-sqr-sqrt42.7%
+-commutative42.7%
Applied egg-rr42.7%
Taylor expanded in x around 0 84.7%
Taylor expanded in x around inf 99.5%
+-commutative99.5%
associate-*r/99.5%
metadata-eval99.5%
unpow299.5%
associate-*r/99.5%
metadata-eval99.5%
Simplified99.5%
if 2.00000000000000016e-5 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.5%
*-un-lft-identity99.5%
clear-num99.5%
associate-/r/99.5%
prod-diff99.5%
*-un-lft-identity99.5%
fma-neg99.5%
*-un-lft-identity99.5%
inv-pow99.5%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification99.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ x 1.0))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 1e-6)
(* (/ 1.0 (+ t_0 (sqrt x))) (/ 1.0 (+ 0.5 (- x (/ 0.125 x)))))
(- (pow x -0.5) (pow (+ x 1.0) -0.5)))))
double code(double x) {
double t_0 = sqrt((x + 1.0));
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 1e-6) {
tmp = (1.0 / (t_0 + sqrt(x))) * (1.0 / (0.5 + (x - (0.125 / x))));
} else {
tmp = pow(x, -0.5) - pow((x + 1.0), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((x + 1.0d0))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 1d-6) then
tmp = (1.0d0 / (t_0 + sqrt(x))) * (1.0d0 / (0.5d0 + (x - (0.125d0 / x))))
else
tmp = (x ** (-0.5d0)) - ((x + 1.0d0) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((x + 1.0));
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 1e-6) {
tmp = (1.0 / (t_0 + Math.sqrt(x))) * (1.0 / (0.5 + (x - (0.125 / x))));
} else {
tmp = Math.pow(x, -0.5) - Math.pow((x + 1.0), -0.5);
}
return tmp;
}
def code(x): t_0 = math.sqrt((x + 1.0)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 1e-6: tmp = (1.0 / (t_0 + math.sqrt(x))) * (1.0 / (0.5 + (x - (0.125 / x)))) else: tmp = math.pow(x, -0.5) - math.pow((x + 1.0), -0.5) return tmp
function code(x) t_0 = sqrt(Float64(x + 1.0)) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / t_0)) <= 1e-6) tmp = Float64(Float64(1.0 / Float64(t_0 + sqrt(x))) * Float64(1.0 / Float64(0.5 + Float64(x - Float64(0.125 / x))))); else tmp = Float64((x ^ -0.5) - (Float64(x + 1.0) ^ -0.5)); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((x + 1.0)); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 1e-6) tmp = (1.0 / (t_0 + sqrt(x))) * (1.0 / (0.5 + (x - (0.125 / x)))); else tmp = (x ^ -0.5) - ((x + 1.0) ^ -0.5); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 1e-6], N[(N[(1.0 / N[(t$95$0 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(0.5 + N[(x - N[(0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{x + 1}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 10^{-6}:\\
\;\;\;\;\frac{1}{t_0 + \sqrt{x}} \cdot \frac{1}{0.5 + \left(x - \frac{0.125}{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 9.99999999999999955e-7Initial program 39.0%
frac-sub39.1%
clear-num39.1%
sqrt-unprod39.1%
+-commutative39.1%
*-un-lft-identity39.1%
*-rgt-identity39.1%
+-commutative39.1%
Applied egg-rr39.1%
associate-/r/39.1%
Simplified39.1%
flip--40.7%
add-sqr-sqrt40.6%
+-commutative40.6%
add-sqr-sqrt41.8%
+-commutative41.8%
Applied egg-rr41.8%
Taylor expanded in x around 0 84.5%
Taylor expanded in x around inf 99.5%
associate--l+99.5%
associate-*r/99.5%
metadata-eval99.5%
Simplified99.5%
if 9.99999999999999955e-7 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.2%
*-un-lft-identity99.2%
clear-num99.2%
associate-/r/99.2%
prod-diff99.2%
*-un-lft-identity99.2%
fma-neg99.2%
*-un-lft-identity99.2%
inv-pow99.2%
sqrt-pow299.7%
metadata-eval99.7%
pow1/299.7%
pow-flip99.8%
+-commutative99.8%
metadata-eval99.8%
Applied egg-rr99.8%
fma-udef99.8%
distribute-lft1-in99.8%
metadata-eval99.8%
mul0-lft99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification99.6%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ x 1.0))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 2e-10)
(* (/ 1.0 (+ t_0 (sqrt x))) (/ 1.0 (+ x 0.5)))
(- (pow x -0.5) (pow (+ x 1.0) -0.5)))))
double code(double x) {
double t_0 = sqrt((x + 1.0));
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 2e-10) {
tmp = (1.0 / (t_0 + sqrt(x))) * (1.0 / (x + 0.5));
} else {
tmp = pow(x, -0.5) - pow((x + 1.0), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((x + 1.0d0))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 2d-10) then
tmp = (1.0d0 / (t_0 + sqrt(x))) * (1.0d0 / (x + 0.5d0))
else
tmp = (x ** (-0.5d0)) - ((x + 1.0d0) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((x + 1.0));
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 2e-10) {
tmp = (1.0 / (t_0 + Math.sqrt(x))) * (1.0 / (x + 0.5));
} else {
tmp = Math.pow(x, -0.5) - Math.pow((x + 1.0), -0.5);
}
return tmp;
}
def code(x): t_0 = math.sqrt((x + 1.0)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 2e-10: tmp = (1.0 / (t_0 + math.sqrt(x))) * (1.0 / (x + 0.5)) else: tmp = math.pow(x, -0.5) - math.pow((x + 1.0), -0.5) return tmp
function code(x) t_0 = sqrt(Float64(x + 1.0)) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / t_0)) <= 2e-10) tmp = Float64(Float64(1.0 / Float64(t_0 + sqrt(x))) * Float64(1.0 / Float64(x + 0.5))); else tmp = Float64((x ^ -0.5) - (Float64(x + 1.0) ^ -0.5)); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((x + 1.0)); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 2e-10) tmp = (1.0 / (t_0 + sqrt(x))) * (1.0 / (x + 0.5)); else tmp = (x ^ -0.5) - ((x + 1.0) ^ -0.5); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 2e-10], N[(N[(1.0 / N[(t$95$0 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{x + 1}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\frac{1}{t_0 + \sqrt{x}} \cdot \frac{1}{x + 0.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 2.00000000000000007e-10Initial program 38.7%
frac-sub38.7%
clear-num38.7%
sqrt-unprod38.7%
+-commutative38.7%
*-un-lft-identity38.7%
*-rgt-identity38.7%
+-commutative38.7%
Applied egg-rr38.7%
associate-/r/38.7%
Simplified38.7%
flip--40.3%
add-sqr-sqrt40.2%
+-commutative40.2%
add-sqr-sqrt41.4%
+-commutative41.4%
Applied egg-rr41.4%
Taylor expanded in x around 0 84.3%
Taylor expanded in x around inf 99.5%
+-commutative99.5%
Simplified99.5%
if 2.00000000000000007e-10 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.0%
*-un-lft-identity99.0%
clear-num99.0%
associate-/r/99.0%
prod-diff99.0%
*-un-lft-identity99.0%
fma-neg99.0%
*-un-lft-identity99.0%
inv-pow99.0%
sqrt-pow299.6%
metadata-eval99.6%
pow1/299.6%
pow-flip99.6%
+-commutative99.6%
metadata-eval99.6%
Applied egg-rr99.6%
fma-udef99.6%
distribute-lft1-in99.6%
metadata-eval99.6%
mul0-lft99.6%
+-rgt-identity99.6%
Simplified99.6%
Final simplification99.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ x 1.0))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 4e-15)
(* (/ 1.0 (+ t_0 (sqrt x))) (/ 1.0 x))
(- (pow x -0.5) (pow (+ x 1.0) -0.5)))))
double code(double x) {
double t_0 = sqrt((x + 1.0));
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 4e-15) {
tmp = (1.0 / (t_0 + sqrt(x))) * (1.0 / x);
} else {
tmp = pow(x, -0.5) - pow((x + 1.0), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((x + 1.0d0))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 4d-15) then
tmp = (1.0d0 / (t_0 + sqrt(x))) * (1.0d0 / x)
else
tmp = (x ** (-0.5d0)) - ((x + 1.0d0) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((x + 1.0));
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 4e-15) {
tmp = (1.0 / (t_0 + Math.sqrt(x))) * (1.0 / x);
} else {
tmp = Math.pow(x, -0.5) - Math.pow((x + 1.0), -0.5);
}
return tmp;
}
def code(x): t_0 = math.sqrt((x + 1.0)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 4e-15: tmp = (1.0 / (t_0 + math.sqrt(x))) * (1.0 / x) else: tmp = math.pow(x, -0.5) - math.pow((x + 1.0), -0.5) return tmp
function code(x) t_0 = sqrt(Float64(x + 1.0)) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / t_0)) <= 4e-15) tmp = Float64(Float64(1.0 / Float64(t_0 + sqrt(x))) * Float64(1.0 / x)); else tmp = Float64((x ^ -0.5) - (Float64(x + 1.0) ^ -0.5)); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((x + 1.0)); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 4e-15) tmp = (1.0 / (t_0 + sqrt(x))) * (1.0 / x); else tmp = (x ^ -0.5) - ((x + 1.0) ^ -0.5); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 4e-15], N[(N[(1.0 / N[(t$95$0 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{x + 1}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 4 \cdot 10^{-15}:\\
\;\;\;\;\frac{1}{t_0 + \sqrt{x}} \cdot \frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 4.0000000000000003e-15Initial program 38.3%
frac-sub38.4%
clear-num38.4%
sqrt-unprod38.4%
+-commutative38.4%
*-un-lft-identity38.4%
*-rgt-identity38.4%
+-commutative38.4%
Applied egg-rr38.4%
associate-/r/38.4%
Simplified38.4%
flip--39.7%
add-sqr-sqrt39.6%
+-commutative39.6%
add-sqr-sqrt40.6%
+-commutative40.6%
Applied egg-rr40.6%
Taylor expanded in x around 0 84.1%
Taylor expanded in x around inf 98.9%
if 4.0000000000000003e-15 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 98.5%
*-un-lft-identity98.5%
clear-num98.5%
associate-/r/98.5%
prod-diff98.5%
*-un-lft-identity98.5%
fma-neg98.5%
*-un-lft-identity98.5%
inv-pow98.5%
sqrt-pow299.0%
metadata-eval99.0%
pow1/299.0%
pow-flip99.0%
+-commutative99.0%
metadata-eval99.0%
Applied egg-rr99.0%
fma-udef99.0%
distribute-lft1-in99.0%
metadata-eval99.0%
mul0-lft99.0%
+-rgt-identity99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (x) :precision binary64 (* (* (pow x -0.5) (pow (+ x 1.0) -0.5)) (/ 1.0 (+ (sqrt (+ x 1.0)) (sqrt x)))))
double code(double x) {
return (pow(x, -0.5) * pow((x + 1.0), -0.5)) * (1.0 / (sqrt((x + 1.0)) + sqrt(x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x ** (-0.5d0)) * ((x + 1.0d0) ** (-0.5d0))) * (1.0d0 / (sqrt((x + 1.0d0)) + sqrt(x)))
end function
public static double code(double x) {
return (Math.pow(x, -0.5) * Math.pow((x + 1.0), -0.5)) * (1.0 / (Math.sqrt((x + 1.0)) + Math.sqrt(x)));
}
def code(x): return (math.pow(x, -0.5) * math.pow((x + 1.0), -0.5)) * (1.0 / (math.sqrt((x + 1.0)) + math.sqrt(x)))
function code(x) return Float64(Float64((x ^ -0.5) * (Float64(x + 1.0) ^ -0.5)) * Float64(1.0 / Float64(sqrt(Float64(x + 1.0)) + sqrt(x)))) end
function tmp = code(x) tmp = ((x ^ -0.5) * ((x + 1.0) ^ -0.5)) * (1.0 / (sqrt((x + 1.0)) + sqrt(x))); end
code[x_] := N[(N[(N[Power[x, -0.5], $MachinePrecision] * N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({x}^{-0.5} \cdot {\left(x + 1\right)}^{-0.5}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}
\end{array}
Initial program 67.2%
frac-sub67.3%
clear-num67.3%
sqrt-unprod67.3%
+-commutative67.3%
*-un-lft-identity67.3%
*-rgt-identity67.3%
+-commutative67.3%
Applied egg-rr67.3%
associate-/r/67.3%
Simplified67.3%
flip--68.2%
add-sqr-sqrt68.1%
+-commutative68.1%
add-sqr-sqrt68.8%
+-commutative68.8%
Applied egg-rr68.8%
Taylor expanded in x around 0 91.5%
inv-pow91.5%
sqrt-pow291.7%
metadata-eval91.7%
pow-prod-down99.6%
+-commutative99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x) :precision binary64 (/ (/ 1.0 (hypot (sqrt x) x)) (+ (sqrt (+ x 1.0)) (sqrt x))))
double code(double x) {
return (1.0 / hypot(sqrt(x), x)) / (sqrt((x + 1.0)) + sqrt(x));
}
public static double code(double x) {
return (1.0 / Math.hypot(Math.sqrt(x), x)) / (Math.sqrt((x + 1.0)) + Math.sqrt(x));
}
def code(x): return (1.0 / math.hypot(math.sqrt(x), x)) / (math.sqrt((x + 1.0)) + math.sqrt(x))
function code(x) return Float64(Float64(1.0 / hypot(sqrt(x), x)) / Float64(sqrt(Float64(x + 1.0)) + sqrt(x))) end
function tmp = code(x) tmp = (1.0 / hypot(sqrt(x), x)) / (sqrt((x + 1.0)) + sqrt(x)); end
code[x_] := N[(N[(1.0 / N[Sqrt[N[Sqrt[x], $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{\mathsf{hypot}\left(\sqrt{x}, x\right)}}{\sqrt{x + 1} + \sqrt{x}}
\end{array}
Initial program 67.2%
frac-sub67.3%
clear-num67.3%
sqrt-unprod67.3%
+-commutative67.3%
*-un-lft-identity67.3%
*-rgt-identity67.3%
+-commutative67.3%
Applied egg-rr67.3%
associate-/r/67.3%
Simplified67.3%
flip--68.2%
add-sqr-sqrt68.1%
+-commutative68.1%
add-sqr-sqrt68.8%
+-commutative68.8%
Applied egg-rr68.8%
Taylor expanded in x around 0 91.5%
un-div-inv91.5%
distribute-rgt-in91.5%
*-un-lft-identity91.5%
add-sqr-sqrt91.5%
hypot-def99.5%
+-commutative99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x) :precision binary64 (if (<= x 122000000.0) (- (pow x -0.5) (pow (+ x 1.0) -0.5)) (* 0.5 (sqrt (/ 1.0 (pow x 3.0))))))
double code(double x) {
double tmp;
if (x <= 122000000.0) {
tmp = pow(x, -0.5) - pow((x + 1.0), -0.5);
} else {
tmp = 0.5 * sqrt((1.0 / pow(x, 3.0)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 122000000.0d0) then
tmp = (x ** (-0.5d0)) - ((x + 1.0d0) ** (-0.5d0))
else
tmp = 0.5d0 * sqrt((1.0d0 / (x ** 3.0d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 122000000.0) {
tmp = Math.pow(x, -0.5) - Math.pow((x + 1.0), -0.5);
} else {
tmp = 0.5 * Math.sqrt((1.0 / Math.pow(x, 3.0)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 122000000.0: tmp = math.pow(x, -0.5) - math.pow((x + 1.0), -0.5) else: tmp = 0.5 * math.sqrt((1.0 / math.pow(x, 3.0))) return tmp
function code(x) tmp = 0.0 if (x <= 122000000.0) tmp = Float64((x ^ -0.5) - (Float64(x + 1.0) ^ -0.5)); else tmp = Float64(0.5 * sqrt(Float64(1.0 / (x ^ 3.0)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 122000000.0) tmp = (x ^ -0.5) - ((x + 1.0) ^ -0.5); else tmp = 0.5 * sqrt((1.0 / (x ^ 3.0))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 122000000.0], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(1.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 122000000:\\
\;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\\
\end{array}
\end{array}
if x < 1.22e8Initial program 98.5%
*-un-lft-identity98.5%
clear-num98.5%
associate-/r/98.5%
prod-diff98.5%
*-un-lft-identity98.5%
fma-neg98.5%
*-un-lft-identity98.5%
inv-pow98.5%
sqrt-pow299.0%
metadata-eval99.0%
pow1/299.0%
pow-flip99.0%
+-commutative99.0%
metadata-eval99.0%
Applied egg-rr99.0%
fma-udef99.0%
distribute-lft1-in99.0%
metadata-eval99.0%
mul0-lft99.0%
+-rgt-identity99.0%
Simplified99.0%
if 1.22e8 < x Initial program 38.3%
*-un-lft-identity38.3%
clear-num38.3%
associate-/r/38.3%
prod-diff38.3%
*-un-lft-identity38.3%
fma-neg38.3%
*-un-lft-identity38.3%
inv-pow38.3%
sqrt-pow232.7%
metadata-eval32.7%
pow1/232.7%
pow-flip38.4%
+-commutative38.4%
metadata-eval38.4%
Applied egg-rr38.4%
fma-udef38.4%
distribute-lft1-in38.4%
metadata-eval38.4%
mul0-lft38.4%
+-rgt-identity38.4%
Simplified38.4%
Taylor expanded in x around inf 69.4%
Final simplification83.6%
(FPCore (x) :precision binary64 (if (<= x 1.0) (+ (pow x -0.5) (- -1.0 (* x -0.5))) (* 0.5 (sqrt (/ 1.0 (pow x 3.0))))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = pow(x, -0.5) + (-1.0 - (x * -0.5));
} else {
tmp = 0.5 * sqrt((1.0 / pow(x, 3.0)));
}
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 * sqrt((1.0d0 / (x ** 3.0d0)))
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.sqrt((1.0 / Math.pow(x, 3.0)));
}
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.sqrt((1.0 / math.pow(x, 3.0))) 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 * sqrt(Float64(1.0 / (x ^ 3.0)))); 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 * sqrt((1.0 / (x ^ 3.0))); 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[Sqrt[N[(1.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]], $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}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\\
\end{array}
\end{array}
if x < 1Initial program 99.5%
*-un-lft-identity99.5%
clear-num99.5%
associate-/r/99.5%
prod-diff99.5%
*-un-lft-identity99.5%
fma-neg99.5%
*-un-lft-identity99.5%
inv-pow99.5%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 99.8%
if 1 < x Initial program 40.1%
*-un-lft-identity40.1%
clear-num40.1%
associate-/r/40.1%
prod-diff40.1%
*-un-lft-identity40.1%
fma-neg40.1%
*-un-lft-identity40.1%
inv-pow40.1%
sqrt-pow234.8%
metadata-eval34.8%
pow1/234.8%
pow-flip40.2%
+-commutative40.2%
metadata-eval40.2%
Applied egg-rr40.2%
fma-udef40.2%
distribute-lft1-in40.2%
metadata-eval40.2%
mul0-lft40.2%
+-rgt-identity40.2%
Simplified40.2%
Taylor expanded in x around inf 68.1%
Final simplification82.6%
(FPCore (x) :precision binary64 (if (<= x 8.2e+76) (+ (pow x -0.5) (- -1.0 (* x -0.5))) 0.0))
double code(double x) {
double tmp;
if (x <= 8.2e+76) {
tmp = pow(x, -0.5) + (-1.0 - (x * -0.5));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 8.2d+76) then
tmp = (x ** (-0.5d0)) + ((-1.0d0) - (x * (-0.5d0)))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 8.2e+76) {
tmp = Math.pow(x, -0.5) + (-1.0 - (x * -0.5));
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 8.2e+76: tmp = math.pow(x, -0.5) + (-1.0 - (x * -0.5)) else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= 8.2e+76) tmp = Float64((x ^ -0.5) + Float64(-1.0 - Float64(x * -0.5))); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 8.2e+76) tmp = (x ^ -0.5) + (-1.0 - (x * -0.5)); else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 8.2e+76], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 - N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.2 \cdot 10^{+76}:\\
\;\;\;\;{x}^{-0.5} + \left(-1 - x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 8.1999999999999997e76Initial program 79.1%
*-un-lft-identity79.1%
clear-num79.1%
associate-/r/79.1%
prod-diff79.1%
*-un-lft-identity79.1%
fma-neg79.1%
*-un-lft-identity79.1%
inv-pow79.1%
sqrt-pow279.8%
metadata-eval79.8%
pow1/279.8%
pow-flip79.6%
+-commutative79.6%
metadata-eval79.6%
Applied egg-rr79.6%
fma-udef79.6%
distribute-lft1-in79.6%
metadata-eval79.6%
mul0-lft79.6%
+-rgt-identity79.6%
Simplified79.6%
Taylor expanded in x around 0 76.1%
if 8.1999999999999997e76 < x Initial program 48.3%
*-un-lft-identity48.3%
clear-num48.3%
associate-/r/48.3%
prod-diff48.3%
*-un-lft-identity48.3%
fma-neg48.3%
*-un-lft-identity48.3%
inv-pow48.3%
sqrt-pow240.5%
metadata-eval40.5%
pow1/240.5%
pow-flip48.3%
+-commutative48.3%
metadata-eval48.3%
Applied egg-rr48.3%
fma-udef48.3%
distribute-lft1-in48.3%
metadata-eval48.3%
mul0-lft48.3%
+-rgt-identity48.3%
Simplified48.3%
metadata-eval48.3%
sqrt-pow240.5%
add-sqr-sqrt25.9%
unpow-prod-down20.9%
pow1/220.9%
sqrt-pow121.9%
+-commutative21.9%
metadata-eval21.9%
pow1/221.9%
sqrt-pow119.8%
+-commutative19.8%
metadata-eval19.8%
Applied egg-rr19.8%
pow-sqr27.6%
metadata-eval27.6%
Simplified27.6%
Taylor expanded in x around inf 48.3%
unpow1/248.3%
+-inverses48.3%
Simplified48.3%
Final simplification65.4%
(FPCore (x) :precision binary64 (/ 1.0 (sqrt (* x (+ x 1.0)))))
double code(double x) {
return 1.0 / sqrt((x * (x + 1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / sqrt((x * (x + 1.0d0)))
end function
public static double code(double x) {
return 1.0 / Math.sqrt((x * (x + 1.0)));
}
def code(x): return 1.0 / math.sqrt((x * (x + 1.0)))
function code(x) return Float64(1.0 / sqrt(Float64(x * Float64(x + 1.0)))) end
function tmp = code(x) tmp = 1.0 / sqrt((x * (x + 1.0))); end
code[x_] := N[(1.0 / N[Sqrt[N[(x * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{x \cdot \left(x + 1\right)}}
\end{array}
Initial program 67.2%
frac-sub67.3%
clear-num67.3%
sqrt-unprod67.3%
+-commutative67.3%
*-un-lft-identity67.3%
*-rgt-identity67.3%
+-commutative67.3%
Applied egg-rr67.3%
associate-/r/67.3%
Simplified67.3%
flip--68.2%
add-sqr-sqrt68.1%
+-commutative68.1%
add-sqr-sqrt68.8%
+-commutative68.8%
Applied egg-rr68.8%
Taylor expanded in x around 0 91.5%
Taylor expanded in x around 0 65.1%
Final simplification65.1%
(FPCore (x) :precision binary64 (if (<= x 8.5e+122) (pow x -0.5) 0.0))
double code(double x) {
double tmp;
if (x <= 8.5e+122) {
tmp = pow(x, -0.5);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 8.5d+122) then
tmp = x ** (-0.5d0)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 8.5e+122) {
tmp = Math.pow(x, -0.5);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 8.5e+122: tmp = math.pow(x, -0.5) else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= 8.5e+122) tmp = x ^ -0.5; else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 8.5e+122) tmp = x ^ -0.5; else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 8.5e+122], N[Power[x, -0.5], $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.5 \cdot 10^{+122}:\\
\;\;\;\;{x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 8.50000000000000003e122Initial program 70.7%
add-log-exp6.5%
*-un-lft-identity6.5%
log-prod6.5%
metadata-eval6.5%
add-log-exp70.7%
pow1/270.7%
pow-flip71.3%
metadata-eval71.3%
Applied egg-rr71.3%
+-lft-identity71.3%
Simplified71.3%
Taylor expanded in x around inf 67.3%
inv-pow67.3%
sqrt-pow167.4%
metadata-eval67.4%
expm1-log1p-u62.2%
expm1-udef61.7%
Applied egg-rr61.7%
expm1-def62.2%
expm1-log1p67.4%
Simplified67.4%
if 8.50000000000000003e122 < x Initial program 59.4%
*-un-lft-identity59.4%
clear-num59.4%
associate-/r/59.4%
prod-diff59.4%
*-un-lft-identity59.4%
fma-neg59.4%
*-un-lft-identity59.4%
inv-pow59.4%
sqrt-pow249.6%
metadata-eval49.6%
pow1/249.6%
pow-flip59.4%
+-commutative59.4%
metadata-eval59.4%
Applied egg-rr59.4%
fma-udef59.4%
distribute-lft1-in59.4%
metadata-eval59.4%
mul0-lft59.4%
+-rgt-identity59.4%
Simplified59.4%
metadata-eval59.4%
sqrt-pow249.6%
add-sqr-sqrt31.2%
unpow-prod-down25.0%
pow1/225.0%
sqrt-pow126.3%
+-commutative26.3%
metadata-eval26.3%
pow1/226.3%
sqrt-pow123.8%
+-commutative23.8%
metadata-eval23.8%
Applied egg-rr23.8%
pow-sqr33.5%
metadata-eval33.5%
Simplified33.5%
Taylor expanded in x around inf 59.4%
unpow1/259.4%
+-inverses59.4%
Simplified59.4%
Final simplification64.9%
(FPCore (x) :precision binary64 (if (<= x 4.6e+153) (/ 1.0 x) 0.0))
double code(double x) {
double tmp;
if (x <= 4.6e+153) {
tmp = 1.0 / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 4.6d+153) then
tmp = 1.0d0 / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 4.6e+153) {
tmp = 1.0 / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 4.6e+153: tmp = 1.0 / x else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= 4.6e+153) tmp = Float64(1.0 / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 4.6e+153) tmp = 1.0 / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 4.6e+153], N[(1.0 / x), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.6 \cdot 10^{+153}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 4.6000000000000003e153Initial program 66.6%
frac-sub66.7%
clear-num66.7%
sqrt-unprod66.7%
+-commutative66.7%
*-un-lft-identity66.7%
*-rgt-identity66.7%
+-commutative66.7%
Applied egg-rr66.7%
associate-/r/66.7%
Simplified66.7%
flip--67.9%
add-sqr-sqrt67.7%
+-commutative67.7%
add-sqr-sqrt68.8%
+-commutative68.8%
Applied egg-rr68.8%
Taylor expanded in x around inf 8.9%
Taylor expanded in x around 0 7.4%
if 4.6000000000000003e153 < x Initial program 69.1%
*-un-lft-identity69.1%
clear-num69.1%
associate-/r/69.1%
prod-diff69.1%
*-un-lft-identity69.1%
fma-neg69.1%
*-un-lft-identity69.1%
inv-pow69.1%
sqrt-pow257.6%
metadata-eval57.6%
pow1/257.6%
pow-flip69.1%
+-commutative69.1%
metadata-eval69.1%
Applied egg-rr69.1%
fma-udef69.1%
distribute-lft1-in69.1%
metadata-eval69.1%
mul0-lft69.1%
+-rgt-identity69.1%
Simplified69.1%
metadata-eval69.1%
sqrt-pow257.6%
add-sqr-sqrt36.0%
unpow-prod-down28.6%
pow1/228.6%
sqrt-pow130.2%
+-commutative30.2%
metadata-eval30.2%
pow1/230.2%
sqrt-pow127.2%
+-commutative27.2%
metadata-eval27.2%
Applied egg-rr27.2%
pow-sqr38.7%
metadata-eval38.7%
Simplified38.7%
Taylor expanded in x around inf 69.1%
unpow1/269.1%
+-inverses69.1%
Simplified69.1%
Final simplification23.5%
(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 67.2%
Taylor expanded in x around 0 46.7%
Taylor expanded in x around inf 1.9%
Final simplification1.9%
(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 67.2%
*-un-lft-identity67.2%
clear-num67.2%
associate-/r/67.2%
prod-diff67.2%
*-un-lft-identity67.2%
fma-neg67.2%
*-un-lft-identity67.2%
inv-pow67.2%
sqrt-pow264.6%
metadata-eval64.6%
pow1/264.6%
pow-flip67.5%
+-commutative67.5%
metadata-eval67.5%
Applied egg-rr67.5%
fma-udef67.5%
distribute-lft1-in67.5%
metadata-eval67.5%
mul0-lft67.5%
+-rgt-identity67.5%
Simplified67.5%
metadata-eval67.5%
sqrt-pow264.6%
add-sqr-sqrt59.0%
unpow-prod-down56.9%
pow1/256.9%
sqrt-pow157.3%
+-commutative57.3%
metadata-eval57.3%
pow1/257.3%
sqrt-pow156.5%
+-commutative56.5%
metadata-eval56.5%
Applied egg-rr56.5%
pow-sqr59.6%
metadata-eval59.6%
Simplified59.6%
Taylor expanded in x around inf 20.4%
unpow1/220.4%
+-inverses20.4%
Simplified20.4%
Final simplification20.4%
(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 2023266
(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)))))