
(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 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
public static double code(double x) {
return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
def code(x): return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
function code(x) return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) end
function tmp = code(x) tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))); end
code[x_] := N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\end{array}
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ x 1.0)))) 0.0) (/ (pow x -1.5) 2.0) (/ (pow x -0.5) (+ (+ x 1.0) (sqrt (+ x (* x x)))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((x + 1.0)))) <= 0.0) {
tmp = pow(x, -1.5) / 2.0;
} else {
tmp = pow(x, -0.5) / ((x + 1.0) + sqrt((x + (x * x))));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((x + 1.0d0)))) <= 0.0d0) then
tmp = (x ** (-1.5d0)) / 2.0d0
else
tmp = (x ** (-0.5d0)) / ((x + 1.0d0) + sqrt((x + (x * 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((x + 1.0)))) <= 0.0) {
tmp = Math.pow(x, -1.5) / 2.0;
} else {
tmp = Math.pow(x, -0.5) / ((x + 1.0) + Math.sqrt((x + (x * x))));
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((x + 1.0)))) <= 0.0: tmp = math.pow(x, -1.5) / 2.0 else: tmp = math.pow(x, -0.5) / ((x + 1.0) + math.sqrt((x + (x * x)))) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(x + 1.0)))) <= 0.0) tmp = Float64((x ^ -1.5) / 2.0); else tmp = Float64((x ^ -0.5) / Float64(Float64(x + 1.0) + sqrt(Float64(x + Float64(x * x))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((x + 1.0)))) <= 0.0) tmp = (x ^ -1.5) / 2.0; else tmp = (x ^ -0.5) / ((x + 1.0) + sqrt((x + (x * 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[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[Power[x, -1.5], $MachinePrecision] / 2.0), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] + N[Sqrt[N[(x + N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{x + 1}} \leq 0:\\
\;\;\;\;\frac{{x}^{-1.5}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{-0.5}}{\left(x + 1\right) + \sqrt{x + x \cdot x}}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 0.0Initial program 37.7%
frac-sub37.7%
div-inv37.7%
*-un-lft-identity37.7%
+-commutative37.7%
*-rgt-identity37.7%
metadata-eval37.7%
frac-times37.7%
un-div-inv37.7%
pow1/237.7%
pow-flip37.7%
metadata-eval37.7%
+-commutative37.7%
Applied egg-rr37.7%
*-commutative37.7%
clear-num37.7%
flip--37.7%
frac-times37.7%
*-un-lft-identity37.7%
add-sqr-sqrt37.4%
add-sqr-sqrt37.7%
Applied egg-rr37.7%
associate--l+98.2%
+-inverses98.2%
metadata-eval98.2%
associate-*l/98.1%
associate-/l*99.4%
*-lft-identity99.4%
distribute-lft-in99.4%
rem-square-sqrt99.6%
Simplified99.6%
Taylor expanded in x around inf 99.7%
*-commutative99.7%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef37.7%
associate-/r*37.7%
pow137.7%
pow-div37.7%
metadata-eval37.7%
Applied egg-rr37.7%
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 98.4%
frac-sub98.4%
div-inv98.4%
*-un-lft-identity98.4%
+-commutative98.4%
*-rgt-identity98.4%
metadata-eval98.4%
frac-times98.4%
un-div-inv98.4%
pow1/298.4%
pow-flip98.7%
metadata-eval98.7%
+-commutative98.7%
Applied egg-rr98.7%
*-commutative98.7%
clear-num98.5%
flip--98.7%
frac-times98.6%
*-un-lft-identity98.6%
add-sqr-sqrt98.6%
add-sqr-sqrt99.7%
Applied egg-rr99.7%
associate--l+99.7%
+-inverses99.7%
metadata-eval99.7%
associate-*l/99.7%
associate-/l*99.9%
*-lft-identity99.9%
distribute-lft-in99.9%
rem-square-sqrt99.9%
Simplified99.9%
*-un-lft-identity99.9%
fma-def99.9%
*-commutative99.9%
sqrt-unprod99.9%
Applied egg-rr99.9%
fma-udef99.9%
*-lft-identity99.9%
+-commutative99.9%
distribute-rgt-in99.9%
*-lft-identity99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ x 1.0)))) 5e-6)
(/
(pow x -0.5)
(+ (+ x 1.0) (- (+ 0.5 (+ x (/ 0.0625 (* x x)))) (/ 0.125 x))))
(- (pow x -0.5) (pow (+ x 1.0) -0.5))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((x + 1.0)))) <= 5e-6) {
tmp = pow(x, -0.5) / ((x + 1.0) + ((0.5 + (x + (0.0625 / (x * x)))) - (0.125 / x)));
} else {
tmp = pow(x, -0.5) - pow((x + 1.0), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((x + 1.0d0)))) <= 5d-6) then
tmp = (x ** (-0.5d0)) / ((x + 1.0d0) + ((0.5d0 + (x + (0.0625d0 / (x * x)))) - (0.125d0 / x)))
else
tmp = (x ** (-0.5d0)) - ((x + 1.0d0) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / Math.sqrt((x + 1.0)))) <= 5e-6) {
tmp = Math.pow(x, -0.5) / ((x + 1.0) + ((0.5 + (x + (0.0625 / (x * x)))) - (0.125 / x)));
} else {
tmp = Math.pow(x, -0.5) - Math.pow((x + 1.0), -0.5);
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((x + 1.0)))) <= 5e-6: tmp = math.pow(x, -0.5) / ((x + 1.0) + ((0.5 + (x + (0.0625 / (x * x)))) - (0.125 / x))) else: tmp = math.pow(x, -0.5) - math.pow((x + 1.0), -0.5) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(x + 1.0)))) <= 5e-6) tmp = Float64((x ^ -0.5) / Float64(Float64(x + 1.0) + Float64(Float64(0.5 + Float64(x + Float64(0.0625 / Float64(x * x)))) - Float64(0.125 / x)))); else tmp = Float64((x ^ -0.5) - (Float64(x + 1.0) ^ -0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((x + 1.0)))) <= 5e-6) tmp = (x ^ -0.5) / ((x + 1.0) + ((0.5 + (x + (0.0625 / (x * x)))) - (0.125 / x))); else tmp = (x ^ -0.5) - ((x + 1.0) ^ -0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e-6], N[(N[Power[x, -0.5], $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] + N[(N[(0.5 + N[(x + N[(0.0625 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{x + 1}} \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{{x}^{-0.5}}{\left(x + 1\right) + \left(\left(0.5 + \left(x + \frac{0.0625}{x \cdot x}\right)\right) - \frac{0.125}{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 5.00000000000000041e-6Initial program 38.5%
frac-sub38.5%
div-inv38.5%
*-un-lft-identity38.5%
+-commutative38.5%
*-rgt-identity38.5%
metadata-eval38.5%
frac-times38.5%
un-div-inv38.5%
pow1/238.5%
pow-flip38.5%
metadata-eval38.5%
+-commutative38.5%
Applied egg-rr38.5%
*-commutative38.5%
clear-num38.5%
flip--38.5%
frac-times38.5%
*-un-lft-identity38.5%
add-sqr-sqrt38.3%
add-sqr-sqrt39.4%
Applied egg-rr39.4%
associate--l+98.2%
+-inverses98.2%
metadata-eval98.2%
associate-*l/98.2%
associate-/l*99.4%
*-lft-identity99.4%
distribute-lft-in99.4%
rem-square-sqrt99.5%
Simplified99.5%
Taylor expanded in x around inf 99.7%
+-commutative99.7%
associate-*r/99.7%
metadata-eval99.7%
unpow299.7%
associate-*r/99.7%
metadata-eval99.7%
Simplified99.7%
if 5.00000000000000041e-6 < (-.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-pow299.9%
metadata-eval99.9%
pow1/299.9%
pow-flip99.9%
+-commutative99.9%
metadata-eval99.9%
Applied egg-rr99.9%
fma-udef99.9%
distribute-lft1-in99.9%
metadata-eval99.9%
mul0-lft99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.8%
(FPCore (x) :precision binary64 (/ (pow x -0.5) (+ (+ x 1.0) (* (sqrt (+ x 1.0)) (sqrt x)))))
double code(double x) {
return pow(x, -0.5) / ((x + 1.0) + (sqrt((x + 1.0)) * sqrt(x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x ** (-0.5d0)) / ((x + 1.0d0) + (sqrt((x + 1.0d0)) * sqrt(x)))
end function
public static double code(double x) {
return Math.pow(x, -0.5) / ((x + 1.0) + (Math.sqrt((x + 1.0)) * Math.sqrt(x)));
}
def code(x): return math.pow(x, -0.5) / ((x + 1.0) + (math.sqrt((x + 1.0)) * math.sqrt(x)))
function code(x) return Float64((x ^ -0.5) / Float64(Float64(x + 1.0) + Float64(sqrt(Float64(x + 1.0)) * sqrt(x)))) end
function tmp = code(x) tmp = (x ^ -0.5) / ((x + 1.0) + (sqrt((x + 1.0)) * sqrt(x))); end
code[x_] := N[(N[Power[x, -0.5], $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] + N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{x}^{-0.5}}{\left(x + 1\right) + \sqrt{x + 1} \cdot \sqrt{x}}
\end{array}
Initial program 64.7%
frac-sub64.7%
div-inv64.7%
*-un-lft-identity64.7%
+-commutative64.7%
*-rgt-identity64.7%
metadata-eval64.7%
frac-times64.7%
un-div-inv64.7%
pow1/264.7%
pow-flip64.9%
metadata-eval64.9%
+-commutative64.9%
Applied egg-rr64.9%
*-commutative64.9%
clear-num64.8%
flip--64.9%
frac-times64.8%
*-un-lft-identity64.8%
add-sqr-sqrt64.7%
add-sqr-sqrt65.3%
Applied egg-rr65.3%
associate--l+98.9%
+-inverses98.9%
metadata-eval98.9%
associate-*l/98.8%
associate-/l*99.6%
*-lft-identity99.6%
distribute-lft-in99.6%
rem-square-sqrt99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x) :precision binary64 (/ (/ 1.0 (* (+ x 1.0) (+ (pow x -0.5) (pow (+ x 1.0) -0.5)))) x))
double code(double x) {
return (1.0 / ((x + 1.0) * (pow(x, -0.5) + pow((x + 1.0), -0.5)))) / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / ((x + 1.0d0) * ((x ** (-0.5d0)) + ((x + 1.0d0) ** (-0.5d0))))) / x
end function
public static double code(double x) {
return (1.0 / ((x + 1.0) * (Math.pow(x, -0.5) + Math.pow((x + 1.0), -0.5)))) / x;
}
def code(x): return (1.0 / ((x + 1.0) * (math.pow(x, -0.5) + math.pow((x + 1.0), -0.5)))) / x
function code(x) return Float64(Float64(1.0 / Float64(Float64(x + 1.0) * Float64((x ^ -0.5) + (Float64(x + 1.0) ^ -0.5)))) / x) end
function tmp = code(x) tmp = (1.0 / ((x + 1.0) * ((x ^ -0.5) + ((x + 1.0) ^ -0.5)))) / x; end
code[x_] := N[(N[(1.0 / N[(N[(x + 1.0), $MachinePrecision] * N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{\left(x + 1\right) \cdot \left({x}^{-0.5} + {\left(x + 1\right)}^{-0.5}\right)}}{x}
\end{array}
Initial program 64.7%
sub-neg64.7%
flip-+64.7%
frac-times54.8%
metadata-eval54.8%
add-sqr-sqrt53.2%
distribute-neg-frac53.2%
metadata-eval53.2%
+-commutative53.2%
distribute-neg-frac53.2%
metadata-eval53.2%
+-commutative53.2%
pow1/253.2%
pow-flip53.2%
metadata-eval53.2%
Applied egg-rr53.2%
frac-times59.1%
metadata-eval59.1%
add-sqr-sqrt64.6%
frac-sub65.1%
*-un-lft-identity65.1%
Applied egg-rr65.1%
*-rgt-identity65.1%
associate--l+90.9%
+-inverses90.9%
metadata-eval90.9%
associate-/r*91.0%
Simplified91.0%
associate-/l/99.4%
div-inv99.4%
sub-neg99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
pow1/299.4%
pow-flip99.4%
metadata-eval99.4%
Applied egg-rr99.4%
associate-*l/99.4%
*-un-lft-identity99.4%
*-commutative99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x)
:precision binary64
(if (<= x 0.44)
(+ (+ (pow x -0.5) (* x 0.5)) -1.0)
(/
(pow x -0.5)
(+ (+ x 1.0) (- (+ 0.5 (+ x (/ 0.0625 (* x x)))) (/ 0.125 x))))))
double code(double x) {
double tmp;
if (x <= 0.44) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = pow(x, -0.5) / ((x + 1.0) + ((0.5 + (x + (0.0625 / (x * x)))) - (0.125 / x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.44d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = (x ** (-0.5d0)) / ((x + 1.0d0) + ((0.5d0 + (x + (0.0625d0 / (x * x)))) - (0.125d0 / x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.44) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = Math.pow(x, -0.5) / ((x + 1.0) + ((0.5 + (x + (0.0625 / (x * x)))) - (0.125 / x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.44: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = math.pow(x, -0.5) / ((x + 1.0) + ((0.5 + (x + (0.0625 / (x * x)))) - (0.125 / x))) return tmp
function code(x) tmp = 0.0 if (x <= 0.44) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); else tmp = Float64((x ^ -0.5) / Float64(Float64(x + 1.0) + Float64(Float64(0.5 + Float64(x + Float64(0.0625 / Float64(x * x)))) - Float64(0.125 / x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.44) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = (x ^ -0.5) / ((x + 1.0) + ((0.5 + (x + (0.0625 / (x * x)))) - (0.125 / x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.44], 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[(x + 1.0), $MachinePrecision] + N[(N[(0.5 + N[(x + N[(0.0625 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.44:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{-0.5}}{\left(x + 1\right) + \left(\left(0.5 + \left(x + \frac{0.0625}{x \cdot x}\right)\right) - \frac{0.125}{x}\right)}\\
\end{array}
\end{array}
if x < 0.440000000000000002Initial program 99.7%
inv-pow99.7%
pow1/299.7%
pow-pow100.0%
add-exp-log92.6%
pow-exp92.6%
metadata-eval92.6%
Applied egg-rr92.6%
Taylor expanded in x around 0 99.9%
if 0.440000000000000002 < x Initial program 39.2%
frac-sub39.3%
div-inv39.2%
*-un-lft-identity39.2%
+-commutative39.2%
*-rgt-identity39.2%
metadata-eval39.2%
frac-times39.3%
un-div-inv39.3%
pow1/239.3%
pow-flip39.3%
metadata-eval39.3%
+-commutative39.3%
Applied egg-rr39.3%
*-commutative39.3%
clear-num39.2%
flip--39.4%
frac-times39.3%
*-un-lft-identity39.3%
add-sqr-sqrt39.1%
add-sqr-sqrt40.2%
Applied egg-rr40.2%
associate--l+98.2%
+-inverses98.2%
metadata-eval98.2%
associate-*l/98.2%
associate-/l*99.4%
*-lft-identity99.4%
distribute-lft-in99.4%
rem-square-sqrt99.5%
Simplified99.5%
Taylor expanded in x around inf 99.2%
+-commutative99.2%
associate-*r/99.2%
metadata-eval99.2%
unpow299.2%
associate-*r/99.2%
metadata-eval99.2%
Simplified99.2%
Final simplification99.5%
(FPCore (x) :precision binary64 (if (<= x 0.43) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (/ (pow x -0.5) (+ (+ x 1.0) (- (+ x 0.5) (/ 0.125 x))))))
double code(double x) {
double tmp;
if (x <= 0.43) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = pow(x, -0.5) / ((x + 1.0) + ((x + 0.5) - (0.125 / x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.43d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = (x ** (-0.5d0)) / ((x + 1.0d0) + ((x + 0.5d0) - (0.125d0 / x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.43) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = Math.pow(x, -0.5) / ((x + 1.0) + ((x + 0.5) - (0.125 / x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.43: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = math.pow(x, -0.5) / ((x + 1.0) + ((x + 0.5) - (0.125 / x))) return tmp
function code(x) tmp = 0.0 if (x <= 0.43) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); else tmp = Float64((x ^ -0.5) / Float64(Float64(x + 1.0) + Float64(Float64(x + 0.5) - Float64(0.125 / x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.43) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = (x ^ -0.5) / ((x + 1.0) + ((x + 0.5) - (0.125 / x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.43], 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[(x + 1.0), $MachinePrecision] + N[(N[(x + 0.5), $MachinePrecision] - N[(0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.43:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{-0.5}}{\left(x + 1\right) + \left(\left(x + 0.5\right) - \frac{0.125}{x}\right)}\\
\end{array}
\end{array}
if x < 0.429999999999999993Initial program 99.7%
inv-pow99.7%
pow1/299.7%
pow-pow100.0%
add-exp-log92.6%
pow-exp92.6%
metadata-eval92.6%
Applied egg-rr92.6%
Taylor expanded in x around 0 99.9%
if 0.429999999999999993 < x Initial program 39.2%
frac-sub39.3%
div-inv39.2%
*-un-lft-identity39.2%
+-commutative39.2%
*-rgt-identity39.2%
metadata-eval39.2%
frac-times39.3%
un-div-inv39.3%
pow1/239.3%
pow-flip39.3%
metadata-eval39.3%
+-commutative39.3%
Applied egg-rr39.3%
*-commutative39.3%
clear-num39.2%
flip--39.4%
frac-times39.3%
*-un-lft-identity39.3%
add-sqr-sqrt39.1%
add-sqr-sqrt40.2%
Applied egg-rr40.2%
associate--l+98.2%
+-inverses98.2%
metadata-eval98.2%
associate-*l/98.2%
associate-/l*99.4%
*-lft-identity99.4%
distribute-lft-in99.4%
rem-square-sqrt99.5%
Simplified99.5%
Taylor expanded in x around inf 98.9%
+-commutative98.9%
associate-*r/98.9%
metadata-eval98.9%
Simplified98.9%
Final simplification99.4%
(FPCore (x) :precision binary64 (if (<= x 0.43) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (/ (pow x -0.5) (+ 1.5 (- (* x 2.0) (/ 0.125 x))))))
double code(double x) {
double tmp;
if (x <= 0.43) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = pow(x, -0.5) / (1.5 + ((x * 2.0) - (0.125 / x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.43d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = (x ** (-0.5d0)) / (1.5d0 + ((x * 2.0d0) - (0.125d0 / x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.43) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = Math.pow(x, -0.5) / (1.5 + ((x * 2.0) - (0.125 / x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.43: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = math.pow(x, -0.5) / (1.5 + ((x * 2.0) - (0.125 / x))) return tmp
function code(x) tmp = 0.0 if (x <= 0.43) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); else tmp = Float64((x ^ -0.5) / Float64(1.5 + Float64(Float64(x * 2.0) - Float64(0.125 / x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.43) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = (x ^ -0.5) / (1.5 + ((x * 2.0) - (0.125 / x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.43], 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[(1.5 + N[(N[(x * 2.0), $MachinePrecision] - N[(0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.43:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{-0.5}}{1.5 + \left(x \cdot 2 - \frac{0.125}{x}\right)}\\
\end{array}
\end{array}
if x < 0.429999999999999993Initial program 99.7%
inv-pow99.7%
pow1/299.7%
pow-pow100.0%
add-exp-log92.6%
pow-exp92.6%
metadata-eval92.6%
Applied egg-rr92.6%
Taylor expanded in x around 0 99.9%
if 0.429999999999999993 < x Initial program 39.2%
frac-sub39.3%
div-inv39.2%
*-un-lft-identity39.2%
+-commutative39.2%
*-rgt-identity39.2%
metadata-eval39.2%
frac-times39.3%
un-div-inv39.3%
pow1/239.3%
pow-flip39.3%
metadata-eval39.3%
+-commutative39.3%
Applied egg-rr39.3%
*-commutative39.3%
clear-num39.2%
flip--39.4%
frac-times39.3%
*-un-lft-identity39.3%
add-sqr-sqrt39.1%
add-sqr-sqrt40.2%
Applied egg-rr40.2%
associate--l+98.2%
+-inverses98.2%
metadata-eval98.2%
associate-*l/98.2%
associate-/l*99.4%
*-lft-identity99.4%
distribute-lft-in99.4%
rem-square-sqrt99.5%
Simplified99.5%
Taylor expanded in x around inf 98.9%
associate--l+98.9%
*-commutative98.9%
associate-*r/98.9%
metadata-eval98.9%
Simplified98.9%
Final simplification99.3%
(FPCore (x) :precision binary64 (if (<= x 1.0) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (/ (pow x -1.5) 2.0)))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = pow(x, -1.5) / 2.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.0d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = (x ** (-1.5d0)) / 2.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = Math.pow(x, -1.5) / 2.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = math.pow(x, -1.5) / 2.0 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((x ^ -1.5) / 2.0); 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 = (x ^ -1.5) / 2.0; 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[Power[x, -1.5], $MachinePrecision] / 2.0), $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{{x}^{-1.5}}{2}\\
\end{array}
\end{array}
if x < 1Initial program 99.7%
inv-pow99.7%
pow1/299.7%
pow-pow100.0%
add-exp-log92.6%
pow-exp92.6%
metadata-eval92.6%
Applied egg-rr92.6%
Taylor expanded in x around 0 99.9%
if 1 < x Initial program 39.2%
frac-sub39.3%
div-inv39.2%
*-un-lft-identity39.2%
+-commutative39.2%
*-rgt-identity39.2%
metadata-eval39.2%
frac-times39.3%
un-div-inv39.3%
pow1/239.3%
pow-flip39.3%
metadata-eval39.3%
+-commutative39.3%
Applied egg-rr39.3%
*-commutative39.3%
clear-num39.2%
flip--39.4%
frac-times39.3%
*-un-lft-identity39.3%
add-sqr-sqrt39.1%
add-sqr-sqrt40.2%
Applied egg-rr40.2%
associate--l+98.2%
+-inverses98.2%
metadata-eval98.2%
associate-*l/98.2%
associate-/l*99.4%
*-lft-identity99.4%
distribute-lft-in99.4%
rem-square-sqrt99.5%
Simplified99.5%
Taylor expanded in x around inf 97.5%
*-commutative97.5%
Simplified97.5%
expm1-log1p-u97.5%
expm1-udef37.5%
associate-/r*37.5%
pow137.5%
pow-div37.5%
metadata-eval37.5%
Applied egg-rr37.5%
expm1-def97.7%
expm1-log1p97.7%
Simplified97.7%
Final simplification98.7%
(FPCore (x) :precision binary64 (if (<= x 0.41) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (/ (pow x -0.5) (+ 1.5 (* x 2.0)))))
double code(double x) {
double tmp;
if (x <= 0.41) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = pow(x, -0.5) / (1.5 + (x * 2.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.41d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = (x ** (-0.5d0)) / (1.5d0 + (x * 2.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.41) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = Math.pow(x, -0.5) / (1.5 + (x * 2.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.41: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = math.pow(x, -0.5) / (1.5 + (x * 2.0)) return tmp
function code(x) tmp = 0.0 if (x <= 0.41) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); else tmp = Float64((x ^ -0.5) / Float64(1.5 + Float64(x * 2.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.41) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = (x ^ -0.5) / (1.5 + (x * 2.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.41], 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[(1.5 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.41:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{-0.5}}{1.5 + x \cdot 2}\\
\end{array}
\end{array}
if x < 0.409999999999999976Initial program 99.7%
inv-pow99.7%
pow1/299.7%
pow-pow100.0%
add-exp-log92.6%
pow-exp92.6%
metadata-eval92.6%
Applied egg-rr92.6%
Taylor expanded in x around 0 99.9%
if 0.409999999999999976 < x Initial program 39.2%
frac-sub39.3%
div-inv39.2%
*-un-lft-identity39.2%
+-commutative39.2%
*-rgt-identity39.2%
metadata-eval39.2%
frac-times39.3%
un-div-inv39.3%
pow1/239.3%
pow-flip39.3%
metadata-eval39.3%
+-commutative39.3%
Applied egg-rr39.3%
*-commutative39.3%
clear-num39.2%
flip--39.4%
frac-times39.3%
*-un-lft-identity39.3%
add-sqr-sqrt39.1%
add-sqr-sqrt40.2%
Applied egg-rr40.2%
associate--l+98.2%
+-inverses98.2%
metadata-eval98.2%
associate-*l/98.2%
associate-/l*99.4%
*-lft-identity99.4%
distribute-lft-in99.4%
rem-square-sqrt99.5%
Simplified99.5%
Taylor expanded in x around inf 98.5%
+-commutative98.5%
*-commutative98.5%
Simplified98.5%
Final simplification99.1%
(FPCore (x) :precision binary64 (if (<= x 0.66) (+ (pow x -0.5) -1.0) (/ (pow x -1.5) 2.0)))
double code(double x) {
double tmp;
if (x <= 0.66) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = pow(x, -1.5) / 2.0;
}
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 = (x ** (-1.5d0)) / 2.0d0
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 = Math.pow(x, -1.5) / 2.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.66: tmp = math.pow(x, -0.5) + -1.0 else: tmp = math.pow(x, -1.5) / 2.0 return tmp
function code(x) tmp = 0.0 if (x <= 0.66) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64((x ^ -1.5) / 2.0); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.66) tmp = (x ^ -0.5) + -1.0; else tmp = (x ^ -1.5) / 2.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.66], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[x, -1.5], $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.66:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{-1.5}}{2}\\
\end{array}
\end{array}
if x < 0.660000000000000031Initial program 99.7%
inv-pow99.7%
pow1/299.7%
pow-pow100.0%
add-exp-log92.6%
pow-exp92.6%
metadata-eval92.6%
Applied egg-rr92.6%
Taylor expanded in x around 0 99.5%
if 0.660000000000000031 < x Initial program 39.2%
frac-sub39.3%
div-inv39.2%
*-un-lft-identity39.2%
+-commutative39.2%
*-rgt-identity39.2%
metadata-eval39.2%
frac-times39.3%
un-div-inv39.3%
pow1/239.3%
pow-flip39.3%
metadata-eval39.3%
+-commutative39.3%
Applied egg-rr39.3%
*-commutative39.3%
clear-num39.2%
flip--39.4%
frac-times39.3%
*-un-lft-identity39.3%
add-sqr-sqrt39.1%
add-sqr-sqrt40.2%
Applied egg-rr40.2%
associate--l+98.2%
+-inverses98.2%
metadata-eval98.2%
associate-*l/98.2%
associate-/l*99.4%
*-lft-identity99.4%
distribute-lft-in99.4%
rem-square-sqrt99.5%
Simplified99.5%
Taylor expanded in x around inf 97.5%
*-commutative97.5%
Simplified97.5%
expm1-log1p-u97.5%
expm1-udef37.5%
associate-/r*37.5%
pow137.5%
pow-div37.5%
metadata-eval37.5%
Applied egg-rr37.5%
expm1-def97.7%
expm1-log1p97.7%
Simplified97.7%
Final simplification98.5%
(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 64.7%
inv-pow64.7%
pow1/264.7%
pow-pow59.8%
add-exp-log43.2%
pow-exp43.2%
metadata-eval43.2%
Applied egg-rr43.2%
Taylor expanded in x around inf 44.0%
inv-pow44.0%
sqrt-pow144.1%
metadata-eval44.1%
*-un-lft-identity44.1%
Applied egg-rr44.1%
*-lft-identity44.1%
Simplified44.1%
Final simplification44.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 2023240
(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)))))