
(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 14 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%
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(Float64(-sqrt(0.5)) * Float64(Float64(p_m * sqrt(2.0)) / 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:\\
\;\;\;\;\left(-\sqrt{0.5}\right) \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%
associate-*r/56.4%
associate-*r*56.4%
neg-mul-156.4%
Simplified56.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)
(/ p_m p_m)
(if (<= p_m 3.8e-153)
(* (* p_m (sqrt 0.5)) (/ (sqrt 2.0) (- x)))
(if (<= p_m 2.9e+20)
(/ p_m p_m)
(* (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 = p_m / p_m;
} else if (p_m <= 3.8e-153) {
tmp = (p_m * sqrt(0.5)) * (sqrt(2.0) / -x);
} else if (p_m <= 2.9e+20) {
tmp = p_m / p_m;
} 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 = p_m / p_m
else if (p_m <= 3.8d-153) then
tmp = (p_m * sqrt(0.5d0)) * (sqrt(2.0d0) / -x)
else if (p_m <= 2.9d+20) then
tmp = p_m / p_m
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 = p_m / p_m;
} else if (p_m <= 3.8e-153) {
tmp = (p_m * Math.sqrt(0.5)) * (Math.sqrt(2.0) / -x);
} else if (p_m <= 2.9e+20) {
tmp = p_m / p_m;
} 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 = p_m / p_m elif p_m <= 3.8e-153: tmp = (p_m * math.sqrt(0.5)) * (math.sqrt(2.0) / -x) elif p_m <= 2.9e+20: tmp = p_m / p_m 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 = Float64(p_m / p_m); elseif (p_m <= 3.8e-153) tmp = Float64(Float64(p_m * sqrt(0.5)) * Float64(sqrt(2.0) / Float64(-x))); elseif (p_m <= 2.9e+20) tmp = Float64(p_m / p_m); 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 = p_m / p_m; elseif (p_m <= 3.8e-153) tmp = (p_m * sqrt(0.5)) * (sqrt(2.0) / -x); elseif (p_m <= 2.9e+20) tmp = p_m / p_m; 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], N[(p$95$m / p$95$m), $MachinePrecision], If[LessEqual[p$95$m, 3.8e-153], N[(N[(p$95$m * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-x)), $MachinePrecision]), $MachinePrecision], If[LessEqual[p$95$m, 2.9e+20], N[(p$95$m / p$95$m), $MachinePrecision], 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}:\\
\;\;\;\;\frac{p\_m}{p\_m}\\
\mathbf{elif}\;p\_m \leq 3.8 \cdot 10^{-153}:\\
\;\;\;\;\left(p\_m \cdot \sqrt{0.5}\right) \cdot \frac{\sqrt{2}}{-x}\\
\mathbf{elif}\;p\_m \leq 2.9 \cdot 10^{+20}:\\
\;\;\;\;\frac{p\_m}{p\_m}\\
\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%
add-sqr-sqrt76.3%
hypot-define76.3%
associate-*l*76.3%
sqrt-prod76.3%
metadata-eval76.3%
sqrt-unprod22.2%
add-sqr-sqrt76.3%
Applied egg-rr76.3%
Applied egg-rr43.6%
if 2.7000000000000001e-278 < p < 3.80000000000000023e-153Initial program 58.1%
add-sqr-sqrt58.1%
hypot-define58.1%
associate-*l*58.1%
sqrt-prod58.1%
metadata-eval58.1%
sqrt-unprod58.1%
add-sqr-sqrt58.1%
Applied egg-rr58.1%
Taylor expanded in x around -inf 58.0%
mul-1-neg58.0%
associate-*r*58.2%
associate-/l*58.2%
distribute-rgt-neg-in58.2%
*-commutative58.2%
Simplified58.2%
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)
(/ p_m p_m)
(if (<= p_m 9e-152)
(* (* p_m (sqrt 0.5)) (/ (sqrt 2.0) (- x)))
(if (<= p_m 3.6e+22) (/ p_m p_m) (sqrt (+ 0.5 (* 0.25 (/ x p_m))))))))p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (p_m <= 8.8e-277) {
tmp = p_m / p_m;
} else if (p_m <= 9e-152) {
tmp = (p_m * sqrt(0.5)) * (sqrt(2.0) / -x);
} else if (p_m <= 3.6e+22) {
tmp = p_m / p_m;
} else {
tmp = sqrt((0.5 + (0.25 * (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 (p_m <= 8.8d-277) then
tmp = p_m / p_m
else if (p_m <= 9d-152) then
tmp = (p_m * sqrt(0.5d0)) * (sqrt(2.0d0) / -x)
else if (p_m <= 3.6d+22) then
tmp = p_m / p_m
else
tmp = sqrt((0.5d0 + (0.25d0 * (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 (p_m <= 8.8e-277) {
tmp = p_m / p_m;
} else if (p_m <= 9e-152) {
tmp = (p_m * Math.sqrt(0.5)) * (Math.sqrt(2.0) / -x);
} else if (p_m <= 3.6e+22) {
tmp = p_m / p_m;
} else {
tmp = Math.sqrt((0.5 + (0.25 * (x / p_m))));
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if p_m <= 8.8e-277: tmp = p_m / p_m elif p_m <= 9e-152: tmp = (p_m * math.sqrt(0.5)) * (math.sqrt(2.0) / -x) elif p_m <= 3.6e+22: tmp = p_m / p_m else: tmp = math.sqrt((0.5 + (0.25 * (x / p_m)))) return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (p_m <= 8.8e-277) tmp = Float64(p_m / p_m); elseif (p_m <= 9e-152) tmp = Float64(Float64(p_m * sqrt(0.5)) * Float64(sqrt(2.0) / Float64(-x))); elseif (p_m <= 3.6e+22) tmp = Float64(p_m / p_m); else tmp = sqrt(Float64(0.5 + Float64(0.25 * Float64(x / 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 = p_m / p_m; elseif (p_m <= 9e-152) tmp = (p_m * sqrt(0.5)) * (sqrt(2.0) / -x); elseif (p_m <= 3.6e+22) tmp = p_m / p_m; else tmp = sqrt((0.5 + (0.25 * (x / 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], N[(p$95$m / p$95$m), $MachinePrecision], If[LessEqual[p$95$m, 9e-152], N[(N[(p$95$m * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-x)), $MachinePrecision]), $MachinePrecision], If[LessEqual[p$95$m, 3.6e+22], N[(p$95$m / p$95$m), $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.25 * N[(x / p$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;p\_m \leq 8.8 \cdot 10^{-277}:\\
\;\;\;\;\frac{p\_m}{p\_m}\\
\mathbf{elif}\;p\_m \leq 9 \cdot 10^{-152}:\\
\;\;\;\;\left(p\_m \cdot \sqrt{0.5}\right) \cdot \frac{\sqrt{2}}{-x}\\
\mathbf{elif}\;p\_m \leq 3.6 \cdot 10^{+22}:\\
\;\;\;\;\frac{p\_m}{p\_m}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + 0.25 \cdot \frac{x}{p\_m}}\\
\end{array}
\end{array}
if p < 8.79999999999999983e-277 or 9.0000000000000008e-152 < p < 3.6e22Initial program 76.3%
add-sqr-sqrt76.3%
hypot-define76.3%
associate-*l*76.3%
sqrt-prod76.3%
metadata-eval76.3%
sqrt-unprod22.2%
add-sqr-sqrt76.3%
Applied egg-rr76.3%
Applied egg-rr43.6%
if 8.79999999999999983e-277 < p < 9.0000000000000008e-152Initial program 58.1%
add-sqr-sqrt58.1%
hypot-define58.1%
associate-*l*58.1%
sqrt-prod58.1%
metadata-eval58.1%
sqrt-unprod58.1%
add-sqr-sqrt58.1%
Applied egg-rr58.1%
Taylor expanded in x around -inf 58.0%
mul-1-neg58.0%
associate-*r*58.2%
associate-/l*58.2%
distribute-rgt-neg-in58.2%
*-commutative58.2%
Simplified58.2%
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%
Final simplification56.8%
p_m = (fabs.f64 p)
(FPCore (p_m x)
:precision binary64
(if (<= p_m 2.2e-276)
(/ p_m p_m)
(if (<= p_m 1.25e-151)
(* (sqrt 0.5) (* (sqrt 2.0) (/ p_m (- x))))
(if (<= p_m 2.2e+20) (/ p_m p_m) (sqrt (+ 0.5 (* 0.25 (/ x p_m))))))))p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (p_m <= 2.2e-276) {
tmp = p_m / p_m;
} else if (p_m <= 1.25e-151) {
tmp = sqrt(0.5) * (sqrt(2.0) * (p_m / -x));
} else if (p_m <= 2.2e+20) {
tmp = p_m / p_m;
} else {
tmp = sqrt((0.5 + (0.25 * (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 (p_m <= 2.2d-276) then
tmp = p_m / p_m
else if (p_m <= 1.25d-151) then
tmp = sqrt(0.5d0) * (sqrt(2.0d0) * (p_m / -x))
else if (p_m <= 2.2d+20) then
tmp = p_m / p_m
else
tmp = sqrt((0.5d0 + (0.25d0 * (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 (p_m <= 2.2e-276) {
tmp = p_m / p_m;
} else if (p_m <= 1.25e-151) {
tmp = Math.sqrt(0.5) * (Math.sqrt(2.0) * (p_m / -x));
} else if (p_m <= 2.2e+20) {
tmp = p_m / p_m;
} else {
tmp = Math.sqrt((0.5 + (0.25 * (x / p_m))));
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if p_m <= 2.2e-276: tmp = p_m / p_m elif p_m <= 1.25e-151: tmp = math.sqrt(0.5) * (math.sqrt(2.0) * (p_m / -x)) elif p_m <= 2.2e+20: tmp = p_m / p_m else: tmp = math.sqrt((0.5 + (0.25 * (x / p_m)))) return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (p_m <= 2.2e-276) tmp = Float64(p_m / p_m); elseif (p_m <= 1.25e-151) tmp = Float64(sqrt(0.5) * Float64(sqrt(2.0) * Float64(p_m / Float64(-x)))); elseif (p_m <= 2.2e+20) tmp = Float64(p_m / p_m); else tmp = sqrt(Float64(0.5 + Float64(0.25 * Float64(x / 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 = p_m / p_m; elseif (p_m <= 1.25e-151) tmp = sqrt(0.5) * (sqrt(2.0) * (p_m / -x)); elseif (p_m <= 2.2e+20) tmp = p_m / p_m; else tmp = sqrt((0.5 + (0.25 * (x / 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], N[(p$95$m / p$95$m), $MachinePrecision], If[LessEqual[p$95$m, 1.25e-151], 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.2e+20], N[(p$95$m / p$95$m), $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.25 * N[(x / p$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;p\_m \leq 2.2 \cdot 10^{-276}:\\
\;\;\;\;\frac{p\_m}{p\_m}\\
\mathbf{elif}\;p\_m \leq 1.25 \cdot 10^{-151}:\\
\;\;\;\;\sqrt{0.5} \cdot \left(\sqrt{2} \cdot \frac{p\_m}{-x}\right)\\
\mathbf{elif}\;p\_m \leq 2.2 \cdot 10^{+20}:\\
\;\;\;\;\frac{p\_m}{p\_m}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + 0.25 \cdot \frac{x}{p\_m}}\\
\end{array}
\end{array}
if p < 2.19999999999999981e-276 or 1.25000000000000001e-151 < p < 2.2e20Initial program 76.3%
add-sqr-sqrt76.3%
hypot-define76.3%
associate-*l*76.3%
sqrt-prod76.3%
metadata-eval76.3%
sqrt-unprod22.2%
add-sqr-sqrt76.3%
Applied egg-rr76.3%
Applied egg-rr43.6%
if 2.19999999999999981e-276 < p < 1.25000000000000001e-151Initial 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%
Simplified58.1%
Taylor expanded in p around 0 58.1%
*-commutative58.1%
associate-*r/58.1%
Simplified58.1%
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%
Final simplification56.8%
p_m = (fabs.f64 p)
(FPCore (p_m x)
:precision binary64
(if (<= p_m 1.4e-277)
(/ p_m p_m)
(if (<= p_m 1.65e-153)
(* p_m (* (sqrt 0.5) (/ (sqrt 2.0) (- x))))
(if (<= p_m 1.02e+21) (/ p_m p_m) (sqrt (+ 0.5 (* 0.25 (/ x p_m))))))))p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (p_m <= 1.4e-277) {
tmp = p_m / p_m;
} 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 = p_m / p_m;
} else {
tmp = sqrt((0.5 + (0.25 * (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 (p_m <= 1.4d-277) then
tmp = p_m / p_m
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 = p_m / p_m
else
tmp = sqrt((0.5d0 + (0.25d0 * (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 (p_m <= 1.4e-277) {
tmp = p_m / p_m;
} 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 = p_m / p_m;
} else {
tmp = Math.sqrt((0.5 + (0.25 * (x / p_m))));
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if p_m <= 1.4e-277: tmp = p_m / p_m 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 = p_m / p_m else: tmp = math.sqrt((0.5 + (0.25 * (x / p_m)))) return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (p_m <= 1.4e-277) tmp = Float64(p_m / p_m); elseif (p_m <= 1.65e-153) tmp = Float64(p_m * Float64(sqrt(0.5) * Float64(sqrt(2.0) / Float64(-x)))); elseif (p_m <= 1.02e+21) tmp = Float64(p_m / p_m); else tmp = sqrt(Float64(0.5 + Float64(0.25 * Float64(x / 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 = p_m / p_m; elseif (p_m <= 1.65e-153) tmp = p_m * (sqrt(0.5) * (sqrt(2.0) / -x)); elseif (p_m <= 1.02e+21) tmp = p_m / p_m; else tmp = sqrt((0.5 + (0.25 * (x / 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], N[(p$95$m / p$95$m), $MachinePrecision], If[LessEqual[p$95$m, 1.65e-153], 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, 1.02e+21], N[(p$95$m / p$95$m), $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.25 * N[(x / p$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;p\_m \leq 1.4 \cdot 10^{-277}:\\
\;\;\;\;\frac{p\_m}{p\_m}\\
\mathbf{elif}\;p\_m \leq 1.65 \cdot 10^{-153}:\\
\;\;\;\;p\_m \cdot \left(\sqrt{0.5} \cdot \frac{\sqrt{2}}{-x}\right)\\
\mathbf{elif}\;p\_m \leq 1.02 \cdot 10^{+21}:\\
\;\;\;\;\frac{p\_m}{p\_m}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + 0.25 \cdot \frac{x}{p\_m}}\\
\end{array}
\end{array}
if p < 1.39999999999999988e-277 or 1.64999999999999994e-153 < p < 1.02e21Initial program 76.3%
add-sqr-sqrt76.3%
hypot-define76.3%
associate-*l*76.3%
sqrt-prod76.3%
metadata-eval76.3%
sqrt-unprod22.2%
add-sqr-sqrt76.3%
Applied egg-rr76.3%
Applied egg-rr43.6%
if 1.39999999999999988e-277 < p < 1.64999999999999994e-153Initial program 58.1%
Taylor expanded in x around -inf 58.0%
mul-1-neg58.0%
associate-/l*57.9%
distribute-lft-neg-in57.9%
associate-/l*58.2%
Simplified58.2%
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%
Final simplification56.8%
p_m = (fabs.f64 p)
(FPCore (p_m x)
:precision binary64
(if (<= p_m 3.8e-276)
(/ p_m p_m)
(if (<= p_m 1.1e-153)
(/ (* p_m (* (sqrt 0.5) (sqrt 2.0))) (- x))
(if (<= p_m 7.8e+21) (/ p_m p_m) (sqrt (+ 0.5 (* 0.25 (/ x p_m))))))))p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (p_m <= 3.8e-276) {
tmp = p_m / p_m;
} else if (p_m <= 1.1e-153) {
tmp = (p_m * (sqrt(0.5) * sqrt(2.0))) / -x;
} else if (p_m <= 7.8e+21) {
tmp = p_m / p_m;
} else {
tmp = sqrt((0.5 + (0.25 * (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 (p_m <= 3.8d-276) then
tmp = p_m / p_m
else if (p_m <= 1.1d-153) then
tmp = (p_m * (sqrt(0.5d0) * sqrt(2.0d0))) / -x
else if (p_m <= 7.8d+21) then
tmp = p_m / p_m
else
tmp = sqrt((0.5d0 + (0.25d0 * (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 (p_m <= 3.8e-276) {
tmp = p_m / p_m;
} else if (p_m <= 1.1e-153) {
tmp = (p_m * (Math.sqrt(0.5) * Math.sqrt(2.0))) / -x;
} else if (p_m <= 7.8e+21) {
tmp = p_m / p_m;
} else {
tmp = Math.sqrt((0.5 + (0.25 * (x / p_m))));
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if p_m <= 3.8e-276: tmp = p_m / p_m elif p_m <= 1.1e-153: tmp = (p_m * (math.sqrt(0.5) * math.sqrt(2.0))) / -x elif p_m <= 7.8e+21: tmp = p_m / p_m else: tmp = math.sqrt((0.5 + (0.25 * (x / p_m)))) return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (p_m <= 3.8e-276) tmp = Float64(p_m / p_m); elseif (p_m <= 1.1e-153) tmp = Float64(Float64(p_m * Float64(sqrt(0.5) * sqrt(2.0))) / Float64(-x)); elseif (p_m <= 7.8e+21) tmp = Float64(p_m / p_m); else tmp = sqrt(Float64(0.5 + Float64(0.25 * Float64(x / p_m)))); end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) tmp = 0.0; if (p_m <= 3.8e-276) tmp = p_m / p_m; elseif (p_m <= 1.1e-153) tmp = (p_m * (sqrt(0.5) * sqrt(2.0))) / -x; elseif (p_m <= 7.8e+21) tmp = p_m / p_m; else tmp = sqrt((0.5 + (0.25 * (x / p_m)))); end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[p$95$m, 3.8e-276], N[(p$95$m / p$95$m), $MachinePrecision], If[LessEqual[p$95$m, 1.1e-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, 7.8e+21], N[(p$95$m / p$95$m), $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.25 * N[(x / p$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;p\_m \leq 3.8 \cdot 10^{-276}:\\
\;\;\;\;\frac{p\_m}{p\_m}\\
\mathbf{elif}\;p\_m \leq 1.1 \cdot 10^{-153}:\\
\;\;\;\;\frac{p\_m \cdot \left(\sqrt{0.5} \cdot \sqrt{2}\right)}{-x}\\
\mathbf{elif}\;p\_m \leq 7.8 \cdot 10^{+21}:\\
\;\;\;\;\frac{p\_m}{p\_m}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + 0.25 \cdot \frac{x}{p\_m}}\\
\end{array}
\end{array}
if p < 3.8e-276 or 1.1e-153 < p < 7.8e21Initial program 76.3%
add-sqr-sqrt76.3%
hypot-define76.3%
associate-*l*76.3%
sqrt-prod76.3%
metadata-eval76.3%
sqrt-unprod22.2%
add-sqr-sqrt76.3%
Applied egg-rr76.3%
Applied egg-rr43.6%
if 3.8e-276 < p < 1.1e-153Initial program 58.1%
Taylor expanded in x around -inf 58.0%
mul-1-neg58.0%
Simplified58.0%
if 7.8e21 < 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%
Final simplification56.8%
p_m = (fabs.f64 p) (FPCore (p_m x) :precision binary64 (if (<= p_m 6.8e+20) (/ p_m p_m) (sqrt (+ 0.5 (* 0.25 (/ x p_m))))))
p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (p_m <= 6.8e+20) {
tmp = p_m / p_m;
} else {
tmp = sqrt((0.5 + (0.25 * (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 (p_m <= 6.8d+20) then
tmp = p_m / p_m
else
tmp = sqrt((0.5d0 + (0.25d0 * (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 (p_m <= 6.8e+20) {
tmp = p_m / p_m;
} else {
tmp = Math.sqrt((0.5 + (0.25 * (x / p_m))));
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if p_m <= 6.8e+20: tmp = p_m / p_m else: tmp = math.sqrt((0.5 + (0.25 * (x / p_m)))) return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (p_m <= 6.8e+20) tmp = Float64(p_m / p_m); else tmp = sqrt(Float64(0.5 + Float64(0.25 * Float64(x / p_m)))); end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) tmp = 0.0; if (p_m <= 6.8e+20) tmp = p_m / p_m; else tmp = sqrt((0.5 + (0.25 * (x / p_m)))); end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[p$95$m, 6.8e+20], N[(p$95$m / p$95$m), $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.25 * N[(x / p$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;p\_m \leq 6.8 \cdot 10^{+20}:\\
\;\;\;\;\frac{p\_m}{p\_m}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + 0.25 \cdot \frac{x}{p\_m}}\\
\end{array}
\end{array}
if p < 6.8e20Initial program 73.8%
add-sqr-sqrt73.8%
hypot-define73.8%
associate-*l*73.8%
sqrt-prod73.8%
metadata-eval73.8%
sqrt-unprod27.0%
add-sqr-sqrt73.8%
Applied egg-rr73.8%
Applied egg-rr43.7%
if 6.8e20 < 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%
p_m = (fabs.f64 p) (FPCore (p_m x) :precision binary64 (if (<= p_m 1.8e+20) (/ p_m p_m) (sqrt 0.5)))
p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (p_m <= 1.8e+20) {
tmp = p_m / 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 <= 1.8d+20) then
tmp = p_m / 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 <= 1.8e+20) {
tmp = p_m / 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 <= 1.8e+20: tmp = p_m / 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 <= 1.8e+20) tmp = Float64(p_m / 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 <= 1.8e+20) tmp = p_m / 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, 1.8e+20], N[(p$95$m / p$95$m), $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;p\_m \leq 1.8 \cdot 10^{+20}:\\
\;\;\;\;\frac{p\_m}{p\_m}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if p < 1.8e20Initial program 73.8%
add-sqr-sqrt73.8%
hypot-define73.8%
associate-*l*73.8%
sqrt-prod73.8%
metadata-eval73.8%
sqrt-unprod27.0%
add-sqr-sqrt73.8%
Applied egg-rr73.8%
Applied egg-rr43.7%
if 1.8e20 < p Initial program 95.5%
Taylor expanded in x around 0 89.7%
p_m = (fabs.f64 p) (FPCore (p_m x) :precision binary64 (if (<= x -2.3e+44) (* p_m p_m) (/ p_m p_m)))
p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (x <= -2.3e+44) {
tmp = p_m * p_m;
} else {
tmp = p_m / 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 <= (-2.3d+44)) then
tmp = p_m * p_m
else
tmp = p_m / 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 <= -2.3e+44) {
tmp = p_m * p_m;
} else {
tmp = p_m / p_m;
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if x <= -2.3e+44: tmp = p_m * p_m else: tmp = p_m / p_m return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (x <= -2.3e+44) tmp = Float64(p_m * p_m); else tmp = Float64(p_m / p_m); end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) tmp = 0.0; if (x <= -2.3e+44) tmp = p_m * p_m; else tmp = p_m / p_m; end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[x, -2.3e+44], N[(p$95$m * p$95$m), $MachinePrecision], N[(p$95$m / p$95$m), $MachinePrecision]]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3 \cdot 10^{+44}:\\
\;\;\;\;p\_m \cdot p\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{p\_m}{p\_m}\\
\end{array}
\end{array}
if x < -2.30000000000000004e44Initial program 46.2%
add-sqr-sqrt46.2%
hypot-define46.2%
associate-*l*46.2%
sqrt-prod46.2%
metadata-eval46.2%
sqrt-unprod26.1%
add-sqr-sqrt46.2%
Applied egg-rr46.2%
Applied egg-rr24.5%
if -2.30000000000000004e44 < x Initial program 85.1%
add-sqr-sqrt85.1%
hypot-define85.1%
associate-*l*85.1%
sqrt-prod85.1%
metadata-eval85.1%
sqrt-unprod47.6%
add-sqr-sqrt85.1%
Applied egg-rr85.1%
Applied egg-rr44.1%
p_m = (fabs.f64 p) (FPCore (p_m x) :precision binary64 (if (<= x -8.5e+43) (* p_m p_m) 1.5))
p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (x <= -8.5e+43) {
tmp = p_m * p_m;
} 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 <= (-8.5d+43)) then
tmp = p_m * p_m
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 <= -8.5e+43) {
tmp = p_m * p_m;
} else {
tmp = 1.5;
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if x <= -8.5e+43: tmp = p_m * p_m else: tmp = 1.5 return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (x <= -8.5e+43) tmp = Float64(p_m * p_m); else tmp = 1.5; end return tmp end
p_m = abs(p); function tmp_2 = code(p_m, x) tmp = 0.0; if (x <= -8.5e+43) tmp = p_m * p_m; else tmp = 1.5; end tmp_2 = tmp; end
p_m = N[Abs[p], $MachinePrecision] code[p$95$m_, x_] := If[LessEqual[x, -8.5e+43], N[(p$95$m * p$95$m), $MachinePrecision], 1.5]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{+43}:\\
\;\;\;\;p\_m \cdot p\_m\\
\mathbf{else}:\\
\;\;\;\;1.5\\
\end{array}
\end{array}
if x < -8.5e43Initial program 46.2%
add-sqr-sqrt46.2%
hypot-define46.2%
associate-*l*46.2%
sqrt-prod46.2%
metadata-eval46.2%
sqrt-unprod26.1%
add-sqr-sqrt46.2%
Applied egg-rr46.2%
Applied egg-rr24.5%
if -8.5e43 < 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 -6e+45) 0.0 1.5))
p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (x <= -6e+45) {
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 <= (-6d+45)) 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 <= -6e+45) {
tmp = 0.0;
} else {
tmp = 1.5;
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if x <= -6e+45: tmp = 0.0 else: tmp = 1.5 return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (x <= -6e+45) 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 <= -6e+45) 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, -6e+45], 0.0, 1.5]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6 \cdot 10^{+45}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;1.5\\
\end{array}
\end{array}
if x < -6.00000000000000021e45Initial 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 -6.00000000000000021e45 < 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 -1.66e+44) 0.0 0.015625))
p_m = fabs(p);
double code(double p_m, double x) {
double tmp;
if (x <= -1.66e+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 <= (-1.66d+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 <= -1.66e+44) {
tmp = 0.0;
} else {
tmp = 0.015625;
}
return tmp;
}
p_m = math.fabs(p) def code(p_m, x): tmp = 0 if x <= -1.66e+44: tmp = 0.0 else: tmp = 0.015625 return tmp
p_m = abs(p) function code(p_m, x) tmp = 0.0 if (x <= -1.66e+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 <= -1.66e+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, -1.66e+44], 0.0, 0.015625]
\begin{array}{l}
p_m = \left|p\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.66 \cdot 10^{+44}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;0.015625\\
\end{array}
\end{array}
if x < -1.65999999999999992e44Initial 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 -1.65999999999999992e44 < 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))))))))