
(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 5 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)))) 0.0) (* 0.5 (pow x -1.5)) (/ 1.0 (* (+ (pow x -0.5) (pow (+ 1.0 x) -0.5)) (+ x (pow x 2.0))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 0.0) {
tmp = 0.5 * pow(x, -1.5);
} else {
tmp = 1.0 / ((pow(x, -0.5) + pow((1.0 + x), -0.5)) * (x + pow(x, 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)))) <= 0.0d0) then
tmp = 0.5d0 * (x ** (-1.5d0))
else
tmp = 1.0d0 / (((x ** (-0.5d0)) + ((1.0d0 + x) ** (-0.5d0))) * (x + (x ** 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)))) <= 0.0) {
tmp = 0.5 * Math.pow(x, -1.5);
} else {
tmp = 1.0 / ((Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5)) * (x + Math.pow(x, 2.0)));
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 0.0: tmp = 0.5 * math.pow(x, -1.5) else: tmp = 1.0 / ((math.pow(x, -0.5) + math.pow((1.0 + x), -0.5)) * (x + math.pow(x, 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)))) <= 0.0) tmp = Float64(0.5 * (x ^ -1.5)); else tmp = Float64(1.0 / Float64(Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5)) * Float64(x + (x ^ 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)))) <= 0.0) tmp = 0.5 * (x ^ -1.5); else tmp = 1.0 / (((x ^ -0.5) + ((1.0 + x) ^ -0.5)) * (x + (x ^ 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], 0.0], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(x + N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 0:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left({x}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right) \cdot \left(x + {x}^{2}\right)}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 0.0Initial program 38.1%
flip--38.1%
clear-num38.1%
pow1/238.1%
pow-flip38.1%
metadata-eval38.1%
inv-pow38.1%
sqrt-pow238.1%
+-commutative38.1%
metadata-eval38.1%
frac-times20.3%
metadata-eval20.3%
add-sqr-sqrt16.8%
frac-times20.3%
metadata-eval20.3%
add-sqr-sqrt38.2%
Applied egg-rr38.2%
Taylor expanded in x around inf 66.7%
expm1-log1p-u66.7%
expm1-udef38.1%
associate-/r*38.1%
metadata-eval38.1%
sqrt-pow138.1%
metadata-eval38.1%
Applied egg-rr38.1%
expm1-def97.8%
expm1-log1p97.8%
Simplified97.8%
add-sqr-sqrt97.6%
sqrt-unprod66.9%
frac-times66.7%
metadata-eval66.7%
pow-prod-up66.8%
metadata-eval66.8%
expm1-log1p-u66.8%
expm1-udef38.1%
Applied egg-rr38.1%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
if 0.0 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 60.9%
add-cbrt-cube58.3%
pow1/354.4%
add-sqr-sqrt54.4%
pow154.4%
pow1/254.4%
pow-prod-up54.4%
+-commutative54.4%
metadata-eval54.4%
Applied egg-rr54.4%
unpow1/357.9%
Simplified57.9%
Applied egg-rr99.6%
+-inverses99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Final simplification100.0%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 0.0) (* 0.5 (pow x -1.5)) (/ (/ 1.0 (+ (pow x -0.5) (pow (+ 1.0 x) -0.5))) (fma x x x))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 0.0) {
tmp = 0.5 * pow(x, -1.5);
} else {
tmp = (1.0 / (pow(x, -0.5) + pow((1.0 + x), -0.5))) / fma(x, x, x);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 0.0) tmp = Float64(0.5 * (x ^ -1.5)); else tmp = Float64(Float64(1.0 / Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5))) / fma(x, x, x)); end return 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], 0.0], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * x + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 0:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}}{\mathsf{fma}\left(x, x, x\right)}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 0.0Initial program 38.1%
flip--38.1%
clear-num38.1%
pow1/238.1%
pow-flip38.1%
metadata-eval38.1%
inv-pow38.1%
sqrt-pow238.1%
+-commutative38.1%
metadata-eval38.1%
frac-times20.3%
metadata-eval20.3%
add-sqr-sqrt16.8%
frac-times20.3%
metadata-eval20.3%
add-sqr-sqrt38.2%
Applied egg-rr38.2%
Taylor expanded in x around inf 66.7%
expm1-log1p-u66.7%
expm1-udef38.1%
associate-/r*38.1%
metadata-eval38.1%
sqrt-pow138.1%
metadata-eval38.1%
Applied egg-rr38.1%
expm1-def97.8%
expm1-log1p97.8%
Simplified97.8%
add-sqr-sqrt97.6%
sqrt-unprod66.9%
frac-times66.7%
metadata-eval66.7%
pow-prod-up66.8%
metadata-eval66.8%
expm1-log1p-u66.8%
expm1-udef38.1%
Applied egg-rr38.1%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
if 0.0 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 60.9%
add-cbrt-cube58.3%
pow1/354.4%
add-sqr-sqrt54.4%
pow154.4%
pow1/254.4%
pow-prod-up54.4%
+-commutative54.4%
metadata-eval54.4%
Applied egg-rr54.4%
unpow1/357.9%
Simplified57.9%
Applied egg-rr99.6%
associate-/r*99.3%
+-inverses99.3%
metadata-eval99.3%
/-rgt-identity99.3%
metadata-eval99.3%
+-inverses99.3%
associate-/l*99.3%
+-inverses99.3%
metadata-eval99.3%
*-rgt-identity99.3%
+-commutative99.3%
+-commutative99.3%
unpow299.3%
fma-def99.5%
Simplified99.5%
Final simplification100.0%
(FPCore (x)
:precision binary64
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 0.0)
(* 0.5 (pow x -1.5))
(/
1.0
(/ (+ (pow x -0.5) (pow (+ 1.0 x) -0.5)) (/ (/ -1.0 x) (- -1.0 x))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 0.0) {
tmp = 0.5 * pow(x, -1.5);
} else {
tmp = 1.0 / ((pow(x, -0.5) + pow((1.0 + x), -0.5)) / ((-1.0 / 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)))) <= 0.0d0) then
tmp = 0.5d0 * (x ** (-1.5d0))
else
tmp = 1.0d0 / (((x ** (-0.5d0)) + ((1.0d0 + x) ** (-0.5d0))) / (((-1.0d0) / 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)))) <= 0.0) {
tmp = 0.5 * Math.pow(x, -1.5);
} else {
tmp = 1.0 / ((Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5)) / ((-1.0 / x) / (-1.0 - x)));
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 0.0: tmp = 0.5 * math.pow(x, -1.5) else: tmp = 1.0 / ((math.pow(x, -0.5) + math.pow((1.0 + x), -0.5)) / ((-1.0 / 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)))) <= 0.0) tmp = Float64(0.5 * (x ^ -1.5)); else tmp = Float64(1.0 / Float64(Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5)) / Float64(Float64(-1.0 / 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)))) <= 0.0) tmp = 0.5 * (x ^ -1.5); else tmp = 1.0 / (((x ^ -0.5) + ((1.0 + x) ^ -0.5)) / ((-1.0 / 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], 0.0], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] / N[(N[(-1.0 / x), $MachinePrecision] / N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 0:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}{\frac{\frac{-1}{x}}{-1 - x}}}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 0.0Initial program 38.1%
flip--38.1%
clear-num38.1%
pow1/238.1%
pow-flip38.1%
metadata-eval38.1%
inv-pow38.1%
sqrt-pow238.1%
+-commutative38.1%
metadata-eval38.1%
frac-times20.3%
metadata-eval20.3%
add-sqr-sqrt16.8%
frac-times20.3%
metadata-eval20.3%
add-sqr-sqrt38.2%
Applied egg-rr38.2%
Taylor expanded in x around inf 66.7%
expm1-log1p-u66.7%
expm1-udef38.1%
associate-/r*38.1%
metadata-eval38.1%
sqrt-pow138.1%
metadata-eval38.1%
Applied egg-rr38.1%
expm1-def97.8%
expm1-log1p97.8%
Simplified97.8%
add-sqr-sqrt97.6%
sqrt-unprod66.9%
frac-times66.7%
metadata-eval66.7%
pow-prod-up66.8%
metadata-eval66.8%
expm1-log1p-u66.8%
expm1-udef38.1%
Applied egg-rr38.1%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
if 0.0 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 60.9%
flip--59.6%
clear-num59.6%
pow1/259.6%
pow-flip59.6%
metadata-eval59.6%
inv-pow59.6%
sqrt-pow259.6%
+-commutative59.6%
metadata-eval59.6%
frac-times59.3%
metadata-eval59.3%
add-sqr-sqrt58.9%
frac-times60.2%
metadata-eval60.2%
add-sqr-sqrt60.9%
Applied egg-rr60.9%
frac-2neg60.9%
metadata-eval60.9%
frac-sub99.4%
*-un-lft-identity99.4%
Applied egg-rr99.4%
associate-/r*99.3%
sub-neg99.3%
*-commutative99.3%
neg-mul-199.3%
distribute-neg-out99.3%
remove-double-neg99.3%
mul-1-neg99.3%
unsub-neg99.3%
mul-1-neg99.3%
remove-double-neg99.3%
associate-+r-99.3%
+-inverses99.3%
metadata-eval99.3%
metadata-eval99.3%
distribute-neg-in99.3%
metadata-eval99.3%
unsub-neg99.3%
Simplified99.3%
Final simplification100.0%
(FPCore (x)
:precision binary64
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 0.0)
(* 0.5 (pow x -1.5))
(/
1.0
(/ (+ (pow x -0.5) (pow (+ 1.0 x) -0.5)) (/ -1.0 (* x (- -1.0 x)))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 0.0) {
tmp = 0.5 * pow(x, -1.5);
} else {
tmp = 1.0 / ((pow(x, -0.5) + pow((1.0 + x), -0.5)) / (-1.0 / (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)))) <= 0.0d0) then
tmp = 0.5d0 * (x ** (-1.5d0))
else
tmp = 1.0d0 / (((x ** (-0.5d0)) + ((1.0d0 + x) ** (-0.5d0))) / ((-1.0d0) / (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)))) <= 0.0) {
tmp = 0.5 * Math.pow(x, -1.5);
} else {
tmp = 1.0 / ((Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5)) / (-1.0 / (x * (-1.0 - x))));
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 0.0: tmp = 0.5 * math.pow(x, -1.5) else: tmp = 1.0 / ((math.pow(x, -0.5) + math.pow((1.0 + x), -0.5)) / (-1.0 / (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)))) <= 0.0) tmp = Float64(0.5 * (x ^ -1.5)); else tmp = Float64(1.0 / Float64(Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5)) / Float64(-1.0 / 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)))) <= 0.0) tmp = 0.5 * (x ^ -1.5); else tmp = 1.0 / (((x ^ -0.5) + ((1.0 + x) ^ -0.5)) / (-1.0 / (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], 0.0], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] / N[(-1.0 / 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 0:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}{\frac{-1}{x \cdot \left(-1 - x\right)}}}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 0.0Initial program 38.1%
flip--38.1%
clear-num38.1%
pow1/238.1%
pow-flip38.1%
metadata-eval38.1%
inv-pow38.1%
sqrt-pow238.1%
+-commutative38.1%
metadata-eval38.1%
frac-times20.3%
metadata-eval20.3%
add-sqr-sqrt16.8%
frac-times20.3%
metadata-eval20.3%
add-sqr-sqrt38.2%
Applied egg-rr38.2%
Taylor expanded in x around inf 66.7%
expm1-log1p-u66.7%
expm1-udef38.1%
associate-/r*38.1%
metadata-eval38.1%
sqrt-pow138.1%
metadata-eval38.1%
Applied egg-rr38.1%
expm1-def97.8%
expm1-log1p97.8%
Simplified97.8%
add-sqr-sqrt97.6%
sqrt-unprod66.9%
frac-times66.7%
metadata-eval66.7%
pow-prod-up66.8%
metadata-eval66.8%
expm1-log1p-u66.8%
expm1-udef38.1%
Applied egg-rr38.1%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
if 0.0 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 60.9%
flip--59.6%
clear-num59.6%
pow1/259.6%
pow-flip59.6%
metadata-eval59.6%
inv-pow59.6%
sqrt-pow259.6%
+-commutative59.6%
metadata-eval59.6%
frac-times59.3%
metadata-eval59.3%
add-sqr-sqrt58.9%
frac-times60.2%
metadata-eval60.2%
add-sqr-sqrt60.9%
Applied egg-rr60.9%
frac-2neg60.9%
metadata-eval60.9%
frac-sub99.4%
*-un-lft-identity99.4%
Applied egg-rr99.4%
*-commutative99.4%
neg-mul-199.4%
*-rgt-identity99.4%
distribute-rgt-neg-out99.4%
distribute-lft-neg-out99.4%
distribute-neg-in99.4%
metadata-eval99.4%
*-rgt-identity99.4%
*-commutative99.4%
Simplified99.4%
Taylor expanded in x around 0 99.4%
Final simplification100.0%
(FPCore (x) :precision binary64 (* 0.5 (pow x -1.5)))
double code(double x) {
return 0.5 * pow(x, -1.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.5d0 * (x ** (-1.5d0))
end function
public static double code(double x) {
return 0.5 * Math.pow(x, -1.5);
}
def code(x): return 0.5 * math.pow(x, -1.5)
function code(x) return Float64(0.5 * (x ^ -1.5)) end
function tmp = code(x) tmp = 0.5 * (x ^ -1.5); end
code[x_] := N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot {x}^{-1.5}
\end{array}
Initial program 39.2%
flip--39.1%
clear-num39.1%
pow1/239.1%
pow-flip39.1%
metadata-eval39.1%
inv-pow39.1%
sqrt-pow239.1%
+-commutative39.1%
metadata-eval39.1%
frac-times22.1%
metadata-eval22.1%
add-sqr-sqrt18.7%
frac-times22.1%
metadata-eval22.1%
add-sqr-sqrt39.3%
Applied egg-rr39.3%
Taylor expanded in x around inf 66.4%
expm1-log1p-u66.4%
expm1-udef37.8%
associate-/r*37.8%
metadata-eval37.8%
sqrt-pow137.8%
metadata-eval37.8%
Applied egg-rr37.8%
expm1-def96.0%
expm1-log1p96.0%
Simplified96.0%
add-sqr-sqrt95.8%
sqrt-unprod66.6%
frac-times66.4%
metadata-eval66.4%
pow-prod-up66.5%
metadata-eval66.5%
expm1-log1p-u66.5%
expm1-udef37.8%
Applied egg-rr37.8%
expm1-def98.1%
expm1-log1p98.1%
Simplified98.1%
Final simplification98.1%
(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 2024040
(FPCore (x)
:name "2isqrt (example 3.6)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:herbie-target
(/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))
(- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))