
(FPCore (p x) :precision binary64 (sqrt (* 0.5 (+ 1.0 (/ x (sqrt (+ (* (* 4.0 p) p) (* x x))))))))
double code(double p, double x) {
return sqrt((0.5 * (1.0 + (x / sqrt((((4.0 * p) * p) + (x * x)))))));
}
real(8) function code(p, x)
real(8), intent (in) :: p
real(8), intent (in) :: x
code = sqrt((0.5d0 * (1.0d0 + (x / sqrt((((4.0d0 * p) * p) + (x * x)))))))
end function
public static double code(double p, double x) {
return Math.sqrt((0.5 * (1.0 + (x / Math.sqrt((((4.0 * p) * p) + (x * x)))))));
}
def code(p, x): return math.sqrt((0.5 * (1.0 + (x / math.sqrt((((4.0 * p) * p) + (x * x)))))))
function code(p, x) return sqrt(Float64(0.5 * Float64(1.0 + Float64(x / sqrt(Float64(Float64(Float64(4.0 * p) * p) + Float64(x * x))))))) end
function tmp = code(p, x) tmp = sqrt((0.5 * (1.0 + (x / sqrt((((4.0 * p) * p) + (x * x))))))); end
code[p_, x_] := N[Sqrt[N[(0.5 * N[(1.0 + N[(x / N[Sqrt[N[(N[(N[(4.0 * p), $MachinePrecision] * p), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (p x) :precision binary64 (sqrt (* 0.5 (+ 1.0 (/ x (sqrt (+ (* (* 4.0 p) p) (* x x))))))))
double code(double p, double x) {
return sqrt((0.5 * (1.0 + (x / sqrt((((4.0 * p) * p) + (x * x)))))));
}
real(8) function code(p, x)
real(8), intent (in) :: p
real(8), intent (in) :: x
code = sqrt((0.5d0 * (1.0d0 + (x / sqrt((((4.0d0 * p) * p) + (x * x)))))))
end function
public static double code(double p, double x) {
return Math.sqrt((0.5 * (1.0 + (x / Math.sqrt((((4.0 * p) * p) + (x * x)))))));
}
def code(p, x): return math.sqrt((0.5 * (1.0 + (x / math.sqrt((((4.0 * p) * p) + (x * x)))))))
function code(p, x) return sqrt(Float64(0.5 * Float64(1.0 + Float64(x / sqrt(Float64(Float64(Float64(4.0 * p) * p) + Float64(x * x))))))) end
function tmp = code(p, x) tmp = sqrt((0.5 * (1.0 + (x / sqrt((((4.0 * p) * p) + (x * x))))))); end
code[p_, x_] := N[Sqrt[N[(0.5 * N[(1.0 + N[(x / N[Sqrt[N[(N[(N[(4.0 * p), $MachinePrecision] * p), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\end{array}
p_m = (fabs.f64 p) (FPCore (p_m x) :precision binary64 (if (<= (/ x (sqrt (+ (* p_m (* 4.0 p_m)) (* x x)))) -0.99998) (/ (+ p_m (* (/ (pow p_m 3.0) (pow x 2.0)) -1.5)) (- x)) (sqrt (* 0.5 (log (exp (+ 1.0 (/ x (hypot x (* p_m 2.0))))))))))
p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if ((x / sqrt(((p_m * (4.0 * p_m)) + (x * x)))) <= -0.99998) {
tmp = (p_m + ((pow(p_m, 3.0) / pow(x, 2.0)) * -1.5)) / -x;
} else {
tmp = sqrt((0.5 * log(exp((1.0 + (x / hypot(x, (p_m * 2.0))))))));
}
return tmp;
}
p_m = Math.abs(p);
public static double code(double p_m, double x) {
double tmp;
if ((x / Math.sqrt(((p_m * (4.0 * p_m)) + (x * x)))) <= -0.99998) {
tmp = (p_m + ((Math.pow(p_m, 3.0) / Math.pow(x, 2.0)) * -1.5)) / -x;
} else {
tmp = Math.sqrt((0.5 * Math.log(Math.exp((1.0 + (x / Math.hypot(x, (p_m * 2.0))))))));
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if (x / math.sqrt(((p_m * (4.0 * p_m)) + (x * x)))) <= -0.99998: tmp = (p_m + ((math.pow(p_m, 3.0) / math.pow(x, 2.0)) * -1.5)) / -x else: tmp = math.sqrt((0.5 * math.log(math.exp((1.0 + (x / math.hypot(x, (p_m * 2.0)))))))) return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (Float64(x / sqrt(Float64(Float64(p_m * Float64(4.0 * p_m)) + Float64(x * x)))) <= -0.99998) tmp = Float64(Float64(p_m + Float64(Float64((p_m ^ 3.0) / (x ^ 2.0)) * -1.5)) / Float64(-x)); else tmp = sqrt(Float64(0.5 * log(exp(Float64(1.0 + Float64(x / hypot(x, Float64(p_m * 2.0)))))))); end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) tmp = 0.0; if ((x / sqrt(((p_m * (4.0 * p_m)) + (x * x)))) <= -0.99998) tmp = (p_m + (((p_m ^ 3.0) / (x ^ 2.0)) * -1.5)) / -x; else tmp = sqrt((0.5 * log(exp((1.0 + (x / hypot(x, (p_m * 2.0)))))))); end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[N[(x / N[Sqrt[N[(N[(p$95$m * N[(4.0 * p$95$m), $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.99998], N[(N[(p$95$m + N[(N[(N[Power[p$95$m, 3.0], $MachinePrecision] / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision] / (-x)), $MachinePrecision], N[Sqrt[N[(0.5 * N[Log[N[Exp[N[(1.0 + N[(x / N[Sqrt[x ^ 2 + N[(p$95$m * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{\sqrt{p\_m \cdot \left(4 \cdot p\_m\right) + x \cdot x}} \leq -0.99998:\\
\;\;\;\;\frac{p\_m + \frac{{p\_m}^{3}}{{x}^{2}} \cdot -1.5}{-x}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 \cdot \log \left(e^{1 + \frac{x}{\mathsf{hypot}\left(x, p\_m \cdot 2\right)}}\right)}\\
\end{array}
\end{array}
if (/.f64 x (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal 4 binary64) p) p) (*.f64 x x)))) < -0.99997999999999998Initial program 21.2%
+-commutative21.2%
sqr-neg21.2%
associate-*l*21.2%
sqr-neg21.2%
fma-define21.2%
sqr-neg21.2%
fma-define21.2%
associate-*l*21.2%
+-commutative21.2%
Simplified21.2%
Taylor expanded in x around -inf 61.8%
mul-1-neg61.8%
distribute-rgt-out61.8%
metadata-eval61.8%
Simplified61.8%
Taylor expanded in x around inf 66.4%
*-commutative66.4%
Simplified66.4%
if -0.99997999999999998 < (/.f64 x (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal 4 binary64) p) p) (*.f64 x x)))) Initial program 99.9%
add-log-exp99.9%
+-commutative99.9%
associate-*r*99.9%
fma-undefine99.9%
fma-undefine99.9%
associate-*r*99.9%
add-sqr-sqrt99.9%
hypot-define99.9%
associate-*r*99.9%
*-commutative99.9%
sqrt-prod99.9%
sqrt-prod47.6%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification90.9%
p_m = (fabs.f64 p) (FPCore (p_m x) :precision binary64 (if (<= (/ x (sqrt (+ (* p_m (* 4.0 p_m)) (* x x)))) -0.99998) (/ (+ p_m (* (/ (pow p_m 3.0) (pow x 2.0)) -1.5)) (- x)) (sqrt (* 0.5 (fma x (/ 1.0 (hypot x (* p_m 2.0))) 1.0)))))
p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if ((x / sqrt(((p_m * (4.0 * p_m)) + (x * x)))) <= -0.99998) {
tmp = (p_m + ((pow(p_m, 3.0) / pow(x, 2.0)) * -1.5)) / -x;
} else {
tmp = sqrt((0.5 * fma(x, (1.0 / hypot(x, (p_m * 2.0))), 1.0)));
}
return tmp;
}
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (Float64(x / sqrt(Float64(Float64(p_m * Float64(4.0 * p_m)) + Float64(x * x)))) <= -0.99998) tmp = Float64(Float64(p_m + Float64(Float64((p_m ^ 3.0) / (x ^ 2.0)) * -1.5)) / Float64(-x)); else tmp = sqrt(Float64(0.5 * fma(x, Float64(1.0 / hypot(x, Float64(p_m * 2.0))), 1.0))); end return tmp end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[N[(x / N[Sqrt[N[(N[(p$95$m * N[(4.0 * p$95$m), $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.99998], N[(N[(p$95$m + N[(N[(N[Power[p$95$m, 3.0], $MachinePrecision] / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision] / (-x)), $MachinePrecision], N[Sqrt[N[(0.5 * N[(x * N[(1.0 / N[Sqrt[x ^ 2 + N[(p$95$m * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{\sqrt{p\_m \cdot \left(4 \cdot p\_m\right) + x \cdot x}} \leq -0.99998:\\
\;\;\;\;\frac{p\_m + \frac{{p\_m}^{3}}{{x}^{2}} \cdot -1.5}{-x}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 \cdot \mathsf{fma}\left(x, \frac{1}{\mathsf{hypot}\left(x, p\_m \cdot 2\right)}, 1\right)}\\
\end{array}
\end{array}
if (/.f64 x (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal 4 binary64) p) p) (*.f64 x x)))) < -0.99997999999999998Initial program 21.2%
+-commutative21.2%
sqr-neg21.2%
associate-*l*21.2%
sqr-neg21.2%
fma-define21.2%
sqr-neg21.2%
fma-define21.2%
associate-*l*21.2%
+-commutative21.2%
Simplified21.2%
Taylor expanded in x around -inf 61.8%
mul-1-neg61.8%
distribute-rgt-out61.8%
metadata-eval61.8%
Simplified61.8%
Taylor expanded in x around inf 66.4%
*-commutative66.4%
Simplified66.4%
if -0.99997999999999998 < (/.f64 x (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal 4 binary64) p) p) (*.f64 x x)))) Initial program 99.9%
+-commutative99.9%
div-inv99.9%
+-commutative99.9%
associate-*r*99.9%
fma-undefine99.9%
fma-define99.9%
Applied egg-rr99.9%
Final simplification90.9%
p_m = (fabs.f64 p) (FPCore (p_m x) :precision binary64 (if (<= (/ x (sqrt (+ (* p_m (* 4.0 p_m)) (* x x)))) -0.99998) (/ (+ p_m (* (/ (pow p_m 3.0) (pow x 2.0)) -1.5)) (- x)) (sqrt (* 0.5 (+ 1.0 (/ x (hypot x (* p_m 2.0))))))))
p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if ((x / sqrt(((p_m * (4.0 * p_m)) + (x * x)))) <= -0.99998) {
tmp = (p_m + ((pow(p_m, 3.0) / pow(x, 2.0)) * -1.5)) / -x;
} else {
tmp = sqrt((0.5 * (1.0 + (x / hypot(x, (p_m * 2.0))))));
}
return tmp;
}
p_m = Math.abs(p);
public static double code(double p_m, double x) {
double tmp;
if ((x / Math.sqrt(((p_m * (4.0 * p_m)) + (x * x)))) <= -0.99998) {
tmp = (p_m + ((Math.pow(p_m, 3.0) / Math.pow(x, 2.0)) * -1.5)) / -x;
} else {
tmp = Math.sqrt((0.5 * (1.0 + (x / Math.hypot(x, (p_m * 2.0))))));
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if (x / math.sqrt(((p_m * (4.0 * p_m)) + (x * x)))) <= -0.99998: tmp = (p_m + ((math.pow(p_m, 3.0) / math.pow(x, 2.0)) * -1.5)) / -x else: tmp = math.sqrt((0.5 * (1.0 + (x / math.hypot(x, (p_m * 2.0)))))) return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (Float64(x / sqrt(Float64(Float64(p_m * Float64(4.0 * p_m)) + Float64(x * x)))) <= -0.99998) tmp = Float64(Float64(p_m + Float64(Float64((p_m ^ 3.0) / (x ^ 2.0)) * -1.5)) / Float64(-x)); else tmp = sqrt(Float64(0.5 * Float64(1.0 + Float64(x / hypot(x, Float64(p_m * 2.0)))))); end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) tmp = 0.0; if ((x / sqrt(((p_m * (4.0 * p_m)) + (x * x)))) <= -0.99998) tmp = (p_m + (((p_m ^ 3.0) / (x ^ 2.0)) * -1.5)) / -x; else tmp = sqrt((0.5 * (1.0 + (x / hypot(x, (p_m * 2.0)))))); end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[N[(x / N[Sqrt[N[(N[(p$95$m * N[(4.0 * p$95$m), $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.99998], N[(N[(p$95$m + N[(N[(N[Power[p$95$m, 3.0], $MachinePrecision] / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision] / (-x)), $MachinePrecision], N[Sqrt[N[(0.5 * N[(1.0 + N[(x / N[Sqrt[x ^ 2 + N[(p$95$m * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{\sqrt{p\_m \cdot \left(4 \cdot p\_m\right) + x \cdot x}} \leq -0.99998:\\
\;\;\;\;\frac{p\_m + \frac{{p\_m}^{3}}{{x}^{2}} \cdot -1.5}{-x}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 \cdot \left(1 + \frac{x}{\mathsf{hypot}\left(x, p\_m \cdot 2\right)}\right)}\\
\end{array}
\end{array}
if (/.f64 x (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal 4 binary64) p) p) (*.f64 x x)))) < -0.99997999999999998Initial program 21.2%
+-commutative21.2%
sqr-neg21.2%
associate-*l*21.2%
sqr-neg21.2%
fma-define21.2%
sqr-neg21.2%
fma-define21.2%
associate-*l*21.2%
+-commutative21.2%
Simplified21.2%
Taylor expanded in x around -inf 61.8%
mul-1-neg61.8%
distribute-rgt-out61.8%
metadata-eval61.8%
Simplified61.8%
Taylor expanded in x around inf 66.4%
*-commutative66.4%
Simplified66.4%
if -0.99997999999999998 < (/.f64 x (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal 4 binary64) p) p) (*.f64 x x)))) Initial program 99.9%
+-commutative99.9%
sqr-neg99.9%
associate-*l*99.9%
sqr-neg99.9%
fma-define99.9%
sqr-neg99.9%
fma-define99.9%
associate-*l*99.9%
+-commutative99.9%
Simplified99.9%
*-commutative99.9%
fma-undefine99.9%
associate-*r*99.9%
+-commutative99.9%
distribute-rgt1-in99.9%
+-commutative99.9%
Applied egg-rr99.9%
Final simplification90.8%
p_m = (fabs.f64 p) (FPCore (p_m x) :precision binary64 (if (<= x -1.2e+30) (/ p_m (- x)) (sqrt (* 0.5 (+ 1.0 (/ x (hypot x (* p_m 2.0))))))))
p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (x <= -1.2e+30) {
tmp = p_m / -x;
} else {
tmp = sqrt((0.5 * (1.0 + (x / hypot(x, (p_m * 2.0))))));
}
return tmp;
}
p_m = Math.abs(p);
public static double code(double p_m, double x) {
double tmp;
if (x <= -1.2e+30) {
tmp = p_m / -x;
} else {
tmp = Math.sqrt((0.5 * (1.0 + (x / Math.hypot(x, (p_m * 2.0))))));
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if x <= -1.2e+30: tmp = p_m / -x else: tmp = math.sqrt((0.5 * (1.0 + (x / math.hypot(x, (p_m * 2.0)))))) return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (x <= -1.2e+30) tmp = Float64(p_m / Float64(-x)); else tmp = sqrt(Float64(0.5 * Float64(1.0 + Float64(x / hypot(x, Float64(p_m * 2.0)))))); end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) tmp = 0.0; if (x <= -1.2e+30) tmp = p_m / -x; else tmp = sqrt((0.5 * (1.0 + (x / hypot(x, (p_m * 2.0)))))); end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[x, -1.2e+30], N[(p$95$m / (-x)), $MachinePrecision], N[Sqrt[N[(0.5 * N[(1.0 + N[(x / N[Sqrt[x ^ 2 + N[(p$95$m * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{+30}:\\
\;\;\;\;\frac{p\_m}{-x}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 \cdot \left(1 + \frac{x}{\mathsf{hypot}\left(x, p\_m \cdot 2\right)}\right)}\\
\end{array}
\end{array}
if x < -1.2e30Initial program 45.6%
+-commutative45.6%
sqr-neg45.6%
associate-*l*45.6%
sqr-neg45.6%
fma-define45.6%
sqr-neg45.6%
fma-define45.6%
associate-*l*45.6%
+-commutative45.6%
Simplified45.6%
Taylor expanded in x around -inf 54.2%
mul-1-neg54.2%
distribute-neg-frac254.2%
Simplified54.2%
if -1.2e30 < x Initial program 88.6%
+-commutative88.6%
sqr-neg88.6%
associate-*l*88.6%
sqr-neg88.6%
fma-define88.6%
sqr-neg88.6%
fma-define88.6%
associate-*l*88.6%
+-commutative88.6%
Simplified88.6%
*-commutative88.6%
fma-undefine88.6%
associate-*r*88.6%
+-commutative88.6%
distribute-rgt1-in88.6%
+-commutative88.6%
Applied egg-rr88.6%
Final simplification80.7%
p_m = (fabs.f64 p)
(FPCore (p_m x)
:precision binary64
(if (<= p_m 2.4e-224)
(/ p_m (- x))
(if (<= p_m 5.5e-78)
(+ 1.0 (/ 1.0 (* -2.0 (* (/ x p_m) (/ x p_m)))))
(if (<= p_m 3e-15)
(/ -1.0 (* p_m (+ (/ 1.5 x) (/ x (pow p_m 2.0)))))
(sqrt 0.5)))))p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (p_m <= 2.4e-224) {
tmp = p_m / -x;
} else if (p_m <= 5.5e-78) {
tmp = 1.0 + (1.0 / (-2.0 * ((x / p_m) * (x / p_m))));
} else if (p_m <= 3e-15) {
tmp = -1.0 / (p_m * ((1.5 / x) + (x / pow(p_m, 2.0))));
} else {
tmp = sqrt(0.5);
}
return tmp;
}
p_m = abs(p)
real(8) function code(p_m, x)
real(8), intent (in) :: p_m
real(8), intent (in) :: x
real(8) :: tmp
if (p_m <= 2.4d-224) then
tmp = p_m / -x
else if (p_m <= 5.5d-78) then
tmp = 1.0d0 + (1.0d0 / ((-2.0d0) * ((x / p_m) * (x / p_m))))
else if (p_m <= 3d-15) then
tmp = (-1.0d0) / (p_m * ((1.5d0 / x) + (x / (p_m ** 2.0d0))))
else
tmp = sqrt(0.5d0)
end if
code = tmp
end function
p_m = Math.abs(p);
public static double code(double p_m, double x) {
double tmp;
if (p_m <= 2.4e-224) {
tmp = p_m / -x;
} else if (p_m <= 5.5e-78) {
tmp = 1.0 + (1.0 / (-2.0 * ((x / p_m) * (x / p_m))));
} else if (p_m <= 3e-15) {
tmp = -1.0 / (p_m * ((1.5 / x) + (x / Math.pow(p_m, 2.0))));
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if p_m <= 2.4e-224: tmp = p_m / -x elif p_m <= 5.5e-78: tmp = 1.0 + (1.0 / (-2.0 * ((x / p_m) * (x / p_m)))) elif p_m <= 3e-15: tmp = -1.0 / (p_m * ((1.5 / x) + (x / math.pow(p_m, 2.0)))) else: tmp = math.sqrt(0.5) return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (p_m <= 2.4e-224) tmp = Float64(p_m / Float64(-x)); elseif (p_m <= 5.5e-78) tmp = Float64(1.0 + Float64(1.0 / Float64(-2.0 * Float64(Float64(x / p_m) * Float64(x / p_m))))); elseif (p_m <= 3e-15) tmp = Float64(-1.0 / Float64(p_m * Float64(Float64(1.5 / x) + Float64(x / (p_m ^ 2.0))))); else tmp = sqrt(0.5); end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) tmp = 0.0; if (p_m <= 2.4e-224) tmp = p_m / -x; elseif (p_m <= 5.5e-78) tmp = 1.0 + (1.0 / (-2.0 * ((x / p_m) * (x / p_m)))); elseif (p_m <= 3e-15) tmp = -1.0 / (p_m * ((1.5 / x) + (x / (p_m ^ 2.0)))); else tmp = sqrt(0.5); end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[p$95$m, 2.4e-224], N[(p$95$m / (-x)), $MachinePrecision], If[LessEqual[p$95$m, 5.5e-78], N[(1.0 + N[(1.0 / N[(-2.0 * N[(N[(x / p$95$m), $MachinePrecision] * N[(x / p$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[p$95$m, 3e-15], N[(-1.0 / N[(p$95$m * N[(N[(1.5 / x), $MachinePrecision] + N[(x / N[Power[p$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;p\_m \leq 2.4 \cdot 10^{-224}:\\
\;\;\;\;\frac{p\_m}{-x}\\
\mathbf{elif}\;p\_m \leq 5.5 \cdot 10^{-78}:\\
\;\;\;\;1 + \frac{1}{-2 \cdot \left(\frac{x}{p\_m} \cdot \frac{x}{p\_m}\right)}\\
\mathbf{elif}\;p\_m \leq 3 \cdot 10^{-15}:\\
\;\;\;\;\frac{-1}{p\_m \cdot \left(\frac{1.5}{x} + \frac{x}{{p\_m}^{2}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if p < 2.40000000000000014e-224Initial program 80.7%
+-commutative80.7%
sqr-neg80.7%
associate-*l*80.7%
sqr-neg80.7%
fma-define80.7%
sqr-neg80.7%
fma-define80.7%
associate-*l*80.7%
+-commutative80.7%
Simplified80.7%
Taylor expanded in x around -inf 14.6%
mul-1-neg14.6%
distribute-neg-frac214.6%
Simplified14.6%
if 2.40000000000000014e-224 < p < 5.50000000000000017e-78Initial program 63.4%
+-commutative63.4%
sqr-neg63.4%
associate-*l*63.4%
sqr-neg63.4%
fma-define63.4%
sqr-neg63.4%
fma-define63.4%
associate-*l*63.4%
+-commutative63.4%
Simplified63.4%
Taylor expanded in x around inf 59.7%
associate-*r/59.7%
Simplified59.7%
clear-num59.7%
inv-pow59.7%
*-un-lft-identity59.7%
times-frac59.7%
metadata-eval59.7%
unpow259.7%
unpow259.7%
frac-times59.7%
pow259.7%
Applied egg-rr59.7%
unpow-159.7%
Simplified59.7%
unpow259.7%
Applied egg-rr59.7%
if 5.50000000000000017e-78 < p < 3e-15Initial program 33.4%
+-commutative33.4%
sqr-neg33.4%
associate-*l*33.4%
sqr-neg33.4%
fma-define33.4%
sqr-neg33.4%
fma-define33.4%
associate-*l*33.4%
+-commutative33.4%
Simplified33.4%
Taylor expanded in x around -inf 69.6%
mul-1-neg69.6%
distribute-rgt-out69.6%
metadata-eval69.6%
Simplified69.6%
clear-num69.4%
inv-pow69.4%
+-commutative69.4%
*-commutative69.4%
fma-define69.4%
times-frac69.4%
pow169.4%
pow-div69.4%
metadata-eval69.4%
Applied egg-rr69.4%
unpow-169.4%
Simplified69.4%
Taylor expanded in x around inf 70.9%
Taylor expanded in p around inf 70.6%
associate-*r/70.6%
metadata-eval70.6%
Simplified70.6%
if 3e-15 < p Initial program 88.7%
Taylor expanded in x around 0 82.2%
Final simplification40.0%
p_m = (fabs.f64 p)
(FPCore (p_m x)
:precision binary64
(if (<= p_m 2.15e-224)
(/ p_m (- x))
(if (<= p_m 1.05e-78)
(+ 1.0 (/ 1.0 (* -2.0 (* (/ x p_m) (/ x p_m)))))
(if (<= p_m 2.6e-6)
(/ -1.0 (/ (+ x (* 1.5 (/ (pow p_m 2.0) x))) p_m))
(sqrt 0.5)))))p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (p_m <= 2.15e-224) {
tmp = p_m / -x;
} else if (p_m <= 1.05e-78) {
tmp = 1.0 + (1.0 / (-2.0 * ((x / p_m) * (x / p_m))));
} else if (p_m <= 2.6e-6) {
tmp = -1.0 / ((x + (1.5 * (pow(p_m, 2.0) / x))) / p_m);
} else {
tmp = sqrt(0.5);
}
return tmp;
}
p_m = abs(p)
real(8) function code(p_m, x)
real(8), intent (in) :: p_m
real(8), intent (in) :: x
real(8) :: tmp
if (p_m <= 2.15d-224) then
tmp = p_m / -x
else if (p_m <= 1.05d-78) then
tmp = 1.0d0 + (1.0d0 / ((-2.0d0) * ((x / p_m) * (x / p_m))))
else if (p_m <= 2.6d-6) then
tmp = (-1.0d0) / ((x + (1.5d0 * ((p_m ** 2.0d0) / x))) / p_m)
else
tmp = sqrt(0.5d0)
end if
code = tmp
end function
p_m = Math.abs(p);
public static double code(double p_m, double x) {
double tmp;
if (p_m <= 2.15e-224) {
tmp = p_m / -x;
} else if (p_m <= 1.05e-78) {
tmp = 1.0 + (1.0 / (-2.0 * ((x / p_m) * (x / p_m))));
} else if (p_m <= 2.6e-6) {
tmp = -1.0 / ((x + (1.5 * (Math.pow(p_m, 2.0) / x))) / p_m);
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if p_m <= 2.15e-224: tmp = p_m / -x elif p_m <= 1.05e-78: tmp = 1.0 + (1.0 / (-2.0 * ((x / p_m) * (x / p_m)))) elif p_m <= 2.6e-6: tmp = -1.0 / ((x + (1.5 * (math.pow(p_m, 2.0) / x))) / p_m) else: tmp = math.sqrt(0.5) return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (p_m <= 2.15e-224) tmp = Float64(p_m / Float64(-x)); elseif (p_m <= 1.05e-78) tmp = Float64(1.0 + Float64(1.0 / Float64(-2.0 * Float64(Float64(x / p_m) * Float64(x / p_m))))); elseif (p_m <= 2.6e-6) tmp = Float64(-1.0 / Float64(Float64(x + Float64(1.5 * Float64((p_m ^ 2.0) / x))) / p_m)); else tmp = sqrt(0.5); end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) tmp = 0.0; if (p_m <= 2.15e-224) tmp = p_m / -x; elseif (p_m <= 1.05e-78) tmp = 1.0 + (1.0 / (-2.0 * ((x / p_m) * (x / p_m)))); elseif (p_m <= 2.6e-6) tmp = -1.0 / ((x + (1.5 * ((p_m ^ 2.0) / x))) / p_m); else tmp = sqrt(0.5); end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[p$95$m, 2.15e-224], N[(p$95$m / (-x)), $MachinePrecision], If[LessEqual[p$95$m, 1.05e-78], N[(1.0 + N[(1.0 / N[(-2.0 * N[(N[(x / p$95$m), $MachinePrecision] * N[(x / p$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[p$95$m, 2.6e-6], N[(-1.0 / N[(N[(x + N[(1.5 * N[(N[Power[p$95$m, 2.0], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / p$95$m), $MachinePrecision]), $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;p\_m \leq 2.15 \cdot 10^{-224}:\\
\;\;\;\;\frac{p\_m}{-x}\\
\mathbf{elif}\;p\_m \leq 1.05 \cdot 10^{-78}:\\
\;\;\;\;1 + \frac{1}{-2 \cdot \left(\frac{x}{p\_m} \cdot \frac{x}{p\_m}\right)}\\
\mathbf{elif}\;p\_m \leq 2.6 \cdot 10^{-6}:\\
\;\;\;\;\frac{-1}{\frac{x + 1.5 \cdot \frac{{p\_m}^{2}}{x}}{p\_m}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if p < 2.15e-224Initial program 80.7%
+-commutative80.7%
sqr-neg80.7%
associate-*l*80.7%
sqr-neg80.7%
fma-define80.7%
sqr-neg80.7%
fma-define80.7%
associate-*l*80.7%
+-commutative80.7%
Simplified80.7%
Taylor expanded in x around -inf 14.6%
mul-1-neg14.6%
distribute-neg-frac214.6%
Simplified14.6%
if 2.15e-224 < p < 1.05e-78Initial program 63.4%
+-commutative63.4%
sqr-neg63.4%
associate-*l*63.4%
sqr-neg63.4%
fma-define63.4%
sqr-neg63.4%
fma-define63.4%
associate-*l*63.4%
+-commutative63.4%
Simplified63.4%
Taylor expanded in x around inf 59.7%
associate-*r/59.7%
Simplified59.7%
clear-num59.7%
inv-pow59.7%
*-un-lft-identity59.7%
times-frac59.7%
metadata-eval59.7%
unpow259.7%
unpow259.7%
frac-times59.7%
pow259.7%
Applied egg-rr59.7%
unpow-159.7%
Simplified59.7%
unpow259.7%
Applied egg-rr59.7%
if 1.05e-78 < p < 2.60000000000000009e-6Initial program 31.3%
+-commutative31.3%
sqr-neg31.3%
associate-*l*31.3%
sqr-neg31.3%
fma-define31.3%
sqr-neg31.3%
fma-define31.3%
associate-*l*31.3%
+-commutative31.3%
Simplified31.3%
Taylor expanded in x around -inf 71.8%
mul-1-neg71.8%
distribute-rgt-out71.8%
metadata-eval71.8%
Simplified71.8%
clear-num71.6%
inv-pow71.6%
+-commutative71.6%
*-commutative71.6%
fma-define71.6%
times-frac71.6%
pow171.6%
pow-div71.6%
metadata-eval71.6%
Applied egg-rr71.6%
unpow-171.6%
Simplified71.6%
Taylor expanded in p around 0 73.2%
if 2.60000000000000009e-6 < p Initial program 89.9%
Taylor expanded in x around 0 83.4%
Final simplification40.4%
p_m = (fabs.f64 p)
(FPCore (p_m x)
:precision binary64
(let* ((t_0 (/ p_m (- x))))
(if (<= p_m 2e-224)
t_0
(if (<= p_m 1.25e-79)
(+ 1.0 (/ 1.0 (* -2.0 (* (/ x p_m) (/ x p_m)))))
(if (<= p_m 2.6e-6) t_0 (sqrt 0.5))))))p_m = fabs(p);
double code(double p_m, double x) {
double t_0 = p_m / -x;
double tmp;
if (p_m <= 2e-224) {
tmp = t_0;
} else if (p_m <= 1.25e-79) {
tmp = 1.0 + (1.0 / (-2.0 * ((x / p_m) * (x / p_m))));
} else if (p_m <= 2.6e-6) {
tmp = t_0;
} else {
tmp = sqrt(0.5);
}
return tmp;
}
p_m = abs(p)
real(8) function code(p_m, x)
real(8), intent (in) :: p_m
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = p_m / -x
if (p_m <= 2d-224) then
tmp = t_0
else if (p_m <= 1.25d-79) then
tmp = 1.0d0 + (1.0d0 / ((-2.0d0) * ((x / p_m) * (x / p_m))))
else if (p_m <= 2.6d-6) then
tmp = t_0
else
tmp = sqrt(0.5d0)
end if
code = tmp
end function
p_m = Math.abs(p);
public static double code(double p_m, double x) {
double t_0 = p_m / -x;
double tmp;
if (p_m <= 2e-224) {
tmp = t_0;
} else if (p_m <= 1.25e-79) {
tmp = 1.0 + (1.0 / (-2.0 * ((x / p_m) * (x / p_m))));
} else if (p_m <= 2.6e-6) {
tmp = t_0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): t_0 = p_m / -x tmp = 0 if p_m <= 2e-224: tmp = t_0 elif p_m <= 1.25e-79: tmp = 1.0 + (1.0 / (-2.0 * ((x / p_m) * (x / p_m)))) elif p_m <= 2.6e-6: tmp = t_0 else: tmp = math.sqrt(0.5) return tmp
p_m = abs(p) function code(p_m, x) t_0 = Float64(p_m / Float64(-x)) tmp = 0.0 if (p_m <= 2e-224) tmp = t_0; elseif (p_m <= 1.25e-79) tmp = Float64(1.0 + Float64(1.0 / Float64(-2.0 * Float64(Float64(x / p_m) * Float64(x / p_m))))); elseif (p_m <= 2.6e-6) tmp = t_0; else tmp = sqrt(0.5); end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) t_0 = p_m / -x; tmp = 0.0; if (p_m <= 2e-224) tmp = t_0; elseif (p_m <= 1.25e-79) tmp = 1.0 + (1.0 / (-2.0 * ((x / p_m) * (x / p_m)))); elseif (p_m <= 2.6e-6) tmp = t_0; else tmp = sqrt(0.5); end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision]
code[p$95$m_, x_] := Block[{t$95$0 = N[(p$95$m / (-x)), $MachinePrecision]}, If[LessEqual[p$95$m, 2e-224], t$95$0, If[LessEqual[p$95$m, 1.25e-79], N[(1.0 + N[(1.0 / N[(-2.0 * N[(N[(x / p$95$m), $MachinePrecision] * N[(x / p$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[p$95$m, 2.6e-6], t$95$0, N[Sqrt[0.5], $MachinePrecision]]]]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
t_0 := \frac{p\_m}{-x}\\
\mathbf{if}\;p\_m \leq 2 \cdot 10^{-224}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;p\_m \leq 1.25 \cdot 10^{-79}:\\
\;\;\;\;1 + \frac{1}{-2 \cdot \left(\frac{x}{p\_m} \cdot \frac{x}{p\_m}\right)}\\
\mathbf{elif}\;p\_m \leq 2.6 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if p < 2e-224 or 1.25e-79 < p < 2.60000000000000009e-6Initial program 76.5%
+-commutative76.5%
sqr-neg76.5%
associate-*l*76.5%
sqr-neg76.5%
fma-define76.5%
sqr-neg76.5%
fma-define76.5%
associate-*l*76.5%
+-commutative76.5%
Simplified76.5%
Taylor expanded in x around -inf 19.7%
mul-1-neg19.7%
distribute-neg-frac219.7%
Simplified19.7%
if 2e-224 < p < 1.25e-79Initial program 63.4%
+-commutative63.4%
sqr-neg63.4%
associate-*l*63.4%
sqr-neg63.4%
fma-define63.4%
sqr-neg63.4%
fma-define63.4%
associate-*l*63.4%
+-commutative63.4%
Simplified63.4%
Taylor expanded in x around inf 59.7%
associate-*r/59.7%
Simplified59.7%
clear-num59.7%
inv-pow59.7%
*-un-lft-identity59.7%
times-frac59.7%
metadata-eval59.7%
unpow259.7%
unpow259.7%
frac-times59.7%
pow259.7%
Applied egg-rr59.7%
unpow-159.7%
Simplified59.7%
unpow259.7%
Applied egg-rr59.7%
if 2.60000000000000009e-6 < p Initial program 89.9%
Taylor expanded in x around 0 83.4%
Final simplification40.4%
p_m = (fabs.f64 p) (FPCore (p_m x) :precision binary64 (if (<= x 8.2e-275) (/ p_m (- x)) (+ 1.0 (/ 1.0 (* -2.0 (* (/ x p_m) (/ x p_m)))))))
p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (x <= 8.2e-275) {
tmp = p_m / -x;
} else {
tmp = 1.0 + (1.0 / (-2.0 * ((x / p_m) * (x / p_m))));
}
return tmp;
}
p_m = abs(p)
real(8) function code(p_m, x)
real(8), intent (in) :: p_m
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 8.2d-275) then
tmp = p_m / -x
else
tmp = 1.0d0 + (1.0d0 / ((-2.0d0) * ((x / p_m) * (x / p_m))))
end if
code = tmp
end function
p_m = Math.abs(p);
public static double code(double p_m, double x) {
double tmp;
if (x <= 8.2e-275) {
tmp = p_m / -x;
} else {
tmp = 1.0 + (1.0 / (-2.0 * ((x / p_m) * (x / p_m))));
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if x <= 8.2e-275: tmp = p_m / -x else: tmp = 1.0 + (1.0 / (-2.0 * ((x / p_m) * (x / p_m)))) return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (x <= 8.2e-275) tmp = Float64(p_m / Float64(-x)); else tmp = Float64(1.0 + Float64(1.0 / Float64(-2.0 * Float64(Float64(x / p_m) * Float64(x / p_m))))); end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) tmp = 0.0; if (x <= 8.2e-275) tmp = p_m / -x; else tmp = 1.0 + (1.0 / (-2.0 * ((x / p_m) * (x / p_m)))); end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[x, 8.2e-275], N[(p$95$m / (-x)), $MachinePrecision], N[(1.0 + N[(1.0 / N[(-2.0 * N[(N[(x / p$95$m), $MachinePrecision] * N[(x / p$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.2 \cdot 10^{-275}:\\
\;\;\;\;\frac{p\_m}{-x}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{1}{-2 \cdot \left(\frac{x}{p\_m} \cdot \frac{x}{p\_m}\right)}\\
\end{array}
\end{array}
if x < 8.19999999999999949e-275Initial program 59.9%
+-commutative59.9%
sqr-neg59.9%
associate-*l*59.9%
sqr-neg59.9%
fma-define59.9%
sqr-neg59.9%
fma-define59.9%
associate-*l*59.9%
+-commutative59.9%
Simplified59.9%
Taylor expanded in x around -inf 35.3%
mul-1-neg35.3%
distribute-neg-frac235.3%
Simplified35.3%
if 8.19999999999999949e-275 < x Initial program 100.0%
+-commutative100.0%
sqr-neg100.0%
associate-*l*100.0%
sqr-neg100.0%
fma-define100.0%
sqr-neg100.0%
fma-define100.0%
associate-*l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 49.5%
associate-*r/49.5%
Simplified49.5%
clear-num49.5%
inv-pow49.5%
*-un-lft-identity49.5%
times-frac49.5%
metadata-eval49.5%
unpow249.5%
unpow249.5%
frac-times49.5%
pow249.5%
Applied egg-rr49.5%
unpow-149.5%
Simplified49.5%
unpow249.5%
Applied egg-rr49.5%
Final simplification42.0%
p_m = (fabs.f64 p) (FPCore (p_m x) :precision binary64 (/ p_m (- x)))
p_m = fabs(p);
double code(double p_m, double x) {
return p_m / -x;
}
p_m = abs(p)
real(8) function code(p_m, x)
real(8), intent (in) :: p_m
real(8), intent (in) :: x
code = p_m / -x
end function
p_m = Math.abs(p);
public static double code(double p_m, double x) {
return p_m / -x;
}
p_m = math.fabs(p) def code(p_m, x): return p_m / -x
p_m = abs(p) function code(p_m, x) return Float64(p_m / Float64(-x)) end
p_m = abs(p); function tmp = code(p_m, x) tmp = p_m / -x; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := N[(p$95$m / (-x)), $MachinePrecision]
\begin{array}{l}
p_m = \left|p\right|
\\
\frac{p\_m}{-x}
\end{array}
Initial program 78.7%
+-commutative78.7%
sqr-neg78.7%
associate-*l*78.7%
sqr-neg78.7%
fma-define78.7%
sqr-neg78.7%
fma-define78.7%
associate-*l*78.7%
+-commutative78.7%
Simplified78.7%
Taylor expanded in x around -inf 20.4%
mul-1-neg20.4%
distribute-neg-frac220.4%
Simplified20.4%
Final simplification20.4%
(FPCore (p x) :precision binary64 (sqrt (+ 0.5 (/ (copysign 0.5 x) (hypot 1.0 (/ (* 2.0 p) x))))))
double code(double p, double x) {
return sqrt((0.5 + (copysign(0.5, x) / hypot(1.0, ((2.0 * p) / x)))));
}
public static double code(double p, double x) {
return Math.sqrt((0.5 + (Math.copySign(0.5, x) / Math.hypot(1.0, ((2.0 * p) / x)))));
}
def code(p, x): return math.sqrt((0.5 + (math.copysign(0.5, x) / math.hypot(1.0, ((2.0 * p) / x)))))
function code(p, x) return sqrt(Float64(0.5 + Float64(copysign(0.5, x) / hypot(1.0, Float64(Float64(2.0 * p) / x))))) end
function tmp = code(p, x) tmp = sqrt((0.5 + ((sign(x) * abs(0.5)) / hypot(1.0, ((2.0 * p) / x))))); end
code[p_, x_] := N[Sqrt[N[(0.5 + N[(N[With[{TMP1 = Abs[0.5], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * p), $MachinePrecision] / x), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{\mathsf{copysign}\left(0.5, x\right)}{\mathsf{hypot}\left(1, \frac{2 \cdot p}{x}\right)}}
\end{array}
herbie shell --seed 2024082
(FPCore (p x)
:name "Given's Rotation SVD example"
:precision binary64
:pre (and (< 1e-150 (fabs x)) (< (fabs x) 1e+150))
:alt
(sqrt (+ 0.5 (/ (copysign 0.5 x) (hypot 1.0 (/ (* 2.0 p) x)))))
(sqrt (* 0.5 (+ 1.0 (/ x (sqrt (+ (* (* 4.0 p) p) (* x x))))))))