
(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 7 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) (* (pow x -1.5) (- (/ -0.5 x) -0.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 = pow(x, -1.5) * ((-0.5 / x) - -0.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((x ^ -1.5) * Float64(Float64(-0.5 / x) - -0.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[(N[Power[x, -1.5], $MachinePrecision] * N[(N[(-0.5 / x), $MachinePrecision] - -0.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:\\
\;\;\;\;{x}^{-1.5} \cdot \left(\frac{-0.5}{x} - -0.5\right)\\
\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 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) < 0.0Initial program 38.1%
Taylor expanded in x around inf 85.0%
distribute-lft-out--85.0%
Simplified85.0%
*-commutative85.0%
unpow285.0%
times-frac99.5%
inv-pow99.5%
sqrt-pow199.5%
metadata-eval99.5%
Applied egg-rr99.5%
clear-num99.5%
clear-num99.5%
frac-times98.3%
metadata-eval98.3%
clear-num98.2%
div-sub98.2%
pow198.2%
pow-div98.2%
metadata-eval98.2%
pow1/298.2%
pow198.2%
pow-div98.3%
metadata-eval98.3%
div-inv98.3%
metadata-eval98.3%
Applied egg-rr98.3%
associate-/r*99.6%
remove-double-div99.7%
Simplified99.7%
div-sub99.7%
sub-neg99.7%
div-inv99.7%
*-commutative99.7%
associate-/r*99.7%
metadata-eval99.7%
*-un-lft-identity99.7%
*-commutative99.7%
times-frac99.7%
metadata-eval99.7%
pow199.7%
pow-div100.0%
metadata-eval100.0%
Applied egg-rr100.0%
sub-neg100.0%
*-commutative100.0%
distribute-lft-out--100.0%
Simplified100.0%
if 0.0 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) Initial program 57.0%
sub-neg57.0%
inv-pow57.0%
sqrt-pow256.9%
metadata-eval56.9%
distribute-neg-frac56.9%
metadata-eval56.9%
+-commutative56.9%
Applied egg-rr56.9%
*-rgt-identity56.9%
cancel-sign-sub56.9%
distribute-lft-neg-in56.9%
*-rgt-identity56.9%
distribute-neg-frac56.9%
metadata-eval56.9%
unpow1/256.9%
exp-to-pow52.8%
log1p-undefine52.8%
*-commutative52.8%
exp-neg53.5%
*-commutative53.5%
distribute-rgt-neg-in53.5%
log1p-undefine53.5%
metadata-eval53.5%
exp-to-pow57.0%
Simplified57.0%
flip--56.9%
pow-prod-up57.4%
metadata-eval57.4%
inv-pow57.4%
pow-prod-up58.7%
metadata-eval58.7%
inv-pow58.7%
un-div-inv58.7%
*-commutative58.7%
frac-sub99.0%
frac-times99.3%
*-un-lft-identity99.3%
*-un-lft-identity99.3%
Applied egg-rr99.3%
*-rgt-identity99.3%
associate--l+99.3%
distribute-lft-in99.2%
*-rgt-identity99.2%
unpow299.2%
Simplified99.2%
*-un-lft-identity99.2%
associate-/r*99.1%
+-inverses99.1%
metadata-eval99.1%
+-commutative99.1%
unpow299.1%
fma-define99.4%
Applied egg-rr99.4%
Final simplification100.0%
(FPCore (x) :precision binary64 (if (<= (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ 1.0 x)))) 0.0) (* (pow x -1.5) (- (/ -0.5 x) -0.5)) (/ -1.0 (* (+ (pow x -0.5) (pow (+ 1.0 x) -0.5)) (* x (- -1.0 x))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) - (1.0 / sqrt((1.0 + x)))) <= 0.0) {
tmp = pow(x, -1.5) * ((-0.5 / x) - -0.5);
} else {
tmp = -1.0 / ((pow(x, -0.5) + pow((1.0 + x), -0.5)) * (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 = (x ** (-1.5d0)) * (((-0.5d0) / x) - (-0.5d0))
else
tmp = (-1.0d0) / (((x ** (-0.5d0)) + ((1.0d0 + x) ** (-0.5d0))) * (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 = Math.pow(x, -1.5) * ((-0.5 / x) - -0.5);
} else {
tmp = -1.0 / ((Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5)) * (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 = math.pow(x, -1.5) * ((-0.5 / x) - -0.5) else: tmp = -1.0 / ((math.pow(x, -0.5) + math.pow((1.0 + x), -0.5)) * (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((x ^ -1.5) * Float64(Float64(-0.5 / x) - -0.5)); else tmp = Float64(-1.0 / Float64(Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5)) * 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 = (x ^ -1.5) * ((-0.5 / x) - -0.5); else tmp = -1.0 / (((x ^ -0.5) + ((1.0 + x) ^ -0.5)) * (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[(N[Power[x, -1.5], $MachinePrecision] * N[(N[(-0.5 / x), $MachinePrecision] - -0.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[(-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:\\
\;\;\;\;{x}^{-1.5} \cdot \left(\frac{-0.5}{x} - -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\left({x}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right) \cdot \left(x \cdot \left(-1 - x\right)\right)}\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) < 0.0Initial program 38.1%
Taylor expanded in x around inf 85.0%
distribute-lft-out--85.0%
Simplified85.0%
*-commutative85.0%
unpow285.0%
times-frac99.5%
inv-pow99.5%
sqrt-pow199.5%
metadata-eval99.5%
Applied egg-rr99.5%
clear-num99.5%
clear-num99.5%
frac-times98.3%
metadata-eval98.3%
clear-num98.2%
div-sub98.2%
pow198.2%
pow-div98.2%
metadata-eval98.2%
pow1/298.2%
pow198.2%
pow-div98.3%
metadata-eval98.3%
div-inv98.3%
metadata-eval98.3%
Applied egg-rr98.3%
associate-/r*99.6%
remove-double-div99.7%
Simplified99.7%
div-sub99.7%
sub-neg99.7%
div-inv99.7%
*-commutative99.7%
associate-/r*99.7%
metadata-eval99.7%
*-un-lft-identity99.7%
*-commutative99.7%
times-frac99.7%
metadata-eval99.7%
pow199.7%
pow-div100.0%
metadata-eval100.0%
Applied egg-rr100.0%
sub-neg100.0%
*-commutative100.0%
distribute-lft-out--100.0%
Simplified100.0%
if 0.0 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) Initial program 57.0%
sub-neg57.0%
inv-pow57.0%
sqrt-pow256.9%
metadata-eval56.9%
distribute-neg-frac56.9%
metadata-eval56.9%
+-commutative56.9%
Applied egg-rr56.9%
*-rgt-identity56.9%
cancel-sign-sub56.9%
distribute-lft-neg-in56.9%
*-rgt-identity56.9%
distribute-neg-frac56.9%
metadata-eval56.9%
unpow1/256.9%
exp-to-pow52.8%
log1p-undefine52.8%
*-commutative52.8%
exp-neg53.5%
*-commutative53.5%
distribute-rgt-neg-in53.5%
log1p-undefine53.5%
metadata-eval53.5%
exp-to-pow57.0%
Simplified57.0%
flip--56.9%
pow-prod-up57.4%
metadata-eval57.4%
inv-pow57.4%
pow-prod-up58.7%
metadata-eval58.7%
inv-pow58.7%
un-div-inv58.7%
*-commutative58.7%
frac-sub99.0%
frac-times99.3%
*-un-lft-identity99.3%
*-un-lft-identity99.3%
Applied egg-rr99.3%
associate-/r*99.4%
*-lft-identity99.4%
*-lft-identity99.4%
times-frac99.4%
metadata-eval99.4%
metadata-eval99.4%
times-frac99.4%
neg-mul-199.4%
neg-mul-199.4%
associate-/r*99.3%
Simplified99.3%
Final simplification99.9%
(FPCore (x) :precision binary64 (let* ((t_0 (sqrt (/ 1.0 x)))) (if (<= x 6.5e+153) (* t_0 0.5) (* (/ -0.5 x) t_0))))
double code(double x) {
double t_0 = sqrt((1.0 / x));
double tmp;
if (x <= 6.5e+153) {
tmp = t_0 * 0.5;
} else {
tmp = (-0.5 / x) * t_0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 / x))
if (x <= 6.5d+153) then
tmp = t_0 * 0.5d0
else
tmp = ((-0.5d0) / x) * t_0
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((1.0 / x));
double tmp;
if (x <= 6.5e+153) {
tmp = t_0 * 0.5;
} else {
tmp = (-0.5 / x) * t_0;
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 / x)) tmp = 0 if x <= 6.5e+153: tmp = t_0 * 0.5 else: tmp = (-0.5 / x) * t_0 return tmp
function code(x) t_0 = sqrt(Float64(1.0 / x)) tmp = 0.0 if (x <= 6.5e+153) tmp = Float64(t_0 * 0.5); else tmp = Float64(Float64(-0.5 / x) * t_0); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((1.0 / x)); tmp = 0.0; if (x <= 6.5e+153) tmp = t_0 * 0.5; else tmp = (-0.5 / x) * t_0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 6.5e+153], N[(t$95$0 * 0.5), $MachinePrecision], N[(N[(-0.5 / x), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{x}}\\
\mathbf{if}\;x \leq 6.5 \cdot 10^{+153}:\\
\;\;\;\;t\_0 \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{x} \cdot t\_0\\
\end{array}
\end{array}
if x < 6.49999999999999972e153Initial program 9.6%
flip--9.6%
div-inv9.6%
frac-times9.8%
metadata-eval9.8%
add-sqr-sqrt9.7%
frac-times9.7%
metadata-eval9.7%
add-sqr-sqrt9.7%
+-commutative9.7%
inv-pow9.7%
sqrt-pow29.7%
metadata-eval9.7%
pow1/29.7%
pow-flip9.7%
+-commutative9.7%
metadata-eval9.7%
Applied egg-rr9.7%
Taylor expanded in x around inf 8.3%
*-commutative8.3%
Simplified8.3%
Taylor expanded in x around 0 7.0%
if 6.49999999999999972e153 < x Initial program 70.9%
Taylor expanded in x around inf 70.9%
distribute-lft-out--70.9%
Simplified70.9%
*-commutative70.9%
unpow270.9%
times-frac99.8%
inv-pow99.8%
sqrt-pow199.8%
metadata-eval99.8%
Applied egg-rr99.8%
/-rgt-identity99.8%
clear-num99.7%
inv-pow99.7%
sqrt-pow299.7%
metadata-eval99.7%
Applied egg-rr99.7%
Taylor expanded in x around -inf 70.4%
Final simplification37.4%
(FPCore (x) :precision binary64 (* (pow x -1.5) (- (/ -0.5 x) -0.5)))
double code(double x) {
return pow(x, -1.5) * ((-0.5 / x) - -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x ** (-1.5d0)) * (((-0.5d0) / x) - (-0.5d0))
end function
public static double code(double x) {
return Math.pow(x, -1.5) * ((-0.5 / x) - -0.5);
}
def code(x): return math.pow(x, -1.5) * ((-0.5 / x) - -0.5)
function code(x) return Float64((x ^ -1.5) * Float64(Float64(-0.5 / x) - -0.5)) end
function tmp = code(x) tmp = (x ^ -1.5) * ((-0.5 / x) - -0.5); end
code[x_] := N[(N[Power[x, -1.5], $MachinePrecision] * N[(N[(-0.5 / x), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{x}^{-1.5} \cdot \left(\frac{-0.5}{x} - -0.5\right)
\end{array}
Initial program 39.0%
Taylor expanded in x around inf 84.0%
distribute-lft-out--84.0%
Simplified84.0%
*-commutative84.0%
unpow284.0%
times-frac97.7%
inv-pow97.7%
sqrt-pow197.7%
metadata-eval97.7%
Applied egg-rr97.7%
clear-num97.7%
clear-num97.7%
frac-times96.6%
metadata-eval96.6%
clear-num96.5%
div-sub96.5%
pow196.5%
pow-div96.5%
metadata-eval96.5%
pow1/296.5%
pow196.5%
pow-div96.6%
metadata-eval96.6%
div-inv96.6%
metadata-eval96.6%
Applied egg-rr96.6%
associate-/r*97.8%
remove-double-div98.0%
Simplified98.0%
div-sub98.0%
sub-neg98.0%
div-inv98.0%
*-commutative98.0%
associate-/r*98.0%
metadata-eval98.0%
*-un-lft-identity98.0%
*-commutative98.0%
times-frac97.9%
metadata-eval97.9%
pow197.9%
pow-div98.2%
metadata-eval98.2%
Applied egg-rr98.2%
sub-neg98.2%
*-commutative98.2%
distribute-lft-out--98.2%
Simplified98.2%
(FPCore (x) :precision binary64 (* (/ -0.5 x) (- (sqrt (/ 1.0 x)))))
double code(double x) {
return (-0.5 / x) * -sqrt((1.0 / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-0.5d0) / x) * -sqrt((1.0d0 / x))
end function
public static double code(double x) {
return (-0.5 / x) * -Math.sqrt((1.0 / x));
}
def code(x): return (-0.5 / x) * -math.sqrt((1.0 / x))
function code(x) return Float64(Float64(-0.5 / x) * Float64(-sqrt(Float64(1.0 / x)))) end
function tmp = code(x) tmp = (-0.5 / x) * -sqrt((1.0 / x)); end
code[x_] := N[(N[(-0.5 / x), $MachinePrecision] * (-N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.5}{x} \cdot \left(-\sqrt{\frac{1}{x}}\right)
\end{array}
Initial program 39.0%
Taylor expanded in x around inf 84.0%
distribute-lft-out--84.0%
Simplified84.0%
*-commutative84.0%
unpow284.0%
times-frac97.7%
inv-pow97.7%
sqrt-pow197.7%
metadata-eval97.7%
Applied egg-rr97.7%
div-sub97.7%
pow197.7%
pow-div97.7%
metadata-eval97.7%
metadata-eval97.7%
metadata-eval97.7%
sqrt-pow197.7%
pow-flip97.7%
pow1/297.7%
pow197.7%
pow-div97.8%
metadata-eval97.8%
sub-neg97.8%
pow-flip97.8%
sqrt-pow197.8%
metadata-eval97.8%
metadata-eval97.8%
Applied egg-rr97.8%
sub-neg97.8%
Simplified97.8%
Taylor expanded in x around inf 97.7%
mul-1-neg97.7%
Simplified97.7%
Final simplification97.7%
(FPCore (x) :precision binary64 (* (sqrt (/ 1.0 x)) 0.5))
double code(double x) {
return sqrt((1.0 / x)) * 0.5;
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((1.0d0 / x)) * 0.5d0
end function
public static double code(double x) {
return Math.sqrt((1.0 / x)) * 0.5;
}
def code(x): return math.sqrt((1.0 / x)) * 0.5
function code(x) return Float64(sqrt(Float64(1.0 / x)) * 0.5) end
function tmp = code(x) tmp = sqrt((1.0 / x)) * 0.5; end
code[x_] := N[(N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{x}} \cdot 0.5
\end{array}
Initial program 39.0%
flip--39.1%
div-inv39.1%
frac-times23.4%
metadata-eval23.4%
add-sqr-sqrt19.0%
frac-times24.6%
metadata-eval24.6%
add-sqr-sqrt39.1%
+-commutative39.1%
inv-pow39.1%
sqrt-pow239.1%
metadata-eval39.1%
pow1/239.1%
pow-flip39.1%
+-commutative39.1%
metadata-eval39.1%
Applied egg-rr39.1%
Taylor expanded in x around inf 38.4%
*-commutative38.4%
Simplified38.4%
Taylor expanded in x around 0 5.7%
Final simplification5.7%
(FPCore (x) :precision binary64 (pow x -0.5))
double code(double x) {
return pow(x, -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x ** (-0.5d0)
end function
public static double code(double x) {
return Math.pow(x, -0.5);
}
def code(x): return math.pow(x, -0.5)
function code(x) return x ^ -0.5 end
function tmp = code(x) tmp = x ^ -0.5; end
code[x_] := N[Power[x, -0.5], $MachinePrecision]
\begin{array}{l}
\\
{x}^{-0.5}
\end{array}
Initial program 39.0%
sub-neg39.0%
inv-pow39.0%
sqrt-pow228.4%
metadata-eval28.4%
distribute-neg-frac28.4%
metadata-eval28.4%
+-commutative28.4%
Applied egg-rr28.4%
*-rgt-identity28.4%
cancel-sign-sub28.4%
distribute-lft-neg-in28.4%
*-rgt-identity28.4%
distribute-neg-frac28.4%
metadata-eval28.4%
unpow1/228.4%
exp-to-pow7.0%
log1p-undefine7.0%
*-commutative7.0%
exp-neg7.1%
*-commutative7.1%
distribute-rgt-neg-in7.1%
log1p-undefine7.1%
metadata-eval7.1%
exp-to-pow39.0%
Simplified39.0%
Taylor expanded in x around 0 5.7%
unpow-15.7%
metadata-eval5.7%
pow-sqr5.7%
rem-sqrt-square5.7%
metadata-eval5.7%
pow-sqr5.7%
fabs-sqr5.7%
pow-sqr5.7%
metadata-eval5.7%
Simplified5.7%
(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 2024139
(FPCore (x)
:name "2isqrt (example 3.6)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:alt
(! :herbie-platform default (/ 1 (+ (* (+ x 1) (sqrt x)) (* x (sqrt (+ x 1))))))
(- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))