
(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)
(/
(/ (+ 1.0 (- x x)) (+ x (pow x 2.0)))
(+ (pow x -0.5) (pow (+ 1.0 x) -0.5)))))
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;
} else {
tmp = ((1.0 + (x - x)) / (x + pow(x, 2.0))) / (pow(x, -0.5) + pow((1.0 + x), -0.5));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((1.0d0 + x)))) <= 0.0d0) then
tmp = (x ** (-1.5d0)) * 0.5d0
else
tmp = ((1.0d0 + (x - x)) / (x + (x ** 2.0d0))) / ((x ** (-0.5d0)) + ((1.0d0 + x) ** (-0.5d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / Math.sqrt((1.0 + x)))) <= 0.0) {
tmp = Math.pow(x, -1.5) * 0.5;
} else {
tmp = ((1.0 + (x - x)) / (x + Math.pow(x, 2.0))) / (Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5));
}
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 else: tmp = ((1.0 + (x - x)) / (x + math.pow(x, 2.0))) / (math.pow(x, -0.5) + math.pow((1.0 + x), -0.5)) 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) * 0.5); else tmp = Float64(Float64(Float64(1.0 + Float64(x - x)) / Float64(x + (x ^ 2.0))) / Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5))); 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; else tmp = ((1.0 + (x - x)) / (x + (x ^ 2.0))) / ((x ^ -0.5) + ((1.0 + x) ^ -0.5)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[Power[x, -1.5], $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(x + N[Power[x, 2.0], $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}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 0:\\
\;\;\;\;{x}^{-1.5} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \left(x - x\right)}{x + {x}^{2}}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}\\
\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 39.9%
Taylor expanded in x around inf 80.6%
Taylor expanded in x around inf 99.7%
+-commutative99.7%
mul-1-neg99.7%
unsub-neg99.7%
*-commutative99.7%
distribute-rgt-out99.7%
metadata-eval99.7%
*-rgt-identity99.7%
times-frac99.7%
metadata-eval99.7%
Simplified99.7%
div-sub99.7%
sub-neg99.7%
Applied egg-rr100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 100.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 67.7%
flip--68.1%
div-inv68.1%
frac-times67.4%
metadata-eval67.4%
add-sqr-sqrt67.6%
frac-times68.0%
metadata-eval68.0%
add-sqr-sqrt69.3%
+-commutative69.3%
inv-pow69.3%
sqrt-pow269.3%
metadata-eval69.3%
pow1/269.3%
pow-flip69.2%
+-commutative69.2%
metadata-eval69.2%
Applied egg-rr69.2%
associate-*r/69.2%
*-rgt-identity69.2%
Simplified69.2%
frac-sub99.2%
*-un-lft-identity99.2%
distribute-rgt-in99.2%
*-un-lft-identity99.2%
unpow299.2%
Applied egg-rr99.2%
*-rgt-identity99.2%
associate--l+99.7%
Simplified99.7%
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) (/ (/ 1.0 (* x (+ 1.0 x))) (+ (pow x -0.5) (pow (+ 1.0 x) -0.5)))))
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;
} else {
tmp = (1.0 / (x * (1.0 + x))) / (pow(x, -0.5) + pow((1.0 + x), -0.5));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((1.0d0 + x)))) <= 0.0d0) then
tmp = (x ** (-1.5d0)) * 0.5d0
else
tmp = (1.0d0 / (x * (1.0d0 + x))) / ((x ** (-0.5d0)) + ((1.0d0 + x) ** (-0.5d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / Math.sqrt((1.0 + x)))) <= 0.0) {
tmp = Math.pow(x, -1.5) * 0.5;
} else {
tmp = (1.0 / (x * (1.0 + x))) / (Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5));
}
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 else: tmp = (1.0 / (x * (1.0 + x))) / (math.pow(x, -0.5) + math.pow((1.0 + x), -0.5)) 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) * 0.5); else tmp = Float64(Float64(1.0 / Float64(x * Float64(1.0 + x))) / Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5))); 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; else tmp = (1.0 / (x * (1.0 + x))) / ((x ^ -0.5) + ((1.0 + x) ^ -0.5)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[Power[x, -1.5], $MachinePrecision] * 0.5), $MachinePrecision], 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}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 0:\\
\;\;\;\;{x}^{-1.5} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x \cdot \left(1 + x\right)}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}\\
\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 39.9%
Taylor expanded in x around inf 80.6%
Taylor expanded in x around inf 99.7%
+-commutative99.7%
mul-1-neg99.7%
unsub-neg99.7%
*-commutative99.7%
distribute-rgt-out99.7%
metadata-eval99.7%
*-rgt-identity99.7%
times-frac99.7%
metadata-eval99.7%
Simplified99.7%
div-sub99.7%
sub-neg99.7%
Applied egg-rr100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 100.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 67.7%
flip--68.1%
div-inv68.1%
frac-times67.4%
metadata-eval67.4%
add-sqr-sqrt67.6%
frac-times68.0%
metadata-eval68.0%
add-sqr-sqrt69.3%
+-commutative69.3%
inv-pow69.3%
sqrt-pow269.3%
metadata-eval69.3%
pow1/269.3%
pow-flip69.2%
+-commutative69.2%
metadata-eval69.2%
Applied egg-rr69.2%
associate-*r/69.2%
*-rgt-identity69.2%
Simplified69.2%
frac-sub99.2%
*-un-lft-identity99.2%
distribute-rgt-in99.2%
*-un-lft-identity99.2%
unpow299.2%
Applied egg-rr99.2%
*-rgt-identity99.2%
associate--l+99.7%
+-inverses99.7%
metadata-eval99.7%
*-rgt-identity99.7%
unpow299.7%
distribute-lft-out99.7%
Simplified99.7%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (sqrt x))))
(if (<= (+ t_0 (/ -1.0 (sqrt (+ 1.0 x)))) 2e-12)
(* (pow x -1.5) (+ 0.5 (/ -0.375 x)))
(- t_0 (pow (+ 1.0 x) -0.5)))))
double code(double x) {
double t_0 = 1.0 / sqrt(x);
double tmp;
if ((t_0 + (-1.0 / sqrt((1.0 + x)))) <= 2e-12) {
tmp = pow(x, -1.5) * (0.5 + (-0.375 / x));
} else {
tmp = t_0 - pow((1.0 + x), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 / sqrt(x)
if ((t_0 + ((-1.0d0) / sqrt((1.0d0 + x)))) <= 2d-12) then
tmp = (x ** (-1.5d0)) * (0.5d0 + ((-0.375d0) / x))
else
tmp = t_0 - ((1.0d0 + x) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = 1.0 / Math.sqrt(x);
double tmp;
if ((t_0 + (-1.0 / Math.sqrt((1.0 + x)))) <= 2e-12) {
tmp = Math.pow(x, -1.5) * (0.5 + (-0.375 / x));
} else {
tmp = t_0 - Math.pow((1.0 + x), -0.5);
}
return tmp;
}
def code(x): t_0 = 1.0 / math.sqrt(x) tmp = 0 if (t_0 + (-1.0 / math.sqrt((1.0 + x)))) <= 2e-12: tmp = math.pow(x, -1.5) * (0.5 + (-0.375 / x)) else: tmp = t_0 - math.pow((1.0 + x), -0.5) return tmp
function code(x) t_0 = Float64(1.0 / sqrt(x)) tmp = 0.0 if (Float64(t_0 + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 2e-12) tmp = Float64((x ^ -1.5) * Float64(0.5 + Float64(-0.375 / x))); else tmp = Float64(t_0 - (Float64(1.0 + x) ^ -0.5)); end return tmp end
function tmp_2 = code(x) t_0 = 1.0 / sqrt(x); tmp = 0.0; if ((t_0 + (-1.0 / sqrt((1.0 + x)))) <= 2e-12) tmp = (x ^ -1.5) * (0.5 + (-0.375 / x)); else tmp = t_0 - ((1.0 + x) ^ -0.5); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 + N[(-1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e-12], N[(N[Power[x, -1.5], $MachinePrecision] * N[(0.5 + N[(-0.375 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\sqrt{x}}\\
\mathbf{if}\;t\_0 + \frac{-1}{\sqrt{1 + x}} \leq 2 \cdot 10^{-12}:\\
\;\;\;\;{x}^{-1.5} \cdot \left(0.5 + \frac{-0.375}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 - {\left(1 + x\right)}^{-0.5}\\
\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))))) < 1.99999999999999996e-12Initial program 40.1%
Taylor expanded in x around inf 81.3%
Taylor expanded in x around inf 99.7%
+-commutative99.7%
mul-1-neg99.7%
unsub-neg99.7%
*-commutative99.7%
distribute-rgt-out99.7%
metadata-eval99.7%
*-rgt-identity99.7%
times-frac99.7%
metadata-eval99.7%
Simplified99.7%
div-sub99.7%
sub-neg99.7%
Applied egg-rr100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
if 1.99999999999999996e-12 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) Initial program 90.2%
frac-2neg90.2%
metadata-eval90.2%
div-inv90.2%
frac-2neg90.2%
metadata-eval90.2%
div-inv90.2%
distribute-neg-frac290.2%
prod-diff90.2%
distribute-neg-frac90.2%
metadata-eval90.2%
+-commutative90.2%
Applied egg-rr91.4%
+-commutative91.4%
fma-undefine91.4%
mul-1-neg91.4%
distribute-neg-out91.4%
unsub-neg91.4%
Simplified91.4%
Final simplification99.7%
(FPCore (x) :precision binary64 (if (<= x 235000.0) (- (pow x -0.5) (pow (+ 1.0 x) -0.5)) (* (pow x -1.5) (+ 0.5 (/ -0.375 x)))))
double code(double x) {
double tmp;
if (x <= 235000.0) {
tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
} else {
tmp = pow(x, -1.5) * (0.5 + (-0.375 / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 235000.0d0) then
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
else
tmp = (x ** (-1.5d0)) * (0.5d0 + ((-0.375d0) / x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 235000.0) {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
} else {
tmp = Math.pow(x, -1.5) * (0.5 + (-0.375 / x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 235000.0: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) else: tmp = math.pow(x, -1.5) * (0.5 + (-0.375 / x)) return tmp
function code(x) tmp = 0.0 if (x <= 235000.0) tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); else tmp = Float64((x ^ -1.5) * Float64(0.5 + Float64(-0.375 / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 235000.0) tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); else tmp = (x ^ -1.5) * (0.5 + (-0.375 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 235000.0], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -1.5], $MachinePrecision] * N[(0.5 + N[(-0.375 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 235000:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-1.5} \cdot \left(0.5 + \frac{-0.375}{x}\right)\\
\end{array}
\end{array}
if x < 235000Initial program 90.2%
sub-neg90.2%
inv-pow90.2%
sqrt-pow290.2%
metadata-eval90.2%
distribute-neg-frac90.2%
metadata-eval90.2%
+-commutative90.2%
Applied egg-rr90.2%
*-rgt-identity90.2%
cancel-sign-sub90.2%
distribute-lft-neg-in90.2%
*-rgt-identity90.2%
distribute-neg-frac90.2%
metadata-eval90.2%
unpow1/290.2%
exp-to-pow89.2%
log1p-undefine89.0%
*-commutative89.0%
exp-neg89.3%
*-commutative89.3%
distribute-rgt-neg-in89.3%
log1p-undefine89.6%
metadata-eval89.6%
exp-to-pow91.3%
Simplified91.3%
if 235000 < x Initial program 40.1%
Taylor expanded in x around inf 81.3%
Taylor expanded in x around inf 99.7%
+-commutative99.7%
mul-1-neg99.7%
unsub-neg99.7%
*-commutative99.7%
distribute-rgt-out99.7%
metadata-eval99.7%
*-rgt-identity99.7%
times-frac99.7%
metadata-eval99.7%
Simplified99.7%
div-sub99.7%
sub-neg99.7%
Applied egg-rr100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification99.7%
(FPCore (x) :precision binary64 (* (pow x -1.5) (+ 0.5 (/ -0.375 x))))
double code(double x) {
return pow(x, -1.5) * (0.5 + (-0.375 / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x ** (-1.5d0)) * (0.5d0 + ((-0.375d0) / x))
end function
public static double code(double x) {
return Math.pow(x, -1.5) * (0.5 + (-0.375 / x));
}
def code(x): return math.pow(x, -1.5) * (0.5 + (-0.375 / x))
function code(x) return Float64((x ^ -1.5) * Float64(0.5 + Float64(-0.375 / x))) end
function tmp = code(x) tmp = (x ^ -1.5) * (0.5 + (-0.375 / x)); end
code[x_] := N[(N[Power[x, -1.5], $MachinePrecision] * N[(0.5 + N[(-0.375 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{x}^{-1.5} \cdot \left(0.5 + \frac{-0.375}{x}\right)
\end{array}
Initial program 41.9%
Taylor expanded in x around inf 79.9%
Taylor expanded in x around inf 97.6%
+-commutative97.6%
mul-1-neg97.6%
unsub-neg97.6%
*-commutative97.6%
distribute-rgt-out97.6%
metadata-eval97.6%
*-rgt-identity97.6%
times-frac97.6%
metadata-eval97.6%
Simplified97.6%
div-sub97.6%
sub-neg97.6%
Applied egg-rr97.8%
*-commutative97.8%
distribute-rgt-neg-in97.8%
distribute-lft-out97.8%
distribute-neg-frac97.8%
metadata-eval97.8%
Simplified97.8%
Final simplification97.8%
(FPCore (x) :precision binary64 (* (pow x -1.5) 0.5))
double code(double x) {
return pow(x, -1.5) * 0.5;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x ** (-1.5d0)) * 0.5d0
end function
public static double code(double x) {
return Math.pow(x, -1.5) * 0.5;
}
def code(x): return math.pow(x, -1.5) * 0.5
function code(x) return Float64((x ^ -1.5) * 0.5) end
function tmp = code(x) tmp = (x ^ -1.5) * 0.5; end
code[x_] := N[(N[Power[x, -1.5], $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
{x}^{-1.5} \cdot 0.5
\end{array}
Initial program 41.9%
Taylor expanded in x around inf 79.9%
Taylor expanded in x around inf 97.6%
+-commutative97.6%
mul-1-neg97.6%
unsub-neg97.6%
*-commutative97.6%
distribute-rgt-out97.6%
metadata-eval97.6%
*-rgt-identity97.6%
times-frac97.6%
metadata-eval97.6%
Simplified97.6%
div-sub97.6%
sub-neg97.6%
Applied egg-rr97.8%
*-commutative97.8%
distribute-rgt-neg-in97.8%
distribute-lft-out97.8%
distribute-neg-frac97.8%
metadata-eval97.8%
Simplified97.8%
Taylor expanded in x around inf 96.6%
Final simplification96.6%
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 41.9%
sub-neg41.9%
+-commutative41.9%
add-cube-cbrt14.3%
distribute-lft-neg-in14.3%
fma-define9.2%
Applied egg-rr9.3%
Taylor expanded in x around inf 37.3%
distribute-rgt1-in37.3%
metadata-eval37.3%
mul0-lft37.3%
Simplified37.3%
Final simplification37.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 2024077
(FPCore (x)
:name "2isqrt (example 3.6)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:alt
(/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))
(- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))