
(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 14 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)))) 4e-6)
(*
(+
(/ 0.5 x)
(-
(/ 0.3125 (pow x 3.0))
(+ (/ 0.375 (* x x)) (/ 0.2734375 (pow x 4.0)))))
(pow x -0.5))
(- (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)))) <= 4e-6) {
tmp = ((0.5 / x) + ((0.3125 / pow(x, 3.0)) - ((0.375 / (x * x)) + (0.2734375 / pow(x, 4.0))))) * pow(x, -0.5);
} else {
tmp = 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)))) <= 4d-6) then
tmp = ((0.5d0 / x) + ((0.3125d0 / (x ** 3.0d0)) - ((0.375d0 / (x * x)) + (0.2734375d0 / (x ** 4.0d0))))) * (x ** (-0.5d0))
else
tmp = (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)))) <= 4e-6) {
tmp = ((0.5 / x) + ((0.3125 / Math.pow(x, 3.0)) - ((0.375 / (x * x)) + (0.2734375 / Math.pow(x, 4.0))))) * Math.pow(x, -0.5);
} else {
tmp = 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)))) <= 4e-6: tmp = ((0.5 / x) + ((0.3125 / math.pow(x, 3.0)) - ((0.375 / (x * x)) + (0.2734375 / math.pow(x, 4.0))))) * math.pow(x, -0.5) else: tmp = 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)))) <= 4e-6) tmp = Float64(Float64(Float64(0.5 / x) + Float64(Float64(0.3125 / (x ^ 3.0)) - Float64(Float64(0.375 / Float64(x * x)) + Float64(0.2734375 / (x ^ 4.0))))) * (x ^ -0.5)); else tmp = 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)))) <= 4e-6) tmp = ((0.5 / x) + ((0.3125 / (x ^ 3.0)) - ((0.375 / (x * x)) + (0.2734375 / (x ^ 4.0))))) * (x ^ -0.5); else tmp = (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], 4e-6], N[(N[(N[(0.5 / x), $MachinePrecision] + N[(N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] - N[(N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(0.2734375 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 4 \cdot 10^{-6}:\\
\;\;\;\;\left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \left(\frac{0.375}{x \cdot x} + \frac{0.2734375}{{x}^{4}}\right)\right)\right) \cdot {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 3.99999999999999982e-6Initial program 40.5%
frac-sub40.6%
div-inv40.6%
*-un-lft-identity40.6%
+-commutative40.6%
*-rgt-identity40.6%
metadata-eval40.6%
frac-times40.6%
un-div-inv40.6%
pow1/240.6%
pow-flip40.6%
metadata-eval40.6%
+-commutative40.6%
Applied egg-rr40.6%
associate-*r/40.6%
*-rgt-identity40.6%
times-frac40.6%
div-sub40.6%
*-inverses40.6%
/-rgt-identity40.6%
Simplified40.6%
Taylor expanded in x around inf 99.6%
associate--l+99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*r/99.6%
metadata-eval99.6%
+-commutative99.6%
associate-*r/99.6%
metadata-eval99.6%
unpow299.6%
associate-*r/99.6%
metadata-eval99.6%
Simplified99.6%
if 3.99999999999999982e-6 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
inv-pow99.6%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 4e-6)
(*
(/ 1.0 (+ (+ x (+ 0.5 (/ 0.0625 (* x x)))) (/ -0.125 x)))
(/ 1.0 (+ (sqrt x) t_0)))
(- (pow x -0.5) (pow (+ 1.0 x) -0.5)))))
double code(double x) {
double t_0 = sqrt((1.0 + x));
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 4e-6) {
tmp = (1.0 / ((x + (0.5 + (0.0625 / (x * x)))) + (-0.125 / x))) * (1.0 / (sqrt(x) + t_0));
} else {
tmp = pow(x, -0.5) - 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 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 4d-6) then
tmp = (1.0d0 / ((x + (0.5d0 + (0.0625d0 / (x * x)))) + ((-0.125d0) / x))) * (1.0d0 / (sqrt(x) + t_0))
else
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((1.0 + x));
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 4e-6) {
tmp = (1.0 / ((x + (0.5 + (0.0625 / (x * x)))) + (-0.125 / x))) * (1.0 / (Math.sqrt(x) + t_0));
} else {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 4e-6: tmp = (1.0 / ((x + (0.5 + (0.0625 / (x * x)))) + (-0.125 / x))) * (1.0 / (math.sqrt(x) + t_0)) else: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) return tmp
function code(x) t_0 = sqrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / t_0)) <= 4e-6) tmp = Float64(Float64(1.0 / Float64(Float64(x + Float64(0.5 + Float64(0.0625 / Float64(x * x)))) + Float64(-0.125 / x))) * Float64(1.0 / Float64(sqrt(x) + t_0))); else tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((1.0 + x)); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 4e-6) tmp = (1.0 / ((x + (0.5 + (0.0625 / (x * x)))) + (-0.125 / x))) * (1.0 / (sqrt(x) + t_0)); else tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 4e-6], N[(N[(1.0 / N[(N[(x + N[(0.5 + N[(0.0625 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 4 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{\left(x + \left(0.5 + \frac{0.0625}{x \cdot x}\right)\right) + \frac{-0.125}{x}} \cdot \frac{1}{\sqrt{x} + t_0}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 3.99999999999999982e-6Initial program 40.5%
frac-sub40.6%
clear-num40.6%
sqrt-unprod40.6%
+-commutative40.6%
*-un-lft-identity40.6%
*-rgt-identity40.6%
+-commutative40.6%
Applied egg-rr40.6%
associate-/r/40.6%
Simplified40.6%
flip--41.4%
add-sqr-sqrt42.8%
add-sqr-sqrt43.0%
Applied egg-rr43.0%
associate--l+91.9%
+-inverses91.9%
metadata-eval91.9%
+-commutative91.9%
Simplified91.9%
Taylor expanded in x around inf 99.6%
sub-neg99.6%
+-commutative99.6%
+-commutative99.6%
associate-+l+99.6%
associate-*r/99.6%
metadata-eval99.6%
unpow299.6%
associate-*r/99.6%
metadata-eval99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
if 3.99999999999999982e-6 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
inv-pow99.6%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification99.8%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 2e-9) (* (pow x -0.5) (+ (/ 0.5 x) (- (/ 0.3125 (pow x 3.0)) (/ 0.375 (* x 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)))) <= 2e-9) {
tmp = pow(x, -0.5) * ((0.5 / x) + ((0.3125 / pow(x, 3.0)) - (0.375 / (x * x))));
} else {
tmp = 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)))) <= 2d-9) then
tmp = (x ** (-0.5d0)) * ((0.5d0 / x) + ((0.3125d0 / (x ** 3.0d0)) - (0.375d0 / (x * x))))
else
tmp = (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)))) <= 2e-9) {
tmp = Math.pow(x, -0.5) * ((0.5 / x) + ((0.3125 / Math.pow(x, 3.0)) - (0.375 / (x * x))));
} else {
tmp = 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)))) <= 2e-9: tmp = math.pow(x, -0.5) * ((0.5 / x) + ((0.3125 / math.pow(x, 3.0)) - (0.375 / (x * x)))) else: tmp = 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)))) <= 2e-9) tmp = Float64((x ^ -0.5) * Float64(Float64(0.5 / x) + Float64(Float64(0.3125 / (x ^ 3.0)) - Float64(0.375 / Float64(x * x))))); else tmp = 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)))) <= 2e-9) tmp = (x ^ -0.5) * ((0.5 / x) + ((0.3125 / (x ^ 3.0)) - (0.375 / (x * x)))); else tmp = (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], 2e-9], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(0.5 / x), $MachinePrecision] + N[(N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] - N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \frac{0.375}{x \cdot x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 2.00000000000000012e-9Initial program 39.8%
frac-sub39.9%
div-inv39.9%
*-un-lft-identity39.9%
+-commutative39.9%
*-rgt-identity39.9%
metadata-eval39.9%
frac-times39.9%
un-div-inv39.9%
pow1/239.9%
pow-flip39.9%
metadata-eval39.9%
+-commutative39.9%
Applied egg-rr39.9%
associate-*r/39.9%
*-rgt-identity39.9%
times-frac39.9%
div-sub39.9%
*-inverses39.9%
/-rgt-identity39.9%
Simplified39.9%
Taylor expanded in x around inf 99.7%
associate--l+99.7%
associate-*r/99.7%
metadata-eval99.7%
associate-*r/99.7%
metadata-eval99.7%
associate-*r/99.7%
metadata-eval99.7%
unpow299.7%
Simplified99.7%
if 2.00000000000000012e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.4%
*-un-lft-identity99.4%
clear-num99.4%
associate-/r/99.4%
prod-diff99.4%
*-un-lft-identity99.4%
fma-neg99.4%
*-un-lft-identity99.4%
inv-pow99.4%
sqrt-pow299.7%
metadata-eval99.7%
pow1/299.7%
pow-flip99.7%
+-commutative99.7%
metadata-eval99.7%
Applied egg-rr99.7%
fma-udef99.7%
distribute-lft1-in99.7%
metadata-eval99.7%
mul0-lft99.7%
+-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 2e-9)
(* (/ 1.0 (+ (sqrt x) t_0)) (/ 1.0 (+ x 0.5)))
(- (pow x -0.5) (pow (+ 1.0 x) -0.5)))))
double code(double x) {
double t_0 = sqrt((1.0 + x));
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 2e-9) {
tmp = (1.0 / (sqrt(x) + t_0)) * (1.0 / (x + 0.5));
} else {
tmp = pow(x, -0.5) - 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 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 2d-9) then
tmp = (1.0d0 / (sqrt(x) + t_0)) * (1.0d0 / (x + 0.5d0))
else
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((1.0 + x));
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 2e-9) {
tmp = (1.0 / (Math.sqrt(x) + t_0)) * (1.0 / (x + 0.5));
} else {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 2e-9: tmp = (1.0 / (math.sqrt(x) + t_0)) * (1.0 / (x + 0.5)) else: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) return tmp
function code(x) t_0 = sqrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / t_0)) <= 2e-9) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) * Float64(1.0 / Float64(x + 0.5))); else tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((1.0 + x)); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 2e-9) tmp = (1.0 / (sqrt(x) + t_0)) * (1.0 / (x + 0.5)); else tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 2e-9], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{\sqrt{x} + t_0} \cdot \frac{1}{x + 0.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 2.00000000000000012e-9Initial program 39.8%
frac-sub39.9%
clear-num39.9%
sqrt-unprod39.9%
+-commutative39.9%
*-un-lft-identity39.9%
*-rgt-identity39.9%
+-commutative39.9%
Applied egg-rr39.9%
associate-/r/39.9%
Simplified39.9%
flip--40.6%
add-sqr-sqrt42.0%
add-sqr-sqrt42.1%
Applied egg-rr42.1%
associate--l+91.8%
+-inverses91.8%
metadata-eval91.8%
+-commutative91.8%
Simplified91.8%
Taylor expanded in x around inf 99.4%
if 2.00000000000000012e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.4%
*-un-lft-identity99.4%
clear-num99.4%
associate-/r/99.4%
prod-diff99.4%
*-un-lft-identity99.4%
fma-neg99.4%
*-un-lft-identity99.4%
inv-pow99.4%
sqrt-pow299.7%
metadata-eval99.7%
pow1/299.7%
pow-flip99.7%
+-commutative99.7%
metadata-eval99.7%
Applied egg-rr99.7%
fma-udef99.7%
distribute-lft1-in99.7%
metadata-eval99.7%
mul0-lft99.7%
+-rgt-identity99.7%
Simplified99.7%
Final simplification99.6%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 2e-9) (* (pow x -0.5) (- (/ 0.5 x) (/ 0.375 (* x 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)))) <= 2e-9) {
tmp = pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
} else {
tmp = 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)))) <= 2d-9) then
tmp = (x ** (-0.5d0)) * ((0.5d0 / x) - (0.375d0 / (x * x)))
else
tmp = (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)))) <= 2e-9) {
tmp = Math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
} else {
tmp = 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)))) <= 2e-9: tmp = math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x))) else: tmp = 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)))) <= 2e-9) tmp = Float64((x ^ -0.5) * Float64(Float64(0.5 / x) - Float64(0.375 / Float64(x * x)))); else tmp = 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)))) <= 2e-9) tmp = (x ^ -0.5) * ((0.5 / x) - (0.375 / (x * x))); else tmp = (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], 2e-9], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(0.5 / x), $MachinePrecision] - N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} - \frac{0.375}{x \cdot x}\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 2.00000000000000012e-9Initial program 39.8%
frac-sub39.9%
div-inv39.9%
*-un-lft-identity39.9%
+-commutative39.9%
*-rgt-identity39.9%
metadata-eval39.9%
frac-times39.9%
un-div-inv39.9%
pow1/239.9%
pow-flip39.9%
metadata-eval39.9%
+-commutative39.9%
Applied egg-rr39.9%
associate-*r/39.9%
*-rgt-identity39.9%
times-frac39.9%
div-sub39.9%
*-inverses39.9%
/-rgt-identity39.9%
Simplified39.9%
Taylor expanded in x around inf 99.4%
associate-*r/99.4%
metadata-eval99.4%
associate-*r/99.4%
metadata-eval99.4%
unpow299.4%
Simplified99.4%
if 2.00000000000000012e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.4%
*-un-lft-identity99.4%
clear-num99.4%
associate-/r/99.4%
prod-diff99.4%
*-un-lft-identity99.4%
fma-neg99.4%
*-un-lft-identity99.4%
inv-pow99.4%
sqrt-pow299.7%
metadata-eval99.7%
pow1/299.7%
pow-flip99.7%
+-commutative99.7%
metadata-eval99.7%
Applied egg-rr99.7%
fma-udef99.7%
distribute-lft1-in99.7%
metadata-eval99.7%
mul0-lft99.7%
+-rgt-identity99.7%
Simplified99.7%
Final simplification99.6%
(FPCore (x) :precision binary64 (/ (/ 1.0 (hypot (sqrt x) x)) (+ (sqrt x) (sqrt (+ 1.0 x)))))
double code(double x) {
return (1.0 / hypot(sqrt(x), x)) / (sqrt(x) + sqrt((1.0 + x)));
}
public static double code(double x) {
return (1.0 / Math.hypot(Math.sqrt(x), x)) / (Math.sqrt(x) + Math.sqrt((1.0 + x)));
}
def code(x): return (1.0 / math.hypot(math.sqrt(x), x)) / (math.sqrt(x) + math.sqrt((1.0 + x)))
function code(x) return Float64(Float64(1.0 / hypot(sqrt(x), x)) / Float64(sqrt(x) + sqrt(Float64(1.0 + x)))) end
function tmp = code(x) tmp = (1.0 / hypot(sqrt(x), x)) / (sqrt(x) + sqrt((1.0 + x))); end
code[x_] := N[(N[(1.0 / N[Sqrt[N[Sqrt[x], $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{\mathsf{hypot}\left(\sqrt{x}, x\right)}}{\sqrt{x} + \sqrt{1 + x}}
\end{array}
Initial program 69.1%
frac-sub69.2%
clear-num69.2%
sqrt-unprod69.1%
+-commutative69.1%
*-un-lft-identity69.1%
*-rgt-identity69.1%
+-commutative69.1%
Applied egg-rr69.1%
associate-/r/69.2%
Simplified69.2%
flip--69.6%
add-sqr-sqrt70.3%
add-sqr-sqrt70.4%
Applied egg-rr70.4%
associate--l+95.6%
+-inverses95.6%
metadata-eval95.6%
+-commutative95.6%
Simplified95.6%
un-div-inv95.6%
distribute-rgt-in95.6%
*-un-lft-identity95.6%
add-sqr-sqrt95.6%
hypot-def99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x) :precision binary64 (if (<= x 1.06) (+ (pow x -0.5) (- -1.0 (* x -0.5))) (* (pow x -0.5) (- (/ 0.5 x) (/ 0.375 (* x x))))))
double code(double x) {
double tmp;
if (x <= 1.06) {
tmp = pow(x, -0.5) + (-1.0 - (x * -0.5));
} else {
tmp = pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.06d0) then
tmp = (x ** (-0.5d0)) + ((-1.0d0) - (x * (-0.5d0)))
else
tmp = (x ** (-0.5d0)) * ((0.5d0 / x) - (0.375d0 / (x * x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.06) {
tmp = Math.pow(x, -0.5) + (-1.0 - (x * -0.5));
} else {
tmp = Math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.06: tmp = math.pow(x, -0.5) + (-1.0 - (x * -0.5)) else: tmp = math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x))) return tmp
function code(x) tmp = 0.0 if (x <= 1.06) tmp = Float64((x ^ -0.5) + Float64(-1.0 - Float64(x * -0.5))); else tmp = Float64((x ^ -0.5) * Float64(Float64(0.5 / x) - Float64(0.375 / Float64(x * x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.06) tmp = (x ^ -0.5) + (-1.0 - (x * -0.5)); else tmp = (x ^ -0.5) * ((0.5 / x) - (0.375 / (x * x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.06], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 - N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(0.5 / x), $MachinePrecision] - N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.06:\\
\;\;\;\;{x}^{-0.5} + \left(-1 - x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} - \frac{0.375}{x \cdot x}\right)\\
\end{array}
\end{array}
if x < 1.0600000000000001Initial program 99.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
inv-pow99.6%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 99.0%
if 1.0600000000000001 < x Initial program 40.5%
frac-sub40.6%
div-inv40.6%
*-un-lft-identity40.6%
+-commutative40.6%
*-rgt-identity40.6%
metadata-eval40.6%
frac-times40.6%
un-div-inv40.6%
pow1/240.6%
pow-flip40.6%
metadata-eval40.6%
+-commutative40.6%
Applied egg-rr40.6%
associate-*r/40.6%
*-rgt-identity40.6%
times-frac40.6%
div-sub40.6%
*-inverses40.6%
/-rgt-identity40.6%
Simplified40.6%
Taylor expanded in x around inf 98.8%
associate-*r/98.8%
metadata-eval98.8%
associate-*r/98.8%
metadata-eval98.8%
unpow298.8%
Simplified98.8%
Final simplification98.9%
(FPCore (x) :precision binary64 (if (<= x 1.0) (+ (pow x -0.5) (- -1.0 (* x -0.5))) (* (/ 0.5 x) (pow x -0.5))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = pow(x, -0.5) + (-1.0 - (x * -0.5));
} else {
tmp = (0.5 / x) * pow(x, -0.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)) + ((-1.0d0) - (x * (-0.5d0)))
else
tmp = (0.5d0 / x) * (x ** (-0.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) + (-1.0 - (x * -0.5));
} else {
tmp = (0.5 / x) * Math.pow(x, -0.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = math.pow(x, -0.5) + (-1.0 - (x * -0.5)) else: tmp = (0.5 / x) * math.pow(x, -0.5) return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = Float64((x ^ -0.5) + Float64(-1.0 - Float64(x * -0.5))); else tmp = Float64(Float64(0.5 / x) * (x ^ -0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = (x ^ -0.5) + (-1.0 - (x * -0.5)); else tmp = (0.5 / x) * (x ^ -0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 - N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;{x}^{-0.5} + \left(-1 - x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{x} \cdot {x}^{-0.5}\\
\end{array}
\end{array}
if x < 1Initial program 99.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
inv-pow99.6%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 99.0%
if 1 < x Initial program 40.5%
frac-sub40.6%
div-inv40.6%
*-un-lft-identity40.6%
+-commutative40.6%
*-rgt-identity40.6%
metadata-eval40.6%
frac-times40.6%
un-div-inv40.6%
pow1/240.6%
pow-flip40.6%
metadata-eval40.6%
+-commutative40.6%
Applied egg-rr40.6%
associate-*r/40.6%
*-rgt-identity40.6%
times-frac40.6%
div-sub40.6%
*-inverses40.6%
/-rgt-identity40.6%
Simplified40.6%
Taylor expanded in x around inf 97.3%
Final simplification98.1%
(FPCore (x) :precision binary64 (if (<= x 0.68) (+ (pow x -0.5) -1.0) (* (/ 0.5 x) (pow x -0.5))))
double code(double x) {
double tmp;
if (x <= 0.68) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = (0.5 / x) * pow(x, -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.68d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = (0.5d0 / x) * (x ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.68) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = (0.5 / x) * Math.pow(x, -0.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.68: tmp = math.pow(x, -0.5) + -1.0 else: tmp = (0.5 / x) * math.pow(x, -0.5) return tmp
function code(x) tmp = 0.0 if (x <= 0.68) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(Float64(0.5 / x) * (x ^ -0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.68) tmp = (x ^ -0.5) + -1.0; else tmp = (0.5 / x) * (x ^ -0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.68], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{x} \cdot {x}^{-0.5}\\
\end{array}
\end{array}
if x < 0.680000000000000049Initial program 99.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
inv-pow99.6%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 99.1%
if 0.680000000000000049 < x Initial program 40.9%
frac-sub41.0%
div-inv41.0%
*-un-lft-identity41.0%
+-commutative41.0%
*-rgt-identity41.0%
metadata-eval41.0%
frac-times41.0%
un-div-inv41.0%
pow1/241.0%
pow-flip41.0%
metadata-eval41.0%
+-commutative41.0%
Applied egg-rr41.0%
associate-*r/41.0%
*-rgt-identity41.0%
times-frac41.0%
div-sub41.0%
*-inverses41.0%
/-rgt-identity41.0%
Simplified41.0%
Taylor expanded in x around inf 96.7%
Final simplification97.8%
(FPCore (x) :precision binary64 (if (<= x 0.44) (+ (pow x -0.5) -1.0) (* (sqrt (/ 1.0 x)) 0.3333333333333333)))
double code(double x) {
double tmp;
if (x <= 0.44) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = sqrt((1.0 / x)) * 0.3333333333333333;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.44d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = sqrt((1.0d0 / x)) * 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.44) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = Math.sqrt((1.0 / x)) * 0.3333333333333333;
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.44: tmp = math.pow(x, -0.5) + -1.0 else: tmp = math.sqrt((1.0 / x)) * 0.3333333333333333 return tmp
function code(x) tmp = 0.0 if (x <= 0.44) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(sqrt(Float64(1.0 / x)) * 0.3333333333333333); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.44) tmp = (x ^ -0.5) + -1.0; else tmp = sqrt((1.0 / x)) * 0.3333333333333333; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.44], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.44:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{1}{x}} \cdot 0.3333333333333333\\
\end{array}
\end{array}
if x < 0.440000000000000002Initial program 99.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
inv-pow99.6%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 99.1%
if 0.440000000000000002 < x Initial program 40.9%
sub-neg40.9%
flip3-+40.9%
inv-pow40.9%
pow-pow40.8%
metadata-eval40.8%
distribute-neg-frac40.8%
metadata-eval40.8%
+-commutative40.8%
frac-times40.8%
metadata-eval40.8%
add-sqr-sqrt40.8%
Applied egg-rr40.8%
Simplified38.1%
Taylor expanded in x around inf 6.0%
*-commutative6.0%
Simplified6.0%
Final simplification50.7%
(FPCore (x) :precision binary64 (if (<= x 0.8) (+ (pow x -0.5) -1.0) (pow x -0.5)))
double code(double x) {
double tmp;
if (x <= 0.8) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = pow(x, -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.8d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = x ** (-0.5d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.8) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = Math.pow(x, -0.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.8: tmp = math.pow(x, -0.5) + -1.0 else: tmp = math.pow(x, -0.5) return tmp
function code(x) tmp = 0.0 if (x <= 0.8) tmp = Float64((x ^ -0.5) + -1.0); else tmp = x ^ -0.5; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.8) tmp = (x ^ -0.5) + -1.0; else tmp = x ^ -0.5; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.8], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[Power[x, -0.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.8:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5}\\
\end{array}
\end{array}
if x < 0.80000000000000004Initial program 99.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
inv-pow99.6%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 98.4%
if 0.80000000000000004 < x Initial program 40.5%
frac-sub40.6%
div-inv40.6%
*-un-lft-identity40.6%
+-commutative40.6%
*-rgt-identity40.6%
metadata-eval40.6%
frac-times40.6%
un-div-inv40.6%
pow1/240.6%
pow-flip40.6%
metadata-eval40.6%
+-commutative40.6%
Applied egg-rr40.6%
associate-*r/40.6%
*-rgt-identity40.6%
times-frac40.6%
div-sub40.6%
*-inverses40.6%
/-rgt-identity40.6%
Simplified40.6%
Taylor expanded in x around 0 5.8%
Final simplification50.7%
(FPCore (x) :precision binary64 (pow x -0.5))
double code(double x) {
return pow(x, -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x ** (-0.5d0)
end function
public static double code(double x) {
return Math.pow(x, -0.5);
}
def code(x): return math.pow(x, -0.5)
function code(x) return x ^ -0.5 end
function tmp = code(x) tmp = x ^ -0.5; end
code[x_] := N[Power[x, -0.5], $MachinePrecision]
\begin{array}{l}
\\
{x}^{-0.5}
\end{array}
Initial program 69.1%
frac-sub69.2%
div-inv69.2%
*-un-lft-identity69.2%
+-commutative69.2%
*-rgt-identity69.2%
metadata-eval69.2%
frac-times69.2%
un-div-inv69.2%
pow1/269.2%
pow-flip69.3%
metadata-eval69.3%
+-commutative69.3%
Applied egg-rr69.3%
associate-*r/69.3%
*-rgt-identity69.3%
times-frac69.3%
div-sub69.3%
*-inverses69.3%
/-rgt-identity69.3%
Simplified69.3%
Taylor expanded in x around 0 48.6%
Final simplification48.6%
(FPCore (x) :precision binary64 (* x 0.5))
double code(double x) {
return x * 0.5;
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * 0.5d0
end function
public static double code(double x) {
return x * 0.5;
}
def code(x): return x * 0.5
function code(x) return Float64(x * 0.5) end
function tmp = code(x) tmp = x * 0.5; end
code[x_] := N[(x * 0.5), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5
\end{array}
Initial program 69.1%
*-un-lft-identity69.1%
clear-num69.1%
associate-/r/69.1%
prod-diff69.1%
*-un-lft-identity69.1%
fma-neg69.1%
*-un-lft-identity69.1%
inv-pow69.1%
sqrt-pow266.3%
metadata-eval66.3%
pow1/266.3%
pow-flip69.4%
+-commutative69.4%
metadata-eval69.4%
Applied egg-rr69.4%
fma-udef69.4%
distribute-lft1-in69.4%
metadata-eval69.4%
mul0-lft69.4%
+-rgt-identity69.4%
Simplified69.4%
Taylor expanded in x around 0 49.8%
Taylor expanded in x around inf 4.1%
*-commutative4.1%
Simplified4.1%
Final simplification4.1%
(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 69.1%
Taylor expanded in x around 0 48.8%
Taylor expanded in x around inf 1.9%
Final simplification1.9%
(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 2023215
(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)))))