
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
public static double code(double x) {
return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
def code(x): return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
function code(x) return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) end
function tmp = code(x) tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))); end
code[x_] := N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
public static double code(double x) {
return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
def code(x): return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
function code(x) return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) end
function tmp = code(x) tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))); end
code[x_] := N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\end{array}
(FPCore (x) :precision binary64 (if (<= (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))) 2e-8) (* (pow x -0.5) (- (+ (/ 0.5 x) (/ 0.3125 (pow x 3.0))) (/ 0.375 (* x x)))) (* (pow x -0.5) (- 1.0 (sqrt (/ x (+ x 1.0)))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)))) <= 2e-8) {
tmp = pow(x, -0.5) * (((0.5 / x) + (0.3125 / pow(x, 3.0))) - (0.375 / (x * x)));
} else {
tmp = pow(x, -0.5) * (1.0 - sqrt((x / (x + 1.0))));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))) <= 2d-8) then
tmp = (x ** (-0.5d0)) * (((0.5d0 / x) + (0.3125d0 / (x ** 3.0d0))) - (0.375d0 / (x * x)))
else
tmp = (x ** (-0.5d0)) * (1.0d0 - sqrt((x / (x + 1.0d0))))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)))) <= 2e-8) {
tmp = Math.pow(x, -0.5) * (((0.5 / x) + (0.3125 / Math.pow(x, 3.0))) - (0.375 / (x * x)));
} else {
tmp = Math.pow(x, -0.5) * (1.0 - Math.sqrt((x / (x + 1.0))));
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))) <= 2e-8: tmp = math.pow(x, -0.5) * (((0.5 / x) + (0.3125 / math.pow(x, 3.0))) - (0.375 / (x * x))) else: tmp = math.pow(x, -0.5) * (1.0 - math.sqrt((x / (x + 1.0)))) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) <= 2e-8) tmp = Float64((x ^ -0.5) * Float64(Float64(Float64(0.5 / x) + Float64(0.3125 / (x ^ 3.0))) - Float64(0.375 / Float64(x * x)))); else tmp = Float64((x ^ -0.5) * Float64(1.0 - sqrt(Float64(x / Float64(x + 1.0))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)))) <= 2e-8) tmp = (x ^ -0.5) * (((0.5 / x) + (0.3125 / (x ^ 3.0))) - (0.375 / (x * x))); else tmp = (x ^ -0.5) * (1.0 - sqrt((x / (x + 1.0)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e-8], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(N[(0.5 / x), $MachinePrecision] + N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $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[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\left(\frac{0.5}{x} + \frac{0.3125}{{x}^{3}}\right) - \frac{0.375}{x \cdot x}\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(1 - \sqrt{\frac{x}{x + 1}}\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 2e-8Initial program 36.0%
frac-sub36.0%
div-inv36.0%
*-un-lft-identity36.0%
+-commutative36.0%
*-rgt-identity36.0%
metadata-eval36.0%
frac-times36.0%
un-div-inv36.0%
pow1/236.0%
pow-flip36.0%
metadata-eval36.0%
+-commutative36.0%
Applied egg-rr36.0%
associate-*r/36.0%
*-rgt-identity36.0%
times-frac36.0%
div-sub36.0%
*-inverses36.0%
/-rgt-identity36.0%
Simplified36.0%
Taylor expanded in x around inf 99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*r/99.6%
metadata-eval99.6%
unpow299.6%
Simplified99.6%
if 2e-8 < (-.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.8%
metadata-eval99.8%
+-commutative99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
times-frac99.8%
div-sub99.8%
*-inverses99.8%
/-rgt-identity99.8%
Simplified99.8%
expm1-log1p-u93.2%
expm1-udef93.2%
*-commutative93.2%
sqrt-undiv93.1%
Applied egg-rr93.1%
expm1-def93.3%
expm1-log1p99.8%
Simplified99.8%
Final simplification99.7%
(FPCore (x) :precision binary64 (let* ((t_0 (pow (+ x 1.0) 0.25))) (* (/ (pow x -0.5) t_0) (/ (/ 1.0 (+ (sqrt (+ x 1.0)) (sqrt x))) t_0))))
double code(double x) {
double t_0 = pow((x + 1.0), 0.25);
return (pow(x, -0.5) / t_0) * ((1.0 / (sqrt((x + 1.0)) + sqrt(x))) / t_0);
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = (x + 1.0d0) ** 0.25d0
code = ((x ** (-0.5d0)) / t_0) * ((1.0d0 / (sqrt((x + 1.0d0)) + sqrt(x))) / t_0)
end function
public static double code(double x) {
double t_0 = Math.pow((x + 1.0), 0.25);
return (Math.pow(x, -0.5) / t_0) * ((1.0 / (Math.sqrt((x + 1.0)) + Math.sqrt(x))) / t_0);
}
def code(x): t_0 = math.pow((x + 1.0), 0.25) return (math.pow(x, -0.5) / t_0) * ((1.0 / (math.sqrt((x + 1.0)) + math.sqrt(x))) / t_0)
function code(x) t_0 = Float64(x + 1.0) ^ 0.25 return Float64(Float64((x ^ -0.5) / t_0) * Float64(Float64(1.0 / Float64(sqrt(Float64(x + 1.0)) + sqrt(x))) / t_0)) end
function tmp = code(x) t_0 = (x + 1.0) ^ 0.25; tmp = ((x ^ -0.5) / t_0) * ((1.0 / (sqrt((x + 1.0)) + sqrt(x))) / t_0); end
code[x_] := Block[{t$95$0 = N[Power[N[(x + 1.0), $MachinePrecision], 0.25], $MachinePrecision]}, N[(N[(N[Power[x, -0.5], $MachinePrecision] / t$95$0), $MachinePrecision] * N[(N[(1.0 / N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x + 1\right)}^{0.25}\\
\frac{{x}^{-0.5}}{t_0} \cdot \frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{t_0}
\end{array}
\end{array}
Initial program 68.2%
frac-sub68.2%
div-inv68.2%
*-un-lft-identity68.2%
+-commutative68.2%
*-rgt-identity68.2%
metadata-eval68.2%
frac-times68.2%
un-div-inv68.2%
pow1/268.2%
pow-flip68.4%
metadata-eval68.4%
+-commutative68.4%
Applied egg-rr68.4%
associate-*r/68.4%
Simplified68.4%
flip--68.5%
add-sqr-sqrt59.8%
add-sqr-sqrt69.5%
Applied egg-rr69.5%
associate--l+99.5%
+-inverses99.5%
metadata-eval99.5%
Simplified99.5%
*-commutative99.5%
metadata-eval99.5%
pow-flip99.3%
pow1/299.3%
add-sqr-sqrt99.2%
times-frac99.2%
pow1/299.2%
pow-flip99.5%
metadata-eval99.5%
pow1/299.5%
sqrt-pow199.5%
metadata-eval99.5%
pow1/299.5%
sqrt-pow199.6%
metadata-eval99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x) :precision binary64 (if (<= (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))) 2e-9) (* (pow x -0.5) (- (/ 0.5 x) (/ 0.375 (* x x)))) (* (pow x -0.5) (- 1.0 (sqrt (/ x (+ x 1.0)))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)))) <= 2e-9) {
tmp = pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
} else {
tmp = pow(x, -0.5) * (1.0 - sqrt((x / (x + 1.0))));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))) <= 2d-9) then
tmp = (x ** (-0.5d0)) * ((0.5d0 / x) - (0.375d0 / (x * x)))
else
tmp = (x ** (-0.5d0)) * (1.0d0 - sqrt((x / (x + 1.0d0))))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)))) <= 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 / (x + 1.0))));
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))) <= 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 / (x + 1.0)))) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) <= 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(x + 1.0))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)))) <= 2e-9) tmp = (x ^ -0.5) * ((0.5 / x) - (0.375 / (x * x))); else tmp = (x ^ -0.5) * (1.0 - sqrt((x / (x + 1.0)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x + 1.0), $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[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \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}{x + 1}}\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 2.00000000000000012e-9Initial program 35.7%
frac-sub35.7%
div-inv35.7%
*-un-lft-identity35.7%
+-commutative35.7%
*-rgt-identity35.7%
metadata-eval35.7%
frac-times35.7%
un-div-inv35.7%
pow1/235.7%
pow-flip35.7%
metadata-eval35.7%
+-commutative35.7%
Applied egg-rr35.7%
associate-*r/35.7%
*-rgt-identity35.7%
times-frac35.7%
div-sub35.6%
*-inverses35.6%
/-rgt-identity35.6%
Simplified35.6%
Taylor expanded in x around inf 99.4%
associate-*r/99.4%
metadata-eval99.4%
associate-*r/99.4%
metadata-eval99.4%
unpow299.4%
Simplified99.4%
if 2.00000000000000012e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.2%
frac-sub99.3%
div-inv99.2%
*-un-lft-identity99.2%
+-commutative99.2%
*-rgt-identity99.2%
metadata-eval99.2%
frac-times99.2%
un-div-inv99.2%
pow1/299.2%
pow-flip99.6%
metadata-eval99.6%
+-commutative99.6%
Applied egg-rr99.6%
associate-*r/99.6%
*-rgt-identity99.6%
times-frac99.6%
div-sub99.7%
*-inverses99.7%
/-rgt-identity99.7%
Simplified99.7%
expm1-log1p-u93.1%
expm1-udef92.9%
*-commutative92.9%
sqrt-undiv92.9%
Applied egg-rr92.9%
expm1-def93.2%
expm1-log1p99.7%
Simplified99.7%
Final simplification99.6%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (sqrt (+ x 1.0)))))
(if (<= (- (/ 1.0 (sqrt x)) t_0) 2e-9)
(* (pow x -0.5) (- (/ 0.5 x) (/ 0.375 (* x x))))
(- (pow x -0.5) t_0))))
double code(double x) {
double t_0 = 1.0 / sqrt((x + 1.0));
double tmp;
if (((1.0 / sqrt(x)) - t_0) <= 2e-9) {
tmp = pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
} else {
tmp = pow(x, -0.5) - t_0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 / sqrt((x + 1.0d0))
if (((1.0d0 / sqrt(x)) - t_0) <= 2d-9) then
tmp = (x ** (-0.5d0)) * ((0.5d0 / x) - (0.375d0 / (x * x)))
else
tmp = (x ** (-0.5d0)) - t_0
end if
code = tmp
end function
public static double code(double x) {
double t_0 = 1.0 / Math.sqrt((x + 1.0));
double tmp;
if (((1.0 / Math.sqrt(x)) - t_0) <= 2e-9) {
tmp = Math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
} else {
tmp = Math.pow(x, -0.5) - t_0;
}
return tmp;
}
def code(x): t_0 = 1.0 / math.sqrt((x + 1.0)) tmp = 0 if ((1.0 / math.sqrt(x)) - t_0) <= 2e-9: tmp = math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x))) else: tmp = math.pow(x, -0.5) - t_0 return tmp
function code(x) t_0 = Float64(1.0 / sqrt(Float64(x + 1.0))) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) - t_0) <= 2e-9) tmp = Float64((x ^ -0.5) * Float64(Float64(0.5 / x) - Float64(0.375 / Float64(x * x)))); else tmp = Float64((x ^ -0.5) - t_0); end return tmp end
function tmp_2 = code(x) t_0 = 1.0 / sqrt((x + 1.0)); tmp = 0.0; if (((1.0 / sqrt(x)) - t_0) <= 2e-9) tmp = (x ^ -0.5) * ((0.5 / x) - (0.375 / (x * x))); else tmp = (x ^ -0.5) - t_0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - t$95$0), $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] - t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\sqrt{x + 1}}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} - t_0 \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} - t_0\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 2.00000000000000012e-9Initial program 35.7%
frac-sub35.7%
div-inv35.7%
*-un-lft-identity35.7%
+-commutative35.7%
*-rgt-identity35.7%
metadata-eval35.7%
frac-times35.7%
un-div-inv35.7%
pow1/235.7%
pow-flip35.7%
metadata-eval35.7%
+-commutative35.7%
Applied egg-rr35.7%
associate-*r/35.7%
*-rgt-identity35.7%
times-frac35.7%
div-sub35.6%
*-inverses35.6%
/-rgt-identity35.6%
Simplified35.6%
Taylor expanded in x around inf 99.4%
associate-*r/99.4%
metadata-eval99.4%
associate-*r/99.4%
metadata-eval99.4%
unpow299.4%
Simplified99.4%
if 2.00000000000000012e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.2%
add-log-exp8.4%
*-un-lft-identity8.4%
log-prod8.4%
metadata-eval8.4%
add-log-exp99.2%
pow1/299.2%
pow-flip99.7%
metadata-eval99.7%
Applied egg-rr99.7%
+-lft-identity99.7%
Simplified99.7%
Final simplification99.6%
(FPCore (x) :precision binary64 (let* ((t_0 (sqrt (+ x 1.0)))) (/ (pow x -0.5) (* t_0 (+ t_0 (sqrt x))))))
double code(double x) {
double t_0 = sqrt((x + 1.0));
return pow(x, -0.5) / (t_0 * (t_0 + sqrt(x)));
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sqrt((x + 1.0d0))
code = (x ** (-0.5d0)) / (t_0 * (t_0 + sqrt(x)))
end function
public static double code(double x) {
double t_0 = Math.sqrt((x + 1.0));
return Math.pow(x, -0.5) / (t_0 * (t_0 + Math.sqrt(x)));
}
def code(x): t_0 = math.sqrt((x + 1.0)) return math.pow(x, -0.5) / (t_0 * (t_0 + math.sqrt(x)))
function code(x) t_0 = sqrt(Float64(x + 1.0)) return Float64((x ^ -0.5) / Float64(t_0 * Float64(t_0 + sqrt(x)))) end
function tmp = code(x) t_0 = sqrt((x + 1.0)); tmp = (x ^ -0.5) / (t_0 * (t_0 + sqrt(x))); end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, N[(N[Power[x, -0.5], $MachinePrecision] / N[(t$95$0 * N[(t$95$0 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{x + 1}\\
\frac{{x}^{-0.5}}{t_0 \cdot \left(t_0 + \sqrt{x}\right)}
\end{array}
\end{array}
Initial program 68.2%
frac-sub68.2%
div-inv68.2%
*-un-lft-identity68.2%
+-commutative68.2%
*-rgt-identity68.2%
metadata-eval68.2%
frac-times68.2%
un-div-inv68.2%
pow1/268.2%
pow-flip68.4%
metadata-eval68.4%
+-commutative68.4%
Applied egg-rr68.4%
associate-*r/68.4%
Simplified68.4%
flip--68.5%
add-sqr-sqrt59.8%
add-sqr-sqrt69.5%
Applied egg-rr69.5%
associate--l+99.5%
+-inverses99.5%
metadata-eval99.5%
Simplified99.5%
metadata-eval99.5%
pow-flip99.3%
pow1/299.3%
*-un-lft-identity99.3%
times-frac99.3%
pow1/299.3%
pow-flip99.5%
metadata-eval99.5%
Applied egg-rr99.5%
/-rgt-identity99.5%
associate-*r/99.5%
associate-*l/99.5%
associate-/l/99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x) :precision binary64 (if (<= x 145000.0) (- (pow x -0.5) (pow (+ x 1.0) -0.5)) (* (pow x -0.5) (- (/ 0.5 x) (/ 0.375 (* x x))))))
double code(double x) {
double tmp;
if (x <= 145000.0) {
tmp = pow(x, -0.5) - pow((x + 1.0), -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 <= 145000.0d0) then
tmp = (x ** (-0.5d0)) - ((x + 1.0d0) ** (-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 <= 145000.0) {
tmp = Math.pow(x, -0.5) - Math.pow((x + 1.0), -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 <= 145000.0: tmp = math.pow(x, -0.5) - math.pow((x + 1.0), -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 <= 145000.0) tmp = Float64((x ^ -0.5) - (Float64(x + 1.0) ^ -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 <= 145000.0) tmp = (x ^ -0.5) - ((x + 1.0) ^ -0.5); else tmp = (x ^ -0.5) * ((0.5 / x) - (0.375 / (x * x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 145000.0], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $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 145000:\\
\;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-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 < 145000Initial 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.7%
+-commutative99.7%
metadata-eval99.7%
Applied egg-rr99.7%
fma-udef99.7%
distribute-lft1-in99.7%
metadata-eval99.7%
mul0-lft99.7%
+-rgt-identity99.7%
Simplified99.7%
if 145000 < x Initial program 35.7%
frac-sub35.7%
div-inv35.7%
*-un-lft-identity35.7%
+-commutative35.7%
*-rgt-identity35.7%
metadata-eval35.7%
frac-times35.7%
un-div-inv35.7%
pow1/235.7%
pow-flip35.7%
metadata-eval35.7%
+-commutative35.7%
Applied egg-rr35.7%
associate-*r/35.7%
*-rgt-identity35.7%
times-frac35.7%
div-sub35.6%
*-inverses35.6%
/-rgt-identity35.6%
Simplified35.6%
Taylor expanded in x around inf 99.4%
associate-*r/99.4%
metadata-eval99.4%
associate-*r/99.4%
metadata-eval99.4%
unpow299.4%
Simplified99.4%
Final simplification99.6%
(FPCore (x) :precision binary64 (if (<= x 1.4) (- (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.4) {
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.4d0) 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.4) {
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.4: 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.4) 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.4) 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.4], 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.4:\\
\;\;\;\;{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.3999999999999999Initial program 99.5%
inv-pow99.5%
pow1/299.5%
pow-pow100.0%
add-exp-log93.3%
pow-exp93.3%
metadata-eval93.3%
Applied egg-rr93.3%
Taylor expanded in x around 0 91.3%
pow-to-exp98.0%
expm1-log1p-u91.3%
expm1-udef91.3%
log1p-udef91.3%
metadata-eval91.3%
*-rgt-identity91.3%
metadata-eval91.3%
sqrt-pow291.3%
inv-pow91.3%
add-exp-log97.6%
metadata-eval97.6%
associate-*l/97.6%
metadata-eval97.6%
pow1/297.6%
pow-flip98.0%
metadata-eval98.0%
+-commutative98.0%
Applied egg-rr98.0%
associate--l+98.0%
metadata-eval98.0%
+-rgt-identity98.0%
Simplified98.0%
if 1.3999999999999999 < x Initial program 36.8%
frac-sub36.9%
div-inv36.9%
*-un-lft-identity36.9%
+-commutative36.9%
*-rgt-identity36.9%
metadata-eval36.9%
frac-times36.9%
un-div-inv36.9%
pow1/236.9%
pow-flip36.9%
metadata-eval36.9%
+-commutative36.9%
Applied egg-rr36.9%
associate-*r/36.9%
*-rgt-identity36.9%
times-frac36.9%
div-sub36.8%
*-inverses36.8%
/-rgt-identity36.8%
Simplified36.8%
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 simplification98.1%
(FPCore (x) :precision binary64 (if (<= x 1.15) (- (pow x -0.5) (/ 1.0 (+ 1.0 (* x 0.5)))) (/ (/ 0.5 x) (sqrt (+ x 1.0)))))
double code(double x) {
double tmp;
if (x <= 1.15) {
tmp = pow(x, -0.5) - (1.0 / (1.0 + (x * 0.5)));
} else {
tmp = (0.5 / x) / sqrt((x + 1.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.15d0) then
tmp = (x ** (-0.5d0)) - (1.0d0 / (1.0d0 + (x * 0.5d0)))
else
tmp = (0.5d0 / x) / sqrt((x + 1.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.15) {
tmp = Math.pow(x, -0.5) - (1.0 / (1.0 + (x * 0.5)));
} else {
tmp = (0.5 / x) / Math.sqrt((x + 1.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.15: tmp = math.pow(x, -0.5) - (1.0 / (1.0 + (x * 0.5))) else: tmp = (0.5 / x) / math.sqrt((x + 1.0)) return tmp
function code(x) tmp = 0.0 if (x <= 1.15) tmp = Float64((x ^ -0.5) - Float64(1.0 / Float64(1.0 + Float64(x * 0.5)))); else tmp = Float64(Float64(0.5 / x) / sqrt(Float64(x + 1.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.15) tmp = (x ^ -0.5) - (1.0 / (1.0 + (x * 0.5))); else tmp = (0.5 / x) / sqrt((x + 1.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.15], N[(N[Power[x, -0.5], $MachinePrecision] - N[(1.0 / N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.15:\\
\;\;\;\;{x}^{-0.5} - \frac{1}{1 + x \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{x + 1}}\\
\end{array}
\end{array}
if x < 1.1499999999999999Initial program 99.5%
inv-pow99.5%
pow1/299.5%
pow-pow100.0%
add-exp-log93.3%
pow-exp93.3%
metadata-eval93.3%
Applied egg-rr93.3%
Taylor expanded in x around 0 91.3%
pow-to-exp98.0%
expm1-log1p-u91.3%
expm1-udef91.3%
log1p-udef91.3%
metadata-eval91.3%
*-rgt-identity91.3%
metadata-eval91.3%
sqrt-pow291.3%
inv-pow91.3%
add-exp-log97.6%
metadata-eval97.6%
associate-*l/97.6%
metadata-eval97.6%
pow1/297.6%
pow-flip98.0%
metadata-eval98.0%
+-commutative98.0%
Applied egg-rr98.0%
associate--l+98.0%
metadata-eval98.0%
+-rgt-identity98.0%
Simplified98.0%
if 1.1499999999999999 < x Initial program 36.8%
frac-sub36.9%
div-inv36.9%
*-un-lft-identity36.9%
+-commutative36.9%
*-rgt-identity36.9%
metadata-eval36.9%
frac-times36.9%
un-div-inv36.9%
pow1/236.9%
pow-flip36.9%
metadata-eval36.9%
+-commutative36.9%
Applied egg-rr36.9%
associate-*r/36.9%
Simplified36.9%
flip--37.1%
add-sqr-sqrt19.9%
add-sqr-sqrt39.2%
Applied egg-rr39.2%
associate--l+99.3%
+-inverses99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in x around inf 97.2%
Final simplification97.6%
(FPCore (x) :precision binary64 (if (<= x 0.7) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (/ (/ 0.5 x) (sqrt (+ x 1.0)))))
double code(double x) {
double tmp;
if (x <= 0.7) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = (0.5 / x) / sqrt((x + 1.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.7d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = (0.5d0 / x) / sqrt((x + 1.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.7) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = (0.5 / x) / Math.sqrt((x + 1.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.7: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = (0.5 / x) / math.sqrt((x + 1.0)) return tmp
function code(x) tmp = 0.0 if (x <= 0.7) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); else tmp = Float64(Float64(0.5 / x) / sqrt(Float64(x + 1.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.7) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = (0.5 / x) / sqrt((x + 1.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.7], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.7:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{x + 1}}\\
\end{array}
\end{array}
if x < 0.69999999999999996Initial 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 97.9%
if 0.69999999999999996 < x Initial program 36.8%
frac-sub36.9%
div-inv36.9%
*-un-lft-identity36.9%
+-commutative36.9%
*-rgt-identity36.9%
metadata-eval36.9%
frac-times36.9%
un-div-inv36.9%
pow1/236.9%
pow-flip36.9%
metadata-eval36.9%
+-commutative36.9%
Applied egg-rr36.9%
associate-*r/36.9%
Simplified36.9%
flip--37.1%
add-sqr-sqrt19.9%
add-sqr-sqrt39.2%
Applied egg-rr39.2%
associate--l+99.3%
+-inverses99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in x around inf 97.2%
Final simplification97.5%
(FPCore (x) :precision binary64 (if (<= x 0.7) (+ (pow x -0.5) (- -1.0 (* x -0.5))) (/ (/ 0.5 x) (sqrt (+ x 1.0)))))
double code(double x) {
double tmp;
if (x <= 0.7) {
tmp = pow(x, -0.5) + (-1.0 - (x * -0.5));
} else {
tmp = (0.5 / x) / sqrt((x + 1.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.7d0) then
tmp = (x ** (-0.5d0)) + ((-1.0d0) - (x * (-0.5d0)))
else
tmp = (0.5d0 / x) / sqrt((x + 1.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.7) {
tmp = Math.pow(x, -0.5) + (-1.0 - (x * -0.5));
} else {
tmp = (0.5 / x) / Math.sqrt((x + 1.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.7: tmp = math.pow(x, -0.5) + (-1.0 - (x * -0.5)) else: tmp = (0.5 / x) / math.sqrt((x + 1.0)) return tmp
function code(x) tmp = 0.0 if (x <= 0.7) tmp = Float64((x ^ -0.5) + Float64(-1.0 - Float64(x * -0.5))); else tmp = Float64(Float64(0.5 / x) / sqrt(Float64(x + 1.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.7) tmp = (x ^ -0.5) + (-1.0 - (x * -0.5)); else tmp = (0.5 / x) / sqrt((x + 1.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.7], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 - N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.7:\\
\;\;\;\;{x}^{-0.5} + \left(-1 - x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{x + 1}}\\
\end{array}
\end{array}
if x < 0.69999999999999996Initial 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 97.9%
if 0.69999999999999996 < x Initial program 36.8%
frac-sub36.9%
div-inv36.9%
*-un-lft-identity36.9%
+-commutative36.9%
*-rgt-identity36.9%
metadata-eval36.9%
frac-times36.9%
un-div-inv36.9%
pow1/236.9%
pow-flip36.9%
metadata-eval36.9%
+-commutative36.9%
Applied egg-rr36.9%
associate-*r/36.9%
Simplified36.9%
flip--37.1%
add-sqr-sqrt19.9%
add-sqr-sqrt39.2%
Applied egg-rr39.2%
associate--l+99.3%
+-inverses99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in x around inf 97.2%
Final simplification97.5%
(FPCore (x) :precision binary64 (if (<= x 0.48) (+ (pow x -0.5) -1.0) (/ (/ 0.5 x) (sqrt (+ x 1.0)))))
double code(double x) {
double tmp;
if (x <= 0.48) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = (0.5 / x) / sqrt((x + 1.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.48d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = (0.5d0 / x) / sqrt((x + 1.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.48) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = (0.5 / x) / Math.sqrt((x + 1.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.48: tmp = math.pow(x, -0.5) + -1.0 else: tmp = (0.5 / x) / math.sqrt((x + 1.0)) return tmp
function code(x) tmp = 0.0 if (x <= 0.48) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(Float64(0.5 / x) / sqrt(Float64(x + 1.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.48) tmp = (x ^ -0.5) + -1.0; else tmp = (0.5 / x) / sqrt((x + 1.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.48], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.48:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{x + 1}}\\
\end{array}
\end{array}
if x < 0.47999999999999998Initial 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 97.2%
if 0.47999999999999998 < x Initial program 36.8%
frac-sub36.9%
div-inv36.9%
*-un-lft-identity36.9%
+-commutative36.9%
*-rgt-identity36.9%
metadata-eval36.9%
frac-times36.9%
un-div-inv36.9%
pow1/236.9%
pow-flip36.9%
metadata-eval36.9%
+-commutative36.9%
Applied egg-rr36.9%
associate-*r/36.9%
Simplified36.9%
flip--37.1%
add-sqr-sqrt19.9%
add-sqr-sqrt39.2%
Applied egg-rr39.2%
associate--l+99.3%
+-inverses99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in x around inf 97.2%
Final simplification97.2%
(FPCore (x) :precision binary64 (if (<= x 0.82) (+ (pow x -0.5) -1.0) (pow (* x x) -0.25)))
double code(double x) {
double tmp;
if (x <= 0.82) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = pow((x * x), -0.25);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.82d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = (x * x) ** (-0.25d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.82) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = Math.pow((x * x), -0.25);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.82: tmp = math.pow(x, -0.5) + -1.0 else: tmp = math.pow((x * x), -0.25) return tmp
function code(x) tmp = 0.0 if (x <= 0.82) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(x * x) ^ -0.25; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.82) tmp = (x ^ -0.5) + -1.0; else tmp = (x * x) ^ -0.25; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.82], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[Power[N[(x * x), $MachinePrecision], -0.25], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.82:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;{\left(x \cdot x\right)}^{-0.25}\\
\end{array}
\end{array}
if x < 0.819999999999999951Initial 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 97.2%
if 0.819999999999999951 < x Initial program 36.8%
inv-pow36.8%
pow1/236.8%
pow-pow28.7%
add-exp-log7.8%
pow-exp7.8%
metadata-eval7.8%
Applied egg-rr7.8%
Taylor expanded in x around 0 5.6%
Taylor expanded in x around inf 5.6%
inv-pow5.6%
sqrt-pow15.6%
metadata-eval5.6%
sqr-pow5.6%
pow-prod-down34.5%
metadata-eval34.5%
Applied egg-rr34.5%
Final simplification65.8%
(FPCore (x) :precision binary64 (+ (pow x -0.5) -1.0))
double code(double x) {
return pow(x, -0.5) + -1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x ** (-0.5d0)) + (-1.0d0)
end function
public static double code(double x) {
return Math.pow(x, -0.5) + -1.0;
}
def code(x): return math.pow(x, -0.5) + -1.0
function code(x) return Float64((x ^ -0.5) + -1.0) end
function tmp = code(x) tmp = (x ^ -0.5) + -1.0; end
code[x_] := N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
{x}^{-0.5} + -1
\end{array}
Initial program 68.2%
*-un-lft-identity68.2%
clear-num68.2%
associate-/r/68.2%
prod-diff68.2%
*-un-lft-identity68.2%
fma-neg68.2%
*-un-lft-identity68.2%
inv-pow68.2%
sqrt-pow264.3%
metadata-eval64.3%
pow1/264.3%
pow-flip68.4%
+-commutative68.4%
metadata-eval68.4%
Applied egg-rr68.4%
fma-udef68.4%
distribute-lft1-in68.4%
metadata-eval68.4%
mul0-lft68.4%
+-rgt-identity68.4%
Simplified68.4%
Taylor expanded in x around 0 49.8%
Final simplification49.8%
(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 68.2%
inv-pow68.2%
pow1/268.2%
pow-pow64.3%
add-exp-log50.6%
pow-exp50.6%
metadata-eval50.6%
Applied egg-rr50.6%
Taylor expanded in x around 0 48.5%
Taylor expanded in x around inf 49.0%
inv-pow49.0%
sqrt-pow149.1%
metadata-eval49.1%
expm1-log1p-u45.9%
expm1-udef60.1%
Applied egg-rr60.1%
expm1-def45.9%
expm1-log1p49.1%
Simplified49.1%
Final simplification49.1%
(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 68.2%
Taylor expanded in x around 0 49.7%
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 2023278
(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)))))