
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* M_m (* (/ 0.5 d) D))) (t_1 (/ t_0 l)) (t_2 (sqrt (- d))))
(if (<= h -5e-310)
(*
(/ t_2 (sqrt (- h)))
(* (/ t_2 (sqrt (- l))) (+ 1.0 (* h (* t_1 (/ t_0 -2.0))))))
(if (<= h 2.5e+195)
(*
(sqrt (/ d h))
(*
(/ (sqrt d) (sqrt l))
(+ 1.0 (* h (* t_1 (/ (/ 0.5 (/ d (* M_m D))) -2.0))))))
(*
(/ (sqrt d) (sqrt h))
(*
(+ 1.0 (* (/ h l) (* (pow (* (/ M_m 2.0) (/ D d)) 2.0) -0.5)))
(sqrt (/ d l))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * ((0.5 / d) * D);
double t_1 = t_0 / l;
double t_2 = sqrt(-d);
double tmp;
if (h <= -5e-310) {
tmp = (t_2 / sqrt(-h)) * ((t_2 / sqrt(-l)) * (1.0 + (h * (t_1 * (t_0 / -2.0)))));
} else if (h <= 2.5e+195) {
tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0 + (h * (t_1 * ((0.5 / (d / (M_m * D))) / -2.0)))));
} else {
tmp = (sqrt(d) / sqrt(h)) * ((1.0 + ((h / l) * (pow(((M_m / 2.0) * (D / d)), 2.0) * -0.5))) * sqrt((d / l)));
}
return tmp;
}
M_m = abs(M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = m_m * ((0.5d0 / d) * d_1)
t_1 = t_0 / l
t_2 = sqrt(-d)
if (h <= (-5d-310)) then
tmp = (t_2 / sqrt(-h)) * ((t_2 / sqrt(-l)) * (1.0d0 + (h * (t_1 * (t_0 / (-2.0d0))))))
else if (h <= 2.5d+195) then
tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0d0 + (h * (t_1 * ((0.5d0 / (d / (m_m * d_1))) / (-2.0d0))))))
else
tmp = (sqrt(d) / sqrt(h)) * ((1.0d0 + ((h / l) * ((((m_m / 2.0d0) * (d_1 / d)) ** 2.0d0) * (-0.5d0)))) * sqrt((d / l)))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * ((0.5 / d) * D);
double t_1 = t_0 / l;
double t_2 = Math.sqrt(-d);
double tmp;
if (h <= -5e-310) {
tmp = (t_2 / Math.sqrt(-h)) * ((t_2 / Math.sqrt(-l)) * (1.0 + (h * (t_1 * (t_0 / -2.0)))));
} else if (h <= 2.5e+195) {
tmp = Math.sqrt((d / h)) * ((Math.sqrt(d) / Math.sqrt(l)) * (1.0 + (h * (t_1 * ((0.5 / (d / (M_m * D))) / -2.0)))));
} else {
tmp = (Math.sqrt(d) / Math.sqrt(h)) * ((1.0 + ((h / l) * (Math.pow(((M_m / 2.0) * (D / d)), 2.0) * -0.5))) * Math.sqrt((d / l)));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = M_m * ((0.5 / d) * D) t_1 = t_0 / l t_2 = math.sqrt(-d) tmp = 0 if h <= -5e-310: tmp = (t_2 / math.sqrt(-h)) * ((t_2 / math.sqrt(-l)) * (1.0 + (h * (t_1 * (t_0 / -2.0))))) elif h <= 2.5e+195: tmp = math.sqrt((d / h)) * ((math.sqrt(d) / math.sqrt(l)) * (1.0 + (h * (t_1 * ((0.5 / (d / (M_m * D))) / -2.0))))) else: tmp = (math.sqrt(d) / math.sqrt(h)) * ((1.0 + ((h / l) * (math.pow(((M_m / 2.0) * (D / d)), 2.0) * -0.5))) * math.sqrt((d / l))) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(M_m * Float64(Float64(0.5 / d) * D)) t_1 = Float64(t_0 / l) t_2 = sqrt(Float64(-d)) tmp = 0.0 if (h <= -5e-310) tmp = Float64(Float64(t_2 / sqrt(Float64(-h))) * Float64(Float64(t_2 / sqrt(Float64(-l))) * Float64(1.0 + Float64(h * Float64(t_1 * Float64(t_0 / -2.0)))))); elseif (h <= 2.5e+195) tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(sqrt(d) / sqrt(l)) * Float64(1.0 + Float64(h * Float64(t_1 * Float64(Float64(0.5 / Float64(d / Float64(M_m * D))) / -2.0)))))); else tmp = Float64(Float64(sqrt(d) / sqrt(h)) * Float64(Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(M_m / 2.0) * Float64(D / d)) ^ 2.0) * -0.5))) * sqrt(Float64(d / l)))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = M_m * ((0.5 / d) * D);
t_1 = t_0 / l;
t_2 = sqrt(-d);
tmp = 0.0;
if (h <= -5e-310)
tmp = (t_2 / sqrt(-h)) * ((t_2 / sqrt(-l)) * (1.0 + (h * (t_1 * (t_0 / -2.0)))));
elseif (h <= 2.5e+195)
tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0 + (h * (t_1 * ((0.5 / (d / (M_m * D))) / -2.0)))));
else
tmp = (sqrt(d) / sqrt(h)) * ((1.0 + ((h / l) * ((((M_m / 2.0) * (D / d)) ^ 2.0) * -0.5))) * sqrt((d / l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(M$95$m * N[(N[(0.5 / d), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / l), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[h, -5e-310], N[(N[(t$95$2 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[(t$95$2 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(h * N[(t$95$1 * N[(t$95$0 / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 2.5e+195], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(h * N[(t$95$1 * N[(N[(0.5 / N[(d / N[(M$95$m * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := M_m \cdot \left(\frac{0.5}{d} \cdot D\right)\\
t_1 := \frac{t_0}{\ell}\\
t_2 := \sqrt{-d}\\
\mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{t_2}{\sqrt{-h}} \cdot \left(\frac{t_2}{\sqrt{-\ell}} \cdot \left(1 + h \cdot \left(t_1 \cdot \frac{t_0}{-2}\right)\right)\right)\\
\mathbf{elif}\;h \leq 2.5 \cdot 10^{+195}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \left(1 + h \cdot \left(t_1 \cdot \frac{\frac{0.5}{\frac{d}{M_m \cdot D}}}{-2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(\left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M_m}{2} \cdot \frac{D}{d}\right)}^{2} \cdot -0.5\right)\right) \cdot \sqrt{\frac{d}{\ell}}\right)\\
\end{array}
\end{array}
if h < -4.999999999999985e-310Initial program 66.4%
Simplified64.3%
Applied egg-rr30.6%
expm1-def30.6%
expm1-log1p64.3%
associate-*l/65.9%
*-commutative65.9%
associate-*l/66.6%
*-commutative66.6%
associate-/l*66.6%
metadata-eval66.6%
times-frac66.6%
*-commutative66.6%
associate-/l*66.6%
associate-*l/66.6%
*-commutative66.6%
associate-/r*66.6%
metadata-eval66.6%
Simplified66.6%
unpow266.6%
div-inv66.6%
metadata-eval66.6%
metadata-eval66.6%
times-frac68.0%
associate-/r/68.0%
associate-/r/68.0%
metadata-eval68.0%
Applied egg-rr68.0%
frac-2neg68.0%
sqrt-div75.2%
Applied egg-rr75.2%
frac-2neg75.2%
sqrt-div89.9%
Applied egg-rr89.9%
if -4.999999999999985e-310 < h < 2.4999999999999999e195Initial program 75.3%
Simplified75.3%
Applied egg-rr44.4%
expm1-def44.4%
expm1-log1p75.3%
associate-*l/75.6%
*-commutative75.6%
associate-*l/74.6%
*-commutative74.6%
associate-/l*74.6%
metadata-eval74.6%
times-frac74.6%
*-commutative74.6%
associate-/l*74.5%
associate-*l/74.5%
*-commutative74.5%
associate-/r*74.5%
metadata-eval74.5%
Simplified74.5%
unpow274.5%
div-inv74.5%
metadata-eval74.5%
metadata-eval74.5%
times-frac75.5%
associate-/r/75.5%
associate-/r/75.6%
metadata-eval75.6%
Applied egg-rr75.6%
*-commutative75.6%
associate-*l/75.6%
associate-/r/75.6%
associate-/l*75.6%
associate-/l/75.6%
Applied egg-rr75.6%
sqrt-div88.0%
div-inv88.0%
Applied egg-rr88.0%
associate-*r/88.0%
*-rgt-identity88.0%
Simplified88.0%
if 2.4999999999999999e195 < h Initial program 46.1%
Simplified46.0%
sqrt-div83.4%
div-inv83.3%
Applied egg-rr83.3%
associate-*r/83.4%
*-rgt-identity83.4%
Simplified83.4%
Final simplification88.6%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
(- 1.0 (* (/ h l) (* 0.5 (pow (/ (* M_m D) (* d 2.0)) 2.0)))))))
(if (or (<= t_0 -4e-120) (and (not (<= t_0 0.0)) (<= t_0 5e+263)))
(*
(sqrt (/ d h))
(*
(sqrt (/ d l))
(+
1.0
(*
h
(* (/ (* M_m (* (/ 0.5 d) D)) l) (/ (* 0.5 (* M_m (/ D d))) -2.0))))))
(fabs (/ d (sqrt (* l h)))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * pow(((M_m * D) / (d * 2.0)), 2.0))));
double tmp;
if ((t_0 <= -4e-120) || (!(t_0 <= 0.0) && (t_0 <= 5e+263))) {
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 + (h * (((M_m * ((0.5 / d) * D)) / l) * ((0.5 * (M_m * (D / d))) / -2.0)))));
} else {
tmp = fabs((d / sqrt((l * h))));
}
return tmp;
}
M_m = abs(M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = (((d / h) ** 0.5d0) * ((d / l) ** 0.5d0)) * (1.0d0 - ((h / l) * (0.5d0 * (((m_m * d_1) / (d * 2.0d0)) ** 2.0d0))))
if ((t_0 <= (-4d-120)) .or. (.not. (t_0 <= 0.0d0)) .and. (t_0 <= 5d+263)) then
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0d0 + (h * (((m_m * ((0.5d0 / d) * d_1)) / l) * ((0.5d0 * (m_m * (d_1 / d))) / (-2.0d0))))))
else
tmp = abs((d / sqrt((l * h))))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = (Math.pow((d / h), 0.5) * Math.pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * Math.pow(((M_m * D) / (d * 2.0)), 2.0))));
double tmp;
if ((t_0 <= -4e-120) || (!(t_0 <= 0.0) && (t_0 <= 5e+263))) {
tmp = Math.sqrt((d / h)) * (Math.sqrt((d / l)) * (1.0 + (h * (((M_m * ((0.5 / d) * D)) / l) * ((0.5 * (M_m * (D / d))) / -2.0)))));
} else {
tmp = Math.abs((d / Math.sqrt((l * h))));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = (math.pow((d / h), 0.5) * math.pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * math.pow(((M_m * D) / (d * 2.0)), 2.0)))) tmp = 0 if (t_0 <= -4e-120) or (not (t_0 <= 0.0) and (t_0 <= 5e+263)): tmp = math.sqrt((d / h)) * (math.sqrt((d / l)) * (1.0 + (h * (((M_m * ((0.5 / d) * D)) / l) * ((0.5 * (M_m * (D / d))) / -2.0))))) else: tmp = math.fabs((d / math.sqrt((l * h)))) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.5 * (Float64(Float64(M_m * D) / Float64(d * 2.0)) ^ 2.0))))) tmp = 0.0 if ((t_0 <= -4e-120) || (!(t_0 <= 0.0) && (t_0 <= 5e+263))) tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(h * Float64(Float64(Float64(M_m * Float64(Float64(0.5 / d) * D)) / l) * Float64(Float64(0.5 * Float64(M_m * Float64(D / d))) / -2.0)))))); else tmp = abs(Float64(d / sqrt(Float64(l * h)))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (((d / h) ^ 0.5) * ((d / l) ^ 0.5)) * (1.0 - ((h / l) * (0.5 * (((M_m * D) / (d * 2.0)) ^ 2.0))));
tmp = 0.0;
if ((t_0 <= -4e-120) || (~((t_0 <= 0.0)) && (t_0 <= 5e+263)))
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 + (h * (((M_m * ((0.5 / d) * D)) / l) * ((0.5 * (M_m * (D / d))) / -2.0)))));
else
tmp = abs((d / sqrt((l * h))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.5 * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -4e-120], And[N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision], LessEqual[t$95$0, 5e+263]]], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(N[(N[(M$95$m * N[(N[(0.5 / d), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(N[(0.5 * N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{M_m \cdot D}{d \cdot 2}\right)}^{2}\right)\right)\\
\mathbf{if}\;t_0 \leq -4 \cdot 10^{-120} \lor \neg \left(t_0 \leq 0\right) \land t_0 \leq 5 \cdot 10^{+263}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + h \cdot \left(\frac{M_m \cdot \left(\frac{0.5}{d} \cdot D\right)}{\ell} \cdot \frac{0.5 \cdot \left(M_m \cdot \frac{D}{d}\right)}{-2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < -3.99999999999999991e-120 or 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < 5.00000000000000022e263Initial program 93.8%
Simplified91.9%
Applied egg-rr41.4%
expm1-def41.4%
expm1-log1p91.9%
associate-*l/92.0%
*-commutative92.0%
associate-*l/92.0%
*-commutative92.0%
associate-/l*92.0%
metadata-eval92.0%
times-frac92.0%
*-commutative92.0%
associate-/l*91.9%
associate-*l/91.9%
*-commutative91.9%
associate-/r*91.9%
metadata-eval91.9%
Simplified91.9%
unpow291.9%
div-inv91.9%
metadata-eval91.9%
metadata-eval91.9%
times-frac93.1%
associate-/r/93.1%
associate-/r/93.2%
metadata-eval93.2%
Applied egg-rr93.2%
Taylor expanded in M around 0 92.6%
*-commutative92.6%
associate-*r/93.2%
Simplified93.2%
if -3.99999999999999991e-120 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < 0.0 or 5.00000000000000022e263 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) Initial program 23.4%
Simplified23.4%
Taylor expanded in h around 0 26.5%
*-rgt-identity26.5%
sqrt-unprod25.6%
Applied egg-rr25.6%
frac-times30.7%
unpow230.7%
associate-/l/27.6%
add-sqr-sqrt27.6%
rem-sqrt-square27.6%
associate-/l/30.7%
sqrt-div36.5%
unpow236.5%
sqrt-prod24.5%
add-sqr-sqrt56.7%
*-commutative56.7%
Applied egg-rr56.7%
Final simplification79.6%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* M_m (* (/ 0.5 d) D))) (t_1 (sqrt (- d))))
(if (<= l -1e-310)
(*
(/ t_1 (sqrt (- h)))
(* (/ t_1 (sqrt (- l))) (+ 1.0 (* h (* (/ t_0 l) (/ t_0 -2.0))))))
(*
(/ 1.0 (/ (sqrt h) (sqrt d)))
(*
(/ (sqrt d) (sqrt l))
(+ 1.0 (* (/ h l) (* (pow (* (/ M_m 2.0) (/ D d)) 2.0) -0.5))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * ((0.5 / d) * D);
double t_1 = sqrt(-d);
double tmp;
if (l <= -1e-310) {
tmp = (t_1 / sqrt(-h)) * ((t_1 / sqrt(-l)) * (1.0 + (h * ((t_0 / l) * (t_0 / -2.0)))));
} else {
tmp = (1.0 / (sqrt(h) / sqrt(d))) * ((sqrt(d) / sqrt(l)) * (1.0 + ((h / l) * (pow(((M_m / 2.0) * (D / d)), 2.0) * -0.5))));
}
return tmp;
}
M_m = abs(M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = m_m * ((0.5d0 / d) * d_1)
t_1 = sqrt(-d)
if (l <= (-1d-310)) then
tmp = (t_1 / sqrt(-h)) * ((t_1 / sqrt(-l)) * (1.0d0 + (h * ((t_0 / l) * (t_0 / (-2.0d0))))))
else
tmp = (1.0d0 / (sqrt(h) / sqrt(d))) * ((sqrt(d) / sqrt(l)) * (1.0d0 + ((h / l) * ((((m_m / 2.0d0) * (d_1 / d)) ** 2.0d0) * (-0.5d0)))))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * ((0.5 / d) * D);
double t_1 = Math.sqrt(-d);
double tmp;
if (l <= -1e-310) {
tmp = (t_1 / Math.sqrt(-h)) * ((t_1 / Math.sqrt(-l)) * (1.0 + (h * ((t_0 / l) * (t_0 / -2.0)))));
} else {
tmp = (1.0 / (Math.sqrt(h) / Math.sqrt(d))) * ((Math.sqrt(d) / Math.sqrt(l)) * (1.0 + ((h / l) * (Math.pow(((M_m / 2.0) * (D / d)), 2.0) * -0.5))));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = M_m * ((0.5 / d) * D) t_1 = math.sqrt(-d) tmp = 0 if l <= -1e-310: tmp = (t_1 / math.sqrt(-h)) * ((t_1 / math.sqrt(-l)) * (1.0 + (h * ((t_0 / l) * (t_0 / -2.0))))) else: tmp = (1.0 / (math.sqrt(h) / math.sqrt(d))) * ((math.sqrt(d) / math.sqrt(l)) * (1.0 + ((h / l) * (math.pow(((M_m / 2.0) * (D / d)), 2.0) * -0.5)))) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(M_m * Float64(Float64(0.5 / d) * D)) t_1 = sqrt(Float64(-d)) tmp = 0.0 if (l <= -1e-310) tmp = Float64(Float64(t_1 / sqrt(Float64(-h))) * Float64(Float64(t_1 / sqrt(Float64(-l))) * Float64(1.0 + Float64(h * Float64(Float64(t_0 / l) * Float64(t_0 / -2.0)))))); else tmp = Float64(Float64(1.0 / Float64(sqrt(h) / sqrt(d))) * Float64(Float64(sqrt(d) / sqrt(l)) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(M_m / 2.0) * Float64(D / d)) ^ 2.0) * -0.5))))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = M_m * ((0.5 / d) * D);
t_1 = sqrt(-d);
tmp = 0.0;
if (l <= -1e-310)
tmp = (t_1 / sqrt(-h)) * ((t_1 / sqrt(-l)) * (1.0 + (h * ((t_0 / l) * (t_0 / -2.0)))));
else
tmp = (1.0 / (sqrt(h) / sqrt(d))) * ((sqrt(d) / sqrt(l)) * (1.0 + ((h / l) * ((((M_m / 2.0) * (D / d)) ^ 2.0) * -0.5))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(M$95$m * N[(N[(0.5 / d), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[l, -1e-310], N[(N[(t$95$1 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[(t$95$1 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(h * N[(N[(t$95$0 / l), $MachinePrecision] * N[(t$95$0 / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[h], $MachinePrecision] / N[Sqrt[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := M_m \cdot \left(\frac{0.5}{d} \cdot D\right)\\
t_1 := \sqrt{-d}\\
\mathbf{if}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\frac{t_1}{\sqrt{-h}} \cdot \left(\frac{t_1}{\sqrt{-\ell}} \cdot \left(1 + h \cdot \left(\frac{t_0}{\ell} \cdot \frac{t_0}{-2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\sqrt{h}}{\sqrt{d}}} \cdot \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M_m}{2} \cdot \frac{D}{d}\right)}^{2} \cdot -0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -9.999999999999969e-311Initial program 66.4%
Simplified64.3%
Applied egg-rr30.6%
expm1-def30.6%
expm1-log1p64.3%
associate-*l/65.9%
*-commutative65.9%
associate-*l/66.6%
*-commutative66.6%
associate-/l*66.6%
metadata-eval66.6%
times-frac66.6%
*-commutative66.6%
associate-/l*66.6%
associate-*l/66.6%
*-commutative66.6%
associate-/r*66.6%
metadata-eval66.6%
Simplified66.6%
unpow266.6%
div-inv66.6%
metadata-eval66.6%
metadata-eval66.6%
times-frac68.0%
associate-/r/68.0%
associate-/r/68.0%
metadata-eval68.0%
Applied egg-rr68.0%
frac-2neg68.0%
sqrt-div75.2%
Applied egg-rr75.2%
frac-2neg75.2%
sqrt-div89.9%
Applied egg-rr89.9%
if -9.999999999999969e-311 < l Initial program 69.2%
Simplified69.2%
sqrt-div80.2%
clear-num80.3%
Applied egg-rr80.3%
sqrt-div80.1%
div-inv80.1%
Applied egg-rr87.0%
associate-*r/80.1%
*-rgt-identity80.1%
Simplified87.0%
Final simplification88.6%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* M_m (* (/ 0.5 d) D))) (t_1 (/ t_0 l)) (t_2 (sqrt (/ d l))))
(if (<= h -5e-310)
(*
(/ (sqrt (- d)) (sqrt (- h)))
(* (+ 1.0 (* h (* t_1 (/ t_0 -2.0)))) t_2))
(if (<= h 6.5e+193)
(*
(sqrt (/ d h))
(*
(/ (sqrt d) (sqrt l))
(+ 1.0 (* h (* t_1 (/ (/ 0.5 (/ d (* M_m D))) -2.0))))))
(*
(/ (sqrt d) (sqrt h))
(*
(+ 1.0 (* (/ h l) (* (pow (* (/ M_m 2.0) (/ D d)) 2.0) -0.5)))
t_2))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * ((0.5 / d) * D);
double t_1 = t_0 / l;
double t_2 = sqrt((d / l));
double tmp;
if (h <= -5e-310) {
tmp = (sqrt(-d) / sqrt(-h)) * ((1.0 + (h * (t_1 * (t_0 / -2.0)))) * t_2);
} else if (h <= 6.5e+193) {
tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0 + (h * (t_1 * ((0.5 / (d / (M_m * D))) / -2.0)))));
} else {
tmp = (sqrt(d) / sqrt(h)) * ((1.0 + ((h / l) * (pow(((M_m / 2.0) * (D / d)), 2.0) * -0.5))) * t_2);
}
return tmp;
}
M_m = abs(M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = m_m * ((0.5d0 / d) * d_1)
t_1 = t_0 / l
t_2 = sqrt((d / l))
if (h <= (-5d-310)) then
tmp = (sqrt(-d) / sqrt(-h)) * ((1.0d0 + (h * (t_1 * (t_0 / (-2.0d0))))) * t_2)
else if (h <= 6.5d+193) then
tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0d0 + (h * (t_1 * ((0.5d0 / (d / (m_m * d_1))) / (-2.0d0))))))
else
tmp = (sqrt(d) / sqrt(h)) * ((1.0d0 + ((h / l) * ((((m_m / 2.0d0) * (d_1 / d)) ** 2.0d0) * (-0.5d0)))) * t_2)
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * ((0.5 / d) * D);
double t_1 = t_0 / l;
double t_2 = Math.sqrt((d / l));
double tmp;
if (h <= -5e-310) {
tmp = (Math.sqrt(-d) / Math.sqrt(-h)) * ((1.0 + (h * (t_1 * (t_0 / -2.0)))) * t_2);
} else if (h <= 6.5e+193) {
tmp = Math.sqrt((d / h)) * ((Math.sqrt(d) / Math.sqrt(l)) * (1.0 + (h * (t_1 * ((0.5 / (d / (M_m * D))) / -2.0)))));
} else {
tmp = (Math.sqrt(d) / Math.sqrt(h)) * ((1.0 + ((h / l) * (Math.pow(((M_m / 2.0) * (D / d)), 2.0) * -0.5))) * t_2);
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = M_m * ((0.5 / d) * D) t_1 = t_0 / l t_2 = math.sqrt((d / l)) tmp = 0 if h <= -5e-310: tmp = (math.sqrt(-d) / math.sqrt(-h)) * ((1.0 + (h * (t_1 * (t_0 / -2.0)))) * t_2) elif h <= 6.5e+193: tmp = math.sqrt((d / h)) * ((math.sqrt(d) / math.sqrt(l)) * (1.0 + (h * (t_1 * ((0.5 / (d / (M_m * D))) / -2.0))))) else: tmp = (math.sqrt(d) / math.sqrt(h)) * ((1.0 + ((h / l) * (math.pow(((M_m / 2.0) * (D / d)), 2.0) * -0.5))) * t_2) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(M_m * Float64(Float64(0.5 / d) * D)) t_1 = Float64(t_0 / l) t_2 = sqrt(Float64(d / l)) tmp = 0.0 if (h <= -5e-310) tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(Float64(1.0 + Float64(h * Float64(t_1 * Float64(t_0 / -2.0)))) * t_2)); elseif (h <= 6.5e+193) tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(sqrt(d) / sqrt(l)) * Float64(1.0 + Float64(h * Float64(t_1 * Float64(Float64(0.5 / Float64(d / Float64(M_m * D))) / -2.0)))))); else tmp = Float64(Float64(sqrt(d) / sqrt(h)) * Float64(Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(M_m / 2.0) * Float64(D / d)) ^ 2.0) * -0.5))) * t_2)); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = M_m * ((0.5 / d) * D);
t_1 = t_0 / l;
t_2 = sqrt((d / l));
tmp = 0.0;
if (h <= -5e-310)
tmp = (sqrt(-d) / sqrt(-h)) * ((1.0 + (h * (t_1 * (t_0 / -2.0)))) * t_2);
elseif (h <= 6.5e+193)
tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0 + (h * (t_1 * ((0.5 / (d / (M_m * D))) / -2.0)))));
else
tmp = (sqrt(d) / sqrt(h)) * ((1.0 + ((h / l) * ((((M_m / 2.0) * (D / d)) ^ 2.0) * -0.5))) * t_2);
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(M$95$m * N[(N[(0.5 / d), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / l), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -5e-310], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 + N[(h * N[(t$95$1 * N[(t$95$0 / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 6.5e+193], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(h * N[(t$95$1 * N[(N[(0.5 / N[(d / N[(M$95$m * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := M_m \cdot \left(\frac{0.5}{d} \cdot D\right)\\
t_1 := \frac{t_0}{\ell}\\
t_2 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\left(1 + h \cdot \left(t_1 \cdot \frac{t_0}{-2}\right)\right) \cdot t_2\right)\\
\mathbf{elif}\;h \leq 6.5 \cdot 10^{+193}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \left(1 + h \cdot \left(t_1 \cdot \frac{\frac{0.5}{\frac{d}{M_m \cdot D}}}{-2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(\left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M_m}{2} \cdot \frac{D}{d}\right)}^{2} \cdot -0.5\right)\right) \cdot t_2\right)\\
\end{array}
\end{array}
if h < -4.999999999999985e-310Initial program 66.4%
Simplified64.3%
Applied egg-rr30.6%
expm1-def30.6%
expm1-log1p64.3%
associate-*l/65.9%
*-commutative65.9%
associate-*l/66.6%
*-commutative66.6%
associate-/l*66.6%
metadata-eval66.6%
times-frac66.6%
*-commutative66.6%
associate-/l*66.6%
associate-*l/66.6%
*-commutative66.6%
associate-/r*66.6%
metadata-eval66.6%
Simplified66.6%
unpow266.6%
div-inv66.6%
metadata-eval66.6%
metadata-eval66.6%
times-frac68.0%
associate-/r/68.0%
associate-/r/68.0%
metadata-eval68.0%
Applied egg-rr68.0%
frac-2neg75.2%
sqrt-div89.9%
Applied egg-rr80.5%
if -4.999999999999985e-310 < h < 6.4999999999999997e193Initial program 75.3%
Simplified75.3%
Applied egg-rr44.4%
expm1-def44.4%
expm1-log1p75.3%
associate-*l/75.6%
*-commutative75.6%
associate-*l/74.6%
*-commutative74.6%
associate-/l*74.6%
metadata-eval74.6%
times-frac74.6%
*-commutative74.6%
associate-/l*74.5%
associate-*l/74.5%
*-commutative74.5%
associate-/r*74.5%
metadata-eval74.5%
Simplified74.5%
unpow274.5%
div-inv74.5%
metadata-eval74.5%
metadata-eval74.5%
times-frac75.5%
associate-/r/75.5%
associate-/r/75.6%
metadata-eval75.6%
Applied egg-rr75.6%
*-commutative75.6%
associate-*l/75.6%
associate-/r/75.6%
associate-/l*75.6%
associate-/l/75.6%
Applied egg-rr75.6%
sqrt-div88.0%
div-inv88.0%
Applied egg-rr88.0%
associate-*r/88.0%
*-rgt-identity88.0%
Simplified88.0%
if 6.4999999999999997e193 < h Initial program 46.1%
Simplified46.0%
sqrt-div83.4%
div-inv83.3%
Applied egg-rr83.3%
associate-*r/83.4%
*-rgt-identity83.4%
Simplified83.4%
Final simplification83.5%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* M_m (* (/ 0.5 d) D))) (t_1 (/ t_0 l)) (t_2 (sqrt (/ d h))))
(if (<= h -5e-310)
(*
(* (/ (sqrt (- d)) (sqrt (- l))) (+ 1.0 (* h (* t_1 (/ t_0 -2.0)))))
t_2)
(if (<= h 1.7e+188)
(*
t_2
(*
(/ (sqrt d) (sqrt l))
(+ 1.0 (* h (* t_1 (/ (/ 0.5 (/ d (* M_m D))) -2.0))))))
(*
(/ (sqrt d) (sqrt h))
(*
(sqrt (/ d l))
(+ 1.0 (* h (* t_1 (/ (* 0.5 (* M_m (/ D d))) -2.0))))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * ((0.5 / d) * D);
double t_1 = t_0 / l;
double t_2 = sqrt((d / h));
double tmp;
if (h <= -5e-310) {
tmp = ((sqrt(-d) / sqrt(-l)) * (1.0 + (h * (t_1 * (t_0 / -2.0))))) * t_2;
} else if (h <= 1.7e+188) {
tmp = t_2 * ((sqrt(d) / sqrt(l)) * (1.0 + (h * (t_1 * ((0.5 / (d / (M_m * D))) / -2.0)))));
} else {
tmp = (sqrt(d) / sqrt(h)) * (sqrt((d / l)) * (1.0 + (h * (t_1 * ((0.5 * (M_m * (D / d))) / -2.0)))));
}
return tmp;
}
M_m = abs(M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = m_m * ((0.5d0 / d) * d_1)
t_1 = t_0 / l
t_2 = sqrt((d / h))
if (h <= (-5d-310)) then
tmp = ((sqrt(-d) / sqrt(-l)) * (1.0d0 + (h * (t_1 * (t_0 / (-2.0d0)))))) * t_2
else if (h <= 1.7d+188) then
tmp = t_2 * ((sqrt(d) / sqrt(l)) * (1.0d0 + (h * (t_1 * ((0.5d0 / (d / (m_m * d_1))) / (-2.0d0))))))
else
tmp = (sqrt(d) / sqrt(h)) * (sqrt((d / l)) * (1.0d0 + (h * (t_1 * ((0.5d0 * (m_m * (d_1 / d))) / (-2.0d0))))))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * ((0.5 / d) * D);
double t_1 = t_0 / l;
double t_2 = Math.sqrt((d / h));
double tmp;
if (h <= -5e-310) {
tmp = ((Math.sqrt(-d) / Math.sqrt(-l)) * (1.0 + (h * (t_1 * (t_0 / -2.0))))) * t_2;
} else if (h <= 1.7e+188) {
tmp = t_2 * ((Math.sqrt(d) / Math.sqrt(l)) * (1.0 + (h * (t_1 * ((0.5 / (d / (M_m * D))) / -2.0)))));
} else {
tmp = (Math.sqrt(d) / Math.sqrt(h)) * (Math.sqrt((d / l)) * (1.0 + (h * (t_1 * ((0.5 * (M_m * (D / d))) / -2.0)))));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = M_m * ((0.5 / d) * D) t_1 = t_0 / l t_2 = math.sqrt((d / h)) tmp = 0 if h <= -5e-310: tmp = ((math.sqrt(-d) / math.sqrt(-l)) * (1.0 + (h * (t_1 * (t_0 / -2.0))))) * t_2 elif h <= 1.7e+188: tmp = t_2 * ((math.sqrt(d) / math.sqrt(l)) * (1.0 + (h * (t_1 * ((0.5 / (d / (M_m * D))) / -2.0))))) else: tmp = (math.sqrt(d) / math.sqrt(h)) * (math.sqrt((d / l)) * (1.0 + (h * (t_1 * ((0.5 * (M_m * (D / d))) / -2.0))))) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(M_m * Float64(Float64(0.5 / d) * D)) t_1 = Float64(t_0 / l) t_2 = sqrt(Float64(d / h)) tmp = 0.0 if (h <= -5e-310) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-l))) * Float64(1.0 + Float64(h * Float64(t_1 * Float64(t_0 / -2.0))))) * t_2); elseif (h <= 1.7e+188) tmp = Float64(t_2 * Float64(Float64(sqrt(d) / sqrt(l)) * Float64(1.0 + Float64(h * Float64(t_1 * Float64(Float64(0.5 / Float64(d / Float64(M_m * D))) / -2.0)))))); else tmp = Float64(Float64(sqrt(d) / sqrt(h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(h * Float64(t_1 * Float64(Float64(0.5 * Float64(M_m * Float64(D / d))) / -2.0)))))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = M_m * ((0.5 / d) * D);
t_1 = t_0 / l;
t_2 = sqrt((d / h));
tmp = 0.0;
if (h <= -5e-310)
tmp = ((sqrt(-d) / sqrt(-l)) * (1.0 + (h * (t_1 * (t_0 / -2.0))))) * t_2;
elseif (h <= 1.7e+188)
tmp = t_2 * ((sqrt(d) / sqrt(l)) * (1.0 + (h * (t_1 * ((0.5 / (d / (M_m * D))) / -2.0)))));
else
tmp = (sqrt(d) / sqrt(h)) * (sqrt((d / l)) * (1.0 + (h * (t_1 * ((0.5 * (M_m * (D / d))) / -2.0)))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(M$95$m * N[(N[(0.5 / d), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / l), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -5e-310], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(h * N[(t$95$1 * N[(t$95$0 / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[h, 1.7e+188], N[(t$95$2 * N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(h * N[(t$95$1 * N[(N[(0.5 / N[(d / N[(M$95$m * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(t$95$1 * N[(N[(0.5 * N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := M_m \cdot \left(\frac{0.5}{d} \cdot D\right)\\
t_1 := \frac{t_0}{\ell}\\
t_2 := \sqrt{\frac{d}{h}}\\
\mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(1 + h \cdot \left(t_1 \cdot \frac{t_0}{-2}\right)\right)\right) \cdot t_2\\
\mathbf{elif}\;h \leq 1.7 \cdot 10^{+188}:\\
\;\;\;\;t_2 \cdot \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \left(1 + h \cdot \left(t_1 \cdot \frac{\frac{0.5}{\frac{d}{M_m \cdot D}}}{-2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + h \cdot \left(t_1 \cdot \frac{0.5 \cdot \left(M_m \cdot \frac{D}{d}\right)}{-2}\right)\right)\right)\\
\end{array}
\end{array}
if h < -4.999999999999985e-310Initial program 66.4%
Simplified64.3%
Applied egg-rr30.6%
expm1-def30.6%
expm1-log1p64.3%
associate-*l/65.9%
*-commutative65.9%
associate-*l/66.6%
*-commutative66.6%
associate-/l*66.6%
metadata-eval66.6%
times-frac66.6%
*-commutative66.6%
associate-/l*66.6%
associate-*l/66.6%
*-commutative66.6%
associate-/r*66.6%
metadata-eval66.6%
Simplified66.6%
unpow266.6%
div-inv66.6%
metadata-eval66.6%
metadata-eval66.6%
times-frac68.0%
associate-/r/68.0%
associate-/r/68.0%
metadata-eval68.0%
Applied egg-rr68.0%
frac-2neg68.0%
sqrt-div75.2%
Applied egg-rr75.2%
if -4.999999999999985e-310 < h < 1.69999999999999998e188Initial program 75.3%
Simplified75.3%
Applied egg-rr44.4%
expm1-def44.4%
expm1-log1p75.3%
associate-*l/75.6%
*-commutative75.6%
associate-*l/74.6%
*-commutative74.6%
associate-/l*74.6%
metadata-eval74.6%
times-frac74.6%
*-commutative74.6%
associate-/l*74.5%
associate-*l/74.5%
*-commutative74.5%
associate-/r*74.5%
metadata-eval74.5%
Simplified74.5%
unpow274.5%
div-inv74.5%
metadata-eval74.5%
metadata-eval74.5%
times-frac75.5%
associate-/r/75.5%
associate-/r/75.6%
metadata-eval75.6%
Applied egg-rr75.6%
*-commutative75.6%
associate-*l/75.6%
associate-/r/75.6%
associate-/l*75.6%
associate-/l/75.6%
Applied egg-rr75.6%
sqrt-div88.0%
div-inv88.0%
Applied egg-rr88.0%
associate-*r/88.0%
*-rgt-identity88.0%
Simplified88.0%
if 1.69999999999999998e188 < h Initial program 46.1%
Simplified46.0%
Applied egg-rr20.9%
expm1-def20.9%
expm1-log1p46.0%
associate-*l/46.0%
*-commutative46.0%
associate-*l/46.0%
*-commutative46.0%
associate-/l*46.0%
metadata-eval46.0%
times-frac46.0%
*-commutative46.0%
associate-/l*46.0%
associate-*l/46.0%
*-commutative46.0%
associate-/r*46.0%
metadata-eval46.0%
Simplified46.0%
unpow246.0%
div-inv46.0%
metadata-eval46.0%
metadata-eval46.0%
times-frac46.0%
associate-/r/46.0%
associate-/r/46.0%
metadata-eval46.0%
Applied egg-rr46.0%
Taylor expanded in M around 0 46.0%
*-commutative46.0%
associate-*r/46.0%
Simplified46.0%
sqrt-div83.4%
div-inv83.3%
Applied egg-rr83.2%
associate-*r/83.4%
*-rgt-identity83.4%
Simplified83.2%
Final simplification80.5%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (/ (* M_m (* (/ 0.5 d) D)) l))
(t_1
(*
(sqrt (/ d l))
(+ 1.0 (* h (* t_0 (/ (* 0.5 (* M_m (/ D d))) -2.0)))))))
(if (<= h -5e-310)
(* (/ (sqrt (- d)) (sqrt (- h))) t_1)
(if (<= h 1.35e+188)
(*
(sqrt (/ d h))
(*
(/ (sqrt d) (sqrt l))
(+ 1.0 (* h (* t_0 (/ (/ 0.5 (/ d (* M_m D))) -2.0))))))
(* (/ (sqrt d) (sqrt h)) t_1)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (M_m * ((0.5 / d) * D)) / l;
double t_1 = sqrt((d / l)) * (1.0 + (h * (t_0 * ((0.5 * (M_m * (D / d))) / -2.0))));
double tmp;
if (h <= -5e-310) {
tmp = (sqrt(-d) / sqrt(-h)) * t_1;
} else if (h <= 1.35e+188) {
tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0 + (h * (t_0 * ((0.5 / (d / (M_m * D))) / -2.0)))));
} else {
tmp = (sqrt(d) / sqrt(h)) * t_1;
}
return tmp;
}
M_m = abs(M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (m_m * ((0.5d0 / d) * d_1)) / l
t_1 = sqrt((d / l)) * (1.0d0 + (h * (t_0 * ((0.5d0 * (m_m * (d_1 / d))) / (-2.0d0)))))
if (h <= (-5d-310)) then
tmp = (sqrt(-d) / sqrt(-h)) * t_1
else if (h <= 1.35d+188) then
tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0d0 + (h * (t_0 * ((0.5d0 / (d / (m_m * d_1))) / (-2.0d0))))))
else
tmp = (sqrt(d) / sqrt(h)) * t_1
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = (M_m * ((0.5 / d) * D)) / l;
double t_1 = Math.sqrt((d / l)) * (1.0 + (h * (t_0 * ((0.5 * (M_m * (D / d))) / -2.0))));
double tmp;
if (h <= -5e-310) {
tmp = (Math.sqrt(-d) / Math.sqrt(-h)) * t_1;
} else if (h <= 1.35e+188) {
tmp = Math.sqrt((d / h)) * ((Math.sqrt(d) / Math.sqrt(l)) * (1.0 + (h * (t_0 * ((0.5 / (d / (M_m * D))) / -2.0)))));
} else {
tmp = (Math.sqrt(d) / Math.sqrt(h)) * t_1;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = (M_m * ((0.5 / d) * D)) / l t_1 = math.sqrt((d / l)) * (1.0 + (h * (t_0 * ((0.5 * (M_m * (D / d))) / -2.0)))) tmp = 0 if h <= -5e-310: tmp = (math.sqrt(-d) / math.sqrt(-h)) * t_1 elif h <= 1.35e+188: tmp = math.sqrt((d / h)) * ((math.sqrt(d) / math.sqrt(l)) * (1.0 + (h * (t_0 * ((0.5 / (d / (M_m * D))) / -2.0))))) else: tmp = (math.sqrt(d) / math.sqrt(h)) * t_1 return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(M_m * Float64(Float64(0.5 / d) * D)) / l) t_1 = Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(h * Float64(t_0 * Float64(Float64(0.5 * Float64(M_m * Float64(D / d))) / -2.0))))) tmp = 0.0 if (h <= -5e-310) tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_1); elseif (h <= 1.35e+188) tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(sqrt(d) / sqrt(l)) * Float64(1.0 + Float64(h * Float64(t_0 * Float64(Float64(0.5 / Float64(d / Float64(M_m * D))) / -2.0)))))); else tmp = Float64(Float64(sqrt(d) / sqrt(h)) * t_1); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (M_m * ((0.5 / d) * D)) / l;
t_1 = sqrt((d / l)) * (1.0 + (h * (t_0 * ((0.5 * (M_m * (D / d))) / -2.0))));
tmp = 0.0;
if (h <= -5e-310)
tmp = (sqrt(-d) / sqrt(-h)) * t_1;
elseif (h <= 1.35e+188)
tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0 + (h * (t_0 * ((0.5 / (d / (M_m * D))) / -2.0)))));
else
tmp = (sqrt(d) / sqrt(h)) * t_1;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(M$95$m * N[(N[(0.5 / d), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(t$95$0 * N[(N[(0.5 * N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -5e-310], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[h, 1.35e+188], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(h * N[(t$95$0 * N[(N[(0.5 / N[(d / N[(M$95$m * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{M_m \cdot \left(\frac{0.5}{d} \cdot D\right)}{\ell}\\
t_1 := \sqrt{\frac{d}{\ell}} \cdot \left(1 + h \cdot \left(t_0 \cdot \frac{0.5 \cdot \left(M_m \cdot \frac{D}{d}\right)}{-2}\right)\right)\\
\mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t_1\\
\mathbf{elif}\;h \leq 1.35 \cdot 10^{+188}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \left(1 + h \cdot \left(t_0 \cdot \frac{\frac{0.5}{\frac{d}{M_m \cdot D}}}{-2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot t_1\\
\end{array}
\end{array}
if h < -4.999999999999985e-310Initial program 66.4%
Simplified64.3%
Applied egg-rr30.6%
expm1-def30.6%
expm1-log1p64.3%
associate-*l/65.9%
*-commutative65.9%
associate-*l/66.6%
*-commutative66.6%
associate-/l*66.6%
metadata-eval66.6%
times-frac66.6%
*-commutative66.6%
associate-/l*66.6%
associate-*l/66.6%
*-commutative66.6%
associate-/r*66.6%
metadata-eval66.6%
Simplified66.6%
unpow266.6%
div-inv66.6%
metadata-eval66.6%
metadata-eval66.6%
times-frac68.0%
associate-/r/68.0%
associate-/r/68.0%
metadata-eval68.0%
Applied egg-rr68.0%
Taylor expanded in M around 0 67.3%
*-commutative67.3%
associate-*r/68.0%
Simplified68.0%
frac-2neg75.2%
sqrt-div89.9%
Applied egg-rr80.5%
if -4.999999999999985e-310 < h < 1.35e188Initial program 75.3%
Simplified75.3%
Applied egg-rr44.4%
expm1-def44.4%
expm1-log1p75.3%
associate-*l/75.6%
*-commutative75.6%
associate-*l/74.6%
*-commutative74.6%
associate-/l*74.6%
metadata-eval74.6%
times-frac74.6%
*-commutative74.6%
associate-/l*74.5%
associate-*l/74.5%
*-commutative74.5%
associate-/r*74.5%
metadata-eval74.5%
Simplified74.5%
unpow274.5%
div-inv74.5%
metadata-eval74.5%
metadata-eval74.5%
times-frac75.5%
associate-/r/75.5%
associate-/r/75.6%
metadata-eval75.6%
Applied egg-rr75.6%
*-commutative75.6%
associate-*l/75.6%
associate-/r/75.6%
associate-/l*75.6%
associate-/l/75.6%
Applied egg-rr75.6%
sqrt-div88.0%
div-inv88.0%
Applied egg-rr88.0%
associate-*r/88.0%
*-rgt-identity88.0%
Simplified88.0%
if 1.35e188 < h Initial program 46.1%
Simplified46.0%
Applied egg-rr20.9%
expm1-def20.9%
expm1-log1p46.0%
associate-*l/46.0%
*-commutative46.0%
associate-*l/46.0%
*-commutative46.0%
associate-/l*46.0%
metadata-eval46.0%
times-frac46.0%
*-commutative46.0%
associate-/l*46.0%
associate-*l/46.0%
*-commutative46.0%
associate-/r*46.0%
metadata-eval46.0%
Simplified46.0%
unpow246.0%
div-inv46.0%
metadata-eval46.0%
metadata-eval46.0%
times-frac46.0%
associate-/r/46.0%
associate-/r/46.0%
metadata-eval46.0%
Applied egg-rr46.0%
Taylor expanded in M around 0 46.0%
*-commutative46.0%
associate-*r/46.0%
Simplified46.0%
sqrt-div83.4%
div-inv83.3%
Applied egg-rr83.2%
associate-*r/83.4%
*-rgt-identity83.4%
Simplified83.2%
Final simplification83.5%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* M_m (* (/ 0.5 d) D))) (t_1 (/ t_0 l)) (t_2 (sqrt (/ d l))))
(if (<= h -5e-310)
(*
(/ (sqrt (- d)) (sqrt (- h)))
(* (+ 1.0 (* h (* t_1 (/ t_0 -2.0)))) t_2))
(if (<= h 1.3e+188)
(*
(sqrt (/ d h))
(*
(/ (sqrt d) (sqrt l))
(+ 1.0 (* h (* t_1 (/ (/ 0.5 (/ d (* M_m D))) -2.0))))))
(*
(/ (sqrt d) (sqrt h))
(* t_2 (+ 1.0 (* h (* t_1 (/ (* 0.5 (* M_m (/ D d))) -2.0))))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * ((0.5 / d) * D);
double t_1 = t_0 / l;
double t_2 = sqrt((d / l));
double tmp;
if (h <= -5e-310) {
tmp = (sqrt(-d) / sqrt(-h)) * ((1.0 + (h * (t_1 * (t_0 / -2.0)))) * t_2);
} else if (h <= 1.3e+188) {
tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0 + (h * (t_1 * ((0.5 / (d / (M_m * D))) / -2.0)))));
} else {
tmp = (sqrt(d) / sqrt(h)) * (t_2 * (1.0 + (h * (t_1 * ((0.5 * (M_m * (D / d))) / -2.0)))));
}
return tmp;
}
M_m = abs(M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = m_m * ((0.5d0 / d) * d_1)
t_1 = t_0 / l
t_2 = sqrt((d / l))
if (h <= (-5d-310)) then
tmp = (sqrt(-d) / sqrt(-h)) * ((1.0d0 + (h * (t_1 * (t_0 / (-2.0d0))))) * t_2)
else if (h <= 1.3d+188) then
tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0d0 + (h * (t_1 * ((0.5d0 / (d / (m_m * d_1))) / (-2.0d0))))))
else
tmp = (sqrt(d) / sqrt(h)) * (t_2 * (1.0d0 + (h * (t_1 * ((0.5d0 * (m_m * (d_1 / d))) / (-2.0d0))))))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * ((0.5 / d) * D);
double t_1 = t_0 / l;
double t_2 = Math.sqrt((d / l));
double tmp;
if (h <= -5e-310) {
tmp = (Math.sqrt(-d) / Math.sqrt(-h)) * ((1.0 + (h * (t_1 * (t_0 / -2.0)))) * t_2);
} else if (h <= 1.3e+188) {
tmp = Math.sqrt((d / h)) * ((Math.sqrt(d) / Math.sqrt(l)) * (1.0 + (h * (t_1 * ((0.5 / (d / (M_m * D))) / -2.0)))));
} else {
tmp = (Math.sqrt(d) / Math.sqrt(h)) * (t_2 * (1.0 + (h * (t_1 * ((0.5 * (M_m * (D / d))) / -2.0)))));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = M_m * ((0.5 / d) * D) t_1 = t_0 / l t_2 = math.sqrt((d / l)) tmp = 0 if h <= -5e-310: tmp = (math.sqrt(-d) / math.sqrt(-h)) * ((1.0 + (h * (t_1 * (t_0 / -2.0)))) * t_2) elif h <= 1.3e+188: tmp = math.sqrt((d / h)) * ((math.sqrt(d) / math.sqrt(l)) * (1.0 + (h * (t_1 * ((0.5 / (d / (M_m * D))) / -2.0))))) else: tmp = (math.sqrt(d) / math.sqrt(h)) * (t_2 * (1.0 + (h * (t_1 * ((0.5 * (M_m * (D / d))) / -2.0))))) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(M_m * Float64(Float64(0.5 / d) * D)) t_1 = Float64(t_0 / l) t_2 = sqrt(Float64(d / l)) tmp = 0.0 if (h <= -5e-310) tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(Float64(1.0 + Float64(h * Float64(t_1 * Float64(t_0 / -2.0)))) * t_2)); elseif (h <= 1.3e+188) tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(sqrt(d) / sqrt(l)) * Float64(1.0 + Float64(h * Float64(t_1 * Float64(Float64(0.5 / Float64(d / Float64(M_m * D))) / -2.0)))))); else tmp = Float64(Float64(sqrt(d) / sqrt(h)) * Float64(t_2 * Float64(1.0 + Float64(h * Float64(t_1 * Float64(Float64(0.5 * Float64(M_m * Float64(D / d))) / -2.0)))))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = M_m * ((0.5 / d) * D);
t_1 = t_0 / l;
t_2 = sqrt((d / l));
tmp = 0.0;
if (h <= -5e-310)
tmp = (sqrt(-d) / sqrt(-h)) * ((1.0 + (h * (t_1 * (t_0 / -2.0)))) * t_2);
elseif (h <= 1.3e+188)
tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0 + (h * (t_1 * ((0.5 / (d / (M_m * D))) / -2.0)))));
else
tmp = (sqrt(d) / sqrt(h)) * (t_2 * (1.0 + (h * (t_1 * ((0.5 * (M_m * (D / d))) / -2.0)))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(M$95$m * N[(N[(0.5 / d), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / l), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -5e-310], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 + N[(h * N[(t$95$1 * N[(t$95$0 / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 1.3e+188], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(h * N[(t$95$1 * N[(N[(0.5 / N[(d / N[(M$95$m * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(t$95$2 * N[(1.0 + N[(h * N[(t$95$1 * N[(N[(0.5 * N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := M_m \cdot \left(\frac{0.5}{d} \cdot D\right)\\
t_1 := \frac{t_0}{\ell}\\
t_2 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\left(1 + h \cdot \left(t_1 \cdot \frac{t_0}{-2}\right)\right) \cdot t_2\right)\\
\mathbf{elif}\;h \leq 1.3 \cdot 10^{+188}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \left(1 + h \cdot \left(t_1 \cdot \frac{\frac{0.5}{\frac{d}{M_m \cdot D}}}{-2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(t_2 \cdot \left(1 + h \cdot \left(t_1 \cdot \frac{0.5 \cdot \left(M_m \cdot \frac{D}{d}\right)}{-2}\right)\right)\right)\\
\end{array}
\end{array}
if h < -4.999999999999985e-310Initial program 66.4%
Simplified64.3%
Applied egg-rr30.6%
expm1-def30.6%
expm1-log1p64.3%
associate-*l/65.9%
*-commutative65.9%
associate-*l/66.6%
*-commutative66.6%
associate-/l*66.6%
metadata-eval66.6%
times-frac66.6%
*-commutative66.6%
associate-/l*66.6%
associate-*l/66.6%
*-commutative66.6%
associate-/r*66.6%
metadata-eval66.6%
Simplified66.6%
unpow266.6%
div-inv66.6%
metadata-eval66.6%
metadata-eval66.6%
times-frac68.0%
associate-/r/68.0%
associate-/r/68.0%
metadata-eval68.0%
Applied egg-rr68.0%
frac-2neg75.2%
sqrt-div89.9%
Applied egg-rr80.5%
if -4.999999999999985e-310 < h < 1.29999999999999994e188Initial program 75.3%
Simplified75.3%
Applied egg-rr44.4%
expm1-def44.4%
expm1-log1p75.3%
associate-*l/75.6%
*-commutative75.6%
associate-*l/74.6%
*-commutative74.6%
associate-/l*74.6%
metadata-eval74.6%
times-frac74.6%
*-commutative74.6%
associate-/l*74.5%
associate-*l/74.5%
*-commutative74.5%
associate-/r*74.5%
metadata-eval74.5%
Simplified74.5%
unpow274.5%
div-inv74.5%
metadata-eval74.5%
metadata-eval74.5%
times-frac75.5%
associate-/r/75.5%
associate-/r/75.6%
metadata-eval75.6%
Applied egg-rr75.6%
*-commutative75.6%
associate-*l/75.6%
associate-/r/75.6%
associate-/l*75.6%
associate-/l/75.6%
Applied egg-rr75.6%
sqrt-div88.0%
div-inv88.0%
Applied egg-rr88.0%
associate-*r/88.0%
*-rgt-identity88.0%
Simplified88.0%
if 1.29999999999999994e188 < h Initial program 46.1%
Simplified46.0%
Applied egg-rr20.9%
expm1-def20.9%
expm1-log1p46.0%
associate-*l/46.0%
*-commutative46.0%
associate-*l/46.0%
*-commutative46.0%
associate-/l*46.0%
metadata-eval46.0%
times-frac46.0%
*-commutative46.0%
associate-/l*46.0%
associate-*l/46.0%
*-commutative46.0%
associate-/r*46.0%
metadata-eval46.0%
Simplified46.0%
unpow246.0%
div-inv46.0%
metadata-eval46.0%
metadata-eval46.0%
times-frac46.0%
associate-/r/46.0%
associate-/r/46.0%
metadata-eval46.0%
Applied egg-rr46.0%
Taylor expanded in M around 0 46.0%
*-commutative46.0%
associate-*r/46.0%
Simplified46.0%
sqrt-div83.4%
div-inv83.3%
Applied egg-rr83.2%
associate-*r/83.4%
*-rgt-identity83.4%
Simplified83.2%
Final simplification83.5%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (or (<= M_m 1.25e-226) (and (not (<= M_m 2.7e-169)) (<= M_m 4.4e-124)))
(fabs (/ d (sqrt (* l h))))
(*
(sqrt (/ d h))
(*
(sqrt (/ d l))
(+
1.0
(* (/ (* h M_m) (/ (* l d) (* 0.5 D))) (* -0.25 (/ D (/ d M_m)))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if ((M_m <= 1.25e-226) || (!(M_m <= 2.7e-169) && (M_m <= 4.4e-124))) {
tmp = fabs((d / sqrt((l * h))));
} else {
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 + (((h * M_m) / ((l * d) / (0.5 * D))) * (-0.25 * (D / (d / M_m))))));
}
return tmp;
}
M_m = abs(M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: tmp
if ((m_m <= 1.25d-226) .or. (.not. (m_m <= 2.7d-169)) .and. (m_m <= 4.4d-124)) then
tmp = abs((d / sqrt((l * h))))
else
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0d0 + (((h * m_m) / ((l * d) / (0.5d0 * d_1))) * ((-0.25d0) * (d_1 / (d / m_m))))))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if ((M_m <= 1.25e-226) || (!(M_m <= 2.7e-169) && (M_m <= 4.4e-124))) {
tmp = Math.abs((d / Math.sqrt((l * h))));
} else {
tmp = Math.sqrt((d / h)) * (Math.sqrt((d / l)) * (1.0 + (((h * M_m) / ((l * d) / (0.5 * D))) * (-0.25 * (D / (d / M_m))))));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if (M_m <= 1.25e-226) or (not (M_m <= 2.7e-169) and (M_m <= 4.4e-124)): tmp = math.fabs((d / math.sqrt((l * h)))) else: tmp = math.sqrt((d / h)) * (math.sqrt((d / l)) * (1.0 + (((h * M_m) / ((l * d) / (0.5 * D))) * (-0.25 * (D / (d / M_m)))))) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if ((M_m <= 1.25e-226) || (!(M_m <= 2.7e-169) && (M_m <= 4.4e-124))) tmp = abs(Float64(d / sqrt(Float64(l * h)))); else tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(Float64(Float64(h * M_m) / Float64(Float64(l * d) / Float64(0.5 * D))) * Float64(-0.25 * Float64(D / Float64(d / M_m))))))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if ((M_m <= 1.25e-226) || (~((M_m <= 2.7e-169)) && (M_m <= 4.4e-124)))
tmp = abs((d / sqrt((l * h))));
else
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 + (((h * M_m) / ((l * d) / (0.5 * D))) * (-0.25 * (D / (d / M_m))))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[Or[LessEqual[M$95$m, 1.25e-226], And[N[Not[LessEqual[M$95$m, 2.7e-169]], $MachinePrecision], LessEqual[M$95$m, 4.4e-124]]], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(N[(h * M$95$m), $MachinePrecision] / N[(N[(l * d), $MachinePrecision] / N[(0.5 * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-0.25 * N[(D / N[(d / M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M_m \leq 1.25 \cdot 10^{-226} \lor \neg \left(M_m \leq 2.7 \cdot 10^{-169}\right) \land M_m \leq 4.4 \cdot 10^{-124}:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h \cdot M_m}{\frac{\ell \cdot d}{0.5 \cdot D}} \cdot \left(-0.25 \cdot \frac{D}{\frac{d}{M_m}}\right)\right)\right)\\
\end{array}
\end{array}
if M < 1.2499999999999999e-226 or 2.7000000000000002e-169 < M < 4.3999999999999998e-124Initial program 69.4%
Simplified69.7%
Taylor expanded in h around 0 37.6%
*-rgt-identity37.6%
sqrt-unprod26.8%
Applied egg-rr26.8%
frac-times19.2%
unpow219.2%
associate-/l/20.0%
add-sqr-sqrt20.0%
rem-sqrt-square20.0%
associate-/l/19.2%
sqrt-div24.0%
unpow224.0%
sqrt-prod20.3%
add-sqr-sqrt40.4%
*-commutative40.4%
Applied egg-rr40.4%
if 1.2499999999999999e-226 < M < 2.7000000000000002e-169 or 4.3999999999999998e-124 < M Initial program 65.0%
Simplified64.0%
Applied egg-rr32.2%
expm1-def32.2%
expm1-log1p64.0%
associate-*l/64.4%
*-commutative64.4%
associate-*l/64.4%
*-commutative64.4%
associate-/l*64.4%
metadata-eval64.4%
times-frac64.4%
*-commutative64.4%
associate-/l*64.3%
associate-*l/64.3%
*-commutative64.3%
associate-/r*64.3%
metadata-eval64.3%
Simplified64.3%
unpow264.3%
div-inv64.3%
metadata-eval64.3%
metadata-eval64.3%
times-frac66.2%
associate-/r/66.2%
associate-/r/66.3%
metadata-eval66.3%
Applied egg-rr66.3%
Taylor expanded in M around 0 66.3%
*-commutative66.3%
associate-*r/66.3%
Simplified66.3%
expm1-log1p-u33.3%
expm1-udef33.3%
associate-*r*33.3%
associate-/l*33.3%
associate-*l/33.3%
div-inv33.3%
associate-*r*33.3%
metadata-eval33.3%
Applied egg-rr33.3%
expm1-def33.3%
expm1-log1p64.9%
*-commutative64.9%
associate-*l/60.9%
associate-/r/59.9%
associate-*l/60.8%
*-commutative60.8%
*-commutative60.8%
associate-*l*60.8%
associate-*r*60.8%
metadata-eval60.8%
associate-*r/61.8%
*-commutative61.8%
associate-/l*61.3%
Simplified61.3%
Final simplification48.6%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= d -7.2e+126)
(fabs (/ d (sqrt (* l h))))
(if (<= d -1.25e-87)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(if (<= d 1.6e-244)
(* d (- (sqrt (/ 1.0 (* l h)))))
(/ (/ d (sqrt l)) (sqrt h))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (d <= -7.2e+126) {
tmp = fabs((d / sqrt((l * h))));
} else if (d <= -1.25e-87) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else if (d <= 1.6e-244) {
tmp = d * -sqrt((1.0 / (l * h)));
} else {
tmp = (d / sqrt(l)) / sqrt(h);
}
return tmp;
}
M_m = abs(M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (d <= (-7.2d+126)) then
tmp = abs((d / sqrt((l * h))))
else if (d <= (-1.25d-87)) then
tmp = sqrt((d / h)) * sqrt((d / l))
else if (d <= 1.6d-244) then
tmp = d * -sqrt((1.0d0 / (l * h)))
else
tmp = (d / sqrt(l)) / sqrt(h)
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (d <= -7.2e+126) {
tmp = Math.abs((d / Math.sqrt((l * h))));
} else if (d <= -1.25e-87) {
tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
} else if (d <= 1.6e-244) {
tmp = d * -Math.sqrt((1.0 / (l * h)));
} else {
tmp = (d / Math.sqrt(l)) / Math.sqrt(h);
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if d <= -7.2e+126: tmp = math.fabs((d / math.sqrt((l * h)))) elif d <= -1.25e-87: tmp = math.sqrt((d / h)) * math.sqrt((d / l)) elif d <= 1.6e-244: tmp = d * -math.sqrt((1.0 / (l * h))) else: tmp = (d / math.sqrt(l)) / math.sqrt(h) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (d <= -7.2e+126) tmp = abs(Float64(d / sqrt(Float64(l * h)))); elseif (d <= -1.25e-87) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); elseif (d <= 1.6e-244) tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))); else tmp = Float64(Float64(d / sqrt(l)) / sqrt(h)); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (d <= -7.2e+126)
tmp = abs((d / sqrt((l * h))));
elseif (d <= -1.25e-87)
tmp = sqrt((d / h)) * sqrt((d / l));
elseif (d <= 1.6e-244)
tmp = d * -sqrt((1.0 / (l * h)));
else
tmp = (d / sqrt(l)) / sqrt(h);
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[d, -7.2e+126], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -1.25e-87], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.6e-244], N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.2 \cdot 10^{+126}:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{elif}\;d \leq -1.25 \cdot 10^{-87}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;d \leq 1.6 \cdot 10^{-244}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if d < -7.2000000000000001e126Initial program 61.0%
Simplified63.3%
Taylor expanded in h around 0 36.9%
*-rgt-identity36.9%
sqrt-unprod27.8%
Applied egg-rr27.8%
frac-times25.3%
unpow225.3%
associate-/l/25.5%
add-sqr-sqrt25.5%
rem-sqrt-square25.5%
associate-/l/25.3%
sqrt-div25.3%
unpow225.3%
sqrt-prod0.0%
add-sqr-sqrt68.5%
*-commutative68.5%
Applied egg-rr68.5%
if -7.2000000000000001e126 < d < -1.25000000000000011e-87Initial program 83.6%
Simplified83.6%
Taylor expanded in h around 0 50.1%
*-rgt-identity50.1%
sqrt-unprod36.6%
Applied egg-rr36.6%
*-commutative36.6%
sqrt-prod50.1%
Applied egg-rr50.1%
if -1.25000000000000011e-87 < d < 1.5999999999999999e-244Initial program 53.0%
Simplified52.3%
Taylor expanded in h around 0 12.6%
*-rgt-identity12.6%
sqrt-unprod9.8%
Applied egg-rr9.8%
Taylor expanded in d around -inf 21.5%
if 1.5999999999999999e-244 < d Initial program 72.2%
Simplified72.2%
Taylor expanded in h around 0 44.2%
expm1-log1p-u42.4%
expm1-udef34.1%
sqrt-div37.3%
*-rgt-identity37.3%
sqrt-div42.3%
frac-times42.3%
add-sqr-sqrt42.3%
Applied egg-rr42.3%
expm1-def52.3%
expm1-log1p55.0%
associate-/l/53.3%
Simplified53.3%
Final simplification47.1%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= d -2.2e+116)
(fabs (/ d (sqrt (* l h))))
(if (<= d -5.8e-87)
(* (sqrt (/ d l)) (/ 1.0 (sqrt (/ h d))))
(if (<= d 7.1e-245)
(* d (- (sqrt (/ 1.0 (* l h)))))
(/ (/ d (sqrt l)) (sqrt h))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (d <= -2.2e+116) {
tmp = fabs((d / sqrt((l * h))));
} else if (d <= -5.8e-87) {
tmp = sqrt((d / l)) * (1.0 / sqrt((h / d)));
} else if (d <= 7.1e-245) {
tmp = d * -sqrt((1.0 / (l * h)));
} else {
tmp = (d / sqrt(l)) / sqrt(h);
}
return tmp;
}
M_m = abs(M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (d <= (-2.2d+116)) then
tmp = abs((d / sqrt((l * h))))
else if (d <= (-5.8d-87)) then
tmp = sqrt((d / l)) * (1.0d0 / sqrt((h / d)))
else if (d <= 7.1d-245) then
tmp = d * -sqrt((1.0d0 / (l * h)))
else
tmp = (d / sqrt(l)) / sqrt(h)
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (d <= -2.2e+116) {
tmp = Math.abs((d / Math.sqrt((l * h))));
} else if (d <= -5.8e-87) {
tmp = Math.sqrt((d / l)) * (1.0 / Math.sqrt((h / d)));
} else if (d <= 7.1e-245) {
tmp = d * -Math.sqrt((1.0 / (l * h)));
} else {
tmp = (d / Math.sqrt(l)) / Math.sqrt(h);
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if d <= -2.2e+116: tmp = math.fabs((d / math.sqrt((l * h)))) elif d <= -5.8e-87: tmp = math.sqrt((d / l)) * (1.0 / math.sqrt((h / d))) elif d <= 7.1e-245: tmp = d * -math.sqrt((1.0 / (l * h))) else: tmp = (d / math.sqrt(l)) / math.sqrt(h) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (d <= -2.2e+116) tmp = abs(Float64(d / sqrt(Float64(l * h)))); elseif (d <= -5.8e-87) tmp = Float64(sqrt(Float64(d / l)) * Float64(1.0 / sqrt(Float64(h / d)))); elseif (d <= 7.1e-245) tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))); else tmp = Float64(Float64(d / sqrt(l)) / sqrt(h)); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (d <= -2.2e+116)
tmp = abs((d / sqrt((l * h))));
elseif (d <= -5.8e-87)
tmp = sqrt((d / l)) * (1.0 / sqrt((h / d)));
elseif (d <= 7.1e-245)
tmp = d * -sqrt((1.0 / (l * h)));
else
tmp = (d / sqrt(l)) / sqrt(h);
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[d, -2.2e+116], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -5.8e-87], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.1e-245], N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.2 \cdot 10^{+116}:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{elif}\;d \leq -5.8 \cdot 10^{-87}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{1}{\sqrt{\frac{h}{d}}}\\
\mathbf{elif}\;d \leq 7.1 \cdot 10^{-245}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if d < -2.2e116Initial program 64.5%
Simplified66.5%
Taylor expanded in h around 0 40.3%
*-rgt-identity40.3%
sqrt-unprod32.0%
Applied egg-rr32.0%
frac-times29.8%
unpow229.8%
associate-/l/29.9%
add-sqr-sqrt29.9%
rem-sqrt-square29.9%
associate-/l/29.8%
sqrt-div29.8%
unpow229.8%
sqrt-prod0.0%
add-sqr-sqrt69.1%
*-commutative69.1%
Applied egg-rr69.1%
if -2.2e116 < d < -5.7999999999999998e-87Initial program 82.1%
Simplified82.1%
clear-num82.2%
sqrt-div83.4%
metadata-eval83.4%
Applied egg-rr83.4%
Taylor expanded in h around 0 49.2%
if -5.7999999999999998e-87 < d < 7.10000000000000016e-245Initial program 53.0%
Simplified52.3%
Taylor expanded in h around 0 12.6%
*-rgt-identity12.6%
sqrt-unprod9.8%
Applied egg-rr9.8%
Taylor expanded in d around -inf 21.5%
if 7.10000000000000016e-245 < d Initial program 72.2%
Simplified72.2%
Taylor expanded in h around 0 44.2%
expm1-log1p-u42.4%
expm1-udef34.1%
sqrt-div37.3%
*-rgt-identity37.3%
sqrt-div42.3%
frac-times42.3%
add-sqr-sqrt42.3%
Applied egg-rr42.3%
expm1-def52.3%
expm1-log1p55.0%
associate-/l/53.3%
Simplified53.3%
Final simplification47.3%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= l -4.5e-239)
(fabs (/ d (sqrt (* l h))))
(if (<= l 4.2e-307)
(/ d (cbrt (pow (* l h) 1.5)))
(/ (/ d (sqrt l)) (sqrt h)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -4.5e-239) {
tmp = fabs((d / sqrt((l * h))));
} else if (l <= 4.2e-307) {
tmp = d / cbrt(pow((l * h), 1.5));
} else {
tmp = (d / sqrt(l)) / sqrt(h);
}
return tmp;
}
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -4.5e-239) {
tmp = Math.abs((d / Math.sqrt((l * h))));
} else if (l <= 4.2e-307) {
tmp = d / Math.cbrt(Math.pow((l * h), 1.5));
} else {
tmp = (d / Math.sqrt(l)) / Math.sqrt(h);
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= -4.5e-239) tmp = abs(Float64(d / sqrt(Float64(l * h)))); elseif (l <= 4.2e-307) tmp = Float64(d / cbrt((Float64(l * h) ^ 1.5))); else tmp = Float64(Float64(d / sqrt(l)) / sqrt(h)); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, -4.5e-239], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, 4.2e-307], N[(d / N[Power[N[Power[N[(l * h), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.5 \cdot 10^{-239}:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{elif}\;\ell \leq 4.2 \cdot 10^{-307}:\\
\;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if l < -4.50000000000000013e-239Initial program 63.7%
Simplified64.1%
Taylor expanded in h around 0 33.7%
*-rgt-identity33.7%
sqrt-unprod25.8%
Applied egg-rr25.8%
frac-times22.7%
unpow222.7%
associate-/l/22.9%
add-sqr-sqrt22.9%
rem-sqrt-square22.9%
associate-/l/22.7%
sqrt-div25.6%
unpow225.6%
sqrt-prod0.0%
add-sqr-sqrt42.3%
*-commutative42.3%
Applied egg-rr42.3%
if -4.50000000000000013e-239 < l < 4.2000000000000002e-307Initial program 86.0%
Simplified86.1%
Taylor expanded in h around 0 21.8%
*-rgt-identity21.8%
sqrt-unprod8.2%
Applied egg-rr8.2%
frac-times8.2%
unpow28.2%
associate-/l/8.3%
expm1-log1p-u8.3%
expm1-udef8.4%
associate-/l/8.2%
unpow28.2%
frac-times8.3%
frac-times8.2%
unpow28.2%
sqrt-div8.2%
unpow28.2%
sqrt-prod0.0%
add-sqr-sqrt0.3%
*-commutative0.3%
Applied egg-rr0.3%
expm1-def0.4%
expm1-log1p37.1%
Simplified37.1%
add-cbrt-cube44.0%
pow1/344.0%
add-sqr-sqrt44.0%
pow144.0%
pow1/244.0%
pow-prod-up44.0%
*-commutative44.0%
metadata-eval44.0%
Applied egg-rr44.0%
unpow1/344.0%
Simplified44.0%
if 4.2000000000000002e-307 < l Initial program 69.8%
Simplified69.8%
Taylor expanded in h around 0 40.6%
expm1-log1p-u39.0%
expm1-udef30.7%
sqrt-div33.6%
*-rgt-identity33.6%
sqrt-div38.0%
frac-times38.0%
add-sqr-sqrt38.0%
Applied egg-rr38.0%
expm1-def47.8%
expm1-log1p50.2%
associate-/l/48.7%
Simplified48.7%
Final simplification45.2%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (sqrt (* l h))))
(if (<= l -1.05e-243)
(fabs (/ d t_0))
(if (<= l -1e-310) (reciprocal (/ t_0 d)) (/ (/ d (sqrt l)) (sqrt h))))))\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;\ell \leq -1.05 \cdot 10^{-243}:\\
\;\;\;\;\left|\frac{d}{t_0}\right|\\
\mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{reciprocal}\left(\left(\frac{t_0}{d}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if l < -1.05e-243Initial program 63.7%
Simplified64.1%
Taylor expanded in h around 0 33.7%
*-rgt-identity33.7%
sqrt-unprod25.8%
Applied egg-rr25.8%
frac-times22.7%
unpow222.7%
associate-/l/22.9%
add-sqr-sqrt22.9%
rem-sqrt-square22.9%
associate-/l/22.7%
sqrt-div25.6%
unpow225.6%
sqrt-prod0.0%
add-sqr-sqrt42.3%
*-commutative42.3%
Applied egg-rr42.3%
if -1.05e-243 < l < -9.999999999999969e-311Initial program 92.1%
Simplified92.2%
Taylor expanded in h around 0 23.4%
*-rgt-identity23.4%
sqrt-unprod8.9%
Applied egg-rr8.9%
frac-times8.8%
unpow28.8%
associate-/l/8.9%
expm1-log1p-u8.9%
expm1-udef9.0%
associate-/l/8.8%
unpow28.8%
frac-times8.9%
frac-times8.8%
unpow28.8%
sqrt-div8.8%
unpow28.8%
sqrt-prod0.0%
add-sqr-sqrt0.2%
*-commutative0.2%
Applied egg-rr0.2%
expm1-def0.4%
expm1-log1p40.0%
Simplified40.0%
clear-num40.0%
reciprocal-define40.0%
*-commutative40.0%
Applied egg-rr40.0%
if -9.999999999999969e-311 < l Initial program 69.2%
Simplified69.2%
Taylor expanded in h around 0 40.2%
expm1-log1p-u38.6%
expm1-udef30.5%
sqrt-div33.3%
*-rgt-identity33.3%
sqrt-div37.7%
frac-times37.7%
add-sqr-sqrt37.7%
Applied egg-rr37.7%
expm1-def47.4%
expm1-log1p49.8%
associate-/l/48.3%
Simplified48.3%
Final simplification44.9%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (let* ((t_0 (/ d (sqrt (* l h))))) (if (<= M_m 2e-7) (fabs t_0) t_0)))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = d / sqrt((l * h));
double tmp;
if (M_m <= 2e-7) {
tmp = fabs(t_0);
} else {
tmp = t_0;
}
return tmp;
}
M_m = abs(M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = d / sqrt((l * h))
if (m_m <= 2d-7) then
tmp = abs(t_0)
else
tmp = t_0
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = d / Math.sqrt((l * h));
double tmp;
if (M_m <= 2e-7) {
tmp = Math.abs(t_0);
} else {
tmp = t_0;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = d / math.sqrt((l * h)) tmp = 0 if M_m <= 2e-7: tmp = math.fabs(t_0) else: tmp = t_0 return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(d / sqrt(Float64(l * h))) tmp = 0.0 if (M_m <= 2e-7) tmp = abs(t_0); else tmp = t_0; end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = d / sqrt((l * h));
tmp = 0.0;
if (M_m <= 2e-7)
tmp = abs(t_0);
else
tmp = t_0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M$95$m, 2e-7], N[Abs[t$95$0], $MachinePrecision], t$95$0]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;M_m \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\left|t_0\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if M < 1.9999999999999999e-7Initial program 70.4%
Simplified70.7%
Taylor expanded in h around 0 40.6%
*-rgt-identity40.6%
sqrt-unprod29.4%
Applied egg-rr29.4%
frac-times22.2%
unpow222.2%
associate-/l/22.4%
add-sqr-sqrt22.4%
rem-sqrt-square22.4%
associate-/l/22.2%
sqrt-div27.0%
unpow227.0%
sqrt-prod21.2%
add-sqr-sqrt44.2%
*-commutative44.2%
Applied egg-rr44.2%
if 1.9999999999999999e-7 < M Initial program 59.4%
Simplified59.4%
Taylor expanded in h around 0 23.1%
*-rgt-identity23.1%
sqrt-unprod23.2%
Applied egg-rr23.2%
frac-times21.7%
unpow221.7%
associate-/l/23.2%
expm1-log1p-u22.6%
expm1-udef18.2%
associate-/l/18.2%
unpow218.2%
frac-times18.2%
frac-times18.2%
unpow218.2%
sqrt-div18.2%
unpow218.2%
sqrt-prod10.9%
add-sqr-sqrt13.1%
*-commutative13.1%
Applied egg-rr13.1%
expm1-def13.1%
expm1-log1p18.3%
Simplified18.3%
Final simplification37.6%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (if (<= l -1.02e-243) (* d (- (sqrt (/ 1.0 (* l h))))) (/ d (sqrt (* l h)))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -1.02e-243) {
tmp = d * -sqrt((1.0 / (l * h)));
} else {
tmp = d / sqrt((l * h));
}
return tmp;
}
M_m = abs(M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= (-1.02d-243)) then
tmp = d * -sqrt((1.0d0 / (l * h)))
else
tmp = d / sqrt((l * h))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -1.02e-243) {
tmp = d * -Math.sqrt((1.0 / (l * h)));
} else {
tmp = d / Math.sqrt((l * h));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if l <= -1.02e-243: tmp = d * -math.sqrt((1.0 / (l * h))) else: tmp = d / math.sqrt((l * h)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= -1.02e-243) tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))); else tmp = Float64(d / sqrt(Float64(l * h))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (l <= -1.02e-243)
tmp = d * -sqrt((1.0 / (l * h)));
else
tmp = d / sqrt((l * h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, -1.02e-243], N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.02 \cdot 10^{-243}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if l < -1.01999999999999996e-243Initial program 63.7%
Simplified64.1%
Taylor expanded in h around 0 33.7%
*-rgt-identity33.7%
sqrt-unprod25.8%
Applied egg-rr25.8%
Taylor expanded in d around -inf 41.6%
if -1.01999999999999996e-243 < l Initial program 71.5%
Simplified71.6%
Taylor expanded in h around 0 38.5%
*-rgt-identity38.5%
sqrt-unprod29.8%
Applied egg-rr29.8%
frac-times21.4%
unpow221.4%
associate-/l/22.4%
expm1-log1p-u21.8%
expm1-udef19.0%
associate-/l/18.1%
unpow218.1%
frac-times23.0%
frac-times18.1%
unpow218.1%
sqrt-div20.7%
unpow220.7%
sqrt-prod29.7%
add-sqr-sqrt29.8%
*-commutative29.8%
Applied egg-rr29.8%
expm1-def35.5%
expm1-log1p41.4%
Simplified41.4%
Final simplification41.5%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (if (<= d -1.7e-68) (sqrt (* (/ d h) (/ d l))) (/ d (sqrt (* l h)))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (d <= -1.7e-68) {
tmp = sqrt(((d / h) * (d / l)));
} else {
tmp = d / sqrt((l * h));
}
return tmp;
}
M_m = abs(M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (d <= (-1.7d-68)) then
tmp = sqrt(((d / h) * (d / l)))
else
tmp = d / sqrt((l * h))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (d <= -1.7e-68) {
tmp = Math.sqrt(((d / h) * (d / l)));
} else {
tmp = d / Math.sqrt((l * h));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if d <= -1.7e-68: tmp = math.sqrt(((d / h) * (d / l))) else: tmp = d / math.sqrt((l * h)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (d <= -1.7e-68) tmp = sqrt(Float64(Float64(d / h) * Float64(d / l))); else tmp = Float64(d / sqrt(Float64(l * h))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (d <= -1.7e-68)
tmp = sqrt(((d / h) * (d / l)));
else
tmp = d / sqrt((l * h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[d, -1.7e-68], N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.7 \cdot 10^{-68}:\\
\;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if d < -1.70000000000000009e-68Initial program 71.6%
Simplified72.7%
Taylor expanded in h around 0 44.3%
*-rgt-identity44.3%
sqrt-unprod34.4%
Applied egg-rr34.4%
if -1.70000000000000009e-68 < d Initial program 65.7%
Simplified65.5%
Taylor expanded in h around 0 32.2%
*-rgt-identity32.2%
sqrt-unprod24.6%
Applied egg-rr24.6%
frac-times17.8%
unpow217.8%
associate-/l/18.0%
expm1-log1p-u17.6%
expm1-udef15.5%
associate-/l/14.8%
unpow214.8%
frac-times18.5%
frac-times14.8%
unpow214.8%
sqrt-div16.8%
unpow216.8%
sqrt-prod22.1%
add-sqr-sqrt24.1%
*-commutative24.1%
Applied egg-rr24.1%
expm1-def28.4%
expm1-log1p34.5%
Simplified34.5%
Final simplification34.4%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (/ d (sqrt (* l h))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
return d / sqrt((l * h));
}
M_m = abs(M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
code = d / sqrt((l * h))
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
return d / Math.sqrt((l * h));
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): return d / math.sqrt((l * h))
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) return Float64(d / sqrt(Float64(l * h))) end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
tmp = d / sqrt((l * h));
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Initial program 67.6%
Simplified67.9%
Taylor expanded in h around 0 36.1%
*-rgt-identity36.1%
sqrt-unprod27.8%
Applied egg-rr27.8%
frac-times22.0%
unpow222.0%
associate-/l/22.6%
expm1-log1p-u21.9%
expm1-udef17.9%
associate-/l/17.4%
unpow217.4%
frac-times20.6%
frac-times17.4%
unpow217.4%
sqrt-div18.7%
unpow218.7%
sqrt-prod14.9%
add-sqr-sqrt16.5%
*-commutative16.5%
Applied egg-rr16.5%
expm1-def19.3%
expm1-log1p25.4%
Simplified25.4%
Final simplification25.4%
herbie shell --seed 2024024
(FPCore (d h l M D)
:name "Henrywood and Agarwal, Equation (12)"
:precision binary64
(* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))