
(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 12 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)))) -1.0) (* (* p_m (* (pow 2.0 0.25) (/ (pow 2.0 0.25) x))) (- (sqrt 0.5))) (sqrt (* 0.5 (+ 1.0 (/ x (hypot (* p_m 2.0) x)))))))
p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if ((x / sqrt(((p_m * (4.0 * p_m)) + (x * x)))) <= -1.0) {
tmp = (p_m * (pow(2.0, 0.25) * (pow(2.0, 0.25) / x))) * -sqrt(0.5);
} else {
tmp = sqrt((0.5 * (1.0 + (x / hypot((p_m * 2.0), x)))));
}
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)))) <= -1.0) {
tmp = (p_m * (Math.pow(2.0, 0.25) * (Math.pow(2.0, 0.25) / x))) * -Math.sqrt(0.5);
} else {
tmp = Math.sqrt((0.5 * (1.0 + (x / Math.hypot((p_m * 2.0), x)))));
}
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)))) <= -1.0: tmp = (p_m * (math.pow(2.0, 0.25) * (math.pow(2.0, 0.25) / x))) * -math.sqrt(0.5) else: tmp = math.sqrt((0.5 * (1.0 + (x / math.hypot((p_m * 2.0), x))))) 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)))) <= -1.0) tmp = Float64(Float64(p_m * Float64((2.0 ^ 0.25) * Float64((2.0 ^ 0.25) / x))) * Float64(-sqrt(0.5))); else tmp = sqrt(Float64(0.5 * Float64(1.0 + Float64(x / hypot(Float64(p_m * 2.0), x))))); 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)))) <= -1.0) tmp = (p_m * ((2.0 ^ 0.25) * ((2.0 ^ 0.25) / x))) * -sqrt(0.5); else tmp = sqrt((0.5 * (1.0 + (x / hypot((p_m * 2.0), x))))); 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], -1.0], N[(N[(p$95$m * N[(N[Power[2.0, 0.25], $MachinePrecision] * N[(N[Power[2.0, 0.25], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-N[Sqrt[0.5], $MachinePrecision])), $MachinePrecision], N[Sqrt[N[(0.5 * N[(1.0 + N[(x / N[Sqrt[N[(p$95$m * 2.0), $MachinePrecision] ^ 2 + x ^ 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 -1:\\
\;\;\;\;\left(p\_m \cdot \left({2}^{0.25} \cdot \frac{{2}^{0.25}}{x}\right)\right) \cdot \left(-\sqrt{0.5}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 \cdot \left(1 + \frac{x}{\mathsf{hypot}\left(p\_m \cdot 2, x\right)}\right)}\\
\end{array}
\end{array}
if (/.f64 x (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal 4 binary64) p) p) (*.f64 x x)))) < -1Initial program 16.0%
sqrt-prod16.0%
*-commutative16.0%
+-commutative16.0%
add-sqr-sqrt16.0%
hypot-define16.0%
associate-*l*16.0%
sqrt-prod16.0%
metadata-eval16.0%
sqrt-unprod9.1%
add-sqr-sqrt16.0%
Applied egg-rr16.0%
Taylor expanded in x around -inf 56.4%
mul-1-neg56.4%
associate-/l*56.3%
distribute-lft-neg-in56.3%
Simplified56.3%
add-sqr-sqrt56.8%
associate-/l*56.8%
pow1/256.8%
sqrt-pow156.8%
metadata-eval56.8%
pow1/256.8%
sqrt-pow156.8%
metadata-eval56.8%
Applied egg-rr56.8%
if -1 < (/.f64 x (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal 4 binary64) p) p) (*.f64 x x)))) Initial program 100.0%
add-sqr-sqrt100.0%
hypot-define100.0%
associate-*l*100.0%
sqrt-prod100.0%
metadata-eval100.0%
sqrt-unprod55.9%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
Final simplification89.3%
p_m = (fabs.f64 p) (FPCore (p_m x) :precision binary64 (if (<= (/ x (sqrt (+ (* p_m (* 4.0 p_m)) (* x x)))) -1.0) (* (sqrt 0.5) (/ (* p_m (sqrt 2.0)) (- x))) (sqrt (* 0.5 (+ 1.0 (/ x (hypot (* p_m 2.0) x)))))))
p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if ((x / sqrt(((p_m * (4.0 * p_m)) + (x * x)))) <= -1.0) {
tmp = sqrt(0.5) * ((p_m * sqrt(2.0)) / -x);
} else {
tmp = sqrt((0.5 * (1.0 + (x / hypot((p_m * 2.0), x)))));
}
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)))) <= -1.0) {
tmp = Math.sqrt(0.5) * ((p_m * Math.sqrt(2.0)) / -x);
} else {
tmp = Math.sqrt((0.5 * (1.0 + (x / Math.hypot((p_m * 2.0), x)))));
}
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)))) <= -1.0: tmp = math.sqrt(0.5) * ((p_m * math.sqrt(2.0)) / -x) else: tmp = math.sqrt((0.5 * (1.0 + (x / math.hypot((p_m * 2.0), x))))) 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)))) <= -1.0) tmp = Float64(sqrt(0.5) * Float64(Float64(p_m * sqrt(2.0)) / Float64(-x))); else tmp = sqrt(Float64(0.5 * Float64(1.0 + Float64(x / hypot(Float64(p_m * 2.0), x))))); 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)))) <= -1.0) tmp = sqrt(0.5) * ((p_m * sqrt(2.0)) / -x); else tmp = sqrt((0.5 * (1.0 + (x / hypot((p_m * 2.0), x))))); 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], -1.0], N[(N[Sqrt[0.5], $MachinePrecision] * N[(N[(p$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] / (-x)), $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(0.5 * N[(1.0 + N[(x / N[Sqrt[N[(p$95$m * 2.0), $MachinePrecision] ^ 2 + x ^ 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 -1:\\
\;\;\;\;\sqrt{0.5} \cdot \frac{p\_m \cdot \sqrt{2}}{-x}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 \cdot \left(1 + \frac{x}{\mathsf{hypot}\left(p\_m \cdot 2, x\right)}\right)}\\
\end{array}
\end{array}
if (/.f64 x (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal 4 binary64) p) p) (*.f64 x x)))) < -1Initial program 16.0%
sqrt-prod16.0%
*-commutative16.0%
+-commutative16.0%
add-sqr-sqrt16.0%
hypot-define16.0%
associate-*l*16.0%
sqrt-prod16.0%
metadata-eval16.0%
sqrt-unprod9.1%
add-sqr-sqrt16.0%
Applied egg-rr16.0%
Taylor expanded in x around -inf 56.4%
mul-1-neg56.4%
associate-/l*56.3%
distribute-lft-neg-in56.3%
Simplified56.3%
associate-*r/56.4%
frac-2neg56.4%
add-sqr-sqrt6.2%
sqrt-unprod15.3%
sqr-neg15.3%
sqrt-unprod8.4%
add-sqr-sqrt57.2%
distribute-lft-neg-out57.2%
add-sqr-sqrt48.7%
sqrt-unprod61.2%
sqr-neg61.2%
sqrt-unprod50.2%
add-sqr-sqrt56.4%
Applied egg-rr56.4%
if -1 < (/.f64 x (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal 4 binary64) p) p) (*.f64 x x)))) Initial program 100.0%
add-sqr-sqrt100.0%
hypot-define100.0%
associate-*l*100.0%
sqrt-prod100.0%
metadata-eval100.0%
sqrt-unprod55.9%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
Final simplification89.3%
p_m = (fabs.f64 p)
(FPCore (p_m x)
:precision binary64
(if (<= p_m 2.7e-278)
1.0
(if (<= p_m 3.8e-153)
(* (sqrt 0.5) (* (sqrt 2.0) (/ p_m (- x))))
(if (<= p_m 2.9e+20)
1.0
(* (sqrt 0.5) (sqrt (+ 1.0 (/ (* x 0.5) p_m))))))))p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (p_m <= 2.7e-278) {
tmp = 1.0;
} else if (p_m <= 3.8e-153) {
tmp = sqrt(0.5) * (sqrt(2.0) * (p_m / -x));
} else if (p_m <= 2.9e+20) {
tmp = 1.0;
} else {
tmp = sqrt(0.5) * sqrt((1.0 + ((x * 0.5) / 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 (p_m <= 2.7d-278) then
tmp = 1.0d0
else if (p_m <= 3.8d-153) then
tmp = sqrt(0.5d0) * (sqrt(2.0d0) * (p_m / -x))
else if (p_m <= 2.9d+20) then
tmp = 1.0d0
else
tmp = sqrt(0.5d0) * sqrt((1.0d0 + ((x * 0.5d0) / 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 (p_m <= 2.7e-278) {
tmp = 1.0;
} else if (p_m <= 3.8e-153) {
tmp = Math.sqrt(0.5) * (Math.sqrt(2.0) * (p_m / -x));
} else if (p_m <= 2.9e+20) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5) * Math.sqrt((1.0 + ((x * 0.5) / p_m)));
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if p_m <= 2.7e-278: tmp = 1.0 elif p_m <= 3.8e-153: tmp = math.sqrt(0.5) * (math.sqrt(2.0) * (p_m / -x)) elif p_m <= 2.9e+20: tmp = 1.0 else: tmp = math.sqrt(0.5) * math.sqrt((1.0 + ((x * 0.5) / p_m))) return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (p_m <= 2.7e-278) tmp = 1.0; elseif (p_m <= 3.8e-153) tmp = Float64(sqrt(0.5) * Float64(sqrt(2.0) * Float64(p_m / Float64(-x)))); elseif (p_m <= 2.9e+20) tmp = 1.0; else tmp = Float64(sqrt(0.5) * sqrt(Float64(1.0 + Float64(Float64(x * 0.5) / p_m)))); end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) tmp = 0.0; if (p_m <= 2.7e-278) tmp = 1.0; elseif (p_m <= 3.8e-153) tmp = sqrt(0.5) * (sqrt(2.0) * (p_m / -x)); elseif (p_m <= 2.9e+20) tmp = 1.0; else tmp = sqrt(0.5) * sqrt((1.0 + ((x * 0.5) / p_m))); end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[p$95$m, 2.7e-278], 1.0, If[LessEqual[p$95$m, 3.8e-153], N[(N[Sqrt[0.5], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(p$95$m / (-x)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[p$95$m, 2.9e+20], 1.0, N[(N[Sqrt[0.5], $MachinePrecision] * N[Sqrt[N[(1.0 + N[(N[(x * 0.5), $MachinePrecision] / p$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;p\_m \leq 2.7 \cdot 10^{-278}:\\
\;\;\;\;1\\
\mathbf{elif}\;p\_m \leq 3.8 \cdot 10^{-153}:\\
\;\;\;\;\sqrt{0.5} \cdot \left(\sqrt{2} \cdot \frac{p\_m}{-x}\right)\\
\mathbf{elif}\;p\_m \leq 2.9 \cdot 10^{+20}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5} \cdot \sqrt{1 + \frac{x \cdot 0.5}{p\_m}}\\
\end{array}
\end{array}
if p < 2.7000000000000001e-278 or 3.80000000000000023e-153 < p < 2.9e20Initial program 76.3%
Taylor expanded in x around inf 43.6%
if 2.7000000000000001e-278 < p < 3.80000000000000023e-153Initial program 58.1%
sqrt-prod57.4%
*-commutative57.4%
+-commutative57.4%
add-sqr-sqrt57.4%
hypot-define57.4%
associate-*l*57.4%
sqrt-prod57.4%
metadata-eval57.4%
sqrt-unprod57.4%
add-sqr-sqrt57.4%
Applied egg-rr57.4%
Taylor expanded in x around -inf 58.1%
mul-1-neg58.1%
associate-/l*58.1%
distribute-lft-neg-in58.1%
Simplified58.1%
Taylor expanded in p around 0 58.1%
neg-mul-158.1%
remove-double-neg58.1%
distribute-neg-frac58.1%
distribute-rgt-neg-out58.1%
distribute-frac-neg258.1%
*-commutative58.1%
associate-/l*58.1%
distribute-lft-neg-in58.1%
remove-double-neg58.1%
Simplified58.1%
if 2.9e20 < p Initial program 95.5%
sqrt-prod95.4%
*-commutative95.4%
+-commutative95.4%
add-sqr-sqrt95.4%
hypot-define95.4%
associate-*l*95.4%
sqrt-prod95.4%
metadata-eval95.4%
sqrt-unprod95.4%
add-sqr-sqrt95.4%
Applied egg-rr95.4%
Taylor expanded in x around 0 89.8%
associate-*r/89.8%
Simplified89.8%
Final simplification56.8%
p_m = (fabs.f64 p)
(FPCore (p_m x)
:precision binary64
(if (<= p_m 8.8e-277)
1.0
(if (<= p_m 9e-152)
(* (sqrt 0.5) (* (sqrt 2.0) (/ p_m (- x))))
(if (<= p_m 3.6e+22) 1.0 (sqrt (+ 0.5 (/ (* x 0.25) p_m)))))))p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (p_m <= 8.8e-277) {
tmp = 1.0;
} else if (p_m <= 9e-152) {
tmp = sqrt(0.5) * (sqrt(2.0) * (p_m / -x));
} else if (p_m <= 3.6e+22) {
tmp = 1.0;
} else {
tmp = sqrt((0.5 + ((x * 0.25) / 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 (p_m <= 8.8d-277) then
tmp = 1.0d0
else if (p_m <= 9d-152) then
tmp = sqrt(0.5d0) * (sqrt(2.0d0) * (p_m / -x))
else if (p_m <= 3.6d+22) then
tmp = 1.0d0
else
tmp = sqrt((0.5d0 + ((x * 0.25d0) / 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 (p_m <= 8.8e-277) {
tmp = 1.0;
} else if (p_m <= 9e-152) {
tmp = Math.sqrt(0.5) * (Math.sqrt(2.0) * (p_m / -x));
} else if (p_m <= 3.6e+22) {
tmp = 1.0;
} else {
tmp = Math.sqrt((0.5 + ((x * 0.25) / p_m)));
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if p_m <= 8.8e-277: tmp = 1.0 elif p_m <= 9e-152: tmp = math.sqrt(0.5) * (math.sqrt(2.0) * (p_m / -x)) elif p_m <= 3.6e+22: tmp = 1.0 else: tmp = math.sqrt((0.5 + ((x * 0.25) / p_m))) return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (p_m <= 8.8e-277) tmp = 1.0; elseif (p_m <= 9e-152) tmp = Float64(sqrt(0.5) * Float64(sqrt(2.0) * Float64(p_m / Float64(-x)))); elseif (p_m <= 3.6e+22) tmp = 1.0; else tmp = sqrt(Float64(0.5 + Float64(Float64(x * 0.25) / p_m))); end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) tmp = 0.0; if (p_m <= 8.8e-277) tmp = 1.0; elseif (p_m <= 9e-152) tmp = sqrt(0.5) * (sqrt(2.0) * (p_m / -x)); elseif (p_m <= 3.6e+22) tmp = 1.0; else tmp = sqrt((0.5 + ((x * 0.25) / p_m))); end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[p$95$m, 8.8e-277], 1.0, If[LessEqual[p$95$m, 9e-152], N[(N[Sqrt[0.5], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(p$95$m / (-x)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[p$95$m, 3.6e+22], 1.0, N[Sqrt[N[(0.5 + N[(N[(x * 0.25), $MachinePrecision] / p$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;p\_m \leq 8.8 \cdot 10^{-277}:\\
\;\;\;\;1\\
\mathbf{elif}\;p\_m \leq 9 \cdot 10^{-152}:\\
\;\;\;\;\sqrt{0.5} \cdot \left(\sqrt{2} \cdot \frac{p\_m}{-x}\right)\\
\mathbf{elif}\;p\_m \leq 3.6 \cdot 10^{+22}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{x \cdot 0.25}{p\_m}}\\
\end{array}
\end{array}
if p < 8.79999999999999983e-277 or 9.0000000000000008e-152 < p < 3.6e22Initial program 76.3%
Taylor expanded in x around inf 43.6%
if 8.79999999999999983e-277 < p < 9.0000000000000008e-152Initial program 58.1%
sqrt-prod57.4%
*-commutative57.4%
+-commutative57.4%
add-sqr-sqrt57.4%
hypot-define57.4%
associate-*l*57.4%
sqrt-prod57.4%
metadata-eval57.4%
sqrt-unprod57.4%
add-sqr-sqrt57.4%
Applied egg-rr57.4%
Taylor expanded in x around -inf 58.1%
mul-1-neg58.1%
associate-/l*58.1%
distribute-lft-neg-in58.1%
Simplified58.1%
Taylor expanded in p around 0 58.1%
neg-mul-158.1%
remove-double-neg58.1%
distribute-neg-frac58.1%
distribute-rgt-neg-out58.1%
distribute-frac-neg258.1%
*-commutative58.1%
associate-/l*58.1%
distribute-lft-neg-in58.1%
remove-double-neg58.1%
Simplified58.1%
if 3.6e22 < p Initial program 95.5%
add-sqr-sqrt95.5%
hypot-define95.5%
associate-*l*95.5%
sqrt-prod95.5%
metadata-eval95.5%
sqrt-unprod95.5%
add-sqr-sqrt95.5%
Applied egg-rr95.5%
Taylor expanded in x around 0 89.8%
associate-*r/89.8%
*-commutative89.8%
Simplified89.8%
Final simplification56.8%
p_m = (fabs.f64 p)
(FPCore (p_m x)
:precision binary64
(if (<= p_m 2.2e-276)
1.0
(if (<= p_m 1.25e-151)
(* (- p_m) (* (sqrt 0.5) (/ (sqrt 2.0) x)))
(if (<= p_m 2.2e+20) 1.0 (sqrt (+ 0.5 (/ (* x 0.25) p_m)))))))p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (p_m <= 2.2e-276) {
tmp = 1.0;
} else if (p_m <= 1.25e-151) {
tmp = -p_m * (sqrt(0.5) * (sqrt(2.0) / x));
} else if (p_m <= 2.2e+20) {
tmp = 1.0;
} else {
tmp = sqrt((0.5 + ((x * 0.25) / 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 (p_m <= 2.2d-276) then
tmp = 1.0d0
else if (p_m <= 1.25d-151) then
tmp = -p_m * (sqrt(0.5d0) * (sqrt(2.0d0) / x))
else if (p_m <= 2.2d+20) then
tmp = 1.0d0
else
tmp = sqrt((0.5d0 + ((x * 0.25d0) / 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 (p_m <= 2.2e-276) {
tmp = 1.0;
} else if (p_m <= 1.25e-151) {
tmp = -p_m * (Math.sqrt(0.5) * (Math.sqrt(2.0) / x));
} else if (p_m <= 2.2e+20) {
tmp = 1.0;
} else {
tmp = Math.sqrt((0.5 + ((x * 0.25) / p_m)));
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if p_m <= 2.2e-276: tmp = 1.0 elif p_m <= 1.25e-151: tmp = -p_m * (math.sqrt(0.5) * (math.sqrt(2.0) / x)) elif p_m <= 2.2e+20: tmp = 1.0 else: tmp = math.sqrt((0.5 + ((x * 0.25) / p_m))) return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (p_m <= 2.2e-276) tmp = 1.0; elseif (p_m <= 1.25e-151) tmp = Float64(Float64(-p_m) * Float64(sqrt(0.5) * Float64(sqrt(2.0) / x))); elseif (p_m <= 2.2e+20) tmp = 1.0; else tmp = sqrt(Float64(0.5 + Float64(Float64(x * 0.25) / p_m))); end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) tmp = 0.0; if (p_m <= 2.2e-276) tmp = 1.0; elseif (p_m <= 1.25e-151) tmp = -p_m * (sqrt(0.5) * (sqrt(2.0) / x)); elseif (p_m <= 2.2e+20) tmp = 1.0; else tmp = sqrt((0.5 + ((x * 0.25) / p_m))); end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[p$95$m, 2.2e-276], 1.0, If[LessEqual[p$95$m, 1.25e-151], N[((-p$95$m) * N[(N[Sqrt[0.5], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[p$95$m, 2.2e+20], 1.0, N[Sqrt[N[(0.5 + N[(N[(x * 0.25), $MachinePrecision] / p$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;p\_m \leq 2.2 \cdot 10^{-276}:\\
\;\;\;\;1\\
\mathbf{elif}\;p\_m \leq 1.25 \cdot 10^{-151}:\\
\;\;\;\;\left(-p\_m\right) \cdot \left(\sqrt{0.5} \cdot \frac{\sqrt{2}}{x}\right)\\
\mathbf{elif}\;p\_m \leq 2.2 \cdot 10^{+20}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{x \cdot 0.25}{p\_m}}\\
\end{array}
\end{array}
if p < 2.19999999999999981e-276 or 1.25000000000000001e-151 < p < 2.2e20Initial program 76.3%
Taylor expanded in x around inf 43.6%
if 2.19999999999999981e-276 < p < 1.25000000000000001e-151Initial program 58.1%
Taylor expanded in x around -inf 58.0%
mul-1-neg58.0%
Simplified58.0%
Taylor expanded in p around 0 58.0%
mul-1-neg58.0%
associate-/l*57.9%
distribute-rgt-neg-in57.9%
associate-/l*58.2%
distribute-rgt-neg-in58.2%
Simplified58.2%
if 2.2e20 < p Initial program 95.5%
add-sqr-sqrt95.5%
hypot-define95.5%
associate-*l*95.5%
sqrt-prod95.5%
metadata-eval95.5%
sqrt-unprod95.5%
add-sqr-sqrt95.5%
Applied egg-rr95.5%
Taylor expanded in x around 0 89.8%
associate-*r/89.8%
*-commutative89.8%
Simplified89.8%
Final simplification56.8%
p_m = (fabs.f64 p)
(FPCore (p_m x)
:precision binary64
(if (<= p_m 1.4e-277)
1.0
(if (<= p_m 1.65e-153)
(/ (* p_m (* (sqrt 0.5) (sqrt 2.0))) (- x))
(if (<= p_m 1.02e+21) 1.0 (sqrt (+ 0.5 (/ (* x 0.25) p_m)))))))p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (p_m <= 1.4e-277) {
tmp = 1.0;
} else if (p_m <= 1.65e-153) {
tmp = (p_m * (sqrt(0.5) * sqrt(2.0))) / -x;
} else if (p_m <= 1.02e+21) {
tmp = 1.0;
} else {
tmp = sqrt((0.5 + ((x * 0.25) / 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 (p_m <= 1.4d-277) then
tmp = 1.0d0
else if (p_m <= 1.65d-153) then
tmp = (p_m * (sqrt(0.5d0) * sqrt(2.0d0))) / -x
else if (p_m <= 1.02d+21) then
tmp = 1.0d0
else
tmp = sqrt((0.5d0 + ((x * 0.25d0) / 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 (p_m <= 1.4e-277) {
tmp = 1.0;
} else if (p_m <= 1.65e-153) {
tmp = (p_m * (Math.sqrt(0.5) * Math.sqrt(2.0))) / -x;
} else if (p_m <= 1.02e+21) {
tmp = 1.0;
} else {
tmp = Math.sqrt((0.5 + ((x * 0.25) / p_m)));
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if p_m <= 1.4e-277: tmp = 1.0 elif p_m <= 1.65e-153: tmp = (p_m * (math.sqrt(0.5) * math.sqrt(2.0))) / -x elif p_m <= 1.02e+21: tmp = 1.0 else: tmp = math.sqrt((0.5 + ((x * 0.25) / p_m))) return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (p_m <= 1.4e-277) tmp = 1.0; elseif (p_m <= 1.65e-153) tmp = Float64(Float64(p_m * Float64(sqrt(0.5) * sqrt(2.0))) / Float64(-x)); elseif (p_m <= 1.02e+21) tmp = 1.0; else tmp = sqrt(Float64(0.5 + Float64(Float64(x * 0.25) / p_m))); end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) tmp = 0.0; if (p_m <= 1.4e-277) tmp = 1.0; elseif (p_m <= 1.65e-153) tmp = (p_m * (sqrt(0.5) * sqrt(2.0))) / -x; elseif (p_m <= 1.02e+21) tmp = 1.0; else tmp = sqrt((0.5 + ((x * 0.25) / p_m))); end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[p$95$m, 1.4e-277], 1.0, If[LessEqual[p$95$m, 1.65e-153], N[(N[(p$95$m * N[(N[Sqrt[0.5], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-x)), $MachinePrecision], If[LessEqual[p$95$m, 1.02e+21], 1.0, N[Sqrt[N[(0.5 + N[(N[(x * 0.25), $MachinePrecision] / p$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;p\_m \leq 1.4 \cdot 10^{-277}:\\
\;\;\;\;1\\
\mathbf{elif}\;p\_m \leq 1.65 \cdot 10^{-153}:\\
\;\;\;\;\frac{p\_m \cdot \left(\sqrt{0.5} \cdot \sqrt{2}\right)}{-x}\\
\mathbf{elif}\;p\_m \leq 1.02 \cdot 10^{+21}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{x \cdot 0.25}{p\_m}}\\
\end{array}
\end{array}
if p < 1.39999999999999988e-277 or 1.64999999999999994e-153 < p < 1.02e21Initial program 76.3%
Taylor expanded in x around inf 43.6%
if 1.39999999999999988e-277 < p < 1.64999999999999994e-153Initial program 58.1%
Taylor expanded in x around -inf 58.0%
mul-1-neg58.0%
Simplified58.0%
if 1.02e21 < p Initial program 95.5%
add-sqr-sqrt95.5%
hypot-define95.5%
associate-*l*95.5%
sqrt-prod95.5%
metadata-eval95.5%
sqrt-unprod95.5%
add-sqr-sqrt95.5%
Applied egg-rr95.5%
Taylor expanded in x around 0 89.8%
associate-*r/89.8%
*-commutative89.8%
Simplified89.8%
Final simplification56.8%
p_m = (fabs.f64 p) (FPCore (p_m x) :precision binary64 (if (<= p_m 3.2e+21) 1.0 (sqrt (+ 0.5 (/ (* x 0.25) p_m)))))
p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (p_m <= 3.2e+21) {
tmp = 1.0;
} else {
tmp = sqrt((0.5 + ((x * 0.25) / 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 (p_m <= 3.2d+21) then
tmp = 1.0d0
else
tmp = sqrt((0.5d0 + ((x * 0.25d0) / 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 (p_m <= 3.2e+21) {
tmp = 1.0;
} else {
tmp = Math.sqrt((0.5 + ((x * 0.25) / p_m)));
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if p_m <= 3.2e+21: tmp = 1.0 else: tmp = math.sqrt((0.5 + ((x * 0.25) / p_m))) return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (p_m <= 3.2e+21) tmp = 1.0; else tmp = sqrt(Float64(0.5 + Float64(Float64(x * 0.25) / p_m))); end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) tmp = 0.0; if (p_m <= 3.2e+21) tmp = 1.0; else tmp = sqrt((0.5 + ((x * 0.25) / p_m))); end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[p$95$m, 3.2e+21], 1.0, N[Sqrt[N[(0.5 + N[(N[(x * 0.25), $MachinePrecision] / p$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;p\_m \leq 3.2 \cdot 10^{+21}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{x \cdot 0.25}{p\_m}}\\
\end{array}
\end{array}
if p < 3.2e21Initial program 73.8%
Taylor expanded in x around inf 43.7%
if 3.2e21 < p Initial program 95.5%
add-sqr-sqrt95.5%
hypot-define95.5%
associate-*l*95.5%
sqrt-prod95.5%
metadata-eval95.5%
sqrt-unprod95.5%
add-sqr-sqrt95.5%
Applied egg-rr95.5%
Taylor expanded in x around 0 89.8%
associate-*r/89.8%
*-commutative89.8%
Simplified89.8%
Final simplification55.4%
p_m = (fabs.f64 p) (FPCore (p_m x) :precision binary64 (if (<= p_m 1.08e+21) 1.0 (sqrt 0.5)))
p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (p_m <= 1.08e+21) {
tmp = 1.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 <= 1.08d+21) then
tmp = 1.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 <= 1.08e+21) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if p_m <= 1.08e+21: tmp = 1.0 else: tmp = math.sqrt(0.5) return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (p_m <= 1.08e+21) tmp = 1.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 <= 1.08e+21) tmp = 1.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, 1.08e+21], 1.0, N[Sqrt[0.5], $MachinePrecision]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;p\_m \leq 1.08 \cdot 10^{+21}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if p < 1.08e21Initial program 73.8%
Taylor expanded in x around inf 43.7%
if 1.08e21 < p Initial program 95.5%
Taylor expanded in x around 0 89.7%
Final simplification55.4%
p_m = (fabs.f64 p) (FPCore (p_m x) :precision binary64 (sqrt 0.5))
p_m = fabs(p);
double code(double p_m, double x) {
return sqrt(0.5);
}
p_m = abs(p)
real(8) function code(p_m, x)
real(8), intent (in) :: p_m
real(8), intent (in) :: x
code = sqrt(0.5d0)
end function
p_m = Math.abs(p);
public static double code(double p_m, double x) {
return Math.sqrt(0.5);
}
p_m = math.fabs(p) def code(p_m, x): return math.sqrt(0.5)
p_m = abs(p) function code(p_m, x) return sqrt(0.5) end
p_m = abs(p); function tmp = code(p_m, x) tmp = sqrt(0.5); end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := N[Sqrt[0.5], $MachinePrecision]
\begin{array}{l}
p_m = \left|p\right|
\\
\sqrt{0.5}
\end{array}
Initial program 79.3%
Taylor expanded in x around 0 53.0%
p_m = (fabs.f64 p) (FPCore (p_m x) :precision binary64 (if (<= x -9.5e+43) 0.0 1.5))
p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (x <= -9.5e+43) {
tmp = 0.0;
} else {
tmp = 1.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 (x <= (-9.5d+43)) then
tmp = 0.0d0
else
tmp = 1.5d0
end if
code = tmp
end function
p_m = Math.abs(p);
public static double code(double p_m, double x) {
double tmp;
if (x <= -9.5e+43) {
tmp = 0.0;
} else {
tmp = 1.5;
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if x <= -9.5e+43: tmp = 0.0 else: tmp = 1.5 return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (x <= -9.5e+43) tmp = 0.0; else tmp = 1.5; end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) tmp = 0.0; if (x <= -9.5e+43) tmp = 0.0; else tmp = 1.5; end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[x, -9.5e+43], 0.0, 1.5]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.5 \cdot 10^{+43}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;1.5\\
\end{array}
\end{array}
if x < -9.5000000000000004e43Initial program 46.2%
Taylor expanded in x around -inf 23.2%
neg-mul-123.2%
Simplified23.2%
Taylor expanded in x around 0 23.2%
if -9.5000000000000004e43 < x Initial program 85.1%
Taylor expanded in x around 0 58.0%
Applied egg-rr17.1%
p_m = (fabs.f64 p) (FPCore (p_m x) :precision binary64 (if (<= x -2.2e+44) 0.0 0.015625))
p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (x <= -2.2e+44) {
tmp = 0.0;
} else {
tmp = 0.015625;
}
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 <= (-2.2d+44)) then
tmp = 0.0d0
else
tmp = 0.015625d0
end if
code = tmp
end function
p_m = Math.abs(p);
public static double code(double p_m, double x) {
double tmp;
if (x <= -2.2e+44) {
tmp = 0.0;
} else {
tmp = 0.015625;
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if x <= -2.2e+44: tmp = 0.0 else: tmp = 0.015625 return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (x <= -2.2e+44) tmp = 0.0; else tmp = 0.015625; end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) tmp = 0.0; if (x <= -2.2e+44) tmp = 0.0; else tmp = 0.015625; end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[x, -2.2e+44], 0.0, 0.015625]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.2 \cdot 10^{+44}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;0.015625\\
\end{array}
\end{array}
if x < -2.19999999999999996e44Initial program 46.2%
Taylor expanded in x around -inf 23.2%
neg-mul-123.2%
Simplified23.2%
Taylor expanded in x around 0 23.2%
if -2.19999999999999996e44 < x Initial program 85.1%
Taylor expanded in x around 0 58.0%
Applied egg-rr13.4%
p_m = (fabs.f64 p) (FPCore (p_m x) :precision binary64 0.0)
p_m = fabs(p);
double code(double p_m, double x) {
return 0.0;
}
p_m = abs(p)
real(8) function code(p_m, x)
real(8), intent (in) :: p_m
real(8), intent (in) :: x
code = 0.0d0
end function
p_m = Math.abs(p);
public static double code(double p_m, double x) {
return 0.0;
}
p_m = math.fabs(p) def code(p_m, x): return 0.0
p_m = abs(p) function code(p_m, x) return 0.0 end
p_m = abs(p); function tmp = code(p_m, x) tmp = 0.0; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := 0.0
\begin{array}{l}
p_m = \left|p\right|
\\
0
\end{array}
Initial program 79.3%
Taylor expanded in x around -inf 6.3%
neg-mul-16.3%
Simplified6.3%
Taylor expanded in x around 0 6.3%
(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 2024139
(FPCore (p x)
:name "Given's Rotation SVD example"
:precision binary64
:pre (and (< 1e-150 (fabs x)) (< (fabs x) 1e+150))
:alt
(! :herbie-platform default (sqrt (+ 1/2 (/ (copysign 1/2 x) (hypot 1 (/ (* 2 p) x))))))
(sqrt (* 0.5 (+ 1.0 (/ x (sqrt (+ (* (* 4.0 p) p) (* x x))))))))