
(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 (let* ((t_0 (hypot (pow (hypot 1.0 (sqrt x)) -0.5) (pow x -0.25)))) (* (/ 1.0 t_0) (/ (/ 1.0 x) (* t_0 (+ 1.0 x))))))
double code(double x) {
double t_0 = hypot(pow(hypot(1.0, sqrt(x)), -0.5), pow(x, -0.25));
return (1.0 / t_0) * ((1.0 / x) / (t_0 * (1.0 + x)));
}
public static double code(double x) {
double t_0 = Math.hypot(Math.pow(Math.hypot(1.0, Math.sqrt(x)), -0.5), Math.pow(x, -0.25));
return (1.0 / t_0) * ((1.0 / x) / (t_0 * (1.0 + x)));
}
def code(x): t_0 = math.hypot(math.pow(math.hypot(1.0, math.sqrt(x)), -0.5), math.pow(x, -0.25)) return (1.0 / t_0) * ((1.0 / x) / (t_0 * (1.0 + x)))
function code(x) t_0 = hypot((hypot(1.0, sqrt(x)) ^ -0.5), (x ^ -0.25)) return Float64(Float64(1.0 / t_0) * Float64(Float64(1.0 / x) / Float64(t_0 * Float64(1.0 + x)))) end
function tmp = code(x) t_0 = hypot((hypot(1.0, sqrt(x)) ^ -0.5), (x ^ -0.25)); tmp = (1.0 / t_0) * ((1.0 / x) / (t_0 * (1.0 + x))); end
code[x_] := Block[{t$95$0 = N[Sqrt[N[Power[N[Sqrt[1.0 ^ 2 + N[Sqrt[x], $MachinePrecision] ^ 2], $MachinePrecision], -0.5], $MachinePrecision] ^ 2 + N[Power[x, -0.25], $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] / N[(t$95$0 * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left({\left(\mathsf{hypot}\left(1, \sqrt{x}\right)\right)}^{-0.5}, {x}^{-0.25}\right)\\
\frac{1}{t_0} \cdot \frac{\frac{1}{x}}{t_0 \cdot \left(1 + x\right)}
\end{array}
\end{array}
Initial program 67.6%
sub-neg67.6%
flip-+67.6%
frac-times63.1%
metadata-eval63.1%
add-sqr-sqrt60.1%
distribute-neg-frac60.1%
metadata-eval60.1%
+-commutative60.1%
distribute-neg-frac60.1%
metadata-eval60.1%
+-commutative60.1%
pow1/260.1%
pow-flip60.1%
metadata-eval60.1%
Applied egg-rr60.1%
associate-*r/61.1%
associate-*l/61.1%
metadata-eval61.1%
associate-/l/61.2%
rem-square-sqrt67.5%
sub-neg67.5%
distribute-neg-frac67.5%
metadata-eval67.5%
sub-neg67.5%
distribute-neg-frac67.5%
metadata-eval67.5%
Simplified67.5%
frac-add68.5%
div-inv68.5%
*-un-lft-identity68.5%
associate-+l+89.6%
metadata-eval89.6%
frac-times90.4%
un-div-inv90.4%
Applied egg-rr90.4%
*-un-lft-identity90.4%
add-sqr-sqrt90.0%
times-frac90.1%
Applied egg-rr89.4%
mul0-rgt89.4%
metadata-eval89.4%
associate-/l/90.2%
associate-/l/92.3%
Simplified92.3%
Final simplification92.3%
(FPCore (x) :precision binary64 (/ (* (+ 1.0 (- x x)) (/ (/ 1.0 x) (+ 1.0 x))) (+ (pow x -0.5) (/ 1.0 (sqrt (+ 1.0 x))))))
double code(double x) {
return ((1.0 + (x - x)) * ((1.0 / x) / (1.0 + x))) / (pow(x, -0.5) + (1.0 / sqrt((1.0 + x))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 + (x - x)) * ((1.0d0 / x) / (1.0d0 + x))) / ((x ** (-0.5d0)) + (1.0d0 / sqrt((1.0d0 + x))))
end function
public static double code(double x) {
return ((1.0 + (x - x)) * ((1.0 / x) / (1.0 + x))) / (Math.pow(x, -0.5) + (1.0 / Math.sqrt((1.0 + x))));
}
def code(x): return ((1.0 + (x - x)) * ((1.0 / x) / (1.0 + x))) / (math.pow(x, -0.5) + (1.0 / math.sqrt((1.0 + x))))
function code(x) return Float64(Float64(Float64(1.0 + Float64(x - x)) * Float64(Float64(1.0 / x) / Float64(1.0 + x))) / Float64((x ^ -0.5) + Float64(1.0 / sqrt(Float64(1.0 + x))))) end
function tmp = code(x) tmp = ((1.0 + (x - x)) * ((1.0 / x) / (1.0 + x))) / ((x ^ -0.5) + (1.0 / sqrt((1.0 + x)))); end
code[x_] := N[(N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, -0.5], $MachinePrecision] + N[(1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \left(x - x\right)\right) \cdot \frac{\frac{1}{x}}{1 + x}}{{x}^{-0.5} + \frac{1}{\sqrt{1 + x}}}
\end{array}
Initial program 67.6%
sub-neg67.6%
flip-+67.6%
frac-times63.1%
metadata-eval63.1%
add-sqr-sqrt60.1%
distribute-neg-frac60.1%
metadata-eval60.1%
+-commutative60.1%
distribute-neg-frac60.1%
metadata-eval60.1%
+-commutative60.1%
pow1/260.1%
pow-flip60.1%
metadata-eval60.1%
Applied egg-rr60.1%
associate-*r/61.1%
associate-*l/61.1%
metadata-eval61.1%
associate-/l/61.2%
rem-square-sqrt67.5%
sub-neg67.5%
distribute-neg-frac67.5%
metadata-eval67.5%
sub-neg67.5%
distribute-neg-frac67.5%
metadata-eval67.5%
Simplified67.5%
frac-add68.5%
div-inv68.5%
*-un-lft-identity68.5%
associate-+l+89.6%
metadata-eval89.6%
frac-times90.4%
un-div-inv90.4%
Applied egg-rr90.4%
Final simplification90.4%
(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(Float64(1.0 / 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[(N[(1.0 / x), $MachinePrecision] / N[(1.0 + x), $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{\frac{1}{x}}{1 + x}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}
\end{array}
Initial program 67.6%
sub-neg67.6%
flip-+67.6%
frac-times63.1%
metadata-eval63.1%
add-sqr-sqrt60.1%
distribute-neg-frac60.1%
metadata-eval60.1%
+-commutative60.1%
distribute-neg-frac60.1%
metadata-eval60.1%
+-commutative60.1%
pow1/260.1%
pow-flip60.1%
metadata-eval60.1%
Applied egg-rr60.1%
associate-*r/61.1%
associate-*l/61.1%
metadata-eval61.1%
associate-/l/61.2%
rem-square-sqrt67.5%
sub-neg67.5%
distribute-neg-frac67.5%
metadata-eval67.5%
sub-neg67.5%
distribute-neg-frac67.5%
metadata-eval67.5%
Simplified67.5%
frac-add68.5%
div-inv68.5%
*-un-lft-identity68.5%
associate-+l+89.6%
metadata-eval89.6%
frac-times90.4%
un-div-inv90.4%
Applied egg-rr90.4%
expm1-log1p-u87.1%
expm1-udef63.7%
Applied egg-rr63.7%
expm1-def86.3%
expm1-log1p89.6%
mul0-rgt89.6%
metadata-eval89.6%
associate-/l/90.4%
Simplified90.4%
Final simplification90.4%
(FPCore (x)
:precision binary64
(if (<= x 1.0)
(+ (+ (pow x -0.5) (* x 0.5)) -1.0)
(if (<= x 5.5e+102)
(* 0.5 (sqrt (/ 1.0 (pow x 3.0))))
(/ 1.0 (pow x 1.5)))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else if (x <= 5.5e+102) {
tmp = 0.5 * sqrt((1.0 / pow(x, 3.0)));
} else {
tmp = 1.0 / pow(x, 1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.0d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else if (x <= 5.5d+102) then
tmp = 0.5d0 * sqrt((1.0d0 / (x ** 3.0d0)))
else
tmp = 1.0d0 / (x ** 1.5d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else if (x <= 5.5e+102) {
tmp = 0.5 * Math.sqrt((1.0 / Math.pow(x, 3.0)));
} else {
tmp = 1.0 / Math.pow(x, 1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 elif x <= 5.5e+102: tmp = 0.5 * math.sqrt((1.0 / math.pow(x, 3.0))) else: tmp = 1.0 / math.pow(x, 1.5) return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); elseif (x <= 5.5e+102) tmp = Float64(0.5 * sqrt(Float64(1.0 / (x ^ 3.0)))); else tmp = Float64(1.0 / (x ^ 1.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; elseif (x <= 5.5e+102) tmp = 0.5 * sqrt((1.0 / (x ^ 3.0))); else tmp = 1.0 / (x ^ 1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, 5.5e+102], N[(0.5 * N[Sqrt[N[(1.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Power[x, 1.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+102}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{{x}^{1.5}}\\
\end{array}
\end{array}
if x < 1Initial program 99.5%
*-un-lft-identity99.5%
clear-num99.5%
associate-/r/99.5%
prod-diff99.5%
*-un-lft-identity99.5%
fma-neg99.5%
*-un-lft-identity99.5%
pow1/299.5%
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.8%
if 1 < x < 5.49999999999999981e102Initial program 13.7%
*-un-lft-identity13.7%
clear-num13.7%
associate-/r/13.7%
prod-diff13.7%
*-un-lft-identity13.7%
fma-neg13.7%
*-un-lft-identity13.7%
pow1/213.7%
pow-flip13.9%
metadata-eval13.9%
pow1/213.9%
pow-flip14.1%
+-commutative14.1%
metadata-eval14.1%
Applied egg-rr14.1%
associate-+l-14.1%
expm1-log1p14.1%
expm1-def13.3%
associate--l-13.3%
fma-udef13.3%
distribute-lft1-in13.3%
metadata-eval13.3%
mul0-lft13.3%
metadata-eval13.3%
expm1-def14.1%
expm1-log1p14.1%
Simplified14.1%
Taylor expanded in x around inf 92.3%
if 5.49999999999999981e102 < x Initial program 47.1%
sub-neg47.1%
flip-+47.1%
frac-times33.7%
metadata-eval33.7%
add-sqr-sqrt25.0%
distribute-neg-frac25.0%
metadata-eval25.0%
+-commutative25.0%
distribute-neg-frac25.0%
metadata-eval25.0%
+-commutative25.0%
pow1/225.0%
pow-flip25.0%
metadata-eval25.0%
Applied egg-rr25.0%
associate-*r/28.0%
associate-*l/28.0%
metadata-eval28.0%
associate-/l/28.5%
rem-square-sqrt47.1%
sub-neg47.1%
distribute-neg-frac47.1%
metadata-eval47.1%
sub-neg47.1%
distribute-neg-frac47.1%
metadata-eval47.1%
Simplified47.1%
Taylor expanded in x around inf 47.1%
sqrt-div47.1%
metadata-eval47.1%
sqrt-pow153.2%
metadata-eval53.2%
Applied egg-rr53.2%
Final simplification82.7%
(FPCore (x)
:precision binary64
(if (<= x 142000000.0)
(- (pow x -0.5) (pow (+ 1.0 x) -0.5))
(if (<= x 5.5e+102)
(* 0.5 (sqrt (/ 1.0 (pow x 3.0))))
(/ 1.0 (pow x 1.5)))))
double code(double x) {
double tmp;
if (x <= 142000000.0) {
tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
} else if (x <= 5.5e+102) {
tmp = 0.5 * sqrt((1.0 / pow(x, 3.0)));
} else {
tmp = 1.0 / pow(x, 1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 142000000.0d0) then
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
else if (x <= 5.5d+102) then
tmp = 0.5d0 * sqrt((1.0d0 / (x ** 3.0d0)))
else
tmp = 1.0d0 / (x ** 1.5d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 142000000.0) {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
} else if (x <= 5.5e+102) {
tmp = 0.5 * Math.sqrt((1.0 / Math.pow(x, 3.0)));
} else {
tmp = 1.0 / Math.pow(x, 1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 142000000.0: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) elif x <= 5.5e+102: tmp = 0.5 * math.sqrt((1.0 / math.pow(x, 3.0))) else: tmp = 1.0 / math.pow(x, 1.5) return tmp
function code(x) tmp = 0.0 if (x <= 142000000.0) tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); elseif (x <= 5.5e+102) tmp = Float64(0.5 * sqrt(Float64(1.0 / (x ^ 3.0)))); else tmp = Float64(1.0 / (x ^ 1.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 142000000.0) tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); elseif (x <= 5.5e+102) tmp = 0.5 * sqrt((1.0 / (x ^ 3.0))); else tmp = 1.0 / (x ^ 1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 142000000.0], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.5e+102], N[(0.5 * N[Sqrt[N[(1.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Power[x, 1.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 142000000:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+102}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{{x}^{1.5}}\\
\end{array}
\end{array}
if x < 1.42e8Initial program 98.6%
*-un-lft-identity98.6%
clear-num98.6%
associate-/r/98.6%
prod-diff98.6%
*-un-lft-identity98.6%
fma-neg98.6%
*-un-lft-identity98.6%
pow1/298.6%
pow-flip99.1%
metadata-eval99.1%
pow1/299.1%
pow-flip99.2%
+-commutative99.2%
metadata-eval99.2%
Applied egg-rr99.2%
associate-+l-99.2%
expm1-log1p99.2%
expm1-def98.6%
associate--l-98.6%
fma-udef98.6%
distribute-lft1-in98.6%
metadata-eval98.6%
mul0-lft98.6%
metadata-eval98.6%
expm1-def99.2%
expm1-log1p99.2%
Simplified99.2%
if 1.42e8 < x < 5.49999999999999981e102Initial program 5.4%
*-un-lft-identity5.4%
clear-num5.4%
associate-/r/5.4%
prod-diff5.4%
*-un-lft-identity5.4%
fma-neg5.4%
*-un-lft-identity5.4%
pow1/25.4%
pow-flip5.5%
metadata-eval5.5%
pow1/25.5%
pow-flip5.4%
+-commutative5.4%
metadata-eval5.4%
Applied egg-rr5.4%
associate-+l-5.4%
expm1-log1p5.4%
expm1-def6.6%
associate--l-6.6%
fma-udef6.6%
distribute-lft1-in6.6%
metadata-eval6.6%
mul0-lft6.6%
metadata-eval6.6%
expm1-def5.4%
expm1-log1p5.4%
Simplified5.4%
Taylor expanded in x around inf 98.8%
if 5.49999999999999981e102 < x Initial program 47.1%
sub-neg47.1%
flip-+47.1%
frac-times33.7%
metadata-eval33.7%
add-sqr-sqrt25.0%
distribute-neg-frac25.0%
metadata-eval25.0%
+-commutative25.0%
distribute-neg-frac25.0%
metadata-eval25.0%
+-commutative25.0%
pow1/225.0%
pow-flip25.0%
metadata-eval25.0%
Applied egg-rr25.0%
associate-*r/28.0%
associate-*l/28.0%
metadata-eval28.0%
associate-/l/28.5%
rem-square-sqrt47.1%
sub-neg47.1%
distribute-neg-frac47.1%
metadata-eval47.1%
sub-neg47.1%
distribute-neg-frac47.1%
metadata-eval47.1%
Simplified47.1%
Taylor expanded in x around inf 47.1%
sqrt-div47.1%
metadata-eval47.1%
sqrt-pow153.2%
metadata-eval53.2%
Applied egg-rr53.2%
Final simplification83.5%
(FPCore (x) :precision binary64 (if (<= x 1.45) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (/ 1.0 (pow x 1.5))))
double code(double x) {
double tmp;
if (x <= 1.45) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = 1.0 / pow(x, 1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.45d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = 1.0d0 / (x ** 1.5d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.45) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = 1.0 / Math.pow(x, 1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.45: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = 1.0 / math.pow(x, 1.5) return tmp
function code(x) tmp = 0.0 if (x <= 1.45) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); else tmp = Float64(1.0 / (x ^ 1.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.45) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = 1.0 / (x ^ 1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.45], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(1.0 / N[Power[x, 1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.45:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{{x}^{1.5}}\\
\end{array}
\end{array}
if x < 1.44999999999999996Initial program 99.5%
*-un-lft-identity99.5%
clear-num99.5%
associate-/r/99.5%
prod-diff99.5%
*-un-lft-identity99.5%
fma-neg99.5%
*-un-lft-identity99.5%
pow1/299.5%
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.8%
if 1.44999999999999996 < x Initial program 36.2%
sub-neg36.2%
flip-+36.2%
frac-times27.5%
metadata-eval27.5%
add-sqr-sqrt21.6%
distribute-neg-frac21.6%
metadata-eval21.6%
+-commutative21.6%
distribute-neg-frac21.6%
metadata-eval21.6%
+-commutative21.6%
pow1/221.6%
pow-flip21.6%
metadata-eval21.6%
Applied egg-rr21.6%
associate-*r/23.6%
associate-*l/23.6%
metadata-eval23.6%
associate-/l/23.8%
rem-square-sqrt36.4%
sub-neg36.4%
distribute-neg-frac36.4%
metadata-eval36.4%
sub-neg36.4%
distribute-neg-frac36.4%
metadata-eval36.4%
Simplified36.4%
Taylor expanded in x around inf 37.8%
sqrt-div37.8%
metadata-eval37.8%
sqrt-pow142.0%
metadata-eval42.0%
Applied egg-rr42.0%
Final simplification70.6%
(FPCore (x) :precision binary64 (if (<= x 0.84) (+ (pow x -0.5) -1.0) (pow x -1.5)))
double code(double x) {
double tmp;
if (x <= 0.84) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = pow(x, -1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.84d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = x ** (-1.5d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.84) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.84: tmp = math.pow(x, -0.5) + -1.0 else: tmp = math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 0.84) tmp = Float64((x ^ -0.5) + -1.0); else tmp = x ^ -1.5; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.84) tmp = (x ^ -0.5) + -1.0; else tmp = x ^ -1.5; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.84], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[Power[x, -1.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.84:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;{x}^{-1.5}\\
\end{array}
\end{array}
if x < 0.839999999999999969Initial program 99.5%
*-un-lft-identity99.5%
clear-num99.5%
associate-/r/99.5%
prod-diff99.5%
*-un-lft-identity99.5%
fma-neg99.5%
*-un-lft-identity99.5%
pow1/299.5%
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.4%
if 0.839999999999999969 < x Initial program 36.2%
sub-neg36.2%
flip-+36.2%
frac-times27.5%
metadata-eval27.5%
add-sqr-sqrt21.6%
distribute-neg-frac21.6%
metadata-eval21.6%
+-commutative21.6%
distribute-neg-frac21.6%
metadata-eval21.6%
+-commutative21.6%
pow1/221.6%
pow-flip21.6%
metadata-eval21.6%
Applied egg-rr21.6%
associate-*r/23.6%
associate-*l/23.6%
metadata-eval23.6%
associate-/l/23.8%
rem-square-sqrt36.4%
sub-neg36.4%
distribute-neg-frac36.4%
metadata-eval36.4%
sub-neg36.4%
distribute-neg-frac36.4%
metadata-eval36.4%
Simplified36.4%
frac-add38.2%
div-inv38.2%
*-un-lft-identity38.2%
associate-+l+80.0%
metadata-eval80.0%
frac-times81.6%
un-div-inv81.7%
Applied egg-rr81.7%
Taylor expanded in x around inf 37.8%
unpow-137.8%
exp-to-pow37.8%
*-commutative37.8%
exp-prod37.9%
*-commutative37.9%
associate-*l*37.9%
metadata-eval37.9%
exp-to-pow37.9%
metadata-eval37.9%
pow-sqr37.9%
rem-sqrt-square42.0%
rem-square-sqrt42.0%
fabs-sqr42.0%
rem-square-sqrt42.0%
Simplified42.0%
Final simplification70.4%
(FPCore (x) :precision binary64 (if (<= x 0.84) (+ (pow x -0.5) -1.0) (/ 1.0 (pow x 1.5))))
double code(double x) {
double tmp;
if (x <= 0.84) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = 1.0 / pow(x, 1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.84d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = 1.0d0 / (x ** 1.5d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.84) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = 1.0 / Math.pow(x, 1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.84: tmp = math.pow(x, -0.5) + -1.0 else: tmp = 1.0 / math.pow(x, 1.5) return tmp
function code(x) tmp = 0.0 if (x <= 0.84) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(1.0 / (x ^ 1.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.84) tmp = (x ^ -0.5) + -1.0; else tmp = 1.0 / (x ^ 1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.84], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(1.0 / N[Power[x, 1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.84:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{{x}^{1.5}}\\
\end{array}
\end{array}
if x < 0.839999999999999969Initial program 99.5%
*-un-lft-identity99.5%
clear-num99.5%
associate-/r/99.5%
prod-diff99.5%
*-un-lft-identity99.5%
fma-neg99.5%
*-un-lft-identity99.5%
pow1/299.5%
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.4%
if 0.839999999999999969 < x Initial program 36.2%
sub-neg36.2%
flip-+36.2%
frac-times27.5%
metadata-eval27.5%
add-sqr-sqrt21.6%
distribute-neg-frac21.6%
metadata-eval21.6%
+-commutative21.6%
distribute-neg-frac21.6%
metadata-eval21.6%
+-commutative21.6%
pow1/221.6%
pow-flip21.6%
metadata-eval21.6%
Applied egg-rr21.6%
associate-*r/23.6%
associate-*l/23.6%
metadata-eval23.6%
associate-/l/23.8%
rem-square-sqrt36.4%
sub-neg36.4%
distribute-neg-frac36.4%
metadata-eval36.4%
sub-neg36.4%
distribute-neg-frac36.4%
metadata-eval36.4%
Simplified36.4%
Taylor expanded in x around inf 37.8%
sqrt-div37.8%
metadata-eval37.8%
sqrt-pow142.0%
metadata-eval42.0%
Applied egg-rr42.0%
Final simplification70.4%
(FPCore (x) :precision binary64 (if (<= x 1.0) (pow x -0.5) (pow x -1.5)))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = pow(x, -0.5);
} else {
tmp = pow(x, -1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.0d0) then
tmp = x ** (-0.5d0)
else
tmp = x ** (-1.5d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = Math.pow(x, -0.5);
} else {
tmp = Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = math.pow(x, -0.5) else: tmp = math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = x ^ -0.5; else tmp = x ^ -1.5; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = x ^ -0.5; else tmp = x ^ -1.5; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[Power[x, -0.5], $MachinePrecision], N[Power[x, -1.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;{x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-1.5}\\
\end{array}
\end{array}
if x < 1Initial program 99.5%
inv-pow99.6%
add-sqr-sqrt99.2%
unpow-prod-down99.0%
pow1/299.0%
sqrt-pow199.1%
metadata-eval99.1%
pow1/299.1%
sqrt-pow199.0%
metadata-eval99.0%
Applied egg-rr99.0%
pow-sqr99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in x around inf 95.9%
inv-pow95.9%
sqrt-pow196.0%
metadata-eval96.0%
expm1-log1p-u89.0%
expm1-udef89.0%
Applied egg-rr89.0%
expm1-def89.0%
expm1-log1p96.0%
Simplified96.0%
if 1 < x Initial program 36.2%
sub-neg36.2%
flip-+36.2%
frac-times27.5%
metadata-eval27.5%
add-sqr-sqrt21.6%
distribute-neg-frac21.6%
metadata-eval21.6%
+-commutative21.6%
distribute-neg-frac21.6%
metadata-eval21.6%
+-commutative21.6%
pow1/221.6%
pow-flip21.6%
metadata-eval21.6%
Applied egg-rr21.6%
associate-*r/23.6%
associate-*l/23.6%
metadata-eval23.6%
associate-/l/23.8%
rem-square-sqrt36.4%
sub-neg36.4%
distribute-neg-frac36.4%
metadata-eval36.4%
sub-neg36.4%
distribute-neg-frac36.4%
metadata-eval36.4%
Simplified36.4%
frac-add38.2%
div-inv38.2%
*-un-lft-identity38.2%
associate-+l+80.0%
metadata-eval80.0%
frac-times81.6%
un-div-inv81.7%
Applied egg-rr81.7%
Taylor expanded in x around inf 37.8%
unpow-137.8%
exp-to-pow37.8%
*-commutative37.8%
exp-prod37.9%
*-commutative37.9%
associate-*l*37.9%
metadata-eval37.9%
exp-to-pow37.9%
metadata-eval37.9%
pow-sqr37.9%
rem-sqrt-square42.0%
rem-square-sqrt42.0%
fabs-sqr42.0%
rem-square-sqrt42.0%
Simplified42.0%
Final simplification68.8%
(FPCore (x) :precision binary64 (pow x -1.5))
double code(double x) {
return pow(x, -1.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x ** (-1.5d0)
end function
public static double code(double x) {
return Math.pow(x, -1.5);
}
def code(x): return math.pow(x, -1.5)
function code(x) return x ^ -1.5 end
function tmp = code(x) tmp = x ^ -1.5; end
code[x_] := N[Power[x, -1.5], $MachinePrecision]
\begin{array}{l}
\\
{x}^{-1.5}
\end{array}
Initial program 67.6%
sub-neg67.6%
flip-+67.6%
frac-times63.1%
metadata-eval63.1%
add-sqr-sqrt60.1%
distribute-neg-frac60.1%
metadata-eval60.1%
+-commutative60.1%
distribute-neg-frac60.1%
metadata-eval60.1%
+-commutative60.1%
pow1/260.1%
pow-flip60.1%
metadata-eval60.1%
Applied egg-rr60.1%
associate-*r/61.1%
associate-*l/61.1%
metadata-eval61.1%
associate-/l/61.2%
rem-square-sqrt67.5%
sub-neg67.5%
distribute-neg-frac67.5%
metadata-eval67.5%
sub-neg67.5%
distribute-neg-frac67.5%
metadata-eval67.5%
Simplified67.5%
frac-add68.5%
div-inv68.5%
*-un-lft-identity68.5%
associate-+l+89.6%
metadata-eval89.6%
frac-times90.4%
un-div-inv90.4%
Applied egg-rr90.4%
Taylor expanded in x around inf 21.7%
unpow-121.7%
exp-to-pow21.7%
*-commutative21.7%
exp-prod21.8%
*-commutative21.8%
associate-*l*21.8%
metadata-eval21.8%
exp-to-pow21.8%
metadata-eval21.8%
pow-sqr21.8%
rem-sqrt-square23.9%
rem-square-sqrt23.9%
fabs-sqr23.9%
rem-square-sqrt23.9%
Simplified23.9%
Final simplification23.9%
(FPCore (x) :precision binary64 (/ 1.0 x))
double code(double x) {
return 1.0 / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / x
end function
public static double code(double x) {
return 1.0 / x;
}
def code(x): return 1.0 / x
function code(x) return Float64(1.0 / x) end
function tmp = code(x) tmp = 1.0 / x; end
code[x_] := N[(1.0 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x}
\end{array}
Initial program 67.6%
sub-neg67.6%
flip-+67.6%
frac-times63.1%
metadata-eval63.1%
add-sqr-sqrt60.1%
distribute-neg-frac60.1%
metadata-eval60.1%
+-commutative60.1%
distribute-neg-frac60.1%
metadata-eval60.1%
+-commutative60.1%
pow1/260.1%
pow-flip60.1%
metadata-eval60.1%
Applied egg-rr60.1%
associate-*r/61.1%
associate-*l/61.1%
metadata-eval61.1%
associate-/l/61.2%
rem-square-sqrt67.5%
sub-neg67.5%
distribute-neg-frac67.5%
metadata-eval67.5%
sub-neg67.5%
distribute-neg-frac67.5%
metadata-eval67.5%
Simplified67.5%
Taylor expanded in x around 0 52.2%
distribute-rgt-in52.2%
*-lft-identity52.2%
pow-plus52.4%
metadata-eval52.4%
Simplified52.4%
Taylor expanded in x around inf 7.3%
Final simplification7.3%
(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 2023320
(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)))))