
(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 13 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)))) 1e-9) (* (+ (/ 0.5 x) (+ (/ 0.3125 (pow x 3.0)) (/ -0.375 (* x x)))) (pow x -0.5)) (* (pow x -0.5) (- 1.0 (/ (sqrt x) (pow (pow (+ 1.0 x) 0.25) 2.0))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 1e-9) {
tmp = ((0.5 / x) + ((0.3125 / pow(x, 3.0)) + (-0.375 / (x * x)))) * pow(x, -0.5);
} else {
tmp = pow(x, -0.5) * (1.0 - (sqrt(x) / pow(pow((1.0 + x), 0.25), 2.0)));
}
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)))) <= 1d-9) then
tmp = ((0.5d0 / x) + ((0.3125d0 / (x ** 3.0d0)) + ((-0.375d0) / (x * x)))) * (x ** (-0.5d0))
else
tmp = (x ** (-0.5d0)) * (1.0d0 - (sqrt(x) / (((1.0d0 + x) ** 0.25d0) ** 2.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((1.0 + x)))) <= 1e-9) {
tmp = ((0.5 / x) + ((0.3125 / Math.pow(x, 3.0)) + (-0.375 / (x * x)))) * Math.pow(x, -0.5);
} else {
tmp = Math.pow(x, -0.5) * (1.0 - (Math.sqrt(x) / Math.pow(Math.pow((1.0 + x), 0.25), 2.0)));
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 1e-9: tmp = ((0.5 / x) + ((0.3125 / math.pow(x, 3.0)) + (-0.375 / (x * x)))) * math.pow(x, -0.5) else: tmp = math.pow(x, -0.5) * (1.0 - (math.sqrt(x) / math.pow(math.pow((1.0 + x), 0.25), 2.0))) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 1e-9) tmp = Float64(Float64(Float64(0.5 / x) + Float64(Float64(0.3125 / (x ^ 3.0)) + Float64(-0.375 / Float64(x * x)))) * (x ^ -0.5)); else tmp = Float64((x ^ -0.5) * Float64(1.0 - Float64(sqrt(x) / ((Float64(1.0 + x) ^ 0.25) ^ 2.0)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 1e-9) tmp = ((0.5 / x) + ((0.3125 / (x ^ 3.0)) + (-0.375 / (x * x)))) * (x ^ -0.5); else tmp = (x ^ -0.5) * (1.0 - (sqrt(x) / (((1.0 + x) ^ 0.25) ^ 2.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[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-9], N[(N[(N[(0.5 / x), $MachinePrecision] + N[(N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(1.0 - N[(N[Sqrt[x], $MachinePrecision] / N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 0.25], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 10^{-9}:\\
\;\;\;\;\left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} + \frac{-0.375}{x \cdot x}\right)\right) \cdot {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(1 - \frac{\sqrt{x}}{{\left({\left(1 + x\right)}^{0.25}\right)}^{2}}\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 1.00000000000000006e-9Initial program 40.9%
frac-sub41.0%
div-inv41.0%
*-un-lft-identity41.0%
+-commutative41.0%
*-rgt-identity41.0%
metadata-eval41.0%
frac-times41.0%
un-div-inv41.0%
pow1/241.0%
pow-flip41.0%
metadata-eval41.0%
+-commutative41.0%
Applied egg-rr41.0%
associate-*r/41.0%
*-rgt-identity41.0%
times-frac41.0%
div-sub41.0%
*-inverses41.0%
unpow141.0%
sqr-pow41.0%
metadata-eval41.0%
exp-to-pow6.7%
metadata-eval6.7%
exp-to-pow6.6%
hypot-1-def6.5%
exp-to-pow41.0%
unpow1/241.0%
/-rgt-identity41.0%
Simplified41.0%
hypot-1-def41.0%
add-sqr-sqrt41.0%
add-sqr-sqrt22.1%
pow1/222.1%
pow-to-exp6.5%
log1p-udef6.5%
*-un-lft-identity6.5%
times-frac6.5%
pow1/26.5%
sqrt-pow16.6%
metadata-eval6.6%
pow1/26.6%
sqrt-pow16.6%
metadata-eval6.6%
log1p-udef6.6%
pow-to-exp27.4%
pow1/227.5%
Applied egg-rr27.5%
/-rgt-identity27.5%
associate-*r/22.0%
pow-sqr41.0%
metadata-eval41.0%
Simplified41.0%
Taylor expanded in x around inf 99.6%
sub-neg99.6%
+-commutative99.6%
associate-+l+99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*r/99.6%
metadata-eval99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
unpow299.6%
Simplified99.6%
if 1.00000000000000006e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.6%
frac-sub99.6%
div-inv99.6%
*-un-lft-identity99.6%
+-commutative99.6%
*-rgt-identity99.6%
metadata-eval99.6%
frac-times99.6%
un-div-inv99.6%
pow1/299.6%
pow-flip100.0%
metadata-eval100.0%
+-commutative100.0%
Applied egg-rr100.0%
associate-*r/100.0%
*-rgt-identity100.0%
times-frac100.0%
div-sub100.0%
*-inverses100.0%
unpow1100.0%
sqr-pow100.0%
metadata-eval100.0%
exp-to-pow100.0%
metadata-eval100.0%
exp-to-pow100.0%
hypot-1-def100.0%
exp-to-pow100.0%
unpow1/2100.0%
/-rgt-identity100.0%
Simplified100.0%
hypot-1-def100.0%
add-sqr-sqrt100.0%
pow1/2100.0%
pow-to-exp100.0%
log1p-udef100.0%
add-sqr-sqrt100.0%
pow2100.0%
log1p-udef100.0%
pow-to-exp100.0%
sqrt-pow1100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification99.8%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 1e-9) (* (+ (/ 0.5 x) (+ (/ 0.3125 (pow x 3.0)) (/ -0.375 (* x x)))) (pow x -0.5)) (* (pow x -0.5) (- 1.0 (* (sqrt x) (pow (+ 1.0 x) -0.5))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 1e-9) {
tmp = ((0.5 / x) + ((0.3125 / pow(x, 3.0)) + (-0.375 / (x * x)))) * pow(x, -0.5);
} else {
tmp = pow(x, -0.5) * (1.0 - (sqrt(x) * 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)))) <= 1d-9) then
tmp = ((0.5d0 / x) + ((0.3125d0 / (x ** 3.0d0)) + ((-0.375d0) / (x * x)))) * (x ** (-0.5d0))
else
tmp = (x ** (-0.5d0)) * (1.0d0 - (sqrt(x) * ((1.0d0 + x) ** (-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)))) <= 1e-9) {
tmp = ((0.5 / x) + ((0.3125 / Math.pow(x, 3.0)) + (-0.375 / (x * x)))) * Math.pow(x, -0.5);
} else {
tmp = Math.pow(x, -0.5) * (1.0 - (Math.sqrt(x) * 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)))) <= 1e-9: tmp = ((0.5 / x) + ((0.3125 / math.pow(x, 3.0)) + (-0.375 / (x * x)))) * math.pow(x, -0.5) else: tmp = math.pow(x, -0.5) * (1.0 - (math.sqrt(x) * 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)))) <= 1e-9) tmp = Float64(Float64(Float64(0.5 / x) + Float64(Float64(0.3125 / (x ^ 3.0)) + Float64(-0.375 / Float64(x * x)))) * (x ^ -0.5)); else tmp = Float64((x ^ -0.5) * Float64(1.0 - Float64(sqrt(x) * (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)))) <= 1e-9) tmp = ((0.5 / x) + ((0.3125 / (x ^ 3.0)) + (-0.375 / (x * x)))) * (x ^ -0.5); else tmp = (x ^ -0.5) * (1.0 - (sqrt(x) * ((1.0 + x) ^ -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], 1e-9], N[(N[(N[(0.5 / x), $MachinePrecision] + N[(N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(1.0 - N[(N[Sqrt[x], $MachinePrecision] * N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 10^{-9}:\\
\;\;\;\;\left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} + \frac{-0.375}{x \cdot x}\right)\right) \cdot {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(1 - \sqrt{x} \cdot {\left(1 + x\right)}^{-0.5}\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 1.00000000000000006e-9Initial program 40.9%
frac-sub41.0%
div-inv41.0%
*-un-lft-identity41.0%
+-commutative41.0%
*-rgt-identity41.0%
metadata-eval41.0%
frac-times41.0%
un-div-inv41.0%
pow1/241.0%
pow-flip41.0%
metadata-eval41.0%
+-commutative41.0%
Applied egg-rr41.0%
associate-*r/41.0%
*-rgt-identity41.0%
times-frac41.0%
div-sub41.0%
*-inverses41.0%
unpow141.0%
sqr-pow41.0%
metadata-eval41.0%
exp-to-pow6.7%
metadata-eval6.7%
exp-to-pow6.6%
hypot-1-def6.5%
exp-to-pow41.0%
unpow1/241.0%
/-rgt-identity41.0%
Simplified41.0%
hypot-1-def41.0%
add-sqr-sqrt41.0%
add-sqr-sqrt22.1%
pow1/222.1%
pow-to-exp6.5%
log1p-udef6.5%
*-un-lft-identity6.5%
times-frac6.5%
pow1/26.5%
sqrt-pow16.6%
metadata-eval6.6%
pow1/26.6%
sqrt-pow16.6%
metadata-eval6.6%
log1p-udef6.6%
pow-to-exp27.4%
pow1/227.5%
Applied egg-rr27.5%
/-rgt-identity27.5%
associate-*r/22.0%
pow-sqr41.0%
metadata-eval41.0%
Simplified41.0%
Taylor expanded in x around inf 99.6%
sub-neg99.6%
+-commutative99.6%
associate-+l+99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*r/99.6%
metadata-eval99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
unpow299.6%
Simplified99.6%
if 1.00000000000000006e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.6%
frac-sub99.6%
div-inv99.6%
*-un-lft-identity99.6%
+-commutative99.6%
*-rgt-identity99.6%
metadata-eval99.6%
frac-times99.6%
un-div-inv99.6%
pow1/299.6%
pow-flip100.0%
metadata-eval100.0%
+-commutative100.0%
Applied egg-rr100.0%
associate-*r/100.0%
*-rgt-identity100.0%
times-frac100.0%
div-sub100.0%
*-inverses100.0%
unpow1100.0%
sqr-pow100.0%
metadata-eval100.0%
exp-to-pow100.0%
metadata-eval100.0%
exp-to-pow100.0%
hypot-1-def100.0%
exp-to-pow100.0%
unpow1/2100.0%
/-rgt-identity100.0%
Simplified100.0%
hypot-1-def100.0%
add-sqr-sqrt100.0%
pow1/2100.0%
pow-to-exp100.0%
log1p-udef100.0%
div-inv100.0%
log1p-udef100.0%
pow-to-exp100.0%
pow-flip100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification99.8%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 1e-9) (* (+ (/ 0.5 x) (+ (/ 0.3125 (pow x 3.0)) (/ -0.375 (* x x)))) (pow x -0.5)) (* (pow x -0.5) (- 1.0 (sqrt (/ x (+ 1.0 x)))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 1e-9) {
tmp = ((0.5 / x) + ((0.3125 / pow(x, 3.0)) + (-0.375 / (x * x)))) * pow(x, -0.5);
} else {
tmp = pow(x, -0.5) * (1.0 - sqrt((x / (1.0 + x))));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((1.0d0 + x)))) <= 1d-9) then
tmp = ((0.5d0 / x) + ((0.3125d0 / (x ** 3.0d0)) + ((-0.375d0) / (x * x)))) * (x ** (-0.5d0))
else
tmp = (x ** (-0.5d0)) * (1.0d0 - sqrt((x / (1.0d0 + x))))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / Math.sqrt((1.0 + x)))) <= 1e-9) {
tmp = ((0.5 / x) + ((0.3125 / Math.pow(x, 3.0)) + (-0.375 / (x * x)))) * Math.pow(x, -0.5);
} else {
tmp = Math.pow(x, -0.5) * (1.0 - Math.sqrt((x / (1.0 + x))));
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 1e-9: tmp = ((0.5 / x) + ((0.3125 / math.pow(x, 3.0)) + (-0.375 / (x * x)))) * math.pow(x, -0.5) else: tmp = math.pow(x, -0.5) * (1.0 - math.sqrt((x / (1.0 + x)))) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 1e-9) tmp = Float64(Float64(Float64(0.5 / x) + Float64(Float64(0.3125 / (x ^ 3.0)) + Float64(-0.375 / Float64(x * x)))) * (x ^ -0.5)); else tmp = Float64((x ^ -0.5) * Float64(1.0 - sqrt(Float64(x / Float64(1.0 + x))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 1e-9) tmp = ((0.5 / x) + ((0.3125 / (x ^ 3.0)) + (-0.375 / (x * x)))) * (x ^ -0.5); else tmp = (x ^ -0.5) * (1.0 - sqrt((x / (1.0 + x)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-9], N[(N[(N[(0.5 / x), $MachinePrecision] + N[(N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(1.0 - N[Sqrt[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 10^{-9}:\\
\;\;\;\;\left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} + \frac{-0.375}{x \cdot x}\right)\right) \cdot {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(1 - \sqrt{\frac{x}{1 + x}}\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 1.00000000000000006e-9Initial program 40.9%
frac-sub41.0%
div-inv41.0%
*-un-lft-identity41.0%
+-commutative41.0%
*-rgt-identity41.0%
metadata-eval41.0%
frac-times41.0%
un-div-inv41.0%
pow1/241.0%
pow-flip41.0%
metadata-eval41.0%
+-commutative41.0%
Applied egg-rr41.0%
associate-*r/41.0%
*-rgt-identity41.0%
times-frac41.0%
div-sub41.0%
*-inverses41.0%
unpow141.0%
sqr-pow41.0%
metadata-eval41.0%
exp-to-pow6.7%
metadata-eval6.7%
exp-to-pow6.6%
hypot-1-def6.5%
exp-to-pow41.0%
unpow1/241.0%
/-rgt-identity41.0%
Simplified41.0%
hypot-1-def41.0%
add-sqr-sqrt41.0%
add-sqr-sqrt22.1%
pow1/222.1%
pow-to-exp6.5%
log1p-udef6.5%
*-un-lft-identity6.5%
times-frac6.5%
pow1/26.5%
sqrt-pow16.6%
metadata-eval6.6%
pow1/26.6%
sqrt-pow16.6%
metadata-eval6.6%
log1p-udef6.6%
pow-to-exp27.4%
pow1/227.5%
Applied egg-rr27.5%
/-rgt-identity27.5%
associate-*r/22.0%
pow-sqr41.0%
metadata-eval41.0%
Simplified41.0%
Taylor expanded in x around inf 99.6%
sub-neg99.6%
+-commutative99.6%
associate-+l+99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*r/99.6%
metadata-eval99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
unpow299.6%
Simplified99.6%
if 1.00000000000000006e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.6%
frac-sub99.6%
div-inv99.6%
*-un-lft-identity99.6%
+-commutative99.6%
*-rgt-identity99.6%
metadata-eval99.6%
frac-times99.6%
un-div-inv99.6%
pow1/299.6%
pow-flip100.0%
metadata-eval100.0%
+-commutative100.0%
Applied egg-rr100.0%
associate-*r/100.0%
*-rgt-identity100.0%
times-frac100.0%
div-sub100.0%
*-inverses100.0%
unpow1100.0%
sqr-pow100.0%
metadata-eval100.0%
exp-to-pow100.0%
metadata-eval100.0%
exp-to-pow100.0%
hypot-1-def100.0%
exp-to-pow100.0%
unpow1/2100.0%
/-rgt-identity100.0%
Simplified100.0%
*-un-lft-identity100.0%
hypot-1-def100.0%
add-sqr-sqrt100.0%
sqrt-undiv100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
Simplified100.0%
Final simplification99.8%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 1e-9) (* (pow x -0.5) (- (/ 0.5 x) (/ 0.375 (* x x)))) (* (pow x -0.5) (- 1.0 (sqrt (/ x (+ 1.0 x)))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 1e-9) {
tmp = pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
} else {
tmp = pow(x, -0.5) * (1.0 - sqrt((x / (1.0 + x))));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((1.0d0 + x)))) <= 1d-9) then
tmp = (x ** (-0.5d0)) * ((0.5d0 / x) - (0.375d0 / (x * x)))
else
tmp = (x ** (-0.5d0)) * (1.0d0 - sqrt((x / (1.0d0 + x))))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / Math.sqrt((1.0 + x)))) <= 1e-9) {
tmp = Math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
} else {
tmp = Math.pow(x, -0.5) * (1.0 - Math.sqrt((x / (1.0 + x))));
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 1e-9: tmp = math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x))) else: tmp = math.pow(x, -0.5) * (1.0 - math.sqrt((x / (1.0 + x)))) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 1e-9) tmp = Float64((x ^ -0.5) * Float64(Float64(0.5 / x) - Float64(0.375 / Float64(x * x)))); else tmp = Float64((x ^ -0.5) * Float64(1.0 - sqrt(Float64(x / Float64(1.0 + x))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 1e-9) tmp = (x ^ -0.5) * ((0.5 / x) - (0.375 / (x * x))); else tmp = (x ^ -0.5) * (1.0 - sqrt((x / (1.0 + x)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-9], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(0.5 / x), $MachinePrecision] - N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(1.0 - N[Sqrt[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 10^{-9}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} - \frac{0.375}{x \cdot x}\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(1 - \sqrt{\frac{x}{1 + x}}\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 1.00000000000000006e-9Initial program 40.9%
frac-sub41.0%
div-inv41.0%
*-un-lft-identity41.0%
+-commutative41.0%
*-rgt-identity41.0%
metadata-eval41.0%
frac-times41.0%
un-div-inv41.0%
pow1/241.0%
pow-flip41.0%
metadata-eval41.0%
+-commutative41.0%
Applied egg-rr41.0%
associate-*r/41.0%
*-rgt-identity41.0%
times-frac41.0%
div-sub41.0%
*-inverses41.0%
unpow141.0%
sqr-pow41.0%
metadata-eval41.0%
exp-to-pow6.7%
metadata-eval6.7%
exp-to-pow6.6%
hypot-1-def6.5%
exp-to-pow41.0%
unpow1/241.0%
/-rgt-identity41.0%
Simplified41.0%
hypot-1-def41.0%
add-sqr-sqrt41.0%
add-sqr-sqrt22.1%
pow1/222.1%
pow-to-exp6.5%
log1p-udef6.5%
*-un-lft-identity6.5%
times-frac6.5%
pow1/26.5%
sqrt-pow16.6%
metadata-eval6.6%
pow1/26.6%
sqrt-pow16.6%
metadata-eval6.6%
log1p-udef6.6%
pow-to-exp27.4%
pow1/227.5%
Applied egg-rr27.5%
/-rgt-identity27.5%
associate-*r/22.0%
pow-sqr41.0%
metadata-eval41.0%
Simplified41.0%
Taylor expanded in x around inf 99.5%
associate-*r/99.5%
metadata-eval99.5%
associate-*r/99.5%
metadata-eval99.5%
unpow299.5%
Simplified99.5%
if 1.00000000000000006e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.6%
frac-sub99.6%
div-inv99.6%
*-un-lft-identity99.6%
+-commutative99.6%
*-rgt-identity99.6%
metadata-eval99.6%
frac-times99.6%
un-div-inv99.6%
pow1/299.6%
pow-flip100.0%
metadata-eval100.0%
+-commutative100.0%
Applied egg-rr100.0%
associate-*r/100.0%
*-rgt-identity100.0%
times-frac100.0%
div-sub100.0%
*-inverses100.0%
unpow1100.0%
sqr-pow100.0%
metadata-eval100.0%
exp-to-pow100.0%
metadata-eval100.0%
exp-to-pow100.0%
hypot-1-def100.0%
exp-to-pow100.0%
unpow1/2100.0%
/-rgt-identity100.0%
Simplified100.0%
*-un-lft-identity100.0%
hypot-1-def100.0%
add-sqr-sqrt100.0%
sqrt-undiv100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
Simplified100.0%
Final simplification99.7%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 1e-9) (* (pow x -0.5) (- (/ 0.5 x) (/ 0.375 (* x x)))) (- (pow x -0.5) (pow (+ 1.0 x) -0.5))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 1e-9) {
tmp = pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
} else {
tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((1.0d0 + x)))) <= 1d-9) then
tmp = (x ** (-0.5d0)) * ((0.5d0 / x) - (0.375d0 / (x * x)))
else
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / Math.sqrt((1.0 + x)))) <= 1e-9) {
tmp = Math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
} else {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 1e-9: tmp = math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x))) else: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 1e-9) tmp = Float64((x ^ -0.5) * Float64(Float64(0.5 / x) - Float64(0.375 / Float64(x * x)))); else tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 1e-9) tmp = (x ^ -0.5) * ((0.5 / x) - (0.375 / (x * x))); else tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-9], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(0.5 / x), $MachinePrecision] - N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 10^{-9}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} - \frac{0.375}{x \cdot x}\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 1.00000000000000006e-9Initial program 40.9%
frac-sub41.0%
div-inv41.0%
*-un-lft-identity41.0%
+-commutative41.0%
*-rgt-identity41.0%
metadata-eval41.0%
frac-times41.0%
un-div-inv41.0%
pow1/241.0%
pow-flip41.0%
metadata-eval41.0%
+-commutative41.0%
Applied egg-rr41.0%
associate-*r/41.0%
*-rgt-identity41.0%
times-frac41.0%
div-sub41.0%
*-inverses41.0%
unpow141.0%
sqr-pow41.0%
metadata-eval41.0%
exp-to-pow6.7%
metadata-eval6.7%
exp-to-pow6.6%
hypot-1-def6.5%
exp-to-pow41.0%
unpow1/241.0%
/-rgt-identity41.0%
Simplified41.0%
hypot-1-def41.0%
add-sqr-sqrt41.0%
add-sqr-sqrt22.1%
pow1/222.1%
pow-to-exp6.5%
log1p-udef6.5%
*-un-lft-identity6.5%
times-frac6.5%
pow1/26.5%
sqrt-pow16.6%
metadata-eval6.6%
pow1/26.6%
sqrt-pow16.6%
metadata-eval6.6%
log1p-udef6.6%
pow-to-exp27.4%
pow1/227.5%
Applied egg-rr27.5%
/-rgt-identity27.5%
associate-*r/22.0%
pow-sqr41.0%
metadata-eval41.0%
Simplified41.0%
Taylor expanded in x around inf 99.5%
associate-*r/99.5%
metadata-eval99.5%
associate-*r/99.5%
metadata-eval99.5%
unpow299.5%
Simplified99.5%
if 1.00000000000000006e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
inv-pow99.6%
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.7%
(FPCore (x) :precision binary64 (if (<= x 1.1) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (* (pow x -0.5) (- (/ 0.5 x) (/ 0.375 (* x x))))))
double code(double x) {
double tmp;
if (x <= 1.1) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} 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.1d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
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.1) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = Math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.1: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 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.1) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); 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.1) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = (x ^ -0.5) * ((0.5 / x) - (0.375 / (x * x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.1], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $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.1:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\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.1000000000000001Initial program 99.6%
sub-neg99.6%
+-commutative99.6%
add-cube-cbrt99.6%
distribute-lft-neg-in99.6%
fma-def99.6%
Applied egg-rr100.0%
Taylor expanded in x around 0 97.3%
if 1.1000000000000001 < x Initial program 40.9%
frac-sub41.0%
div-inv41.0%
*-un-lft-identity41.0%
+-commutative41.0%
*-rgt-identity41.0%
metadata-eval41.0%
frac-times41.0%
un-div-inv41.0%
pow1/241.0%
pow-flip41.0%
metadata-eval41.0%
+-commutative41.0%
Applied egg-rr41.0%
associate-*r/41.0%
*-rgt-identity41.0%
times-frac41.0%
div-sub41.0%
*-inverses41.0%
unpow141.0%
sqr-pow41.0%
metadata-eval41.0%
exp-to-pow6.7%
metadata-eval6.7%
exp-to-pow6.6%
hypot-1-def6.5%
exp-to-pow41.0%
unpow1/241.0%
/-rgt-identity41.0%
Simplified41.0%
hypot-1-def41.0%
add-sqr-sqrt41.0%
add-sqr-sqrt22.1%
pow1/222.1%
pow-to-exp6.5%
log1p-udef6.5%
*-un-lft-identity6.5%
times-frac6.5%
pow1/26.5%
sqrt-pow16.6%
metadata-eval6.6%
pow1/26.6%
sqrt-pow16.6%
metadata-eval6.6%
log1p-udef6.6%
pow-to-exp27.4%
pow1/227.5%
Applied egg-rr27.5%
/-rgt-identity27.5%
associate-*r/22.0%
pow-sqr41.0%
metadata-eval41.0%
Simplified41.0%
Taylor expanded in x around inf 99.5%
associate-*r/99.5%
metadata-eval99.5%
associate-*r/99.5%
metadata-eval99.5%
unpow299.5%
Simplified99.5%
Final simplification98.3%
(FPCore (x) :precision binary64 (if (<= x 1.0) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (* (/ 0.5 x) (pow x -0.5))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = (0.5 / x) * pow(x, -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.0d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = (0.5d0 / x) * (x ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = (0.5 / x) * Math.pow(x, -0.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = (0.5 / x) * math.pow(x, -0.5) return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); else tmp = Float64(Float64(0.5 / x) * (x ^ -0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = (0.5 / x) * (x ^ -0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{x} \cdot {x}^{-0.5}\\
\end{array}
\end{array}
if x < 1Initial program 99.6%
sub-neg99.6%
+-commutative99.6%
add-cube-cbrt99.6%
distribute-lft-neg-in99.6%
fma-def99.6%
Applied egg-rr100.0%
Taylor expanded in x around 0 97.3%
if 1 < x Initial program 40.9%
frac-sub41.0%
div-inv41.0%
*-un-lft-identity41.0%
+-commutative41.0%
*-rgt-identity41.0%
metadata-eval41.0%
frac-times41.0%
un-div-inv41.0%
pow1/241.0%
pow-flip41.0%
metadata-eval41.0%
+-commutative41.0%
Applied egg-rr41.0%
associate-*r/41.0%
*-rgt-identity41.0%
times-frac41.0%
div-sub41.0%
*-inverses41.0%
unpow141.0%
sqr-pow41.0%
metadata-eval41.0%
exp-to-pow6.7%
metadata-eval6.7%
exp-to-pow6.6%
hypot-1-def6.5%
exp-to-pow41.0%
unpow1/241.0%
/-rgt-identity41.0%
Simplified41.0%
hypot-1-def41.0%
add-sqr-sqrt41.0%
add-sqr-sqrt22.1%
pow1/222.1%
pow-to-exp6.5%
log1p-udef6.5%
*-un-lft-identity6.5%
times-frac6.5%
pow1/26.5%
sqrt-pow16.6%
metadata-eval6.6%
pow1/26.6%
sqrt-pow16.6%
metadata-eval6.6%
log1p-udef6.6%
pow-to-exp27.4%
pow1/227.5%
Applied egg-rr27.5%
/-rgt-identity27.5%
associate-*r/22.0%
pow-sqr41.0%
metadata-eval41.0%
Simplified41.0%
Taylor expanded in x around inf 98.2%
Final simplification97.7%
(FPCore (x) :precision binary64 (if (<= x 0.66) (+ (pow x -0.5) -1.0) (* (/ 0.5 x) (pow x -0.5))))
double code(double x) {
double tmp;
if (x <= 0.66) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = (0.5 / x) * pow(x, -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.66d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = (0.5d0 / x) * (x ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.66) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = (0.5 / x) * Math.pow(x, -0.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.66: tmp = math.pow(x, -0.5) + -1.0 else: tmp = (0.5 / x) * math.pow(x, -0.5) return tmp
function code(x) tmp = 0.0 if (x <= 0.66) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(Float64(0.5 / x) * (x ^ -0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.66) tmp = (x ^ -0.5) + -1.0; else tmp = (0.5 / x) * (x ^ -0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.66], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.66:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{x} \cdot {x}^{-0.5}\\
\end{array}
\end{array}
if x < 0.660000000000000031Initial program 99.6%
sub-neg99.6%
+-commutative99.6%
add-cube-cbrt99.6%
distribute-lft-neg-in99.6%
fma-def99.6%
Applied egg-rr100.0%
Taylor expanded in x around 0 96.9%
if 0.660000000000000031 < x Initial program 40.9%
frac-sub41.0%
div-inv41.0%
*-un-lft-identity41.0%
+-commutative41.0%
*-rgt-identity41.0%
metadata-eval41.0%
frac-times41.0%
un-div-inv41.0%
pow1/241.0%
pow-flip41.0%
metadata-eval41.0%
+-commutative41.0%
Applied egg-rr41.0%
associate-*r/41.0%
*-rgt-identity41.0%
times-frac41.0%
div-sub41.0%
*-inverses41.0%
unpow141.0%
sqr-pow41.0%
metadata-eval41.0%
exp-to-pow6.7%
metadata-eval6.7%
exp-to-pow6.6%
hypot-1-def6.5%
exp-to-pow41.0%
unpow1/241.0%
/-rgt-identity41.0%
Simplified41.0%
hypot-1-def41.0%
add-sqr-sqrt41.0%
add-sqr-sqrt22.1%
pow1/222.1%
pow-to-exp6.5%
log1p-udef6.5%
*-un-lft-identity6.5%
times-frac6.5%
pow1/26.5%
sqrt-pow16.6%
metadata-eval6.6%
pow1/26.6%
sqrt-pow16.6%
metadata-eval6.6%
log1p-udef6.6%
pow-to-exp27.4%
pow1/227.5%
Applied egg-rr27.5%
/-rgt-identity27.5%
associate-*r/22.0%
pow-sqr41.0%
metadata-eval41.0%
Simplified41.0%
Taylor expanded in x around inf 98.2%
Final simplification97.5%
(FPCore (x) :precision binary64 (/ 1.0 (+ x (sqrt x))))
double code(double x) {
return 1.0 / (x + sqrt(x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (x + sqrt(x))
end function
public static double code(double x) {
return 1.0 / (x + Math.sqrt(x));
}
def code(x): return 1.0 / (x + math.sqrt(x))
function code(x) return Float64(1.0 / Float64(x + sqrt(x))) end
function tmp = code(x) tmp = 1.0 / (x + sqrt(x)); end
code[x_] := N[(1.0 / N[(x + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x + \sqrt{x}}
\end{array}
Initial program 71.4%
pow1/271.4%
pow-to-exp54.9%
+-commutative54.9%
log1p-udef54.9%
Applied egg-rr54.9%
Applied egg-rr52.3%
Taylor expanded in x around 0 53.3%
distribute-rgt-in53.3%
*-lft-identity53.3%
pow-plus53.6%
metadata-eval53.6%
unpow1/253.6%
Simplified53.6%
Final simplification53.6%
(FPCore (x) :precision binary64 (sqrt (/ 1.0 x)))
double code(double x) {
return sqrt((1.0 / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((1.0d0 / x))
end function
public static double code(double x) {
return Math.sqrt((1.0 / x));
}
def code(x): return math.sqrt((1.0 / x))
function code(x) return sqrt(Float64(1.0 / x)) end
function tmp = code(x) tmp = sqrt((1.0 / x)); end
code[x_] := N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{x}}
\end{array}
Initial program 71.4%
pow1/271.4%
pow-to-exp54.9%
+-commutative54.9%
log1p-udef54.9%
Applied egg-rr54.9%
Applied egg-rr52.3%
Taylor expanded in x around inf 51.6%
Final simplification51.6%
(FPCore (x) :precision binary64 (pow x -0.5))
double code(double x) {
return pow(x, -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x ** (-0.5d0)
end function
public static double code(double x) {
return Math.pow(x, -0.5);
}
def code(x): return math.pow(x, -0.5)
function code(x) return x ^ -0.5 end
function tmp = code(x) tmp = x ^ -0.5; end
code[x_] := N[Power[x, -0.5], $MachinePrecision]
\begin{array}{l}
\\
{x}^{-0.5}
\end{array}
Initial program 71.4%
frac-sub71.4%
div-inv71.4%
*-un-lft-identity71.4%
+-commutative71.4%
*-rgt-identity71.4%
metadata-eval71.4%
frac-times71.4%
un-div-inv71.4%
pow1/271.4%
pow-flip71.6%
metadata-eval71.6%
+-commutative71.6%
Applied egg-rr71.6%
associate-*r/71.6%
*-rgt-identity71.6%
times-frac71.6%
div-sub71.7%
*-inverses71.7%
unpow171.7%
sqr-pow71.6%
metadata-eval71.6%
exp-to-pow55.2%
metadata-eval55.2%
exp-to-pow55.1%
hypot-1-def55.1%
exp-to-pow71.6%
unpow1/271.7%
/-rgt-identity71.7%
Simplified71.7%
Taylor expanded in x around 0 51.8%
Final simplification51.8%
(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 71.4%
pow1/271.4%
pow-to-exp54.9%
+-commutative54.9%
log1p-udef54.9%
Applied egg-rr54.9%
Taylor expanded in x around 0 51.9%
*-commutative51.9%
Simplified51.9%
Taylor expanded in x around inf 4.0%
Final simplification4.0%
(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 71.4%
Taylor expanded in x around 0 51.4%
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 2023279
(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)))))