
(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 14 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 (<= x 62000000.0) (- (pow x -0.5) (pow (+ 1.0 x) -0.5)) (/ (/ -1.0 (* x (- -1.0 x))) (* 2.0 (sqrt (/ 1.0 x))))))
double code(double x) {
double tmp;
if (x <= 62000000.0) {
tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
} else {
tmp = (-1.0 / (x * (-1.0 - x))) / (2.0 * sqrt((1.0 / x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 62000000.0d0) then
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
else
tmp = ((-1.0d0) / (x * ((-1.0d0) - x))) / (2.0d0 * sqrt((1.0d0 / x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 62000000.0) {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
} else {
tmp = (-1.0 / (x * (-1.0 - x))) / (2.0 * Math.sqrt((1.0 / x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 62000000.0: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) else: tmp = (-1.0 / (x * (-1.0 - x))) / (2.0 * math.sqrt((1.0 / x))) return tmp
function code(x) tmp = 0.0 if (x <= 62000000.0) tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); else tmp = Float64(Float64(-1.0 / Float64(x * Float64(-1.0 - x))) / Float64(2.0 * sqrt(Float64(1.0 / x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 62000000.0) tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); else tmp = (-1.0 / (x * (-1.0 - x))) / (2.0 * sqrt((1.0 / x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 62000000.0], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 / N[(x * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 62000000:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1}{x \cdot \left(-1 - x\right)}}{2 \cdot \sqrt{\frac{1}{x}}}\\
\end{array}
\end{array}
if x < 6.2e7Initial 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%
pow1/299.4%
pow-flip99.8%
metadata-eval99.8%
pow1/299.8%
pow-flip99.8%
+-commutative99.8%
metadata-eval99.8%
Applied egg-rr99.8%
associate-+l-99.8%
expm1-log1p99.8%
expm1-def99.7%
associate--l-99.7%
fma-udef99.7%
distribute-lft1-in99.7%
metadata-eval99.7%
mul0-lft99.7%
metadata-eval99.7%
expm1-def99.8%
expm1-log1p99.8%
Simplified99.8%
if 6.2e7 < x Initial program 37.7%
flip--37.7%
frac-times26.0%
metadata-eval26.0%
add-sqr-sqrt16.1%
frac-times21.4%
metadata-eval21.4%
add-sqr-sqrt37.7%
+-commutative37.7%
pow1/237.7%
pow-flip37.7%
metadata-eval37.7%
inv-pow37.7%
sqrt-pow237.7%
+-commutative37.7%
metadata-eval37.7%
Applied egg-rr37.7%
frac-2neg37.7%
metadata-eval37.7%
frac-sub37.7%
*-un-lft-identity37.7%
distribute-neg-in37.7%
metadata-eval37.7%
distribute-neg-in37.7%
metadata-eval37.7%
Applied egg-rr37.7%
associate--l+80.4%
*-commutative80.4%
neg-mul-180.4%
+-inverses80.4%
metadata-eval80.4%
unsub-neg80.4%
Simplified80.4%
Taylor expanded in x around inf 80.4%
Final simplification91.4%
(FPCore (x) :precision binary64 (/ (* (/ 1.0 x) (/ -1.0 (- -1.0 x))) (+ (pow x -0.5) (pow (+ 1.0 x) -0.5))))
double code(double x) {
return ((1.0 / x) * (-1.0 / (-1.0 - x))) / (pow(x, -0.5) + pow((1.0 + x), -0.5));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 / x) * ((-1.0d0) / ((-1.0d0) - x))) / ((x ** (-0.5d0)) + ((1.0d0 + x) ** (-0.5d0)))
end function
public static double code(double x) {
return ((1.0 / x) * (-1.0 / (-1.0 - x))) / (Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5));
}
def code(x): return ((1.0 / x) * (-1.0 / (-1.0 - x))) / (math.pow(x, -0.5) + math.pow((1.0 + x), -0.5))
function code(x) return Float64(Float64(Float64(1.0 / x) * Float64(-1.0 / Float64(-1.0 - x))) / Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5))) end
function tmp = code(x) tmp = ((1.0 / x) * (-1.0 / (-1.0 - x))) / ((x ^ -0.5) + ((1.0 + x) ^ -0.5)); end
code[x_] := N[(N[(N[(1.0 / x), $MachinePrecision] * N[(-1.0 / N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x} \cdot \frac{-1}{-1 - x}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}
\end{array}
Initial program 72.7%
flip--72.6%
frac-times67.4%
metadata-eval67.4%
add-sqr-sqrt63.1%
frac-times65.4%
metadata-eval65.4%
add-sqr-sqrt72.5%
+-commutative72.5%
pow1/272.5%
pow-flip72.5%
metadata-eval72.5%
inv-pow72.5%
sqrt-pow272.5%
+-commutative72.5%
metadata-eval72.5%
Applied egg-rr72.5%
frac-2neg72.5%
metadata-eval72.5%
frac-sub72.6%
*-un-lft-identity72.6%
distribute-neg-in72.6%
metadata-eval72.6%
distribute-neg-in72.6%
metadata-eval72.6%
Applied egg-rr72.6%
associate--l+91.1%
*-commutative91.1%
neg-mul-191.1%
+-inverses91.1%
metadata-eval91.1%
unsub-neg91.1%
Simplified91.1%
metadata-eval91.1%
/-rgt-identity91.1%
sub-neg91.1%
metadata-eval91.1%
distribute-neg-in91.1%
frac-times91.2%
clear-num91.2%
distribute-neg-in91.2%
metadata-eval91.2%
sub-neg91.2%
Applied egg-rr91.2%
Final simplification91.2%
(FPCore (x) :precision binary64 (/ -1.0 (* (+ (pow x -0.5) (pow (+ 1.0 x) -0.5)) (* x (- -1.0 x)))))
double code(double x) {
return -1.0 / ((pow(x, -0.5) + pow((1.0 + x), -0.5)) * (x * (-1.0 - x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-1.0d0) / (((x ** (-0.5d0)) + ((1.0d0 + x) ** (-0.5d0))) * (x * ((-1.0d0) - x)))
end function
public static double code(double x) {
return -1.0 / ((Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5)) * (x * (-1.0 - x)));
}
def code(x): return -1.0 / ((math.pow(x, -0.5) + math.pow((1.0 + x), -0.5)) * (x * (-1.0 - x)))
function code(x) return Float64(-1.0 / Float64(Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5)) * Float64(x * Float64(-1.0 - x)))) end
function tmp = code(x) tmp = -1.0 / (((x ^ -0.5) + ((1.0 + x) ^ -0.5)) * (x * (-1.0 - x))); end
code[x_] := 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[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{\left({x}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right) \cdot \left(x \cdot \left(-1 - x\right)\right)}
\end{array}
Initial program 72.7%
flip--72.6%
frac-times67.4%
metadata-eval67.4%
add-sqr-sqrt63.1%
frac-times65.4%
metadata-eval65.4%
add-sqr-sqrt72.5%
+-commutative72.5%
pow1/272.5%
pow-flip72.5%
metadata-eval72.5%
inv-pow72.5%
sqrt-pow272.5%
+-commutative72.5%
metadata-eval72.5%
Applied egg-rr72.5%
frac-2neg72.5%
metadata-eval72.5%
frac-sub72.6%
*-un-lft-identity72.6%
distribute-neg-in72.6%
metadata-eval72.6%
distribute-neg-in72.6%
metadata-eval72.6%
Applied egg-rr72.6%
associate--l+91.1%
*-commutative91.1%
neg-mul-191.1%
+-inverses91.1%
metadata-eval91.1%
unsub-neg91.1%
Simplified91.1%
expm1-log1p-u87.6%
expm1-udef68.9%
associate-/l/68.9%
*-commutative68.9%
+-commutative68.9%
Applied egg-rr68.9%
expm1-def87.5%
expm1-log1p91.1%
+-commutative91.1%
Simplified91.1%
Final simplification91.1%
(FPCore (x) :precision binary64 (/ (/ -1.0 (* x (- -1.0 x))) (+ (pow x -0.5) (pow (+ 1.0 x) -0.5))))
double code(double x) {
return (-1.0 / (x * (-1.0 - x))) / (pow(x, -0.5) + pow((1.0 + x), -0.5));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-1.0d0) / (x * ((-1.0d0) - x))) / ((x ** (-0.5d0)) + ((1.0d0 + x) ** (-0.5d0)))
end function
public static double code(double x) {
return (-1.0 / (x * (-1.0 - x))) / (Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5));
}
def code(x): return (-1.0 / (x * (-1.0 - x))) / (math.pow(x, -0.5) + math.pow((1.0 + x), -0.5))
function code(x) return Float64(Float64(-1.0 / Float64(x * Float64(-1.0 - x))) / Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5))) end
function tmp = code(x) tmp = (-1.0 / (x * (-1.0 - x))) / ((x ^ -0.5) + ((1.0 + x) ^ -0.5)); end
code[x_] := N[(N[(-1.0 / N[(x * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{-1}{x \cdot \left(-1 - x\right)}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}
\end{array}
Initial program 72.7%
flip--72.6%
frac-times67.4%
metadata-eval67.4%
add-sqr-sqrt63.1%
frac-times65.4%
metadata-eval65.4%
add-sqr-sqrt72.5%
+-commutative72.5%
pow1/272.5%
pow-flip72.5%
metadata-eval72.5%
inv-pow72.5%
sqrt-pow272.5%
+-commutative72.5%
metadata-eval72.5%
Applied egg-rr72.5%
frac-2neg72.5%
metadata-eval72.5%
frac-sub72.6%
*-un-lft-identity72.6%
distribute-neg-in72.6%
metadata-eval72.6%
distribute-neg-in72.6%
metadata-eval72.6%
Applied egg-rr72.6%
associate--l+91.1%
*-commutative91.1%
neg-mul-191.1%
+-inverses91.1%
metadata-eval91.1%
unsub-neg91.1%
Simplified91.1%
Final simplification91.1%
(FPCore (x) :precision binary64 (if (<= x 0.68) (+ -1.0 (+ (pow x -0.5) (* x 0.5))) (/ (/ -1.0 (* x (- -1.0 x))) (* 2.0 (sqrt (/ 1.0 x))))))
double code(double x) {
double tmp;
if (x <= 0.68) {
tmp = -1.0 + (pow(x, -0.5) + (x * 0.5));
} else {
tmp = (-1.0 / (x * (-1.0 - x))) / (2.0 * sqrt((1.0 / x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.68d0) then
tmp = (-1.0d0) + ((x ** (-0.5d0)) + (x * 0.5d0))
else
tmp = ((-1.0d0) / (x * ((-1.0d0) - x))) / (2.0d0 * sqrt((1.0d0 / x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.68) {
tmp = -1.0 + (Math.pow(x, -0.5) + (x * 0.5));
} else {
tmp = (-1.0 / (x * (-1.0 - x))) / (2.0 * Math.sqrt((1.0 / x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.68: tmp = -1.0 + (math.pow(x, -0.5) + (x * 0.5)) else: tmp = (-1.0 / (x * (-1.0 - x))) / (2.0 * math.sqrt((1.0 / x))) return tmp
function code(x) tmp = 0.0 if (x <= 0.68) tmp = Float64(-1.0 + Float64((x ^ -0.5) + Float64(x * 0.5))); else tmp = Float64(Float64(-1.0 / Float64(x * Float64(-1.0 - x))) / Float64(2.0 * sqrt(Float64(1.0 / x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.68) tmp = -1.0 + ((x ^ -0.5) + (x * 0.5)); else tmp = (-1.0 / (x * (-1.0 - x))) / (2.0 * sqrt((1.0 / x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.68], N[(-1.0 + N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 / N[(x * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;-1 + \left({x}^{-0.5} + x \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1}{x \cdot \left(-1 - x\right)}}{2 \cdot \sqrt{\frac{1}{x}}}\\
\end{array}
\end{array}
if x < 0.680000000000000049Initial 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%
pow1/299.6%
pow-flip100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
associate-+l-100.0%
expm1-log1p100.0%
expm1-def100.0%
associate--l-100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
metadata-eval100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in x around 0 99.6%
if 0.680000000000000049 < x Initial program 38.6%
flip--38.6%
frac-times27.1%
metadata-eval27.1%
add-sqr-sqrt17.3%
frac-times22.5%
metadata-eval22.5%
add-sqr-sqrt38.6%
+-commutative38.6%
pow1/238.6%
pow-flip38.6%
metadata-eval38.6%
inv-pow38.6%
sqrt-pow238.6%
+-commutative38.6%
metadata-eval38.6%
Applied egg-rr38.6%
frac-2neg38.6%
metadata-eval38.6%
frac-sub38.8%
*-un-lft-identity38.8%
distribute-neg-in38.8%
metadata-eval38.8%
distribute-neg-in38.8%
metadata-eval38.8%
Applied egg-rr38.8%
associate--l+80.8%
*-commutative80.8%
neg-mul-180.8%
+-inverses80.8%
metadata-eval80.8%
unsub-neg80.8%
Simplified80.8%
Taylor expanded in x around inf 79.6%
Final simplification90.8%
(FPCore (x) :precision binary64 (if (<= x 8.5e+122) (- (/ 1.0 (sqrt x)) (/ 1.0 (+ 1.0 (* x 0.5)))) (+ 1.0 (- -1.0 (pow x -0.5)))))
double code(double x) {
double tmp;
if (x <= 8.5e+122) {
tmp = (1.0 / sqrt(x)) - (1.0 / (1.0 + (x * 0.5)));
} else {
tmp = 1.0 + (-1.0 - pow(x, -0.5));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 8.5d+122) then
tmp = (1.0d0 / sqrt(x)) - (1.0d0 / (1.0d0 + (x * 0.5d0)))
else
tmp = 1.0d0 + ((-1.0d0) - (x ** (-0.5d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 8.5e+122) {
tmp = (1.0 / Math.sqrt(x)) - (1.0 / (1.0 + (x * 0.5)));
} else {
tmp = 1.0 + (-1.0 - Math.pow(x, -0.5));
}
return tmp;
}
def code(x): tmp = 0 if x <= 8.5e+122: tmp = (1.0 / math.sqrt(x)) - (1.0 / (1.0 + (x * 0.5))) else: tmp = 1.0 + (-1.0 - math.pow(x, -0.5)) return tmp
function code(x) tmp = 0.0 if (x <= 8.5e+122) tmp = Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / Float64(1.0 + Float64(x * 0.5)))); else tmp = Float64(1.0 + Float64(-1.0 - (x ^ -0.5))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 8.5e+122) tmp = (1.0 / sqrt(x)) - (1.0 / (1.0 + (x * 0.5))); else tmp = 1.0 + (-1.0 - (x ^ -0.5)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 8.5e+122], N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-1.0 - N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.5 \cdot 10^{+122}:\\
\;\;\;\;\frac{1}{\sqrt{x}} - \frac{1}{1 + x \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(-1 - {x}^{-0.5}\right)\\
\end{array}
\end{array}
if x < 8.50000000000000003e122Initial program 81.8%
Taylor expanded in x around 0 81.2%
*-commutative81.2%
Simplified81.2%
if 8.50000000000000003e122 < x Initial program 51.9%
pow1/251.9%
pow-to-exp4.3%
+-commutative4.3%
log1p-udef4.3%
Applied egg-rr4.3%
Taylor expanded in x around inf 3.8%
mul-1-neg3.8%
Simplified3.8%
inv-pow3.8%
sqrt-pow13.8%
metadata-eval3.8%
expm1-log1p-u3.8%
expm1-udef51.9%
Applied egg-rr51.9%
expm1-def3.8%
expm1-log1p3.8%
Simplified3.8%
expm1-log1p-u3.8%
expm1-udef51.9%
log1p-udef51.9%
+-commutative51.9%
add-exp-log51.9%
Applied egg-rr51.9%
Final simplification72.3%
(FPCore (x) :precision binary64 (/ (/ -1.0 (* x (- -1.0 x))) (+ 1.0 (pow x -0.5))))
double code(double x) {
return (-1.0 / (x * (-1.0 - x))) / (1.0 + pow(x, -0.5));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-1.0d0) / (x * ((-1.0d0) - x))) / (1.0d0 + (x ** (-0.5d0)))
end function
public static double code(double x) {
return (-1.0 / (x * (-1.0 - x))) / (1.0 + Math.pow(x, -0.5));
}
def code(x): return (-1.0 / (x * (-1.0 - x))) / (1.0 + math.pow(x, -0.5))
function code(x) return Float64(Float64(-1.0 / Float64(x * Float64(-1.0 - x))) / Float64(1.0 + (x ^ -0.5))) end
function tmp = code(x) tmp = (-1.0 / (x * (-1.0 - x))) / (1.0 + (x ^ -0.5)); end
code[x_] := N[(N[(-1.0 / N[(x * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{-1}{x \cdot \left(-1 - x\right)}}{1 + {x}^{-0.5}}
\end{array}
Initial program 72.7%
flip--72.6%
frac-times67.4%
metadata-eval67.4%
add-sqr-sqrt63.1%
frac-times65.4%
metadata-eval65.4%
add-sqr-sqrt72.5%
+-commutative72.5%
pow1/272.5%
pow-flip72.5%
metadata-eval72.5%
inv-pow72.5%
sqrt-pow272.5%
+-commutative72.5%
metadata-eval72.5%
Applied egg-rr72.5%
frac-2neg72.5%
metadata-eval72.5%
frac-sub72.6%
*-un-lft-identity72.6%
distribute-neg-in72.6%
metadata-eval72.6%
distribute-neg-in72.6%
metadata-eval72.6%
Applied egg-rr72.6%
associate--l+91.1%
*-commutative91.1%
neg-mul-191.1%
+-inverses91.1%
metadata-eval91.1%
unsub-neg91.1%
Simplified91.1%
Taylor expanded in x around 0 72.1%
Final simplification72.1%
(FPCore (x) :precision binary64 (if (<= x 8.2e+76) (+ -1.0 (+ (pow x -0.5) (* x 0.5))) (+ 1.0 (- -1.0 (pow x -0.5)))))
double code(double x) {
double tmp;
if (x <= 8.2e+76) {
tmp = -1.0 + (pow(x, -0.5) + (x * 0.5));
} else {
tmp = 1.0 + (-1.0 - pow(x, -0.5));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 8.2d+76) then
tmp = (-1.0d0) + ((x ** (-0.5d0)) + (x * 0.5d0))
else
tmp = 1.0d0 + ((-1.0d0) - (x ** (-0.5d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 8.2e+76) {
tmp = -1.0 + (Math.pow(x, -0.5) + (x * 0.5));
} else {
tmp = 1.0 + (-1.0 - Math.pow(x, -0.5));
}
return tmp;
}
def code(x): tmp = 0 if x <= 8.2e+76: tmp = -1.0 + (math.pow(x, -0.5) + (x * 0.5)) else: tmp = 1.0 + (-1.0 - math.pow(x, -0.5)) return tmp
function code(x) tmp = 0.0 if (x <= 8.2e+76) tmp = Float64(-1.0 + Float64((x ^ -0.5) + Float64(x * 0.5))); else tmp = Float64(1.0 + Float64(-1.0 - (x ^ -0.5))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 8.2e+76) tmp = -1.0 + ((x ^ -0.5) + (x * 0.5)); else tmp = 1.0 + (-1.0 - (x ^ -0.5)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 8.2e+76], N[(-1.0 + N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-1.0 - N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.2 \cdot 10^{+76}:\\
\;\;\;\;-1 + \left({x}^{-0.5} + x \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(-1 - {x}^{-0.5}\right)\\
\end{array}
\end{array}
if x < 8.1999999999999997e76Initial program 89.4%
*-un-lft-identity89.4%
clear-num89.4%
associate-/r/89.4%
prod-diff89.4%
*-un-lft-identity89.4%
fma-neg89.4%
*-un-lft-identity89.4%
pow1/289.4%
pow-flip89.7%
metadata-eval89.7%
pow1/289.7%
pow-flip89.7%
+-commutative89.7%
metadata-eval89.7%
Applied egg-rr89.7%
associate-+l-89.7%
expm1-log1p89.7%
expm1-def89.9%
associate--l-89.9%
fma-udef89.9%
distribute-lft1-in89.9%
metadata-eval89.9%
mul0-lft89.9%
metadata-eval89.9%
expm1-def89.7%
expm1-log1p89.7%
Simplified89.7%
Taylor expanded in x around 0 88.7%
if 8.1999999999999997e76 < x Initial program 43.9%
pow1/243.9%
pow-to-exp4.3%
+-commutative4.3%
log1p-udef4.3%
Applied egg-rr4.3%
Taylor expanded in x around inf 3.6%
mul-1-neg3.6%
Simplified3.6%
inv-pow3.6%
sqrt-pow13.6%
metadata-eval3.6%
expm1-log1p-u3.6%
expm1-udef43.9%
Applied egg-rr43.9%
expm1-def3.6%
expm1-log1p3.6%
Simplified3.6%
expm1-log1p-u3.6%
expm1-udef43.9%
log1p-udef43.9%
+-commutative43.9%
add-exp-log43.9%
Applied egg-rr43.9%
Final simplification72.2%
(FPCore (x) :precision binary64 (if (<= x 4.0) (+ -1.0 (pow x -0.5)) (+ 1.0 (- -1.0 (pow x -0.5)))))
double code(double x) {
double tmp;
if (x <= 4.0) {
tmp = -1.0 + pow(x, -0.5);
} else {
tmp = 1.0 + (-1.0 - pow(x, -0.5));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 4.0d0) then
tmp = (-1.0d0) + (x ** (-0.5d0))
else
tmp = 1.0d0 + ((-1.0d0) - (x ** (-0.5d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 4.0) {
tmp = -1.0 + Math.pow(x, -0.5);
} else {
tmp = 1.0 + (-1.0 - Math.pow(x, -0.5));
}
return tmp;
}
def code(x): tmp = 0 if x <= 4.0: tmp = -1.0 + math.pow(x, -0.5) else: tmp = 1.0 + (-1.0 - math.pow(x, -0.5)) return tmp
function code(x) tmp = 0.0 if (x <= 4.0) tmp = Float64(-1.0 + (x ^ -0.5)); else tmp = Float64(1.0 + Float64(-1.0 - (x ^ -0.5))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 4.0) tmp = -1.0 + (x ^ -0.5); else tmp = 1.0 + (-1.0 - (x ^ -0.5)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 4.0], N[(-1.0 + N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-1.0 - N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4:\\
\;\;\;\;-1 + {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(-1 - {x}^{-0.5}\right)\\
\end{array}
\end{array}
if x < 4Initial 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%
pow1/299.6%
pow-flip99.9%
metadata-eval99.9%
pow1/299.9%
pow-flip99.9%
+-commutative99.9%
metadata-eval99.9%
Applied egg-rr99.9%
associate-+l-99.9%
expm1-log1p99.9%
expm1-def99.9%
associate--l-99.9%
fma-udef99.9%
distribute-lft1-in99.9%
metadata-eval99.9%
mul0-lft99.9%
metadata-eval99.9%
expm1-def99.9%
expm1-log1p99.9%
Simplified99.9%
Taylor expanded in x around 0 98.7%
if 4 < x Initial program 38.0%
pow1/238.0%
pow-to-exp5.1%
+-commutative5.1%
log1p-udef5.1%
Applied egg-rr5.1%
Taylor expanded in x around inf 3.3%
mul-1-neg3.3%
Simplified3.3%
inv-pow3.3%
sqrt-pow13.3%
metadata-eval3.3%
expm1-log1p-u3.3%
expm1-udef37.4%
Applied egg-rr37.4%
expm1-def3.3%
expm1-log1p3.3%
Simplified3.3%
expm1-log1p-u3.3%
expm1-udef37.4%
log1p-udef37.4%
+-commutative37.4%
add-exp-log37.4%
Applied egg-rr37.4%
Final simplification71.8%
(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 72.7%
flip--72.6%
frac-times67.4%
metadata-eval67.4%
add-sqr-sqrt63.1%
frac-times65.4%
metadata-eval65.4%
add-sqr-sqrt72.5%
+-commutative72.5%
pow1/272.5%
pow-flip72.5%
metadata-eval72.5%
inv-pow72.5%
sqrt-pow272.5%
+-commutative72.5%
metadata-eval72.5%
Applied egg-rr72.5%
Taylor expanded in x around 0 57.9%
+-commutative57.9%
distribute-lft-in57.9%
pow157.9%
pow-prod-up58.0%
metadata-eval58.0%
pow1/258.0%
*-rgt-identity58.0%
Applied egg-rr58.0%
Final simplification58.0%
(FPCore (x) :precision binary64 (+ -1.0 (pow x -0.5)))
double code(double x) {
return -1.0 + pow(x, -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-1.0d0) + (x ** (-0.5d0))
end function
public static double code(double x) {
return -1.0 + Math.pow(x, -0.5);
}
def code(x): return -1.0 + math.pow(x, -0.5)
function code(x) return Float64(-1.0 + (x ^ -0.5)) end
function tmp = code(x) tmp = -1.0 + (x ^ -0.5); end
code[x_] := N[(-1.0 + N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + {x}^{-0.5}
\end{array}
Initial program 72.7%
*-un-lft-identity72.7%
clear-num72.7%
associate-/r/72.7%
prod-diff72.7%
*-un-lft-identity72.7%
fma-neg72.7%
*-un-lft-identity72.7%
pow1/272.7%
pow-flip68.6%
metadata-eval68.6%
pow1/268.6%
pow-flip72.9%
+-commutative72.9%
metadata-eval72.9%
Applied egg-rr72.9%
associate-+l-72.9%
expm1-log1p72.9%
expm1-def58.6%
associate--l-58.6%
fma-udef58.6%
distribute-lft1-in58.6%
metadata-eval58.6%
mul0-lft58.6%
metadata-eval58.6%
expm1-def72.9%
expm1-log1p72.9%
Simplified72.9%
Taylor expanded in x around 0 56.7%
Final simplification56.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 Float64(-(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 72.7%
pow1/272.7%
pow-to-exp58.2%
+-commutative58.2%
log1p-udef58.2%
Applied egg-rr58.2%
Taylor expanded in x around inf 2.1%
mul-1-neg2.1%
Simplified2.1%
inv-pow2.1%
sqrt-pow12.1%
metadata-eval2.1%
expm1-log1p-u2.1%
expm1-udef17.0%
Applied egg-rr17.0%
expm1-def2.1%
expm1-log1p2.1%
Simplified2.1%
Final simplification2.1%
(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 72.7%
*-un-lft-identity72.7%
clear-num72.7%
associate-/r/72.7%
prod-diff72.7%
*-un-lft-identity72.7%
fma-neg72.7%
*-un-lft-identity72.7%
pow1/272.7%
pow-flip68.6%
metadata-eval68.6%
pow1/268.6%
pow-flip72.9%
+-commutative72.9%
metadata-eval72.9%
Applied egg-rr72.9%
associate-+l-72.9%
expm1-log1p72.9%
expm1-def58.6%
associate--l-58.6%
fma-udef58.6%
distribute-lft1-in58.6%
metadata-eval58.6%
mul0-lft58.6%
metadata-eval58.6%
expm1-def72.9%
expm1-log1p72.9%
Simplified72.9%
Applied egg-rr56.8%
associate-*r/56.9%
*-rgt-identity56.9%
Simplified56.9%
Taylor expanded in x around inf 56.1%
Final simplification56.1%
(FPCore (x) :precision binary64 -1.0)
double code(double x) {
return -1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = -1.0d0
end function
public static double code(double x) {
return -1.0;
}
def code(x): return -1.0
function code(x) return -1.0 end
function tmp = code(x) tmp = -1.0; end
code[x_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 72.7%
Taylor expanded in x around 0 56.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 2024010
(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)))))