
(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 10 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 (pow (* (hypot (pow x -0.25) (pow (+ x 1.0) -0.25)) (hypot x (sqrt x))) -2.0))
double code(double x) {
return pow((hypot(pow(x, -0.25), pow((x + 1.0), -0.25)) * hypot(x, sqrt(x))), -2.0);
}
public static double code(double x) {
return Math.pow((Math.hypot(Math.pow(x, -0.25), Math.pow((x + 1.0), -0.25)) * Math.hypot(x, Math.sqrt(x))), -2.0);
}
def code(x): return math.pow((math.hypot(math.pow(x, -0.25), math.pow((x + 1.0), -0.25)) * math.hypot(x, math.sqrt(x))), -2.0)
function code(x) return Float64(hypot((x ^ -0.25), (Float64(x + 1.0) ^ -0.25)) * hypot(x, sqrt(x))) ^ -2.0 end
function tmp = code(x) tmp = (hypot((x ^ -0.25), ((x + 1.0) ^ -0.25)) * hypot(x, sqrt(x))) ^ -2.0; end
code[x_] := N[Power[N[(N[Sqrt[N[Power[x, -0.25], $MachinePrecision] ^ 2 + N[Power[N[(x + 1.0), $MachinePrecision], -0.25], $MachinePrecision] ^ 2], $MachinePrecision] * N[Sqrt[x ^ 2 + N[Sqrt[x], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(\mathsf{hypot}\left({x}^{-0.25}, {\left(x + 1\right)}^{-0.25}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)\right)}^{-2}
\end{array}
Initial program 38.7%
sub-neg38.7%
flip-+38.6%
frac-times19.4%
metadata-eval19.4%
add-sqr-sqrt17.0%
distribute-neg-frac17.0%
metadata-eval17.0%
+-commutative17.0%
distribute-neg-frac17.0%
metadata-eval17.0%
+-commutative17.0%
pow1/217.0%
pow-flip17.0%
metadata-eval17.0%
Applied egg-rr17.0%
associate-*r/21.5%
associate-*l/21.5%
metadata-eval21.5%
associate-/l/26.9%
rem-square-sqrt38.8%
sub-neg38.8%
distribute-neg-frac38.8%
metadata-eval38.8%
sub-neg38.8%
distribute-neg-frac38.8%
metadata-eval38.8%
Simplified38.8%
frac-add41.0%
*-un-lft-identity41.0%
distribute-rgt-in41.0%
*-un-lft-identity41.0%
pow241.0%
Applied egg-rr41.0%
*-commutative41.0%
neg-mul-141.0%
sub-neg41.0%
associate--l+81.7%
Simplified81.7%
add-sqr-sqrt81.5%
Applied egg-rr99.2%
unpow299.2%
associate-/l/99.2%
Simplified99.2%
Applied egg-rr37.5%
expm1-def99.2%
expm1-log1p99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x) :precision binary64 (if (<= x 1.35e+154) (/ (/ 1.0 (- (- (pow (+ x 1.0) -0.5)) (pow x -0.5))) (* x (- -1.0 x))) (pow x -1.5)))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = (1.0 / (-pow((x + 1.0), -0.5) - pow(x, -0.5))) / (x * (-1.0 - x));
} else {
tmp = pow(x, -1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.35d+154) then
tmp = (1.0d0 / (-((x + 1.0d0) ** (-0.5d0)) - (x ** (-0.5d0)))) / (x * ((-1.0d0) - x))
else
tmp = x ** (-1.5d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = (1.0 / (-Math.pow((x + 1.0), -0.5) - Math.pow(x, -0.5))) / (x * (-1.0 - x));
} else {
tmp = Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.35e+154: tmp = (1.0 / (-math.pow((x + 1.0), -0.5) - math.pow(x, -0.5))) / (x * (-1.0 - x)) else: tmp = math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(Float64(1.0 / Float64(Float64(-(Float64(x + 1.0) ^ -0.5)) - (x ^ -0.5))) / Float64(x * Float64(-1.0 - x))); else tmp = x ^ -1.5; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.35e+154) tmp = (1.0 / (-((x + 1.0) ^ -0.5) - (x ^ -0.5))) / (x * (-1.0 - x)); else tmp = x ^ -1.5; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.35e+154], N[(N[(1.0 / N[((-N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]) - N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[x, -1.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{\frac{1}{\left(-{\left(x + 1\right)}^{-0.5}\right) - {x}^{-0.5}}}{x \cdot \left(-1 - x\right)}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-1.5}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 9.8%
flip--9.6%
clear-num9.6%
pow1/29.6%
pow-flip9.6%
metadata-eval9.6%
inv-pow9.6%
sqrt-pow29.6%
+-commutative9.6%
metadata-eval9.6%
frac-times10.1%
metadata-eval10.1%
add-sqr-sqrt10.1%
frac-times9.8%
metadata-eval9.8%
add-sqr-sqrt10.1%
Applied egg-rr10.1%
frac-2neg10.1%
metadata-eval10.1%
frac-sub14.6%
Applied egg-rr14.6%
*-commutative14.6%
neg-mul-114.6%
*-rgt-identity14.6%
*-lft-identity14.6%
neg-sub014.6%
associate--l-14.6%
associate-+l+99.2%
*-rgt-identity99.2%
sub-neg99.2%
+-inverses99.2%
metadata-eval99.2%
metadata-eval99.2%
distribute-neg-in99.2%
metadata-eval99.2%
unsub-neg99.2%
Simplified99.2%
inv-pow99.2%
associate-/r/99.3%
unpow-prod-down99.3%
div-inv99.3%
metadata-eval99.3%
inv-pow99.3%
Applied egg-rr99.3%
associate-*r/99.3%
*-rgt-identity99.3%
unpow-199.3%
*-commutative99.3%
neg-mul-199.3%
neg-sub099.3%
+-commutative99.3%
associate--r+99.3%
neg-sub099.3%
Simplified99.3%
if 1.35000000000000003e154 < x Initial program 65.4%
sub-neg65.4%
flip-+65.4%
frac-times28.0%
metadata-eval28.0%
add-sqr-sqrt23.5%
distribute-neg-frac23.5%
metadata-eval23.5%
+-commutative23.5%
distribute-neg-frac23.5%
metadata-eval23.5%
+-commutative23.5%
pow1/223.5%
pow-flip23.5%
metadata-eval23.5%
Applied egg-rr23.5%
associate-*r/32.2%
associate-*l/32.2%
metadata-eval32.2%
associate-/l/42.7%
rem-square-sqrt65.4%
sub-neg65.4%
distribute-neg-frac65.4%
metadata-eval65.4%
sub-neg65.4%
distribute-neg-frac65.4%
metadata-eval65.4%
Simplified65.4%
frac-add65.4%
*-un-lft-identity65.4%
distribute-rgt-in65.4%
*-un-lft-identity65.4%
pow265.4%
Applied egg-rr65.4%
*-commutative65.4%
neg-mul-165.4%
sub-neg65.4%
associate--l+65.4%
Simplified65.4%
Taylor expanded in x around inf 65.4%
metadata-eval65.4%
cube-div65.4%
Simplified65.4%
expm1-log1p-u65.4%
expm1-udef65.4%
sqrt-pow165.4%
inv-pow65.4%
pow-pow65.4%
metadata-eval65.4%
metadata-eval65.4%
Applied egg-rr65.4%
expm1-def69.0%
expm1-log1p69.0%
Simplified69.0%
Final simplification83.6%
(FPCore (x) :precision binary64 (if (<= x 1.35e+154) (/ (/ -1.0 (* x (- -1.0 x))) (+ (pow x -0.5) (pow (+ x 1.0) -0.5))) (pow x -1.5)))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = (-1.0 / (x * (-1.0 - x))) / (pow(x, -0.5) + pow((x + 1.0), -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.35d+154) then
tmp = ((-1.0d0) / (x * ((-1.0d0) - x))) / ((x ** (-0.5d0)) + ((x + 1.0d0) ** (-0.5d0)))
else
tmp = x ** (-1.5d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = (-1.0 / (x * (-1.0 - x))) / (Math.pow(x, -0.5) + Math.pow((x + 1.0), -0.5));
} else {
tmp = Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.35e+154: tmp = (-1.0 / (x * (-1.0 - x))) / (math.pow(x, -0.5) + math.pow((x + 1.0), -0.5)) else: tmp = math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(Float64(-1.0 / Float64(x * Float64(-1.0 - x))) / Float64((x ^ -0.5) + (Float64(x + 1.0) ^ -0.5))); else tmp = x ^ -1.5; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.35e+154) tmp = (-1.0 / (x * (-1.0 - x))) / ((x ^ -0.5) + ((x + 1.0) ^ -0.5)); else tmp = x ^ -1.5; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.35e+154], N[(N[(-1.0 / N[(x * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[x, -1.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{\frac{-1}{x \cdot \left(-1 - x\right)}}{{x}^{-0.5} + {\left(x + 1\right)}^{-0.5}}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-1.5}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 9.8%
sub-neg9.8%
flip-+9.6%
frac-times10.1%
metadata-eval10.1%
add-sqr-sqrt10.1%
distribute-neg-frac10.1%
metadata-eval10.1%
+-commutative10.1%
distribute-neg-frac10.1%
metadata-eval10.1%
+-commutative10.1%
pow1/210.1%
pow-flip10.1%
metadata-eval10.1%
Applied egg-rr10.1%
associate-*r/10.0%
associate-*l/10.0%
metadata-eval10.0%
associate-/l/9.8%
rem-square-sqrt10.1%
sub-neg10.1%
distribute-neg-frac10.1%
metadata-eval10.1%
sub-neg10.1%
distribute-neg-frac10.1%
metadata-eval10.1%
Simplified10.1%
frac-add14.6%
*-un-lft-identity14.6%
distribute-rgt-in14.7%
*-un-lft-identity14.7%
pow214.7%
Applied egg-rr14.7%
*-commutative14.7%
neg-mul-114.7%
sub-neg14.7%
associate--l+99.3%
Simplified99.3%
add-sqr-sqrt98.9%
Applied egg-rr98.6%
unpow298.6%
associate-/l/98.7%
Simplified98.7%
metadata-eval98.7%
hypot-udef98.6%
pow-sqr98.6%
metadata-eval98.6%
pow-sqr98.7%
metadata-eval98.7%
hypot-udef98.7%
add-sqr-sqrt98.7%
fma-udef98.7%
sqrt-prod98.8%
sqrt-div99.0%
Applied egg-rr99.3%
associate-/r*99.3%
fma-udef99.3%
distribute-lft1-in99.3%
+-commutative99.3%
metadata-eval99.3%
associate--r-99.3%
neg-sub099.3%
*-commutative99.3%
distribute-rgt-neg-out99.3%
remove-double-neg99.3%
associate-*r/99.3%
associate-*l/99.3%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
if 1.35000000000000003e154 < x Initial program 65.4%
sub-neg65.4%
flip-+65.4%
frac-times28.0%
metadata-eval28.0%
add-sqr-sqrt23.5%
distribute-neg-frac23.5%
metadata-eval23.5%
+-commutative23.5%
distribute-neg-frac23.5%
metadata-eval23.5%
+-commutative23.5%
pow1/223.5%
pow-flip23.5%
metadata-eval23.5%
Applied egg-rr23.5%
associate-*r/32.2%
associate-*l/32.2%
metadata-eval32.2%
associate-/l/42.7%
rem-square-sqrt65.4%
sub-neg65.4%
distribute-neg-frac65.4%
metadata-eval65.4%
sub-neg65.4%
distribute-neg-frac65.4%
metadata-eval65.4%
Simplified65.4%
frac-add65.4%
*-un-lft-identity65.4%
distribute-rgt-in65.4%
*-un-lft-identity65.4%
pow265.4%
Applied egg-rr65.4%
*-commutative65.4%
neg-mul-165.4%
sub-neg65.4%
associate--l+65.4%
Simplified65.4%
Taylor expanded in x around inf 65.4%
metadata-eval65.4%
cube-div65.4%
Simplified65.4%
expm1-log1p-u65.4%
expm1-udef65.4%
sqrt-pow165.4%
inv-pow65.4%
pow-pow65.4%
metadata-eval65.4%
metadata-eval65.4%
Applied egg-rr65.4%
expm1-def69.0%
expm1-log1p69.0%
Simplified69.0%
Final simplification83.6%
(FPCore (x) :precision binary64 (if (<= x 1.35e+154) (/ 1.0 (* (+ (pow x -0.5) (pow (+ x 1.0) -0.5)) (* x (- x -1.0)))) (pow x -1.5)))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 1.0 / ((pow(x, -0.5) + pow((x + 1.0), -0.5)) * (x * (x - -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 <= 1.35d+154) then
tmp = 1.0d0 / (((x ** (-0.5d0)) + ((x + 1.0d0) ** (-0.5d0))) * (x * (x - (-1.0d0))))
else
tmp = x ** (-1.5d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 1.0 / ((Math.pow(x, -0.5) + Math.pow((x + 1.0), -0.5)) * (x * (x - -1.0)));
} else {
tmp = Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.35e+154: tmp = 1.0 / ((math.pow(x, -0.5) + math.pow((x + 1.0), -0.5)) * (x * (x - -1.0))) else: tmp = math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(1.0 / Float64(Float64((x ^ -0.5) + (Float64(x + 1.0) ^ -0.5)) * Float64(x * Float64(x - -1.0)))); else tmp = x ^ -1.5; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.35e+154) tmp = 1.0 / (((x ^ -0.5) + ((x + 1.0) ^ -0.5)) * (x * (x - -1.0))); else tmp = x ^ -1.5; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.35e+154], N[(1.0 / N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(x * N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[x, -1.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\left({x}^{-0.5} + {\left(x + 1\right)}^{-0.5}\right) \cdot \left(x \cdot \left(x - -1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-1.5}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 9.8%
flip--9.6%
clear-num9.6%
pow1/29.6%
pow-flip9.6%
metadata-eval9.6%
inv-pow9.6%
sqrt-pow29.6%
+-commutative9.6%
metadata-eval9.6%
frac-times10.1%
metadata-eval10.1%
add-sqr-sqrt10.1%
frac-times9.8%
metadata-eval9.8%
add-sqr-sqrt10.1%
Applied egg-rr10.1%
frac-2neg10.1%
metadata-eval10.1%
frac-sub14.6%
Applied egg-rr14.6%
*-commutative14.6%
neg-mul-114.6%
*-rgt-identity14.6%
*-lft-identity14.6%
neg-sub014.6%
associate--l-14.6%
associate-+l+99.2%
*-rgt-identity99.2%
sub-neg99.2%
+-inverses99.2%
metadata-eval99.2%
metadata-eval99.2%
distribute-neg-in99.2%
metadata-eval99.2%
unsub-neg99.2%
Simplified99.2%
expm1-log1p-u92.0%
expm1-udef92.0%
pow192.0%
pow192.0%
div-inv92.0%
frac-2neg92.0%
metadata-eval92.0%
remove-double-div92.0%
distribute-rgt-neg-in92.0%
Applied egg-rr92.0%
expm1-def92.0%
expm1-log1p99.3%
Simplified99.3%
if 1.35000000000000003e154 < x Initial program 65.4%
sub-neg65.4%
flip-+65.4%
frac-times28.0%
metadata-eval28.0%
add-sqr-sqrt23.5%
distribute-neg-frac23.5%
metadata-eval23.5%
+-commutative23.5%
distribute-neg-frac23.5%
metadata-eval23.5%
+-commutative23.5%
pow1/223.5%
pow-flip23.5%
metadata-eval23.5%
Applied egg-rr23.5%
associate-*r/32.2%
associate-*l/32.2%
metadata-eval32.2%
associate-/l/42.7%
rem-square-sqrt65.4%
sub-neg65.4%
distribute-neg-frac65.4%
metadata-eval65.4%
sub-neg65.4%
distribute-neg-frac65.4%
metadata-eval65.4%
Simplified65.4%
frac-add65.4%
*-un-lft-identity65.4%
distribute-rgt-in65.4%
*-un-lft-identity65.4%
pow265.4%
Applied egg-rr65.4%
*-commutative65.4%
neg-mul-165.4%
sub-neg65.4%
associate--l+65.4%
Simplified65.4%
Taylor expanded in x around inf 65.4%
metadata-eval65.4%
cube-div65.4%
Simplified65.4%
expm1-log1p-u65.4%
expm1-udef65.4%
sqrt-pow165.4%
inv-pow65.4%
pow-pow65.4%
metadata-eval65.4%
metadata-eval65.4%
Applied egg-rr65.4%
expm1-def69.0%
expm1-log1p69.0%
Simplified69.0%
Final simplification83.6%
(FPCore (x) :precision binary64 (/ 1.0 (* x (* (+ (pow x -0.5) (pow (+ x 1.0) -0.5)) (- x -1.0)))))
double code(double x) {
return 1.0 / (x * ((pow(x, -0.5) + pow((x + 1.0), -0.5)) * (x - -1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (x * (((x ** (-0.5d0)) + ((x + 1.0d0) ** (-0.5d0))) * (x - (-1.0d0))))
end function
public static double code(double x) {
return 1.0 / (x * ((Math.pow(x, -0.5) + Math.pow((x + 1.0), -0.5)) * (x - -1.0)));
}
def code(x): return 1.0 / (x * ((math.pow(x, -0.5) + math.pow((x + 1.0), -0.5)) * (x - -1.0)))
function code(x) return Float64(1.0 / Float64(x * Float64(Float64((x ^ -0.5) + (Float64(x + 1.0) ^ -0.5)) * Float64(x - -1.0)))) end
function tmp = code(x) tmp = 1.0 / (x * (((x ^ -0.5) + ((x + 1.0) ^ -0.5)) * (x - -1.0))); end
code[x_] := N[(1.0 / N[(x * N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot \left(\left({x}^{-0.5} + {\left(x + 1\right)}^{-0.5}\right) \cdot \left(x - -1\right)\right)}
\end{array}
Initial program 38.7%
flip--38.6%
clear-num38.6%
pow1/238.6%
pow-flip38.6%
metadata-eval38.6%
inv-pow38.6%
sqrt-pow238.6%
+-commutative38.6%
metadata-eval38.6%
frac-times19.4%
metadata-eval19.4%
add-sqr-sqrt17.0%
frac-times26.9%
metadata-eval26.9%
add-sqr-sqrt38.8%
Applied egg-rr38.8%
frac-2neg38.8%
metadata-eval38.8%
frac-sub41.0%
Applied egg-rr41.0%
*-commutative41.0%
neg-mul-141.0%
*-rgt-identity41.0%
*-lft-identity41.0%
neg-sub041.0%
associate--l-41.0%
associate-+l+81.6%
*-rgt-identity81.6%
sub-neg81.6%
+-inverses81.6%
metadata-eval81.6%
metadata-eval81.6%
distribute-neg-in81.6%
metadata-eval81.6%
unsub-neg81.6%
Simplified81.6%
associate-/r/81.7%
*-commutative81.7%
associate-*r*98.3%
div-inv98.3%
metadata-eval98.3%
Applied egg-rr98.3%
Final simplification98.3%
(FPCore (x) :precision binary64 (if (<= x 1.35e+154) (/ 1.0 (* (* (sqrt (/ 1.0 x)) 2.0) (fma x x x))) (pow x -1.5)))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 1.0 / ((sqrt((1.0 / x)) * 2.0) * fma(x, x, x));
} else {
tmp = pow(x, -1.5);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(1.0 / Float64(Float64(sqrt(Float64(1.0 / x)) * 2.0) * fma(x, x, x))); else tmp = x ^ -1.5; end return tmp end
code[x_] := If[LessEqual[x, 1.35e+154], N[(1.0 / N[(N[(N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision] * N[(x * x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[x, -1.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\left(\sqrt{\frac{1}{x}} \cdot 2\right) \cdot \mathsf{fma}\left(x, x, x\right)}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-1.5}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 9.8%
sub-neg9.8%
flip-+9.6%
frac-times10.1%
metadata-eval10.1%
add-sqr-sqrt10.1%
distribute-neg-frac10.1%
metadata-eval10.1%
+-commutative10.1%
distribute-neg-frac10.1%
metadata-eval10.1%
+-commutative10.1%
pow1/210.1%
pow-flip10.1%
metadata-eval10.1%
Applied egg-rr10.1%
associate-*r/10.0%
associate-*l/10.0%
metadata-eval10.0%
associate-/l/9.8%
rem-square-sqrt10.1%
sub-neg10.1%
distribute-neg-frac10.1%
metadata-eval10.1%
sub-neg10.1%
distribute-neg-frac10.1%
metadata-eval10.1%
Simplified10.1%
frac-add14.6%
*-un-lft-identity14.6%
distribute-rgt-in14.7%
*-un-lft-identity14.7%
pow214.7%
Applied egg-rr14.7%
*-commutative14.7%
neg-mul-114.7%
sub-neg14.7%
associate--l+99.3%
Simplified99.3%
*-un-lft-identity99.3%
associate-/l/99.3%
+-inverses99.3%
metadata-eval99.3%
inv-pow99.3%
sqrt-pow299.3%
metadata-eval99.3%
+-commutative99.3%
unpow299.3%
fma-def99.3%
Applied egg-rr99.3%
Taylor expanded in x around inf 96.0%
*-commutative95.9%
Simplified96.0%
if 1.35000000000000003e154 < x Initial program 65.4%
sub-neg65.4%
flip-+65.4%
frac-times28.0%
metadata-eval28.0%
add-sqr-sqrt23.5%
distribute-neg-frac23.5%
metadata-eval23.5%
+-commutative23.5%
distribute-neg-frac23.5%
metadata-eval23.5%
+-commutative23.5%
pow1/223.5%
pow-flip23.5%
metadata-eval23.5%
Applied egg-rr23.5%
associate-*r/32.2%
associate-*l/32.2%
metadata-eval32.2%
associate-/l/42.7%
rem-square-sqrt65.4%
sub-neg65.4%
distribute-neg-frac65.4%
metadata-eval65.4%
sub-neg65.4%
distribute-neg-frac65.4%
metadata-eval65.4%
Simplified65.4%
frac-add65.4%
*-un-lft-identity65.4%
distribute-rgt-in65.4%
*-un-lft-identity65.4%
pow265.4%
Applied egg-rr65.4%
*-commutative65.4%
neg-mul-165.4%
sub-neg65.4%
associate--l+65.4%
Simplified65.4%
Taylor expanded in x around inf 65.4%
metadata-eval65.4%
cube-div65.4%
Simplified65.4%
expm1-log1p-u65.4%
expm1-udef65.4%
sqrt-pow165.4%
inv-pow65.4%
pow-pow65.4%
metadata-eval65.4%
metadata-eval65.4%
Applied egg-rr65.4%
expm1-def69.0%
expm1-log1p69.0%
Simplified69.0%
Final simplification82.0%
(FPCore (x) :precision binary64 (if (<= x 1.35e+154) (/ 1.0 (/ (* (sqrt (/ 1.0 x)) 2.0) (/ -1.0 (* x (- -1.0 x))))) (pow x -1.5)))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 1.0 / ((sqrt((1.0 / x)) * 2.0) / (-1.0 / (x * (-1.0 - x))));
} else {
tmp = pow(x, -1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.35d+154) then
tmp = 1.0d0 / ((sqrt((1.0d0 / x)) * 2.0d0) / ((-1.0d0) / (x * ((-1.0d0) - x))))
else
tmp = x ** (-1.5d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 1.0 / ((Math.sqrt((1.0 / x)) * 2.0) / (-1.0 / (x * (-1.0 - x))));
} else {
tmp = Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.35e+154: tmp = 1.0 / ((math.sqrt((1.0 / x)) * 2.0) / (-1.0 / (x * (-1.0 - x)))) else: tmp = math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(1.0 / Float64(Float64(sqrt(Float64(1.0 / x)) * 2.0) / Float64(-1.0 / Float64(x * Float64(-1.0 - x))))); else tmp = x ^ -1.5; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.35e+154) tmp = 1.0 / ((sqrt((1.0 / x)) * 2.0) / (-1.0 / (x * (-1.0 - x)))); else tmp = x ^ -1.5; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.35e+154], N[(1.0 / N[(N[(N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision] / N[(-1.0 / N[(x * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[x, -1.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\frac{\sqrt{\frac{1}{x}} \cdot 2}{\frac{-1}{x \cdot \left(-1 - x\right)}}}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-1.5}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 9.8%
flip--9.6%
clear-num9.6%
pow1/29.6%
pow-flip9.6%
metadata-eval9.6%
inv-pow9.6%
sqrt-pow29.6%
+-commutative9.6%
metadata-eval9.6%
frac-times10.1%
metadata-eval10.1%
add-sqr-sqrt10.1%
frac-times9.8%
metadata-eval9.8%
add-sqr-sqrt10.1%
Applied egg-rr10.1%
frac-2neg10.1%
metadata-eval10.1%
frac-sub14.6%
Applied egg-rr14.6%
*-commutative14.6%
neg-mul-114.6%
*-rgt-identity14.6%
*-lft-identity14.6%
neg-sub014.6%
associate--l-14.6%
associate-+l+99.2%
*-rgt-identity99.2%
sub-neg99.2%
+-inverses99.2%
metadata-eval99.2%
metadata-eval99.2%
distribute-neg-in99.2%
metadata-eval99.2%
unsub-neg99.2%
Simplified99.2%
Taylor expanded in x around inf 95.9%
*-commutative95.9%
Simplified95.9%
if 1.35000000000000003e154 < x Initial program 65.4%
sub-neg65.4%
flip-+65.4%
frac-times28.0%
metadata-eval28.0%
add-sqr-sqrt23.5%
distribute-neg-frac23.5%
metadata-eval23.5%
+-commutative23.5%
distribute-neg-frac23.5%
metadata-eval23.5%
+-commutative23.5%
pow1/223.5%
pow-flip23.5%
metadata-eval23.5%
Applied egg-rr23.5%
associate-*r/32.2%
associate-*l/32.2%
metadata-eval32.2%
associate-/l/42.7%
rem-square-sqrt65.4%
sub-neg65.4%
distribute-neg-frac65.4%
metadata-eval65.4%
sub-neg65.4%
distribute-neg-frac65.4%
metadata-eval65.4%
Simplified65.4%
frac-add65.4%
*-un-lft-identity65.4%
distribute-rgt-in65.4%
*-un-lft-identity65.4%
pow265.4%
Applied egg-rr65.4%
*-commutative65.4%
neg-mul-165.4%
sub-neg65.4%
associate--l+65.4%
Simplified65.4%
Taylor expanded in x around inf 65.4%
metadata-eval65.4%
cube-div65.4%
Simplified65.4%
expm1-log1p-u65.4%
expm1-udef65.4%
sqrt-pow165.4%
inv-pow65.4%
pow-pow65.4%
metadata-eval65.4%
metadata-eval65.4%
Applied egg-rr65.4%
expm1-def69.0%
expm1-log1p69.0%
Simplified69.0%
Final simplification81.9%
(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 38.7%
sub-neg38.7%
flip-+38.6%
frac-times19.4%
metadata-eval19.4%
add-sqr-sqrt17.0%
distribute-neg-frac17.0%
metadata-eval17.0%
+-commutative17.0%
distribute-neg-frac17.0%
metadata-eval17.0%
+-commutative17.0%
pow1/217.0%
pow-flip17.0%
metadata-eval17.0%
Applied egg-rr17.0%
associate-*r/21.5%
associate-*l/21.5%
metadata-eval21.5%
associate-/l/26.9%
rem-square-sqrt38.8%
sub-neg38.8%
distribute-neg-frac38.8%
metadata-eval38.8%
sub-neg38.8%
distribute-neg-frac38.8%
metadata-eval38.8%
Simplified38.8%
frac-add41.0%
*-un-lft-identity41.0%
distribute-rgt-in41.0%
*-un-lft-identity41.0%
pow241.0%
Applied egg-rr41.0%
*-commutative41.0%
neg-mul-141.0%
sub-neg41.0%
associate--l+81.7%
Simplified81.7%
Taylor expanded in x around inf 40.7%
metadata-eval40.7%
cube-div41.1%
Simplified41.1%
expm1-log1p-u41.1%
expm1-udef36.6%
sqrt-pow136.6%
inv-pow36.6%
pow-pow36.6%
metadata-eval36.6%
metadata-eval36.6%
Applied egg-rr36.6%
expm1-def44.9%
expm1-log1p44.9%
Simplified44.9%
Final simplification44.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 38.7%
sub-neg38.7%
flip-+38.6%
frac-times19.4%
metadata-eval19.4%
add-sqr-sqrt17.0%
distribute-neg-frac17.0%
metadata-eval17.0%
+-commutative17.0%
distribute-neg-frac17.0%
metadata-eval17.0%
+-commutative17.0%
pow1/217.0%
pow-flip17.0%
metadata-eval17.0%
Applied egg-rr17.0%
associate-*r/21.5%
associate-*l/21.5%
metadata-eval21.5%
associate-/l/26.9%
rem-square-sqrt38.8%
sub-neg38.8%
distribute-neg-frac38.8%
metadata-eval38.8%
sub-neg38.8%
distribute-neg-frac38.8%
metadata-eval38.8%
Simplified38.8%
Taylor expanded in x around 0 7.7%
distribute-rgt-in7.7%
*-lft-identity7.7%
pow-plus7.7%
metadata-eval7.7%
Simplified7.7%
Taylor expanded in x around inf 7.7%
Final simplification7.7%
(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 38.7%
Taylor expanded in x around 0 2.6%
Taylor expanded in x around inf 2.6%
Final simplification2.6%
(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 2024024
(FPCore (x)
:name "2isqrt (example 3.6)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:herbie-target
(/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))
(- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))