
(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 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
public static double code(double x) {
return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
def code(x): return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
function code(x) return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) end
function tmp = code(x) tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))); end
code[x_] := N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\end{array}
(FPCore (x)
:precision binary64
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 2e-8)
(/
(-
(+ (/ 0.5 x) (/ 0.3125 (pow x 3.0)))
(+ (/ 0.375 (* x x)) (/ 0.2734375 (pow x 4.0))))
(sqrt x))
(- (pow x -0.5) (pow (+ 1.0 x) -0.5))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 2e-8) {
tmp = (((0.5 / x) + (0.3125 / pow(x, 3.0))) - ((0.375 / (x * x)) + (0.2734375 / pow(x, 4.0)))) / sqrt(x);
} else {
tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((1.0d0 + x)))) <= 2d-8) then
tmp = (((0.5d0 / x) + (0.3125d0 / (x ** 3.0d0))) - ((0.375d0 / (x * x)) + (0.2734375d0 / (x ** 4.0d0)))) / sqrt(x)
else
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / Math.sqrt((1.0 + x)))) <= 2e-8) {
tmp = (((0.5 / x) + (0.3125 / Math.pow(x, 3.0))) - ((0.375 / (x * x)) + (0.2734375 / Math.pow(x, 4.0)))) / Math.sqrt(x);
} else {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 2e-8: tmp = (((0.5 / x) + (0.3125 / math.pow(x, 3.0))) - ((0.375 / (x * x)) + (0.2734375 / math.pow(x, 4.0)))) / math.sqrt(x) else: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 2e-8) tmp = Float64(Float64(Float64(Float64(0.5 / x) + Float64(0.3125 / (x ^ 3.0))) - Float64(Float64(0.375 / Float64(x * x)) + Float64(0.2734375 / (x ^ 4.0)))) / sqrt(x)); else tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 2e-8) tmp = (((0.5 / x) + (0.3125 / (x ^ 3.0))) - ((0.375 / (x * x)) + (0.2734375 / (x ^ 4.0)))) / sqrt(x); else tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e-8], N[(N[(N[(N[(0.5 / x), $MachinePrecision] + N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(0.2734375 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\left(\frac{0.5}{x} + \frac{0.3125}{{x}^{3}}\right) - \left(\frac{0.375}{x \cdot x} + \frac{0.2734375}{{x}^{4}}\right)}{\sqrt{x}}\\
\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)))) < 2e-8Initial program 39.3%
frac-sub39.3%
div-inv39.3%
*-un-lft-identity39.3%
+-commutative39.3%
*-rgt-identity39.3%
metadata-eval39.3%
frac-times39.3%
un-div-inv39.3%
pow1/239.3%
pow-flip39.3%
metadata-eval39.3%
+-commutative39.3%
Applied egg-rr39.3%
associate-*r/39.3%
remove-double-neg39.3%
neg-mul-139.3%
*-commutative39.3%
times-frac39.3%
Simplified39.1%
associate-*r/39.1%
clear-num39.1%
*-commutative39.1%
sub-neg39.1%
distribute-neg-frac39.1%
add-sqr-sqrt0.0%
sqrt-unprod5.4%
sqr-neg5.4%
sqrt-prod5.4%
add-sqr-sqrt5.4%
remove-double-neg5.4%
frac-2neg5.4%
add-sqr-sqrt0.0%
sqrt-unprod39.1%
Applied egg-rr39.3%
associate-/r/39.3%
associate-*l/39.3%
neg-mul-139.3%
distribute-rgt-neg-in39.3%
*-lft-identity39.3%
neg-sub039.3%
associate--r+39.3%
metadata-eval39.3%
Simplified39.3%
Taylor expanded in x around inf 99.7%
+-commutative99.7%
associate-*r/99.7%
metadata-eval99.7%
associate-*r/99.7%
metadata-eval99.7%
+-commutative99.7%
associate-*r/99.7%
metadata-eval99.7%
unpow299.7%
associate-*r/99.7%
metadata-eval99.7%
Simplified99.7%
if 2e-8 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.4%
*-un-lft-identity99.4%
clear-num99.4%
associate-/r/99.4%
prod-diff99.4%
*-un-lft-identity99.4%
fma-neg99.4%
*-un-lft-identity99.4%
inv-pow99.4%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
neg-mul-1100.0%
rem-log-exp100.0%
log-rec100.0%
+-commutative100.0%
log-rec100.0%
rem-log-exp100.0%
sub-neg100.0%
+-inverses100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification99.8%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 2e-8) (/ (+ (/ 0.5 x) (+ (/ 0.3125 (pow x 3.0)) (/ -0.375 (* x x)))) (sqrt x)) (- (pow x -0.5) (pow (+ 1.0 x) -0.5))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 2e-8) {
tmp = ((0.5 / x) + ((0.3125 / pow(x, 3.0)) + (-0.375 / (x * x)))) / sqrt(x);
} else {
tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((1.0d0 + x)))) <= 2d-8) then
tmp = ((0.5d0 / x) + ((0.3125d0 / (x ** 3.0d0)) + ((-0.375d0) / (x * x)))) / sqrt(x)
else
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / Math.sqrt((1.0 + x)))) <= 2e-8) {
tmp = ((0.5 / x) + ((0.3125 / Math.pow(x, 3.0)) + (-0.375 / (x * x)))) / Math.sqrt(x);
} else {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 2e-8: tmp = ((0.5 / x) + ((0.3125 / math.pow(x, 3.0)) + (-0.375 / (x * x)))) / math.sqrt(x) else: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 2e-8) tmp = Float64(Float64(Float64(0.5 / x) + Float64(Float64(0.3125 / (x ^ 3.0)) + Float64(-0.375 / Float64(x * x)))) / sqrt(x)); else tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 2e-8) tmp = ((0.5 / x) + ((0.3125 / (x ^ 3.0)) + (-0.375 / (x * x)))) / sqrt(x); else tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e-8], N[(N[(N[(0.5 / x), $MachinePrecision] + N[(N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} + \frac{-0.375}{x \cdot x}\right)}{\sqrt{x}}\\
\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)))) < 2e-8Initial program 39.3%
frac-sub39.3%
div-inv39.3%
*-un-lft-identity39.3%
+-commutative39.3%
*-rgt-identity39.3%
metadata-eval39.3%
frac-times39.3%
un-div-inv39.3%
pow1/239.3%
pow-flip39.3%
metadata-eval39.3%
+-commutative39.3%
Applied egg-rr39.3%
associate-*r/39.3%
remove-double-neg39.3%
neg-mul-139.3%
*-commutative39.3%
times-frac39.3%
Simplified39.1%
associate-*r/39.1%
clear-num39.1%
*-commutative39.1%
sub-neg39.1%
distribute-neg-frac39.1%
add-sqr-sqrt0.0%
sqrt-unprod5.4%
sqr-neg5.4%
sqrt-prod5.4%
add-sqr-sqrt5.4%
remove-double-neg5.4%
frac-2neg5.4%
add-sqr-sqrt0.0%
sqrt-unprod39.1%
Applied egg-rr39.3%
associate-/r/39.3%
associate-*l/39.3%
neg-mul-139.3%
distribute-rgt-neg-in39.3%
*-lft-identity39.3%
neg-sub039.3%
associate--r+39.3%
metadata-eval39.3%
Simplified39.3%
Taylor expanded in x around inf 99.7%
sub-neg99.7%
+-commutative99.7%
associate-+l+99.7%
associate-*r/99.7%
metadata-eval99.7%
associate-*r/99.7%
metadata-eval99.7%
associate-*r/99.7%
metadata-eval99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
unpow299.7%
Simplified99.7%
if 2e-8 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.4%
*-un-lft-identity99.4%
clear-num99.4%
associate-/r/99.4%
prod-diff99.4%
*-un-lft-identity99.4%
fma-neg99.4%
*-un-lft-identity99.4%
inv-pow99.4%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
neg-mul-1100.0%
rem-log-exp100.0%
log-rec100.0%
+-commutative100.0%
log-rec100.0%
rem-log-exp100.0%
sub-neg100.0%
+-inverses100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification99.8%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 2e-11) (* (pow x -0.5) (+ (/ 0.5 x) (* -0.375 (pow x -2.0)))) (- (pow x -0.5) (pow (+ 1.0 x) -0.5))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 2e-11) {
tmp = pow(x, -0.5) * ((0.5 / x) + (-0.375 * pow(x, -2.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) :: tmp
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((1.0d0 + x)))) <= 2d-11) then
tmp = (x ** (-0.5d0)) * ((0.5d0 / x) + ((-0.375d0) * (x ** (-2.0d0))))
else
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / Math.sqrt((1.0 + x)))) <= 2e-11) {
tmp = Math.pow(x, -0.5) * ((0.5 / x) + (-0.375 * Math.pow(x, -2.0)));
} else {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 2e-11: tmp = math.pow(x, -0.5) * ((0.5 / x) + (-0.375 * math.pow(x, -2.0))) else: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 2e-11) tmp = Float64((x ^ -0.5) * Float64(Float64(0.5 / x) + Float64(-0.375 * (x ^ -2.0)))); else tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 2e-11) tmp = (x ^ -0.5) * ((0.5 / x) + (-0.375 * (x ^ -2.0))); else tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e-11], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(0.5 / x), $MachinePrecision] + N[(-0.375 * N[Power[x, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 2 \cdot 10^{-11}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} + -0.375 \cdot {x}^{-2}\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 1.99999999999999988e-11Initial program 38.9%
frac-sub39.0%
div-inv39.0%
*-un-lft-identity39.0%
+-commutative39.0%
*-rgt-identity39.0%
metadata-eval39.0%
frac-times39.0%
un-div-inv39.0%
pow1/239.0%
pow-flip39.0%
metadata-eval39.0%
+-commutative39.0%
Applied egg-rr39.0%
associate-*r/39.0%
remove-double-neg39.0%
neg-mul-139.0%
*-commutative39.0%
times-frac39.0%
Simplified38.9%
associate-*r/38.9%
clear-num38.9%
*-commutative38.9%
sub-neg38.9%
distribute-neg-frac38.9%
add-sqr-sqrt0.0%
sqrt-unprod5.4%
sqr-neg5.4%
sqrt-prod5.4%
add-sqr-sqrt5.4%
remove-double-neg5.4%
frac-2neg5.4%
add-sqr-sqrt0.0%
sqrt-unprod38.9%
Applied egg-rr39.0%
associate-/r/39.0%
associate-*l/39.0%
neg-mul-139.0%
distribute-rgt-neg-in39.0%
*-lft-identity39.0%
neg-sub039.0%
associate--r+39.0%
metadata-eval39.0%
Simplified39.0%
Taylor expanded in x around inf 99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*r/99.6%
metadata-eval99.6%
unpow299.6%
Simplified99.6%
div-inv99.6%
div-inv99.6%
pow299.6%
pow-flip99.6%
metadata-eval99.6%
pow1/299.6%
pow-flip99.7%
metadata-eval99.7%
Applied egg-rr99.7%
*-commutative99.7%
cancel-sign-sub-inv99.7%
metadata-eval99.7%
Simplified99.7%
if 1.99999999999999988e-11 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.3%
*-un-lft-identity99.3%
clear-num99.3%
associate-/r/99.3%
prod-diff99.3%
*-un-lft-identity99.3%
fma-neg99.3%
*-un-lft-identity99.3%
inv-pow99.3%
sqrt-pow299.8%
metadata-eval99.8%
pow1/299.8%
pow-flip99.8%
+-commutative99.8%
metadata-eval99.8%
Applied egg-rr99.8%
fma-udef99.8%
neg-mul-199.8%
rem-log-exp99.7%
log-rec99.6%
+-commutative99.6%
log-rec99.7%
rem-log-exp99.8%
sub-neg99.8%
+-inverses99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification99.7%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 2e-11) (/ (- (/ 0.5 x) (/ 0.375 (* x x))) (sqrt x)) (- (pow x -0.5) (pow (+ 1.0 x) -0.5))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 2e-11) {
tmp = ((0.5 / x) - (0.375 / (x * x))) / sqrt(x);
} else {
tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((1.0d0 + x)))) <= 2d-11) then
tmp = ((0.5d0 / x) - (0.375d0 / (x * x))) / sqrt(x)
else
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / Math.sqrt((1.0 + x)))) <= 2e-11) {
tmp = ((0.5 / x) - (0.375 / (x * x))) / Math.sqrt(x);
} else {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 2e-11: tmp = ((0.5 / x) - (0.375 / (x * x))) / math.sqrt(x) else: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 2e-11) tmp = Float64(Float64(Float64(0.5 / x) - Float64(0.375 / Float64(x * x))) / sqrt(x)); else tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 2e-11) tmp = ((0.5 / x) - (0.375 / (x * x))) / sqrt(x); else tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e-11], N[(N[(N[(0.5 / x), $MachinePrecision] - N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 2 \cdot 10^{-11}:\\
\;\;\;\;\frac{\frac{0.5}{x} - \frac{0.375}{x \cdot x}}{\sqrt{x}}\\
\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.99999999999999988e-11Initial program 38.9%
frac-sub39.0%
div-inv39.0%
*-un-lft-identity39.0%
+-commutative39.0%
*-rgt-identity39.0%
metadata-eval39.0%
frac-times39.0%
un-div-inv39.0%
pow1/239.0%
pow-flip39.0%
metadata-eval39.0%
+-commutative39.0%
Applied egg-rr39.0%
associate-*r/39.0%
remove-double-neg39.0%
neg-mul-139.0%
*-commutative39.0%
times-frac39.0%
Simplified38.9%
associate-*r/38.9%
clear-num38.9%
*-commutative38.9%
sub-neg38.9%
distribute-neg-frac38.9%
add-sqr-sqrt0.0%
sqrt-unprod5.4%
sqr-neg5.4%
sqrt-prod5.4%
add-sqr-sqrt5.4%
remove-double-neg5.4%
frac-2neg5.4%
add-sqr-sqrt0.0%
sqrt-unprod38.9%
Applied egg-rr39.0%
associate-/r/39.0%
associate-*l/39.0%
neg-mul-139.0%
distribute-rgt-neg-in39.0%
*-lft-identity39.0%
neg-sub039.0%
associate--r+39.0%
metadata-eval39.0%
Simplified39.0%
Taylor expanded in x around inf 99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*r/99.6%
metadata-eval99.6%
unpow299.6%
Simplified99.6%
if 1.99999999999999988e-11 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.3%
*-un-lft-identity99.3%
clear-num99.3%
associate-/r/99.3%
prod-diff99.3%
*-un-lft-identity99.3%
fma-neg99.3%
*-un-lft-identity99.3%
inv-pow99.3%
sqrt-pow299.8%
metadata-eval99.8%
pow1/299.8%
pow-flip99.8%
+-commutative99.8%
metadata-eval99.8%
Applied egg-rr99.8%
fma-udef99.8%
neg-mul-199.8%
rem-log-exp99.7%
log-rec99.6%
+-commutative99.6%
log-rec99.7%
rem-log-exp99.8%
sub-neg99.8%
+-inverses99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification99.7%
(FPCore (x) :precision binary64 (if (<= x 1.1) (+ (pow x -0.5) (- -1.0 (* x -0.5))) (/ (- (/ 0.5 x) (/ 0.375 (* x x))) (sqrt x))))
double code(double x) {
double tmp;
if (x <= 1.1) {
tmp = pow(x, -0.5) + (-1.0 - (x * -0.5));
} else {
tmp = ((0.5 / x) - (0.375 / (x * x))) / sqrt(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.1d0) then
tmp = (x ** (-0.5d0)) + ((-1.0d0) - (x * (-0.5d0)))
else
tmp = ((0.5d0 / x) - (0.375d0 / (x * x))) / sqrt(x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.1) {
tmp = Math.pow(x, -0.5) + (-1.0 - (x * -0.5));
} else {
tmp = ((0.5 / x) - (0.375 / (x * x))) / Math.sqrt(x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.1: tmp = math.pow(x, -0.5) + (-1.0 - (x * -0.5)) else: tmp = ((0.5 / x) - (0.375 / (x * x))) / math.sqrt(x) return tmp
function code(x) tmp = 0.0 if (x <= 1.1) tmp = Float64((x ^ -0.5) + Float64(-1.0 - Float64(x * -0.5))); else tmp = Float64(Float64(Float64(0.5 / x) - Float64(0.375 / Float64(x * x))) / sqrt(x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.1) tmp = (x ^ -0.5) + (-1.0 - (x * -0.5)); else tmp = ((0.5 / x) - (0.375 / (x * x))) / sqrt(x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.1], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 - N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 / x), $MachinePrecision] - N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.1:\\
\;\;\;\;{x}^{-0.5} + \left(-1 - x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{x} - \frac{0.375}{x \cdot x}}{\sqrt{x}}\\
\end{array}
\end{array}
if x < 1.1000000000000001Initial program 99.4%
*-un-lft-identity99.4%
clear-num99.4%
associate-/r/99.4%
prod-diff99.4%
*-un-lft-identity99.4%
fma-neg99.4%
*-un-lft-identity99.4%
inv-pow99.4%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
neg-mul-1100.0%
rem-log-exp100.0%
log-rec100.0%
+-commutative100.0%
log-rec100.0%
rem-log-exp100.0%
sub-neg100.0%
+-inverses100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 99.2%
*-commutative99.2%
Simplified99.2%
if 1.1000000000000001 < x Initial program 39.3%
frac-sub39.3%
div-inv39.3%
*-un-lft-identity39.3%
+-commutative39.3%
*-rgt-identity39.3%
metadata-eval39.3%
frac-times39.3%
un-div-inv39.3%
pow1/239.3%
pow-flip39.3%
metadata-eval39.3%
+-commutative39.3%
Applied egg-rr39.3%
associate-*r/39.3%
remove-double-neg39.3%
neg-mul-139.3%
*-commutative39.3%
times-frac39.3%
Simplified39.1%
associate-*r/39.1%
clear-num39.1%
*-commutative39.1%
sub-neg39.1%
distribute-neg-frac39.1%
add-sqr-sqrt0.0%
sqrt-unprod5.4%
sqr-neg5.4%
sqrt-prod5.4%
add-sqr-sqrt5.4%
remove-double-neg5.4%
frac-2neg5.4%
add-sqr-sqrt0.0%
sqrt-unprod39.1%
Applied egg-rr39.3%
associate-/r/39.3%
associate-*l/39.3%
neg-mul-139.3%
distribute-rgt-neg-in39.3%
*-lft-identity39.3%
neg-sub039.3%
associate--r+39.3%
metadata-eval39.3%
Simplified39.3%
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.3%
(FPCore (x) :precision binary64 (if (<= x 1.0) (+ (pow x -0.5) (- -1.0 (* x -0.5))) (/ (/ 0.5 x) (sqrt x))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = pow(x, -0.5) + (-1.0 - (x * -0.5));
} else {
tmp = (0.5 / x) / sqrt(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) - (x * (-0.5d0)))
else
tmp = (0.5d0 / x) / sqrt(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 - (x * -0.5));
} else {
tmp = (0.5 / x) / Math.sqrt(x);
}
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 / x) / math.sqrt(x) 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(Float64(0.5 / x) / sqrt(x)); 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) / sqrt(x); 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[(N[(0.5 / x), $MachinePrecision] / N[Sqrt[x], $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{\frac{0.5}{x}}{\sqrt{x}}\\
\end{array}
\end{array}
if x < 1Initial program 99.4%
*-un-lft-identity99.4%
clear-num99.4%
associate-/r/99.4%
prod-diff99.4%
*-un-lft-identity99.4%
fma-neg99.4%
*-un-lft-identity99.4%
inv-pow99.4%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
neg-mul-1100.0%
rem-log-exp100.0%
log-rec100.0%
+-commutative100.0%
log-rec100.0%
rem-log-exp100.0%
sub-neg100.0%
+-inverses100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 99.2%
*-commutative99.2%
Simplified99.2%
if 1 < x Initial program 39.3%
frac-sub39.3%
div-inv39.3%
*-un-lft-identity39.3%
+-commutative39.3%
*-rgt-identity39.3%
metadata-eval39.3%
frac-times39.3%
un-div-inv39.3%
pow1/239.3%
pow-flip39.3%
metadata-eval39.3%
+-commutative39.3%
Applied egg-rr39.3%
associate-*r/39.3%
remove-double-neg39.3%
neg-mul-139.3%
*-commutative39.3%
times-frac39.3%
Simplified39.1%
associate-*r/39.1%
clear-num39.1%
*-commutative39.1%
sub-neg39.1%
distribute-neg-frac39.1%
add-sqr-sqrt0.0%
sqrt-unprod5.4%
sqr-neg5.4%
sqrt-prod5.4%
add-sqr-sqrt5.4%
remove-double-neg5.4%
frac-2neg5.4%
add-sqr-sqrt0.0%
sqrt-unprod39.1%
Applied egg-rr39.3%
associate-/r/39.3%
associate-*l/39.3%
neg-mul-139.3%
distribute-rgt-neg-in39.3%
*-lft-identity39.3%
neg-sub039.3%
associate--r+39.3%
metadata-eval39.3%
Simplified39.3%
Taylor expanded in x around inf 98.8%
Final simplification99.0%
(FPCore (x) :precision binary64 (if (<= x 1.0) (+ (pow x -0.5) -1.0) (* 0.0 (sqrt (/ 1.0 x)))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = 0.0 * sqrt((1.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 * sqrt((1.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 * Math.sqrt((1.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 * math.sqrt((1.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 * sqrt(Float64(1.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 * sqrt((1.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 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;0 \cdot \sqrt{\frac{1}{x}}\\
\end{array}
\end{array}
if x < 1Initial program 99.4%
*-un-lft-identity99.4%
clear-num99.4%
associate-/r/99.4%
prod-diff99.4%
*-un-lft-identity99.4%
fma-neg99.4%
*-un-lft-identity99.4%
inv-pow99.4%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
neg-mul-1100.0%
rem-log-exp100.0%
log-rec100.0%
+-commutative100.0%
log-rec100.0%
rem-log-exp100.0%
sub-neg100.0%
+-inverses100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 98.7%
if 1 < x Initial program 39.3%
sub-neg39.3%
+-commutative39.3%
add-sqr-sqrt19.1%
distribute-rgt-neg-in19.1%
fma-def6.0%
inv-pow6.0%
sqrt-pow25.9%
+-commutative5.9%
metadata-eval5.9%
inv-pow5.9%
sqrt-pow25.9%
+-commutative5.9%
metadata-eval5.9%
pow1/25.9%
pow-flip5.9%
metadata-eval5.9%
Applied egg-rr5.9%
Taylor expanded in x around inf 37.8%
unpow1/237.8%
distribute-lft1-in37.8%
metadata-eval37.8%
Simplified37.8%
Final simplification67.5%
(FPCore (x) :precision binary64 (if (<= x 0.68) (+ (pow x -0.5) -1.0) (/ (/ 0.5 x) (sqrt x))))
double code(double x) {
double tmp;
if (x <= 0.68) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = (0.5 / x) / sqrt(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.68d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = (0.5d0 / x) / sqrt(x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.68) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = (0.5 / x) / Math.sqrt(x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.68: tmp = math.pow(x, -0.5) + -1.0 else: tmp = (0.5 / x) / math.sqrt(x) return tmp
function code(x) tmp = 0.0 if (x <= 0.68) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(Float64(0.5 / x) / sqrt(x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.68) tmp = (x ^ -0.5) + -1.0; else tmp = (0.5 / x) / sqrt(x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.68], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{x}}\\
\end{array}
\end{array}
if x < 0.680000000000000049Initial program 99.4%
*-un-lft-identity99.4%
clear-num99.4%
associate-/r/99.4%
prod-diff99.4%
*-un-lft-identity99.4%
fma-neg99.4%
*-un-lft-identity99.4%
inv-pow99.4%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
neg-mul-1100.0%
rem-log-exp100.0%
log-rec100.0%
+-commutative100.0%
log-rec100.0%
rem-log-exp100.0%
sub-neg100.0%
+-inverses100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 98.7%
if 0.680000000000000049 < x Initial program 39.3%
frac-sub39.3%
div-inv39.3%
*-un-lft-identity39.3%
+-commutative39.3%
*-rgt-identity39.3%
metadata-eval39.3%
frac-times39.3%
un-div-inv39.3%
pow1/239.3%
pow-flip39.3%
metadata-eval39.3%
+-commutative39.3%
Applied egg-rr39.3%
associate-*r/39.3%
remove-double-neg39.3%
neg-mul-139.3%
*-commutative39.3%
times-frac39.3%
Simplified39.1%
associate-*r/39.1%
clear-num39.1%
*-commutative39.1%
sub-neg39.1%
distribute-neg-frac39.1%
add-sqr-sqrt0.0%
sqrt-unprod5.4%
sqr-neg5.4%
sqrt-prod5.4%
add-sqr-sqrt5.4%
remove-double-neg5.4%
frac-2neg5.4%
add-sqr-sqrt0.0%
sqrt-unprod39.1%
Applied egg-rr39.3%
associate-/r/39.3%
associate-*l/39.3%
neg-mul-139.3%
distribute-rgt-neg-in39.3%
*-lft-identity39.3%
neg-sub039.3%
associate--r+39.3%
metadata-eval39.3%
Simplified39.3%
Taylor expanded in x around inf 98.8%
Final simplification98.7%
(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.6%
frac-sub68.7%
div-inv68.7%
*-un-lft-identity68.7%
+-commutative68.7%
*-rgt-identity68.7%
metadata-eval68.7%
frac-times68.7%
un-div-inv68.7%
pow1/268.7%
pow-flip68.9%
metadata-eval68.9%
+-commutative68.9%
Applied egg-rr68.9%
associate-*r/68.9%
remove-double-neg68.9%
neg-mul-168.9%
*-commutative68.9%
times-frac68.9%
Simplified68.6%
associate-*r/68.6%
clear-num68.6%
*-commutative68.6%
sub-neg68.6%
distribute-neg-frac68.6%
add-sqr-sqrt0.0%
sqrt-unprod50.0%
sqr-neg50.0%
sqrt-prod50.0%
add-sqr-sqrt50.0%
remove-double-neg50.0%
frac-2neg50.0%
add-sqr-sqrt0.0%
sqrt-unprod68.6%
Applied egg-rr68.7%
associate-/r/68.7%
associate-*l/68.7%
neg-mul-168.7%
distribute-rgt-neg-in68.7%
*-lft-identity68.7%
neg-sub068.7%
associate--r+68.7%
metadata-eval68.7%
Simplified68.7%
Taylor expanded in x around 0 50.0%
add-log-exp21.6%
*-un-lft-identity21.6%
log-prod21.6%
metadata-eval21.6%
add-log-exp50.0%
pow1/250.0%
pow-flip50.3%
metadata-eval50.3%
Applied egg-rr50.3%
+-lft-identity50.3%
Simplified50.3%
Final simplification50.3%
(FPCore (x) :precision binary64 (* x 0.5))
double code(double x) {
return 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 x * 0.5;
}
def code(x): return x * 0.5
function code(x) return Float64(x * 0.5) end
function tmp = code(x) tmp = x * 0.5; end
code[x_] := N[(x * 0.5), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5
\end{array}
Initial program 68.6%
*-un-lft-identity68.6%
clear-num68.6%
associate-/r/68.6%
prod-diff68.6%
*-un-lft-identity68.6%
fma-neg68.6%
*-un-lft-identity68.6%
inv-pow68.6%
sqrt-pow266.2%
metadata-eval66.2%
pow1/266.2%
pow-flip68.9%
+-commutative68.9%
metadata-eval68.9%
Applied egg-rr68.9%
fma-udef68.9%
neg-mul-168.9%
rem-log-exp51.9%
log-rec51.9%
+-commutative51.9%
log-rec51.9%
rem-log-exp68.9%
sub-neg68.9%
+-inverses68.9%
+-rgt-identity68.9%
Simplified68.9%
Taylor expanded in x around 0 50.1%
*-commutative50.1%
Simplified50.1%
Taylor expanded in x around inf 3.6%
*-commutative3.6%
Simplified3.6%
Final simplification3.6%
(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 2023283
(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)))))