
(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 12 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 (/ 1.0 (fma x (* (sqrt (/ 1.0 x)) 1.5) (* 2.0 (fabs (pow x 1.5))))))
double code(double x) {
return 1.0 / fma(x, (sqrt((1.0 / x)) * 1.5), (2.0 * fabs(pow(x, 1.5))));
}
function code(x) return Float64(1.0 / fma(x, Float64(sqrt(Float64(1.0 / x)) * 1.5), Float64(2.0 * abs((x ^ 1.5))))) end
code[x_] := N[(1.0 / N[(x * N[(N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] * 1.5), $MachinePrecision] + N[(2.0 * N[Abs[N[Power[x, 1.5], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(x, \sqrt{\frac{1}{x}} \cdot 1.5, 2 \cdot \left|{x}^{1.5}\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%
Taylor expanded in x around inf 65.5%
+-commutative65.5%
fma-def65.5%
distribute-rgt-out--65.5%
metadata-eval65.5%
sqr-pow65.5%
rem-sqrt-square98.0%
metadata-eval98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x)
:precision binary64
(if (<= x 1e+69)
(/
(/ (+ 1.0 (- x x)) (+ x (pow x 2.0)))
(+ (pow x -0.5) (pow (+ x 1.0) -0.5)))
(/ 1.0 (* 2.0 (fabs (pow x 1.5))))))
double code(double x) {
double tmp;
if (x <= 1e+69) {
tmp = ((1.0 + (x - x)) / (x + pow(x, 2.0))) / (pow(x, -0.5) + pow((x + 1.0), -0.5));
} else {
tmp = 1.0 / (2.0 * fabs(pow(x, 1.5)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1d+69) then
tmp = ((1.0d0 + (x - x)) / (x + (x ** 2.0d0))) / ((x ** (-0.5d0)) + ((x + 1.0d0) ** (-0.5d0)))
else
tmp = 1.0d0 / (2.0d0 * abs((x ** 1.5d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1e+69) {
tmp = ((1.0 + (x - x)) / (x + Math.pow(x, 2.0))) / (Math.pow(x, -0.5) + Math.pow((x + 1.0), -0.5));
} else {
tmp = 1.0 / (2.0 * Math.abs(Math.pow(x, 1.5)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1e+69: tmp = ((1.0 + (x - x)) / (x + math.pow(x, 2.0))) / (math.pow(x, -0.5) + math.pow((x + 1.0), -0.5)) else: tmp = 1.0 / (2.0 * math.fabs(math.pow(x, 1.5))) return tmp
function code(x) tmp = 0.0 if (x <= 1e+69) tmp = Float64(Float64(Float64(1.0 + Float64(x - x)) / Float64(x + (x ^ 2.0))) / Float64((x ^ -0.5) + (Float64(x + 1.0) ^ -0.5))); else tmp = Float64(1.0 / Float64(2.0 * abs((x ^ 1.5)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1e+69) tmp = ((1.0 + (x - x)) / (x + (x ^ 2.0))) / ((x ^ -0.5) + ((x + 1.0) ^ -0.5)); else tmp = 1.0 / (2.0 * abs((x ^ 1.5))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1e+69], 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[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 * N[Abs[N[Power[x, 1.5], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+69}:\\
\;\;\;\;\frac{\frac{1 + \left(x - x\right)}{x + {x}^{2}}}{{x}^{-0.5} + {\left(x + 1\right)}^{-0.5}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 \cdot \left|{x}^{1.5}\right|}\\
\end{array}
\end{array}
if x < 1.0000000000000001e69Initial program 17.0%
sub-neg17.0%
flip-+16.5%
frac-times18.0%
metadata-eval18.0%
add-sqr-sqrt18.2%
distribute-neg-frac18.2%
metadata-eval18.2%
+-commutative18.2%
distribute-neg-frac18.2%
metadata-eval18.2%
+-commutative18.2%
pow1/218.2%
pow-flip18.2%
metadata-eval18.2%
Applied egg-rr18.2%
associate-*r/18.2%
associate-*l/18.2%
metadata-eval18.2%
associate-/l/17.5%
rem-square-sqrt17.7%
sub-neg17.7%
distribute-neg-frac17.7%
metadata-eval17.7%
sub-neg17.7%
distribute-neg-frac17.7%
metadata-eval17.7%
Simplified17.7%
frac-add28.7%
*-un-lft-identity28.7%
distribute-rgt-in28.8%
*-un-lft-identity28.8%
pow228.8%
Applied egg-rr28.8%
*-commutative28.8%
neg-mul-128.8%
sub-neg28.8%
associate--l+99.3%
Simplified99.3%
Applied egg-rr39.3%
expm1-def99.3%
expm1-log1p99.3%
Simplified99.3%
if 1.0000000000000001e69 < x Initial program 44.0%
flip--44.0%
clear-num44.0%
pow1/244.0%
pow-flip44.0%
metadata-eval44.0%
inv-pow44.0%
sqrt-pow244.0%
+-commutative44.0%
metadata-eval44.0%
frac-times19.7%
metadata-eval19.7%
add-sqr-sqrt16.8%
frac-times29.2%
metadata-eval29.2%
add-sqr-sqrt44.0%
Applied egg-rr44.0%
Taylor expanded in x around inf 57.9%
sqr-pow57.9%
rem-sqrt-square98.3%
metadata-eval98.3%
Simplified98.3%
Final simplification98.5%
(FPCore (x) :precision binary64 (if (<= x 6e+23) (/ (/ 1.0 (+ (pow x -0.5) (pow (+ x 1.0) -0.5))) (fma x x x)) (/ 1.0 (* 2.0 (fabs (pow x 1.5))))))
double code(double x) {
double tmp;
if (x <= 6e+23) {
tmp = (1.0 / (pow(x, -0.5) + pow((x + 1.0), -0.5))) / fma(x, x, x);
} else {
tmp = 1.0 / (2.0 * fabs(pow(x, 1.5)));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 6e+23) tmp = Float64(Float64(1.0 / Float64((x ^ -0.5) + (Float64(x + 1.0) ^ -0.5))) / fma(x, x, x)); else tmp = Float64(1.0 / Float64(2.0 * abs((x ^ 1.5)))); end return tmp end
code[x_] := If[LessEqual[x, 6e+23], N[(N[(1.0 / N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * x + x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 * N[Abs[N[Power[x, 1.5], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6 \cdot 10^{+23}:\\
\;\;\;\;\frac{\frac{1}{{x}^{-0.5} + {\left(x + 1\right)}^{-0.5}}}{\mathsf{fma}\left(x, x, x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 \cdot \left|{x}^{1.5}\right|}\\
\end{array}
\end{array}
if x < 6.0000000000000002e23Initial program 42.6%
sub-neg42.6%
flip-+41.3%
frac-times43.9%
metadata-eval43.9%
add-sqr-sqrt44.3%
distribute-neg-frac44.3%
metadata-eval44.3%
+-commutative44.3%
distribute-neg-frac44.3%
metadata-eval44.3%
+-commutative44.3%
pow1/244.3%
pow-flip44.3%
metadata-eval44.3%
Applied egg-rr44.3%
associate-*r/44.4%
associate-*l/44.4%
metadata-eval44.4%
associate-/l/43.2%
rem-square-sqrt44.8%
sub-neg44.8%
distribute-neg-frac44.8%
metadata-eval44.8%
sub-neg44.8%
distribute-neg-frac44.8%
metadata-eval44.8%
Simplified44.8%
frac-add77.2%
*-un-lft-identity77.2%
distribute-rgt-in77.5%
*-un-lft-identity77.5%
pow277.5%
Applied egg-rr77.5%
*-commutative77.5%
neg-mul-177.5%
sub-neg77.5%
associate--l+99.2%
Simplified99.2%
expm1-log1p-u99.2%
expm1-udef25.1%
Applied egg-rr25.1%
expm1-def98.9%
expm1-log1p98.9%
associate-/r*99.2%
Simplified99.2%
if 6.0000000000000002e23 < x Initial program 38.4%
flip--38.4%
clear-num38.4%
pow1/238.4%
pow-flip38.4%
metadata-eval38.4%
inv-pow38.4%
sqrt-pow238.4%
+-commutative38.4%
metadata-eval38.4%
frac-times17.6%
metadata-eval17.6%
add-sqr-sqrt15.1%
frac-times25.7%
metadata-eval25.7%
add-sqr-sqrt38.4%
Applied egg-rr38.4%
Taylor expanded in x around inf 63.6%
sqr-pow63.6%
rem-sqrt-square98.4%
metadata-eval98.4%
Simplified98.4%
Final simplification98.5%
(FPCore (x) :precision binary64 (if (<= x 1e+59) (* (/ 1.0 (+ (pow x -0.5) (pow (+ x 1.0) -0.5))) (/ 1.0 (* x (+ x 1.0)))) (/ 1.0 (* 2.0 (fabs (pow x 1.5))))))
double code(double x) {
double tmp;
if (x <= 1e+59) {
tmp = (1.0 / (pow(x, -0.5) + pow((x + 1.0), -0.5))) * (1.0 / (x * (x + 1.0)));
} else {
tmp = 1.0 / (2.0 * fabs(pow(x, 1.5)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1d+59) then
tmp = (1.0d0 / ((x ** (-0.5d0)) + ((x + 1.0d0) ** (-0.5d0)))) * (1.0d0 / (x * (x + 1.0d0)))
else
tmp = 1.0d0 / (2.0d0 * abs((x ** 1.5d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1e+59) {
tmp = (1.0 / (Math.pow(x, -0.5) + Math.pow((x + 1.0), -0.5))) * (1.0 / (x * (x + 1.0)));
} else {
tmp = 1.0 / (2.0 * Math.abs(Math.pow(x, 1.5)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1e+59: tmp = (1.0 / (math.pow(x, -0.5) + math.pow((x + 1.0), -0.5))) * (1.0 / (x * (x + 1.0))) else: tmp = 1.0 / (2.0 * math.fabs(math.pow(x, 1.5))) return tmp
function code(x) tmp = 0.0 if (x <= 1e+59) tmp = Float64(Float64(1.0 / Float64((x ^ -0.5) + (Float64(x + 1.0) ^ -0.5))) * Float64(1.0 / Float64(x * Float64(x + 1.0)))); else tmp = Float64(1.0 / Float64(2.0 * abs((x ^ 1.5)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1e+59) tmp = (1.0 / ((x ^ -0.5) + ((x + 1.0) ^ -0.5))) * (1.0 / (x * (x + 1.0))); else tmp = 1.0 / (2.0 * abs((x ^ 1.5))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1e+59], N[(N[(1.0 / N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(x * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 * N[Abs[N[Power[x, 1.5], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+59}:\\
\;\;\;\;\frac{1}{{x}^{-0.5} + {\left(x + 1\right)}^{-0.5}} \cdot \frac{1}{x \cdot \left(x + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 \cdot \left|{x}^{1.5}\right|}\\
\end{array}
\end{array}
if x < 9.99999999999999972e58Initial program 19.8%
flip--19.3%
frac-times20.7%
metadata-eval20.7%
add-sqr-sqrt21.1%
frac-times20.4%
metadata-eval20.4%
add-sqr-sqrt20.7%
+-commutative20.7%
pow1/220.7%
pow-flip20.7%
metadata-eval20.7%
inv-pow20.7%
sqrt-pow220.7%
+-commutative20.7%
metadata-eval20.7%
Applied egg-rr20.7%
div-inv20.7%
frac-sub34.2%
*-un-lft-identity34.2%
*-rgt-identity34.2%
associate-+r-99.3%
+-inverses99.3%
metadata-eval99.3%
Applied egg-rr99.3%
if 9.99999999999999972e58 < x Initial program 42.3%
flip--42.3%
clear-num42.3%
pow1/242.3%
pow-flip42.3%
metadata-eval42.3%
inv-pow42.3%
sqrt-pow242.3%
+-commutative42.3%
metadata-eval42.3%
frac-times19.1%
metadata-eval19.1%
add-sqr-sqrt16.3%
frac-times28.1%
metadata-eval28.1%
add-sqr-sqrt42.3%
Applied egg-rr42.3%
Taylor expanded in x around inf 59.6%
sqr-pow59.6%
rem-sqrt-square98.3%
metadata-eval98.3%
Simplified98.3%
Final simplification98.5%
(FPCore (x) :precision binary64 (if (<= x 1e+69) (/ (/ -1.0 (* x (- -1.0 x))) (+ (pow x -0.5) (pow (+ x 1.0) -0.5))) (/ 1.0 (* 2.0 (fabs (pow x 1.5))))))
double code(double x) {
double tmp;
if (x <= 1e+69) {
tmp = (-1.0 / (x * (-1.0 - x))) / (pow(x, -0.5) + pow((x + 1.0), -0.5));
} else {
tmp = 1.0 / (2.0 * fabs(pow(x, 1.5)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1d+69) then
tmp = ((-1.0d0) / (x * ((-1.0d0) - x))) / ((x ** (-0.5d0)) + ((x + 1.0d0) ** (-0.5d0)))
else
tmp = 1.0d0 / (2.0d0 * abs((x ** 1.5d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1e+69) {
tmp = (-1.0 / (x * (-1.0 - x))) / (Math.pow(x, -0.5) + Math.pow((x + 1.0), -0.5));
} else {
tmp = 1.0 / (2.0 * Math.abs(Math.pow(x, 1.5)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1e+69: tmp = (-1.0 / (x * (-1.0 - x))) / (math.pow(x, -0.5) + math.pow((x + 1.0), -0.5)) else: tmp = 1.0 / (2.0 * math.fabs(math.pow(x, 1.5))) return tmp
function code(x) tmp = 0.0 if (x <= 1e+69) tmp = Float64(Float64(-1.0 / Float64(x * Float64(-1.0 - x))) / Float64((x ^ -0.5) + (Float64(x + 1.0) ^ -0.5))); else tmp = Float64(1.0 / Float64(2.0 * abs((x ^ 1.5)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1e+69) tmp = (-1.0 / (x * (-1.0 - x))) / ((x ^ -0.5) + ((x + 1.0) ^ -0.5)); else tmp = 1.0 / (2.0 * abs((x ^ 1.5))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1e+69], 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[(1.0 / N[(2.0 * N[Abs[N[Power[x, 1.5], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+69}:\\
\;\;\;\;\frac{\frac{-1}{x \cdot \left(-1 - x\right)}}{{x}^{-0.5} + {\left(x + 1\right)}^{-0.5}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 \cdot \left|{x}^{1.5}\right|}\\
\end{array}
\end{array}
if x < 1.0000000000000001e69Initial program 17.0%
flip--16.5%
frac-times18.0%
metadata-eval18.0%
add-sqr-sqrt18.2%
frac-times17.4%
metadata-eval17.4%
add-sqr-sqrt17.7%
+-commutative17.7%
pow1/217.7%
pow-flip17.7%
metadata-eval17.7%
inv-pow17.7%
sqrt-pow217.7%
+-commutative17.7%
metadata-eval17.7%
Applied egg-rr17.7%
frac-2neg17.7%
metadata-eval17.7%
frac-sub28.7%
Applied egg-rr28.7%
/-rgt-identity28.7%
/-rgt-identity28.7%
*-commutative28.7%
neg-mul-128.7%
*-rgt-identity28.7%
*-lft-identity28.7%
neg-sub028.7%
associate--l-28.7%
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%
if 1.0000000000000001e69 < x Initial program 44.0%
flip--44.0%
clear-num44.0%
pow1/244.0%
pow-flip44.0%
metadata-eval44.0%
inv-pow44.0%
sqrt-pow244.0%
+-commutative44.0%
metadata-eval44.0%
frac-times19.7%
metadata-eval19.7%
add-sqr-sqrt16.8%
frac-times29.2%
metadata-eval29.2%
add-sqr-sqrt44.0%
Applied egg-rr44.0%
Taylor expanded in x around inf 57.9%
sqr-pow57.9%
rem-sqrt-square98.3%
metadata-eval98.3%
Simplified98.3%
Final simplification98.5%
(FPCore (x) :precision binary64 (if (<= x 5.5e+102) (* 0.5 (sqrt (/ 1.0 (pow x 3.0)))) (pow x -1.5)))
double code(double x) {
double tmp;
if (x <= 5.5e+102) {
tmp = 0.5 * sqrt((1.0 / pow(x, 3.0)));
} else {
tmp = pow(x, -1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 5.5d+102) then
tmp = 0.5d0 * sqrt((1.0d0 / (x ** 3.0d0)))
else
tmp = x ** (-1.5d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 5.5e+102) {
tmp = 0.5 * Math.sqrt((1.0 / Math.pow(x, 3.0)));
} else {
tmp = Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 5.5e+102: tmp = 0.5 * math.sqrt((1.0 / math.pow(x, 3.0))) else: tmp = math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 5.5e+102) tmp = Float64(0.5 * sqrt(Float64(1.0 / (x ^ 3.0)))); else tmp = x ^ -1.5; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 5.5e+102) tmp = 0.5 * sqrt((1.0 / (x ^ 3.0))); else tmp = x ^ -1.5; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 5.5e+102], N[(0.5 * N[Sqrt[N[(1.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[x, -1.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.5 \cdot 10^{+102}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-1.5}\\
\end{array}
\end{array}
if x < 5.49999999999999981e102Initial program 12.2%
flip--11.9%
clear-num11.9%
pow1/211.9%
pow-flip11.9%
metadata-eval11.9%
inv-pow11.9%
sqrt-pow211.9%
+-commutative11.9%
metadata-eval11.9%
frac-times12.9%
metadata-eval12.9%
add-sqr-sqrt13.1%
frac-times12.5%
metadata-eval12.5%
add-sqr-sqrt12.7%
Applied egg-rr12.7%
Taylor expanded in x around inf 94.2%
if 5.49999999999999981e102 < x Initial program 50.7%
sub-neg50.7%
flip-+50.7%
frac-times22.3%
metadata-eval22.3%
add-sqr-sqrt18.8%
distribute-neg-frac18.8%
metadata-eval18.8%
+-commutative18.8%
distribute-neg-frac18.8%
metadata-eval18.8%
+-commutative18.8%
pow1/218.8%
pow-flip18.8%
metadata-eval18.8%
Applied egg-rr18.8%
associate-*r/25.4%
associate-*l/25.4%
metadata-eval25.4%
associate-/l/33.4%
rem-square-sqrt50.7%
sub-neg50.7%
distribute-neg-frac50.7%
metadata-eval50.7%
sub-neg50.7%
distribute-neg-frac50.7%
metadata-eval50.7%
Simplified50.7%
frac-add50.7%
*-un-lft-identity50.7%
distribute-rgt-in50.7%
*-un-lft-identity50.7%
pow250.7%
Applied egg-rr50.7%
*-commutative50.7%
neg-mul-150.7%
sub-neg50.7%
associate--l+73.7%
Simplified73.7%
Taylor expanded in x around inf 50.7%
metadata-eval50.7%
cube-div51.2%
Simplified51.2%
expm1-log1p-u51.2%
expm1-udef50.7%
sqrt-pow150.7%
inv-pow50.7%
pow-pow50.7%
metadata-eval50.7%
metadata-eval50.7%
Applied egg-rr50.7%
expm1-def56.7%
expm1-log1p56.7%
Simplified56.7%
Final simplification68.4%
(FPCore (x) :precision binary64 (if (<= x 7.5e+107) (* 0.5 (sqrt (pow (/ 1.0 x) 3.0))) (pow x -1.5)))
double code(double x) {
double tmp;
if (x <= 7.5e+107) {
tmp = 0.5 * sqrt(pow((1.0 / x), 3.0));
} else {
tmp = pow(x, -1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 7.5d+107) then
tmp = 0.5d0 * sqrt(((1.0d0 / x) ** 3.0d0))
else
tmp = x ** (-1.5d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 7.5e+107) {
tmp = 0.5 * Math.sqrt(Math.pow((1.0 / x), 3.0));
} else {
tmp = Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 7.5e+107: tmp = 0.5 * math.sqrt(math.pow((1.0 / x), 3.0)) else: tmp = math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 7.5e+107) tmp = Float64(0.5 * sqrt((Float64(1.0 / x) ^ 3.0))); else tmp = x ^ -1.5; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 7.5e+107) tmp = 0.5 * sqrt(((1.0 / x) ^ 3.0)); else tmp = x ^ -1.5; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 7.5e+107], N[(0.5 * N[Sqrt[N[Power[N[(1.0 / x), $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[x, -1.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.5 \cdot 10^{+107}:\\
\;\;\;\;0.5 \cdot \sqrt{{\left(\frac{1}{x}\right)}^{3}}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-1.5}\\
\end{array}
\end{array}
if x < 7.4999999999999996e107Initial program 11.7%
flip--11.4%
clear-num11.4%
pow1/211.4%
pow-flip11.4%
metadata-eval11.4%
inv-pow11.4%
sqrt-pow211.4%
+-commutative11.4%
metadata-eval11.4%
frac-times12.3%
metadata-eval12.3%
add-sqr-sqrt12.5%
frac-times12.0%
metadata-eval12.0%
add-sqr-sqrt12.1%
Applied egg-rr12.1%
Taylor expanded in x around inf 88.0%
metadata-eval88.0%
cube-div91.5%
Simplified91.5%
if 7.4999999999999996e107 < x Initial program 52.4%
sub-neg52.4%
flip-+52.4%
frac-times23.0%
metadata-eval23.0%
add-sqr-sqrt19.3%
distribute-neg-frac19.3%
metadata-eval19.3%
+-commutative19.3%
distribute-neg-frac19.3%
metadata-eval19.3%
+-commutative19.3%
pow1/219.3%
pow-flip19.3%
metadata-eval19.3%
Applied egg-rr19.3%
associate-*r/26.1%
associate-*l/26.1%
metadata-eval26.1%
associate-/l/34.4%
rem-square-sqrt52.4%
sub-neg52.4%
distribute-neg-frac52.4%
metadata-eval52.4%
sub-neg52.4%
distribute-neg-frac52.4%
metadata-eval52.4%
Simplified52.4%
frac-add52.4%
*-un-lft-identity52.4%
distribute-rgt-in52.4%
*-un-lft-identity52.4%
pow252.4%
Applied egg-rr52.4%
*-commutative52.4%
neg-mul-152.4%
sub-neg52.4%
associate--l+72.8%
Simplified72.8%
Taylor expanded in x around inf 52.4%
metadata-eval52.4%
cube-div52.4%
Simplified52.4%
expm1-log1p-u52.4%
expm1-udef52.4%
sqrt-pow152.4%
inv-pow52.4%
pow-pow52.4%
metadata-eval52.4%
metadata-eval52.4%
Applied egg-rr52.4%
expm1-def58.1%
expm1-log1p58.1%
Simplified58.1%
Final simplification69.3%
(FPCore (x) :precision binary64 (/ 1.0 (* 2.0 (fabs (pow x 1.5)))))
double code(double x) {
return 1.0 / (2.0 * fabs(pow(x, 1.5)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (2.0d0 * abs((x ** 1.5d0)))
end function
public static double code(double x) {
return 1.0 / (2.0 * Math.abs(Math.pow(x, 1.5)));
}
def code(x): return 1.0 / (2.0 * math.fabs(math.pow(x, 1.5)))
function code(x) return Float64(1.0 / Float64(2.0 * abs((x ^ 1.5)))) end
function tmp = code(x) tmp = 1.0 / (2.0 * abs((x ^ 1.5))); end
code[x_] := N[(1.0 / N[(2.0 * N[Abs[N[Power[x, 1.5], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{2 \cdot \left|{x}^{1.5}\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%
Taylor expanded in x around inf 64.3%
sqr-pow64.2%
rem-sqrt-square96.8%
metadata-eval96.8%
Simplified96.8%
Final simplification96.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 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)))))