
(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 18 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 (<= x 5500.0) (* (- 1.0 (/ (sqrt x) (hypot 1.0 (sqrt x)))) (pow x -0.5)) (/ (/ 1.0 (+ (sqrt x) (sqrt (+ 1.0 x)))) (+ x (- 0.5 (/ 0.125 x))))))
double code(double x) {
double tmp;
if (x <= 5500.0) {
tmp = (1.0 - (sqrt(x) / hypot(1.0, sqrt(x)))) * pow(x, -0.5);
} else {
tmp = (1.0 / (sqrt(x) + sqrt((1.0 + x)))) / (x + (0.5 - (0.125 / x)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 5500.0) {
tmp = (1.0 - (Math.sqrt(x) / Math.hypot(1.0, Math.sqrt(x)))) * Math.pow(x, -0.5);
} else {
tmp = (1.0 / (Math.sqrt(x) + Math.sqrt((1.0 + x)))) / (x + (0.5 - (0.125 / x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 5500.0: tmp = (1.0 - (math.sqrt(x) / math.hypot(1.0, math.sqrt(x)))) * math.pow(x, -0.5) else: tmp = (1.0 / (math.sqrt(x) + math.sqrt((1.0 + x)))) / (x + (0.5 - (0.125 / x))) return tmp
function code(x) tmp = 0.0 if (x <= 5500.0) tmp = Float64(Float64(1.0 - Float64(sqrt(x) / hypot(1.0, sqrt(x)))) * (x ^ -0.5)); else tmp = Float64(Float64(1.0 / Float64(sqrt(x) + sqrt(Float64(1.0 + x)))) / Float64(x + Float64(0.5 - Float64(0.125 / x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 5500.0) tmp = (1.0 - (sqrt(x) / hypot(1.0, sqrt(x)))) * (x ^ -0.5); else tmp = (1.0 / (sqrt(x) + sqrt((1.0 + x)))) / (x + (0.5 - (0.125 / x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 5500.0], N[(N[(1.0 - N[(N[Sqrt[x], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[Sqrt[x], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + N[(0.5 - N[(0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5500:\\
\;\;\;\;\left(1 - \frac{\sqrt{x}}{\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}{x + \left(0.5 - \frac{0.125}{x}\right)}\\
\end{array}
\end{array}
if x < 5500Initial program 99.4%
frac-sub99.4%
div-inv99.4%
*-un-lft-identity99.4%
+-commutative99.4%
*-rgt-identity99.4%
metadata-eval99.4%
frac-times99.4%
un-div-inv99.4%
pow1/299.4%
pow-flip99.8%
metadata-eval99.8%
+-commutative99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
times-frac99.8%
div-sub99.8%
*-inverses99.8%
unpow199.8%
sqr-pow99.8%
metadata-eval99.8%
exp-to-pow99.8%
metadata-eval99.8%
exp-to-pow99.8%
hypot-1-def99.8%
exp-to-pow99.8%
unpow1/299.8%
/-rgt-identity99.8%
Simplified99.8%
if 5500 < x Initial program 40.1%
frac-sub40.1%
clear-num40.1%
sqrt-unprod40.1%
+-commutative40.1%
*-un-lft-identity40.1%
*-rgt-identity40.1%
+-commutative40.1%
Applied egg-rr40.1%
associate-/r/40.1%
associate-*l/40.1%
*-lft-identity40.1%
distribute-rgt-in40.1%
*-lft-identity40.1%
Simplified40.1%
pow1/240.1%
metadata-eval40.1%
pow-pow40.1%
flip--40.0%
pow-pow40.7%
metadata-eval40.7%
pow1/240.7%
pow-pow40.8%
metadata-eval40.8%
pow1/240.8%
add-sqr-sqrt41.8%
add-sqr-sqrt43.2%
pow-pow43.2%
metadata-eval43.2%
pow1/243.2%
Applied egg-rr43.2%
associate--l+77.2%
+-inverses77.2%
metadata-eval77.2%
+-commutative77.2%
Simplified77.2%
Taylor expanded in x around inf 99.7%
+-commutative99.7%
associate--l+99.7%
associate-*r/99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 4e-11)
(/ (/ 1.0 (+ (sqrt x) t_0)) (+ x (- 0.5 (/ 0.125 x))))
(- (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-11) {
tmp = (1.0 / (sqrt(x) + t_0)) / (x + (0.5 - (0.125 / 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) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 4d-11) then
tmp = (1.0d0 / (sqrt(x) + t_0)) / (x + (0.5d0 - (0.125d0 / x)))
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-11) {
tmp = (1.0 / (Math.sqrt(x) + t_0)) / (x + (0.5 - (0.125 / x)));
} 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-11: tmp = (1.0 / (math.sqrt(x) + t_0)) / (x + (0.5 - (0.125 / x))) 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-11) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) / Float64(x + Float64(0.5 - Float64(0.125 / x)))); 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-11) tmp = (1.0 / (sqrt(x) + t_0)) / (x + (0.5 - (0.125 / x))); 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-11], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[(x + N[(0.5 - N[(0.125 / 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}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 4 \cdot 10^{-11}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + t_0}}{x + \left(0.5 - \frac{0.125}{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)))) < 3.99999999999999976e-11Initial program 40.1%
frac-sub40.1%
clear-num40.1%
sqrt-unprod40.1%
+-commutative40.1%
*-un-lft-identity40.1%
*-rgt-identity40.1%
+-commutative40.1%
Applied egg-rr40.1%
associate-/r/40.1%
associate-*l/40.1%
*-lft-identity40.1%
distribute-rgt-in40.1%
*-lft-identity40.1%
Simplified40.1%
pow1/240.1%
metadata-eval40.1%
pow-pow40.1%
flip--40.0%
pow-pow40.7%
metadata-eval40.7%
pow1/240.7%
pow-pow40.8%
metadata-eval40.8%
pow1/240.8%
add-sqr-sqrt41.8%
add-sqr-sqrt43.2%
pow-pow43.2%
metadata-eval43.2%
pow1/243.2%
Applied egg-rr43.2%
associate--l+77.2%
+-inverses77.2%
metadata-eval77.2%
+-commutative77.2%
Simplified77.2%
Taylor expanded in x around inf 99.7%
+-commutative99.7%
associate--l+99.7%
associate-*r/99.7%
metadata-eval99.7%
Simplified99.7%
if 3.99999999999999976e-11 < (-.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.8%
metadata-eval99.8%
pow1/299.8%
pow-flip99.8%
+-commutative99.8%
metadata-eval99.8%
Applied egg-rr99.8%
fma-udef99.8%
neg-mul-199.8%
rem-log-exp99.7%
log-rec99.7%
+-commutative99.7%
log-rec99.7%
rem-log-exp99.8%
sub-neg99.8%
+-inverses99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 4e-11)
(/ (/ 1.0 (+ (sqrt x) t_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)) <= 4e-11) {
tmp = (1.0 / (sqrt(x) + t_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)) <= 4d-11) then
tmp = (1.0d0 / (sqrt(x) + t_0)) / (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)) <= 4e-11) {
tmp = (1.0 / (Math.sqrt(x) + t_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)) <= 4e-11: tmp = (1.0 / (math.sqrt(x) + t_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)) <= 4e-11) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_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)) <= 4e-11) tmp = (1.0 / (sqrt(x) + t_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], 4e-11], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[(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}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 4 \cdot 10^{-11}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + t_0}}{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.99999999999999976e-11Initial program 40.1%
frac-sub40.1%
clear-num40.1%
sqrt-unprod40.1%
+-commutative40.1%
*-un-lft-identity40.1%
*-rgt-identity40.1%
+-commutative40.1%
Applied egg-rr40.1%
associate-/r/40.1%
associate-*l/40.1%
*-lft-identity40.1%
distribute-rgt-in40.1%
*-lft-identity40.1%
Simplified40.1%
pow1/240.1%
metadata-eval40.1%
pow-pow40.1%
flip--40.0%
pow-pow40.7%
metadata-eval40.7%
pow1/240.7%
pow-pow40.8%
metadata-eval40.8%
pow1/240.8%
add-sqr-sqrt41.8%
add-sqr-sqrt43.2%
pow-pow43.2%
metadata-eval43.2%
pow1/243.2%
Applied egg-rr43.2%
associate--l+77.2%
+-inverses77.2%
metadata-eval77.2%
+-commutative77.2%
Simplified77.2%
Taylor expanded in x around inf 99.6%
+-commutative99.6%
Simplified99.6%
if 3.99999999999999976e-11 < (-.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.8%
metadata-eval99.8%
pow1/299.8%
pow-flip99.8%
+-commutative99.8%
metadata-eval99.8%
Applied egg-rr99.8%
fma-udef99.8%
neg-mul-199.8%
rem-log-exp99.7%
log-rec99.7%
+-commutative99.7%
log-rec99.7%
rem-log-exp99.8%
sub-neg99.8%
+-inverses99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification99.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 5e-13)
(/ (/ 1.0 (+ (sqrt x) t_0)) x)
(- (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)) <= 5e-13) {
tmp = (1.0 / (sqrt(x) + t_0)) / 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) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 5d-13) then
tmp = (1.0d0 / (sqrt(x) + t_0)) / x
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)) <= 5e-13) {
tmp = (1.0 / (Math.sqrt(x) + t_0)) / x;
} 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)) <= 5e-13: tmp = (1.0 / (math.sqrt(x) + t_0)) / x 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)) <= 5e-13) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) / x); 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)) <= 5e-13) tmp = (1.0 / (sqrt(x) + t_0)) / x; 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], 5e-13], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / x), $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 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + t_0}}{x}\\
\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)))) < 4.9999999999999999e-13Initial program 39.6%
frac-sub39.6%
clear-num39.6%
sqrt-unprod39.6%
+-commutative39.6%
*-un-lft-identity39.6%
*-rgt-identity39.6%
+-commutative39.6%
Applied egg-rr39.6%
associate-/r/39.6%
associate-*l/39.6%
*-lft-identity39.6%
distribute-rgt-in39.6%
*-lft-identity39.6%
Simplified39.6%
pow1/239.6%
metadata-eval39.6%
pow-pow39.6%
flip--39.5%
pow-pow39.9%
metadata-eval39.9%
pow1/239.9%
pow-pow40.0%
metadata-eval40.0%
pow1/240.0%
add-sqr-sqrt41.0%
add-sqr-sqrt41.8%
pow-pow41.8%
metadata-eval41.8%
pow1/241.8%
Applied egg-rr41.8%
associate--l+76.6%
+-inverses76.6%
metadata-eval76.6%
+-commutative76.6%
Simplified76.6%
Taylor expanded in x around inf 98.8%
if 4.9999999999999999e-13 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 98.6%
*-un-lft-identity98.6%
clear-num98.6%
associate-/r/98.6%
prod-diff98.6%
*-un-lft-identity98.6%
fma-neg98.6%
*-un-lft-identity98.6%
inv-pow98.6%
sqrt-pow299.0%
metadata-eval99.0%
pow1/299.0%
pow-flip99.0%
+-commutative99.0%
metadata-eval99.0%
Applied egg-rr99.0%
fma-udef99.0%
neg-mul-199.0%
rem-log-exp98.5%
log-rec98.5%
+-commutative98.5%
log-rec98.5%
rem-log-exp99.0%
sub-neg99.0%
+-inverses99.0%
+-rgt-identity99.0%
Simplified99.0%
Final simplification98.9%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 5e-13) (* 0.5 (sqrt (/ (pow x -2.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)))) <= 5e-13) {
tmp = 0.5 * sqrt((pow(x, -2.0) / 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)))) <= 5d-13) then
tmp = 0.5d0 * sqrt(((x ** (-2.0d0)) / 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)))) <= 5e-13) {
tmp = 0.5 * Math.sqrt((Math.pow(x, -2.0) / 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)))) <= 5e-13: tmp = 0.5 * math.sqrt((math.pow(x, -2.0) / 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)))) <= 5e-13) tmp = Float64(0.5 * sqrt(Float64((x ^ -2.0) / 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)))) <= 5e-13) tmp = 0.5 * sqrt(((x ^ -2.0) / 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], 5e-13], N[(0.5 * N[Sqrt[N[(N[Power[x, -2.0], $MachinePrecision] / x), $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 5 \cdot 10^{-13}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{{x}^{-2}}{x}}\\
\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)))) < 4.9999999999999999e-13Initial program 39.6%
flip--39.5%
div-inv39.5%
frac-times24.3%
metadata-eval24.3%
add-sqr-sqrt21.5%
frac-times29.0%
metadata-eval29.0%
add-sqr-sqrt39.7%
+-commutative39.7%
pow1/239.7%
pow-flip39.7%
metadata-eval39.7%
inv-pow39.7%
sqrt-pow239.7%
+-commutative39.7%
metadata-eval39.7%
Applied egg-rr39.7%
Taylor expanded in x around inf 67.3%
unpow367.3%
unpow267.3%
associate-/r*67.4%
unpow267.4%
associate-/r*67.4%
unpow-167.4%
*-lft-identity67.4%
associate-*l/67.4%
unpow-167.4%
pow-sqr67.5%
metadata-eval67.5%
Simplified67.5%
if 4.9999999999999999e-13 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 98.6%
*-un-lft-identity98.6%
clear-num98.6%
associate-/r/98.6%
prod-diff98.6%
*-un-lft-identity98.6%
fma-neg98.6%
*-un-lft-identity98.6%
inv-pow98.6%
sqrt-pow299.0%
metadata-eval99.0%
pow1/299.0%
pow-flip99.0%
+-commutative99.0%
metadata-eval99.0%
Applied egg-rr99.0%
fma-udef99.0%
neg-mul-199.0%
rem-log-exp98.5%
log-rec98.5%
+-commutative98.5%
log-rec98.5%
rem-log-exp99.0%
sub-neg99.0%
+-inverses99.0%
+-rgt-identity99.0%
Simplified99.0%
Final simplification83.9%
(FPCore (x) :precision binary64 (/ (/ 1.0 (hypot x (sqrt x))) (+ (sqrt x) (sqrt (+ 1.0 x)))))
double code(double x) {
return (1.0 / hypot(x, sqrt(x))) / (sqrt(x) + sqrt((1.0 + x)));
}
public static double code(double x) {
return (1.0 / Math.hypot(x, Math.sqrt(x))) / (Math.sqrt(x) + Math.sqrt((1.0 + x)));
}
def code(x): return (1.0 / math.hypot(x, math.sqrt(x))) / (math.sqrt(x) + math.sqrt((1.0 + x)))
function code(x) return Float64(Float64(1.0 / hypot(x, sqrt(x))) / Float64(sqrt(x) + sqrt(Float64(1.0 + x)))) end
function tmp = code(x) tmp = (1.0 / hypot(x, sqrt(x))) / (sqrt(x) + sqrt((1.0 + x))); end
code[x_] := N[(N[(1.0 / N[Sqrt[x ^ 2 + N[Sqrt[x], $MachinePrecision] ^ 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(x, \sqrt{x}\right)}}{\sqrt{x} + \sqrt{1 + x}}
\end{array}
Initial program 70.2%
frac-sub70.3%
clear-num70.3%
sqrt-unprod70.2%
+-commutative70.2%
*-un-lft-identity70.2%
*-rgt-identity70.2%
+-commutative70.2%
Applied egg-rr70.2%
associate-/r/70.3%
associate-*l/70.3%
*-lft-identity70.3%
distribute-rgt-in70.2%
*-lft-identity70.2%
Simplified70.2%
pow1/270.2%
metadata-eval70.2%
pow-pow70.2%
flip--70.2%
pow-pow70.5%
metadata-eval70.5%
pow1/270.5%
pow-pow70.6%
metadata-eval70.6%
pow1/270.6%
add-sqr-sqrt71.1%
add-sqr-sqrt71.8%
pow-pow71.8%
metadata-eval71.8%
pow1/271.8%
Applied egg-rr71.8%
associate--l+88.5%
+-inverses88.5%
metadata-eval88.5%
+-commutative88.5%
Simplified88.5%
expm1-log1p-u85.1%
expm1-udef66.0%
associate-/l/66.0%
+-commutative66.0%
add-sqr-sqrt66.0%
hypot-def66.0%
Applied egg-rr66.0%
expm1-def95.1%
expm1-log1p98.6%
associate-/r*99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x) :precision binary64 (/ 1.0 (* (hypot x (sqrt x)) (+ (sqrt x) (sqrt (+ 1.0 x))))))
double code(double x) {
return 1.0 / (hypot(x, sqrt(x)) * (sqrt(x) + sqrt((1.0 + x))));
}
public static double code(double x) {
return 1.0 / (Math.hypot(x, Math.sqrt(x)) * (Math.sqrt(x) + Math.sqrt((1.0 + x))));
}
def code(x): return 1.0 / (math.hypot(x, math.sqrt(x)) * (math.sqrt(x) + math.sqrt((1.0 + x))))
function code(x) return Float64(1.0 / Float64(hypot(x, sqrt(x)) * Float64(sqrt(x) + sqrt(Float64(1.0 + x))))) end
function tmp = code(x) tmp = 1.0 / (hypot(x, sqrt(x)) * (sqrt(x) + sqrt((1.0 + x)))); end
code[x_] := N[(1.0 / N[(N[Sqrt[x ^ 2 + N[Sqrt[x], $MachinePrecision] ^ 2], $MachinePrecision] * N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right) \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)}
\end{array}
Initial program 70.2%
frac-sub70.3%
clear-num70.3%
sqrt-unprod70.2%
+-commutative70.2%
*-un-lft-identity70.2%
*-rgt-identity70.2%
+-commutative70.2%
Applied egg-rr70.2%
associate-/r/70.3%
associate-*l/70.3%
*-lft-identity70.3%
distribute-rgt-in70.2%
*-lft-identity70.2%
Simplified70.2%
pow1/270.2%
metadata-eval70.2%
pow-pow70.2%
flip--70.2%
pow-pow70.5%
metadata-eval70.5%
pow1/270.5%
pow-pow70.6%
metadata-eval70.6%
pow1/270.6%
add-sqr-sqrt71.1%
add-sqr-sqrt71.8%
pow-pow71.8%
metadata-eval71.8%
pow1/271.8%
Applied egg-rr71.8%
associate--l+88.5%
+-inverses88.5%
metadata-eval88.5%
+-commutative88.5%
Simplified88.5%
expm1-log1p-u85.1%
expm1-udef66.0%
associate-/l/66.0%
+-commutative66.0%
add-sqr-sqrt66.0%
hypot-def66.0%
Applied egg-rr66.0%
expm1-def95.1%
expm1-log1p98.6%
Simplified98.6%
Final simplification98.6%
(FPCore (x) :precision binary64 (if (<= x 1.7) (+ (pow x -0.5) (/ -1.0 (+ 1.0 (* x 0.5)))) (* 0.5 (sqrt (/ 1.0 (pow x 3.0))))))
double code(double x) {
double tmp;
if (x <= 1.7) {
tmp = pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5)));
} else {
tmp = 0.5 * sqrt((1.0 / pow(x, 3.0)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.7d0) then
tmp = (x ** (-0.5d0)) + ((-1.0d0) / (1.0d0 + (x * 0.5d0)))
else
tmp = 0.5d0 * sqrt((1.0d0 / (x ** 3.0d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.7) {
tmp = Math.pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5)));
} else {
tmp = 0.5 * Math.sqrt((1.0 / Math.pow(x, 3.0)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.7: tmp = math.pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5))) else: tmp = 0.5 * math.sqrt((1.0 / math.pow(x, 3.0))) return tmp
function code(x) tmp = 0.0 if (x <= 1.7) tmp = Float64((x ^ -0.5) + Float64(-1.0 / Float64(1.0 + Float64(x * 0.5)))); else tmp = Float64(0.5 * sqrt(Float64(1.0 / (x ^ 3.0)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.7) tmp = (x ^ -0.5) + (-1.0 / (1.0 + (x * 0.5))); else tmp = 0.5 * sqrt((1.0 / (x ^ 3.0))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.7], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 / N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(1.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.7:\\
\;\;\;\;{x}^{-0.5} + \frac{-1}{1 + x \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\\
\end{array}
\end{array}
if x < 1.69999999999999996Initial program 99.6%
add-log-exp7.5%
*-un-lft-identity7.5%
log-prod7.5%
metadata-eval7.5%
add-log-exp99.6%
pow1/299.6%
pow-flip100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 98.3%
*-commutative98.3%
Simplified98.3%
if 1.69999999999999996 < x Initial program 40.5%
*-un-lft-identity40.5%
clear-num40.5%
associate-/r/40.5%
prod-diff40.5%
*-un-lft-identity40.5%
fma-neg40.5%
*-un-lft-identity40.5%
inv-pow40.5%
sqrt-pow232.8%
metadata-eval32.8%
pow1/232.8%
pow-flip40.6%
+-commutative40.6%
metadata-eval40.6%
Applied egg-rr40.6%
fma-udef40.6%
neg-mul-140.6%
rem-log-exp7.1%
log-rec7.1%
+-commutative7.1%
log-rec7.1%
rem-log-exp40.6%
sub-neg40.6%
+-inverses40.6%
+-rgt-identity40.6%
Simplified40.6%
Taylor expanded in x around inf 66.8%
Final simplification82.7%
(FPCore (x) :precision binary64 (if (<= x 1.7) (+ (pow x -0.5) (/ -1.0 (+ 1.0 (* x 0.5)))) (* 0.5 (sqrt (/ (pow x -2.0) x)))))
double code(double x) {
double tmp;
if (x <= 1.7) {
tmp = pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5)));
} else {
tmp = 0.5 * sqrt((pow(x, -2.0) / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.7d0) then
tmp = (x ** (-0.5d0)) + ((-1.0d0) / (1.0d0 + (x * 0.5d0)))
else
tmp = 0.5d0 * sqrt(((x ** (-2.0d0)) / x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.7) {
tmp = Math.pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5)));
} else {
tmp = 0.5 * Math.sqrt((Math.pow(x, -2.0) / x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.7: tmp = math.pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5))) else: tmp = 0.5 * math.sqrt((math.pow(x, -2.0) / x)) return tmp
function code(x) tmp = 0.0 if (x <= 1.7) tmp = Float64((x ^ -0.5) + Float64(-1.0 / Float64(1.0 + Float64(x * 0.5)))); else tmp = Float64(0.5 * sqrt(Float64((x ^ -2.0) / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.7) tmp = (x ^ -0.5) + (-1.0 / (1.0 + (x * 0.5))); else tmp = 0.5 * sqrt(((x ^ -2.0) / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.7], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 / N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(N[Power[x, -2.0], $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.7:\\
\;\;\;\;{x}^{-0.5} + \frac{-1}{1 + x \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{{x}^{-2}}{x}}\\
\end{array}
\end{array}
if x < 1.69999999999999996Initial program 99.6%
add-log-exp7.5%
*-un-lft-identity7.5%
log-prod7.5%
metadata-eval7.5%
add-log-exp99.6%
pow1/299.6%
pow-flip100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 98.3%
*-commutative98.3%
Simplified98.3%
if 1.69999999999999996 < x Initial program 40.5%
flip--40.5%
div-inv40.5%
frac-times25.7%
metadata-eval25.7%
add-sqr-sqrt23.0%
frac-times30.3%
metadata-eval30.3%
add-sqr-sqrt40.6%
+-commutative40.6%
pow1/240.6%
pow-flip40.6%
metadata-eval40.6%
inv-pow40.6%
sqrt-pow240.6%
+-commutative40.6%
metadata-eval40.6%
Applied egg-rr40.6%
Taylor expanded in x around inf 66.8%
unpow366.8%
unpow266.8%
associate-/r*67.0%
unpow267.0%
associate-/r*67.0%
unpow-167.0%
*-lft-identity67.0%
associate-*l/66.9%
unpow-166.9%
pow-sqr67.0%
metadata-eval67.0%
Simplified67.0%
Final simplification82.8%
(FPCore (x) :precision binary64 (if (<= x 1.2) (+ (pow x -0.5) (/ -1.0 (+ 1.0 (* x 0.5)))) (* (+ (/ 1.0 x) (/ -1.0 (+ 1.0 x))) (* (sqrt x) 0.5))))
double code(double x) {
double tmp;
if (x <= 1.2) {
tmp = pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5)));
} else {
tmp = ((1.0 / x) + (-1.0 / (1.0 + x))) * (sqrt(x) * 0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.2d0) then
tmp = (x ** (-0.5d0)) + ((-1.0d0) / (1.0d0 + (x * 0.5d0)))
else
tmp = ((1.0d0 / x) + ((-1.0d0) / (1.0d0 + x))) * (sqrt(x) * 0.5d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.2) {
tmp = Math.pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5)));
} else {
tmp = ((1.0 / x) + (-1.0 / (1.0 + x))) * (Math.sqrt(x) * 0.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.2: tmp = math.pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5))) else: tmp = ((1.0 / x) + (-1.0 / (1.0 + x))) * (math.sqrt(x) * 0.5) return tmp
function code(x) tmp = 0.0 if (x <= 1.2) tmp = Float64((x ^ -0.5) + Float64(-1.0 / Float64(1.0 + Float64(x * 0.5)))); else tmp = Float64(Float64(Float64(1.0 / x) + Float64(-1.0 / Float64(1.0 + x))) * Float64(sqrt(x) * 0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.2) tmp = (x ^ -0.5) + (-1.0 / (1.0 + (x * 0.5))); else tmp = ((1.0 / x) + (-1.0 / (1.0 + x))) * (sqrt(x) * 0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.2], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 / N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] + N[(-1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[x], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.2:\\
\;\;\;\;{x}^{-0.5} + \frac{-1}{1 + x \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{x} + \frac{-1}{1 + x}\right) \cdot \left(\sqrt{x} \cdot 0.5\right)\\
\end{array}
\end{array}
if x < 1.19999999999999996Initial program 99.6%
add-log-exp7.5%
*-un-lft-identity7.5%
log-prod7.5%
metadata-eval7.5%
add-log-exp99.6%
pow1/299.6%
pow-flip100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 98.3%
*-commutative98.3%
Simplified98.3%
if 1.19999999999999996 < x Initial program 40.5%
flip--40.5%
div-inv40.5%
frac-times25.7%
metadata-eval25.7%
add-sqr-sqrt23.0%
frac-times30.3%
metadata-eval30.3%
add-sqr-sqrt40.6%
+-commutative40.6%
pow1/240.6%
pow-flip40.6%
metadata-eval40.6%
inv-pow40.6%
sqrt-pow240.6%
+-commutative40.6%
metadata-eval40.6%
Applied egg-rr40.6%
Taylor expanded in x around inf 40.1%
Final simplification69.4%
(FPCore (x) :precision binary64 (if (<= x 6.0) (+ (pow x -0.5) (/ -1.0 (+ 1.0 (* x 0.5)))) (/ 1.0 (sqrt (+ x (* x x))))))
double code(double x) {
double tmp;
if (x <= 6.0) {
tmp = pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5)));
} else {
tmp = 1.0 / sqrt((x + (x * x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 6.0d0) then
tmp = (x ** (-0.5d0)) + ((-1.0d0) / (1.0d0 + (x * 0.5d0)))
else
tmp = 1.0d0 / sqrt((x + (x * x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 6.0) {
tmp = Math.pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5)));
} else {
tmp = 1.0 / Math.sqrt((x + (x * x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 6.0: tmp = math.pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5))) else: tmp = 1.0 / math.sqrt((x + (x * x))) return tmp
function code(x) tmp = 0.0 if (x <= 6.0) tmp = Float64((x ^ -0.5) + Float64(-1.0 / Float64(1.0 + Float64(x * 0.5)))); else tmp = Float64(1.0 / sqrt(Float64(x + Float64(x * x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 6.0) tmp = (x ^ -0.5) + (-1.0 / (1.0 + (x * 0.5))); else tmp = 1.0 / sqrt((x + (x * x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 6.0], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 / N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sqrt[N[(x + N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6:\\
\;\;\;\;{x}^{-0.5} + \frac{-1}{1 + x \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{x + x \cdot x}}\\
\end{array}
\end{array}
if x < 6Initial program 99.6%
add-log-exp7.5%
*-un-lft-identity7.5%
log-prod7.5%
metadata-eval7.5%
add-log-exp99.6%
pow1/299.6%
pow-flip100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 98.3%
*-commutative98.3%
Simplified98.3%
if 6 < x Initial program 40.5%
frac-sub40.5%
clear-num40.5%
sqrt-unprod40.5%
+-commutative40.5%
*-un-lft-identity40.5%
*-rgt-identity40.5%
+-commutative40.5%
Applied egg-rr40.5%
associate-/r/40.5%
associate-*l/40.5%
*-lft-identity40.5%
distribute-rgt-in40.5%
*-lft-identity40.5%
Simplified40.5%
Taylor expanded in x around 0 38.8%
Final simplification68.8%
(FPCore (x) :precision binary64 (if (<= x 1.4) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (/ 1.0 (sqrt (+ x (* x x))))))
double code(double x) {
double tmp;
if (x <= 1.4) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = 1.0 / sqrt((x + (x * x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.4d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = 1.0d0 / sqrt((x + (x * x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.4) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = 1.0 / Math.sqrt((x + (x * x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.4: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = 1.0 / math.sqrt((x + (x * x))) return tmp
function code(x) tmp = 0.0 if (x <= 1.4) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); else tmp = Float64(1.0 / sqrt(Float64(x + Float64(x * x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.4) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = 1.0 / sqrt((x + (x * x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.4], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(1.0 / N[Sqrt[N[(x + N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.4:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{x + x \cdot x}}\\
\end{array}
\end{array}
if x < 1.3999999999999999Initial 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%
neg-mul-1100.0%
rem-log-exp100.0%
log-rec100.0%
+-commutative100.0%
log-rec100.0%
rem-log-exp100.0%
sub-neg100.0%
+-inverses100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 98.2%
if 1.3999999999999999 < x Initial program 40.5%
frac-sub40.5%
clear-num40.5%
sqrt-unprod40.5%
+-commutative40.5%
*-un-lft-identity40.5%
*-rgt-identity40.5%
+-commutative40.5%
Applied egg-rr40.5%
associate-/r/40.5%
associate-*l/40.5%
*-lft-identity40.5%
distribute-rgt-in40.5%
*-lft-identity40.5%
Simplified40.5%
Taylor expanded in x around 0 38.8%
Final simplification68.7%
(FPCore (x) :precision binary64 (if (<= x 0.7) (+ (pow x -0.5) -1.0) (/ 1.0 (sqrt (+ x (* x x))))))
double code(double x) {
double tmp;
if (x <= 0.7) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = 1.0 / sqrt((x + (x * x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.7d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = 1.0d0 / sqrt((x + (x * x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.7) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = 1.0 / Math.sqrt((x + (x * x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.7: tmp = math.pow(x, -0.5) + -1.0 else: tmp = 1.0 / math.sqrt((x + (x * x))) return tmp
function code(x) tmp = 0.0 if (x <= 0.7) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(1.0 / sqrt(Float64(x + Float64(x * x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.7) tmp = (x ^ -0.5) + -1.0; else tmp = 1.0 / sqrt((x + (x * x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.7], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(1.0 / N[Sqrt[N[(x + N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.7:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{x + x \cdot x}}\\
\end{array}
\end{array}
if x < 0.69999999999999996Initial 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%
neg-mul-1100.0%
rem-log-exp100.0%
log-rec100.0%
+-commutative100.0%
log-rec100.0%
rem-log-exp100.0%
sub-neg100.0%
+-inverses100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 97.4%
if 0.69999999999999996 < x Initial program 40.5%
frac-sub40.5%
clear-num40.5%
sqrt-unprod40.5%
+-commutative40.5%
*-un-lft-identity40.5%
*-rgt-identity40.5%
+-commutative40.5%
Applied egg-rr40.5%
associate-/r/40.5%
associate-*l/40.5%
*-lft-identity40.5%
distribute-rgt-in40.5%
*-lft-identity40.5%
Simplified40.5%
Taylor expanded in x around 0 38.8%
Final simplification68.3%
(FPCore (x) :precision binary64 (if (<= x 0.8) (+ (pow x -0.5) -1.0) (pow (* x x) -0.25)))
double code(double x) {
double tmp;
if (x <= 0.8) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = pow((x * x), -0.25);
}
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 * x) ** (-0.25d0)
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 * x), -0.25);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.8: tmp = math.pow(x, -0.5) + -1.0 else: tmp = math.pow((x * x), -0.25) return tmp
function code(x) tmp = 0.0 if (x <= 0.8) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(x * x) ^ -0.25; 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 * x) ^ -0.25; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.8], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[Power[N[(x * x), $MachinePrecision], -0.25], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.8:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;{\left(x \cdot x\right)}^{-0.25}\\
\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%
neg-mul-1100.0%
rem-log-exp100.0%
log-rec100.0%
+-commutative100.0%
log-rec100.0%
rem-log-exp100.0%
sub-neg100.0%
+-inverses100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 97.4%
if 0.80000000000000004 < x Initial program 40.5%
add-log-exp5.6%
*-un-lft-identity5.6%
log-prod5.6%
metadata-eval5.6%
add-log-exp40.5%
pow1/240.5%
pow-flip32.8%
metadata-eval32.8%
Applied egg-rr32.8%
+-lft-identity32.8%
Simplified32.8%
Taylor expanded in x around inf 5.6%
inv-pow5.6%
sqrt-pow15.6%
metadata-eval5.6%
sqr-pow5.6%
pow-prod-down38.1%
metadata-eval38.1%
Applied egg-rr38.1%
Final simplification68.0%
(FPCore (x) :precision binary64 (+ (pow x -0.5) -1.0))
double code(double x) {
return pow(x, -0.5) + -1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x ** (-0.5d0)) + (-1.0d0)
end function
public static double code(double x) {
return Math.pow(x, -0.5) + -1.0;
}
def code(x): return math.pow(x, -0.5) + -1.0
function code(x) return Float64((x ^ -0.5) + -1.0) end
function tmp = code(x) tmp = (x ^ -0.5) + -1.0; end
code[x_] := N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
{x}^{-0.5} + -1
\end{array}
Initial program 70.2%
*-un-lft-identity70.2%
clear-num70.2%
associate-/r/70.2%
prod-diff70.2%
*-un-lft-identity70.2%
fma-neg70.2%
*-un-lft-identity70.2%
inv-pow70.2%
sqrt-pow266.6%
metadata-eval66.6%
pow1/266.6%
pow-flip70.5%
+-commutative70.5%
metadata-eval70.5%
Applied egg-rr70.5%
fma-udef70.5%
neg-mul-170.5%
rem-log-exp53.9%
log-rec53.9%
+-commutative53.9%
log-rec53.9%
rem-log-exp70.5%
sub-neg70.5%
+-inverses70.5%
+-rgt-identity70.5%
Simplified70.5%
Taylor expanded in x around 0 50.3%
Final simplification50.3%
(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 70.2%
add-log-exp6.6%
*-un-lft-identity6.6%
log-prod6.6%
metadata-eval6.6%
add-log-exp70.2%
pow1/270.2%
pow-flip66.6%
metadata-eval66.6%
Applied egg-rr66.6%
+-lft-identity66.6%
Simplified66.6%
Taylor expanded in x around inf 49.4%
inv-pow49.4%
sqrt-pow149.9%
metadata-eval49.9%
expm1-log1p-u46.4%
expm1-udef62.2%
Applied egg-rr62.2%
expm1-def46.4%
expm1-log1p49.9%
Simplified49.9%
Final simplification49.9%
(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 70.2%
add-cbrt-cube54.5%
pow1/353.5%
add-sqr-sqrt53.5%
pow153.5%
pow1/253.5%
pow-prod-up53.5%
+-commutative53.5%
metadata-eval53.5%
Applied egg-rr53.5%
unpow1/354.4%
Simplified54.4%
Taylor expanded in x around 0 51.0%
*-commutative51.0%
Simplified51.0%
Taylor expanded in x around inf 4.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 70.2%
Taylor expanded in x around 0 50.1%
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 2023297
(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)))))