
(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 20 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 (* (sqrt l) (sqrt h))) (t_1 (sqrt (- d))))
(if (<= l -5e-175)
(*
(sqrt (/ d l))
(*
(/ t_1 (sqrt (- h)))
(+ 1.0 (* (/ h l) (* (pow (* D (/ (/ M_m 2.0) d)) 2.0) -0.5)))))
(if (<= l -3.8e-308)
(*
(sqrt (/ d h))
(*
(fma h (* (/ -0.125 l) (pow (* M_m (/ D d)) 2.0)) 1.0)
(/ t_1 (sqrt (- l)))))
(if (<= l 1.7e-120)
(*
(/ d t_0)
(- 1.0 (* 0.5 (/ (* h (* 0.25 (pow (/ M_m (/ d D)) 2.0))) l))))
(*
d
(/
(fma (* -0.125 (pow (/ 1.0 (/ d (* M_m D))) 2.0)) (/ h l) 1.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 = sqrt(l) * sqrt(h);
double t_1 = sqrt(-d);
double tmp;
if (l <= -5e-175) {
tmp = sqrt((d / l)) * ((t_1 / sqrt(-h)) * (1.0 + ((h / l) * (pow((D * ((M_m / 2.0) / d)), 2.0) * -0.5))));
} else if (l <= -3.8e-308) {
tmp = sqrt((d / h)) * (fma(h, ((-0.125 / l) * pow((M_m * (D / d)), 2.0)), 1.0) * (t_1 / sqrt(-l)));
} else if (l <= 1.7e-120) {
tmp = (d / t_0) * (1.0 - (0.5 * ((h * (0.25 * pow((M_m / (d / D)), 2.0))) / l)));
} else {
tmp = d * (fma((-0.125 * pow((1.0 / (d / (M_m * D))), 2.0)), (h / l), 1.0) / 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(sqrt(l) * sqrt(h)) t_1 = sqrt(Float64(-d)) tmp = 0.0 if (l <= -5e-175) tmp = Float64(sqrt(Float64(d / l)) * Float64(Float64(t_1 / sqrt(Float64(-h))) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(D * Float64(Float64(M_m / 2.0) / d)) ^ 2.0) * -0.5))))); elseif (l <= -3.8e-308) tmp = Float64(sqrt(Float64(d / h)) * Float64(fma(h, Float64(Float64(-0.125 / l) * (Float64(M_m * Float64(D / d)) ^ 2.0)), 1.0) * Float64(t_1 / sqrt(Float64(-l))))); elseif (l <= 1.7e-120) tmp = Float64(Float64(d / t_0) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * Float64(0.25 * (Float64(M_m / Float64(d / D)) ^ 2.0))) / l)))); else tmp = Float64(d * Float64(fma(Float64(-0.125 * (Float64(1.0 / Float64(d / Float64(M_m * D))) ^ 2.0)), Float64(h / l), 1.0) / t_0)); 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_] := Block[{t$95$0 = N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[l, -5e-175], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(t$95$1 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(D * N[(N[(M$95$m / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -3.8e-308], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(h * N[(N[(-0.125 / l), $MachinePrecision] * N[Power[N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(t$95$1 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.7e-120], N[(N[(d / t$95$0), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[(0.25 * N[Power[N[(M$95$m / N[(d / D), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(N[(-0.125 * N[Power[N[(1.0 / N[(d / N[(M$95$m * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $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 := \sqrt{\ell} \cdot \sqrt{h}\\
t_1 := \sqrt{-d}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-175}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\frac{t\_1}{\sqrt{-h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(D \cdot \frac{\frac{M\_m}{2}}{d}\right)}^{2} \cdot -0.5\right)\right)\right)\\
\mathbf{elif}\;\ell \leq -3.8 \cdot 10^{-308}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(M\_m \cdot \frac{D}{d}\right)}^{2}, 1\right) \cdot \frac{t\_1}{\sqrt{-\ell}}\right)\\
\mathbf{elif}\;\ell \leq 1.7 \cdot 10^{-120}:\\
\;\;\;\;\frac{d}{t\_0} \cdot \left(1 - 0.5 \cdot \frac{h \cdot \left(0.25 \cdot {\left(\frac{M\_m}{\frac{d}{D}}\right)}^{2}\right)}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\left(\frac{1}{\frac{d}{M\_m \cdot D}}\right)}^{2}, \frac{h}{\ell}, 1\right)}{t\_0}\\
\end{array}
\end{array}
if l < -5e-175Initial program 67.5%
Simplified67.6%
frac-2neg68.8%
sqrt-div85.3%
Applied egg-rr83.1%
if -5e-175 < l < -3.79999999999999975e-308Initial program 57.7%
Simplified59.6%
Taylor expanded in M around 0 46.2%
associate-*r/46.2%
associate-*r*46.5%
associate-*r*46.5%
associate-*l/46.5%
associate-*r/46.5%
*-commutative46.5%
+-commutative46.5%
fma-undefine46.5%
Simplified71.8%
frac-2neg71.8%
sqrt-div90.6%
Applied egg-rr90.6%
if -3.79999999999999975e-308 < l < 1.70000000000000005e-120Initial program 60.6%
Simplified53.2%
*-commutative53.2%
sqrt-div55.5%
sqrt-div67.5%
frac-times67.5%
add-sqr-sqrt67.6%
Applied egg-rr67.6%
associate-*r/87.6%
associate-*l/87.6%
div-inv87.6%
metadata-eval87.6%
*-commutative87.6%
unpow-prod-down87.6%
metadata-eval87.6%
clear-num85.1%
un-div-inv87.5%
Applied egg-rr87.5%
if 1.70000000000000005e-120 < l Initial program 57.6%
Simplified57.5%
pow157.5%
associate-*r*57.5%
sqrt-div69.6%
sqrt-div74.3%
frac-times74.4%
add-sqr-sqrt74.6%
unpow-prod-down74.6%
metadata-eval74.6%
clear-num74.6%
un-div-inv74.6%
Applied egg-rr74.6%
unpow174.6%
associate-*l/83.3%
associate-/l*83.3%
fma-define83.3%
associate-*r*83.3%
fma-define83.3%
*-commutative83.3%
associate-*l*83.3%
metadata-eval83.3%
*-commutative83.3%
associate-/r/83.4%
associate-*l/84.4%
associate-/l*83.3%
Simplified83.3%
associate-*r/84.4%
clear-num84.4%
Applied egg-rr84.4%
Final simplification85.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
(let* ((t_0 (* (sqrt l) (sqrt h))))
(if (<= l -2e-310)
(*
(/ (sqrt (- d)) (sqrt (- h)))
(*
(sqrt (/ d l))
(fma h (* (/ -0.125 l) (pow (* M_m (/ D d)) 2.0)) 1.0)))
(if (<= l 3.7e-121)
(*
(/ d t_0)
(- 1.0 (* 0.5 (/ (* h (* 0.25 (pow (/ M_m (/ d D)) 2.0))) l))))
(*
d
(/
(fma (* -0.125 (pow (/ 1.0 (/ d (* M_m D))) 2.0)) (/ h l) 1.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 = sqrt(l) * sqrt(h);
double tmp;
if (l <= -2e-310) {
tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * fma(h, ((-0.125 / l) * pow((M_m * (D / d)), 2.0)), 1.0));
} else if (l <= 3.7e-121) {
tmp = (d / t_0) * (1.0 - (0.5 * ((h * (0.25 * pow((M_m / (d / D)), 2.0))) / l)));
} else {
tmp = d * (fma((-0.125 * pow((1.0 / (d / (M_m * D))), 2.0)), (h / l), 1.0) / 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(sqrt(l) * sqrt(h)) tmp = 0.0 if (l <= -2e-310) tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(sqrt(Float64(d / l)) * fma(h, Float64(Float64(-0.125 / l) * (Float64(M_m * Float64(D / d)) ^ 2.0)), 1.0))); elseif (l <= 3.7e-121) tmp = Float64(Float64(d / t_0) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * Float64(0.25 * (Float64(M_m / Float64(d / D)) ^ 2.0))) / l)))); else tmp = Float64(d * Float64(fma(Float64(-0.125 * (Float64(1.0 / Float64(d / Float64(M_m * D))) ^ 2.0)), Float64(h / l), 1.0) / t_0)); 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_] := Block[{t$95$0 = N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2e-310], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(h * N[(N[(-0.125 / l), $MachinePrecision] * N[Power[N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.7e-121], N[(N[(d / t$95$0), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[(0.25 * N[Power[N[(M$95$m / N[(d / D), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(N[(-0.125 * N[Power[N[(1.0 / N[(d / N[(M$95$m * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $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 := \sqrt{\ell} \cdot \sqrt{h}\\
\mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(M\_m \cdot \frac{D}{d}\right)}^{2}, 1\right)\right)\\
\mathbf{elif}\;\ell \leq 3.7 \cdot 10^{-121}:\\
\;\;\;\;\frac{d}{t\_0} \cdot \left(1 - 0.5 \cdot \frac{h \cdot \left(0.25 \cdot {\left(\frac{M\_m}{\frac{d}{D}}\right)}^{2}\right)}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\left(\frac{1}{\frac{d}{M\_m \cdot D}}\right)}^{2}, \frac{h}{\ell}, 1\right)}{t\_0}\\
\end{array}
\end{array}
if l < -1.999999999999994e-310Initial program 64.7%
Simplified66.0%
Taylor expanded in M around 0 41.5%
associate-*r/41.5%
associate-*r*44.9%
associate-*r*44.9%
associate-*l/45.7%
associate-*r/45.7%
*-commutative45.7%
+-commutative45.7%
fma-undefine45.7%
Simplified68.9%
frac-2neg68.9%
sqrt-div84.3%
Applied egg-rr84.3%
if -1.999999999999994e-310 < l < 3.7000000000000002e-121Initial program 62.1%
Simplified54.5%
*-commutative54.5%
sqrt-div56.9%
sqrt-div69.2%
frac-times69.3%
add-sqr-sqrt69.3%
Applied egg-rr69.3%
associate-*r/89.9%
associate-*l/89.9%
div-inv89.9%
metadata-eval89.9%
*-commutative89.9%
unpow-prod-down89.9%
metadata-eval89.9%
clear-num87.3%
un-div-inv89.8%
Applied egg-rr89.8%
if 3.7000000000000002e-121 < l Initial program 57.6%
Simplified57.5%
pow157.5%
associate-*r*57.5%
sqrt-div69.6%
sqrt-div74.3%
frac-times74.4%
add-sqr-sqrt74.6%
unpow-prod-down74.6%
metadata-eval74.6%
clear-num74.6%
un-div-inv74.6%
Applied egg-rr74.6%
unpow174.6%
associate-*l/83.3%
associate-/l*83.3%
fma-define83.3%
associate-*r*83.3%
fma-define83.3%
*-commutative83.3%
associate-*l*83.3%
metadata-eval83.3%
*-commutative83.3%
associate-/r/83.4%
associate-*l/84.4%
associate-/l*83.3%
Simplified83.3%
associate-*r/84.4%
clear-num84.4%
Applied egg-rr84.4%
Final simplification85.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) (sqrt h))))
(if (<= d -1e+197)
(/ (- d) (sqrt (* l h)))
(if (<= d -8.2e-203)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (* 0.5 (* 0.25 (pow (* D (* (/ M_m d) (sqrt (/ h l)))) 2.0)))))
(if (<= d -5e-310)
(*
(sqrt (/ h (pow l 3.0)))
(* -0.125 (* (pow D 2.0) (/ (pow M_m 2.0) (- d)))))
(if (<= d 3.9e-116)
(*
d
(/
(fma (* -0.125 (pow (/ 1.0 (/ d (* M_m D))) 2.0)) (/ h l) 1.0)
t_0))
(*
(/ d t_0)
(-
1.0
(* 0.5 (/ (* h (* 0.25 (pow (/ M_m (/ d D)) 2.0))) 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 = sqrt(l) * sqrt(h);
double tmp;
if (d <= -1e+197) {
tmp = -d / sqrt((l * h));
} else if (d <= -8.2e-203) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * (0.25 * pow((D * ((M_m / d) * sqrt((h / l)))), 2.0))));
} else if (d <= -5e-310) {
tmp = sqrt((h / pow(l, 3.0))) * (-0.125 * (pow(D, 2.0) * (pow(M_m, 2.0) / -d)));
} else if (d <= 3.9e-116) {
tmp = d * (fma((-0.125 * pow((1.0 / (d / (M_m * D))), 2.0)), (h / l), 1.0) / t_0);
} else {
tmp = (d / t_0) * (1.0 - (0.5 * ((h * (0.25 * pow((M_m / (d / D)), 2.0))) / 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(sqrt(l) * sqrt(h)) tmp = 0.0 if (d <= -1e+197) tmp = Float64(Float64(-d) / sqrt(Float64(l * h))); elseif (d <= -8.2e-203) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(0.5 * Float64(0.25 * (Float64(D * Float64(Float64(M_m / d) * sqrt(Float64(h / l)))) ^ 2.0))))); elseif (d <= -5e-310) tmp = Float64(sqrt(Float64(h / (l ^ 3.0))) * Float64(-0.125 * Float64((D ^ 2.0) * Float64((M_m ^ 2.0) / Float64(-d))))); elseif (d <= 3.9e-116) tmp = Float64(d * Float64(fma(Float64(-0.125 * (Float64(1.0 / Float64(d / Float64(M_m * D))) ^ 2.0)), Float64(h / l), 1.0) / t_0)); else tmp = Float64(Float64(d / t_0) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * Float64(0.25 * (Float64(M_m / Float64(d / D)) ^ 2.0))) / l)))); 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_] := Block[{t$95$0 = N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1e+197], N[((-d) / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -8.2e-203], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(0.25 * N[Power[N[(D * N[(N[(M$95$m / d), $MachinePrecision] * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-310], N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-0.125 * N[(N[Power[D, 2.0], $MachinePrecision] * N[(N[Power[M$95$m, 2.0], $MachinePrecision] / (-d)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.9e-116], N[(d * N[(N[(N[(-0.125 * N[Power[N[(1.0 / N[(d / N[(M$95$m * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(d / t$95$0), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[(0.25 * N[Power[N[(M$95$m / N[(d / D), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 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 := \sqrt{\ell} \cdot \sqrt{h}\\
\mathbf{if}\;d \leq -1 \cdot 10^{+197}:\\
\;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\
\mathbf{elif}\;d \leq -8.2 \cdot 10^{-203}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot {\left(D \cdot \left(\frac{M\_m}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(-0.125 \cdot \left({D}^{2} \cdot \frac{{M\_m}^{2}}{-d}\right)\right)\\
\mathbf{elif}\;d \leq 3.9 \cdot 10^{-116}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\left(\frac{1}{\frac{d}{M\_m \cdot D}}\right)}^{2}, \frac{h}{\ell}, 1\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_0} \cdot \left(1 - 0.5 \cdot \frac{h \cdot \left(0.25 \cdot {\left(\frac{M\_m}{\frac{d}{D}}\right)}^{2}\right)}{\ell}\right)\\
\end{array}
\end{array}
if d < -9.9999999999999995e196Initial program 54.8%
Simplified58.9%
Taylor expanded in M around 0 36.0%
associate-*r/36.0%
associate-*r*43.9%
associate-*r*43.9%
associate-*l/43.9%
associate-*r/43.9%
*-commutative43.9%
+-commutative43.9%
fma-undefine43.9%
Simplified67.6%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt92.2%
neg-mul-192.2%
distribute-rgt-neg-in92.2%
unpow1/292.2%
rem-exp-log90.3%
exp-neg90.3%
exp-prod90.3%
distribute-lft-neg-out90.3%
exp-neg90.3%
exp-to-pow92.2%
unpow1/292.2%
associate-*l/92.2%
*-lft-identity92.2%
distribute-frac-neg292.2%
Simplified92.2%
if -9.9999999999999995e196 < d < -8.19999999999999962e-203Initial program 74.6%
Simplified75.4%
add-sqr-sqrt75.3%
pow275.3%
sqrt-prod75.4%
sqrt-pow179.0%
metadata-eval79.0%
associate-*l/79.0%
div-inv79.0%
metadata-eval79.0%
*-commutative79.0%
pow179.0%
clear-num78.9%
un-div-inv79.0%
Applied egg-rr79.0%
metadata-eval79.0%
pow-prod-up79.0%
associate-*l*79.0%
pow179.0%
div-inv78.9%
clear-num78.9%
associate-*l*78.9%
pow178.9%
div-inv78.9%
clear-num79.0%
Applied egg-rr79.0%
swap-sqr79.0%
metadata-eval79.0%
unpow279.0%
associate-*r/79.4%
*-commutative79.4%
associate-/l*77.6%
associate-*l*77.6%
Simplified77.6%
if -8.19999999999999962e-203 < d < -4.999999999999985e-310Initial program 37.2%
Simplified37.3%
pow1/237.3%
pow-to-exp36.5%
Applied egg-rr36.5%
Taylor expanded in h around -inf 0.0%
associate-*r*0.0%
*-commutative0.0%
associate-/l*0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt73.9%
mul-1-neg73.9%
Simplified73.9%
if -4.999999999999985e-310 < d < 3.9000000000000001e-116Initial program 42.4%
Simplified40.1%
pow140.1%
associate-*r*40.1%
sqrt-div49.5%
sqrt-div51.7%
frac-times51.8%
add-sqr-sqrt51.8%
unpow-prod-down51.8%
metadata-eval51.8%
clear-num51.8%
un-div-inv54.1%
Applied egg-rr54.1%
unpow154.1%
associate-*l/73.1%
associate-/l*73.1%
fma-define73.1%
associate-*r*73.1%
fma-define73.1%
*-commutative73.1%
associate-*l*73.1%
metadata-eval73.1%
*-commutative73.1%
associate-/r/73.1%
associate-*l/75.4%
associate-/l*70.9%
Simplified70.9%
associate-*r/75.4%
clear-num75.4%
Applied egg-rr75.4%
if 3.9000000000000001e-116 < d Initial program 66.8%
Simplified64.6%
*-commutative64.6%
sqrt-div69.6%
sqrt-div83.0%
frac-times83.0%
add-sqr-sqrt83.3%
Applied egg-rr83.3%
associate-*r/91.1%
associate-*l/91.1%
div-inv91.1%
metadata-eval91.1%
*-commutative91.1%
unpow-prod-down91.1%
metadata-eval91.1%
clear-num90.1%
un-div-inv90.1%
Applied egg-rr90.1%
Final simplification82.8%
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) (sqrt h))))
(if (<= d -1.9e+197)
(/ (- d) (sqrt (* l h)))
(if (<= d -8.5e-203)
(*
(* (sqrt (/ d l)) (/ 1.0 (sqrt (/ h d))))
(- 1.0 (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M_m 2.0)) 2.0)))))
(if (<= d -5e-310)
(*
(sqrt (/ h (pow l 3.0)))
(* -0.125 (* (pow D 2.0) (/ (pow M_m 2.0) (- d)))))
(if (<= d 4.5e-113)
(*
d
(/
(fma (* -0.125 (pow (/ 1.0 (/ d (* M_m D))) 2.0)) (/ h l) 1.0)
t_0))
(*
(/ d t_0)
(-
1.0
(* 0.5 (/ (* h (* 0.25 (pow (/ M_m (/ d D)) 2.0))) 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 = sqrt(l) * sqrt(h);
double tmp;
if (d <= -1.9e+197) {
tmp = -d / sqrt((l * h));
} else if (d <= -8.5e-203) {
tmp = (sqrt((d / l)) * (1.0 / sqrt((h / d)))) * (1.0 - (0.5 * ((h / l) * pow(((D / d) * (M_m / 2.0)), 2.0))));
} else if (d <= -5e-310) {
tmp = sqrt((h / pow(l, 3.0))) * (-0.125 * (pow(D, 2.0) * (pow(M_m, 2.0) / -d)));
} else if (d <= 4.5e-113) {
tmp = d * (fma((-0.125 * pow((1.0 / (d / (M_m * D))), 2.0)), (h / l), 1.0) / t_0);
} else {
tmp = (d / t_0) * (1.0 - (0.5 * ((h * (0.25 * pow((M_m / (d / D)), 2.0))) / 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(sqrt(l) * sqrt(h)) tmp = 0.0 if (d <= -1.9e+197) tmp = Float64(Float64(-d) / sqrt(Float64(l * h))); elseif (d <= -8.5e-203) tmp = Float64(Float64(sqrt(Float64(d / l)) * Float64(1.0 / sqrt(Float64(h / d)))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M_m / 2.0)) ^ 2.0))))); elseif (d <= -5e-310) tmp = Float64(sqrt(Float64(h / (l ^ 3.0))) * Float64(-0.125 * Float64((D ^ 2.0) * Float64((M_m ^ 2.0) / Float64(-d))))); elseif (d <= 4.5e-113) tmp = Float64(d * Float64(fma(Float64(-0.125 * (Float64(1.0 / Float64(d / Float64(M_m * D))) ^ 2.0)), Float64(h / l), 1.0) / t_0)); else tmp = Float64(Float64(d / t_0) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * Float64(0.25 * (Float64(M_m / Float64(d / D)) ^ 2.0))) / l)))); 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_] := Block[{t$95$0 = N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.9e+197], N[((-d) / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -8.5e-203], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-310], N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-0.125 * N[(N[Power[D, 2.0], $MachinePrecision] * N[(N[Power[M$95$m, 2.0], $MachinePrecision] / (-d)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.5e-113], N[(d * N[(N[(N[(-0.125 * N[Power[N[(1.0 / N[(d / N[(M$95$m * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(d / t$95$0), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[(0.25 * N[Power[N[(M$95$m / N[(d / D), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 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 := \sqrt{\ell} \cdot \sqrt{h}\\
\mathbf{if}\;d \leq -1.9 \cdot 10^{+197}:\\
\;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\
\mathbf{elif}\;d \leq -8.5 \cdot 10^{-203}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \frac{1}{\sqrt{\frac{h}{d}}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right)\right)\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(-0.125 \cdot \left({D}^{2} \cdot \frac{{M\_m}^{2}}{-d}\right)\right)\\
\mathbf{elif}\;d \leq 4.5 \cdot 10^{-113}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\left(\frac{1}{\frac{d}{M\_m \cdot D}}\right)}^{2}, \frac{h}{\ell}, 1\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_0} \cdot \left(1 - 0.5 \cdot \frac{h \cdot \left(0.25 \cdot {\left(\frac{M\_m}{\frac{d}{D}}\right)}^{2}\right)}{\ell}\right)\\
\end{array}
\end{array}
if d < -1.9000000000000001e197Initial program 54.8%
Simplified58.9%
Taylor expanded in M around 0 36.0%
associate-*r/36.0%
associate-*r*43.9%
associate-*r*43.9%
associate-*l/43.9%
associate-*r/43.9%
*-commutative43.9%
+-commutative43.9%
fma-undefine43.9%
Simplified67.6%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt92.2%
neg-mul-192.2%
distribute-rgt-neg-in92.2%
unpow1/292.2%
rem-exp-log90.3%
exp-neg90.3%
exp-prod90.3%
distribute-lft-neg-out90.3%
exp-neg90.3%
exp-to-pow92.2%
unpow1/292.2%
associate-*l/92.2%
*-lft-identity92.2%
distribute-frac-neg292.2%
Simplified92.2%
if -1.9000000000000001e197 < d < -8.50000000000000031e-203Initial program 74.6%
Simplified75.4%
clear-num75.3%
sqrt-div77.8%
metadata-eval77.8%
Applied egg-rr77.8%
if -8.50000000000000031e-203 < d < -4.999999999999985e-310Initial program 37.2%
Simplified37.3%
pow1/237.3%
pow-to-exp36.5%
Applied egg-rr36.5%
Taylor expanded in h around -inf 0.0%
associate-*r*0.0%
*-commutative0.0%
associate-/l*0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt73.9%
mul-1-neg73.9%
Simplified73.9%
if -4.999999999999985e-310 < d < 4.5000000000000001e-113Initial program 42.4%
Simplified40.1%
pow140.1%
associate-*r*40.1%
sqrt-div49.5%
sqrt-div51.7%
frac-times51.8%
add-sqr-sqrt51.8%
unpow-prod-down51.8%
metadata-eval51.8%
clear-num51.8%
un-div-inv54.1%
Applied egg-rr54.1%
unpow154.1%
associate-*l/73.1%
associate-/l*73.1%
fma-define73.1%
associate-*r*73.1%
fma-define73.1%
*-commutative73.1%
associate-*l*73.1%
metadata-eval73.1%
*-commutative73.1%
associate-/r/73.1%
associate-*l/75.4%
associate-/l*70.9%
Simplified70.9%
associate-*r/75.4%
clear-num75.4%
Applied egg-rr75.4%
if 4.5000000000000001e-113 < d Initial program 66.8%
Simplified64.6%
*-commutative64.6%
sqrt-div69.6%
sqrt-div83.0%
frac-times83.0%
add-sqr-sqrt83.3%
Applied egg-rr83.3%
associate-*r/91.1%
associate-*l/91.1%
div-inv91.1%
metadata-eval91.1%
*-commutative91.1%
unpow-prod-down91.1%
metadata-eval91.1%
clear-num90.1%
un-div-inv90.1%
Applied egg-rr90.1%
Final simplification82.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 (* (sqrt l) (sqrt h))))
(if (<= d -3.5e+196)
(/ (- d) (sqrt (* l h)))
(if (<= d -8.2e-203)
(*
(* (sqrt (/ d l)) (/ 1.0 (sqrt (/ h d))))
(- 1.0 (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M_m 2.0)) 2.0)))))
(if (<= d -5e-310)
(*
(sqrt (/ h (pow l 3.0)))
(* -0.125 (* (pow D 2.0) (/ (pow M_m 2.0) (- d)))))
(if (<= d 1.25e-130)
(* d (/ (fma (* -0.125 (pow (* M_m (/ D d)) 2.0)) (/ h l) 1.0) t_0))
(*
(/ d t_0)
(-
1.0
(* 0.5 (/ (* h (* 0.25 (pow (/ M_m (/ d D)) 2.0))) 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 = sqrt(l) * sqrt(h);
double tmp;
if (d <= -3.5e+196) {
tmp = -d / sqrt((l * h));
} else if (d <= -8.2e-203) {
tmp = (sqrt((d / l)) * (1.0 / sqrt((h / d)))) * (1.0 - (0.5 * ((h / l) * pow(((D / d) * (M_m / 2.0)), 2.0))));
} else if (d <= -5e-310) {
tmp = sqrt((h / pow(l, 3.0))) * (-0.125 * (pow(D, 2.0) * (pow(M_m, 2.0) / -d)));
} else if (d <= 1.25e-130) {
tmp = d * (fma((-0.125 * pow((M_m * (D / d)), 2.0)), (h / l), 1.0) / t_0);
} else {
tmp = (d / t_0) * (1.0 - (0.5 * ((h * (0.25 * pow((M_m / (d / D)), 2.0))) / 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(sqrt(l) * sqrt(h)) tmp = 0.0 if (d <= -3.5e+196) tmp = Float64(Float64(-d) / sqrt(Float64(l * h))); elseif (d <= -8.2e-203) tmp = Float64(Float64(sqrt(Float64(d / l)) * Float64(1.0 / sqrt(Float64(h / d)))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M_m / 2.0)) ^ 2.0))))); elseif (d <= -5e-310) tmp = Float64(sqrt(Float64(h / (l ^ 3.0))) * Float64(-0.125 * Float64((D ^ 2.0) * Float64((M_m ^ 2.0) / Float64(-d))))); elseif (d <= 1.25e-130) tmp = Float64(d * Float64(fma(Float64(-0.125 * (Float64(M_m * Float64(D / d)) ^ 2.0)), Float64(h / l), 1.0) / t_0)); else tmp = Float64(Float64(d / t_0) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * Float64(0.25 * (Float64(M_m / Float64(d / D)) ^ 2.0))) / l)))); 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_] := Block[{t$95$0 = N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.5e+196], N[((-d) / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -8.2e-203], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-310], N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-0.125 * N[(N[Power[D, 2.0], $MachinePrecision] * N[(N[Power[M$95$m, 2.0], $MachinePrecision] / (-d)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.25e-130], N[(d * N[(N[(N[(-0.125 * N[Power[N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(d / t$95$0), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[(0.25 * N[Power[N[(M$95$m / N[(d / D), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 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 := \sqrt{\ell} \cdot \sqrt{h}\\
\mathbf{if}\;d \leq -3.5 \cdot 10^{+196}:\\
\;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\
\mathbf{elif}\;d \leq -8.2 \cdot 10^{-203}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \frac{1}{\sqrt{\frac{h}{d}}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right)\right)\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(-0.125 \cdot \left({D}^{2} \cdot \frac{{M\_m}^{2}}{-d}\right)\right)\\
\mathbf{elif}\;d \leq 1.25 \cdot 10^{-130}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\left(M\_m \cdot \frac{D}{d}\right)}^{2}, \frac{h}{\ell}, 1\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_0} \cdot \left(1 - 0.5 \cdot \frac{h \cdot \left(0.25 \cdot {\left(\frac{M\_m}{\frac{d}{D}}\right)}^{2}\right)}{\ell}\right)\\
\end{array}
\end{array}
if d < -3.4999999999999998e196Initial program 54.8%
Simplified58.9%
Taylor expanded in M around 0 36.0%
associate-*r/36.0%
associate-*r*43.9%
associate-*r*43.9%
associate-*l/43.9%
associate-*r/43.9%
*-commutative43.9%
+-commutative43.9%
fma-undefine43.9%
Simplified67.6%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt92.2%
neg-mul-192.2%
distribute-rgt-neg-in92.2%
unpow1/292.2%
rem-exp-log90.3%
exp-neg90.3%
exp-prod90.3%
distribute-lft-neg-out90.3%
exp-neg90.3%
exp-to-pow92.2%
unpow1/292.2%
associate-*l/92.2%
*-lft-identity92.2%
distribute-frac-neg292.2%
Simplified92.2%
if -3.4999999999999998e196 < d < -8.19999999999999962e-203Initial program 74.6%
Simplified75.4%
clear-num75.3%
sqrt-div77.8%
metadata-eval77.8%
Applied egg-rr77.8%
if -8.19999999999999962e-203 < d < -4.999999999999985e-310Initial program 37.2%
Simplified37.3%
pow1/237.3%
pow-to-exp36.5%
Applied egg-rr36.5%
Taylor expanded in h around -inf 0.0%
associate-*r*0.0%
*-commutative0.0%
associate-/l*0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt73.9%
mul-1-neg73.9%
Simplified73.9%
if -4.999999999999985e-310 < d < 1.2499999999999999e-130Initial program 40.5%
Simplified38.1%
pow138.1%
associate-*r*38.1%
sqrt-div48.2%
sqrt-div50.6%
frac-times50.7%
add-sqr-sqrt50.7%
unpow-prod-down50.7%
metadata-eval50.7%
clear-num50.7%
un-div-inv53.1%
Applied egg-rr53.1%
unpow153.1%
associate-*l/73.6%
associate-/l*73.6%
fma-define73.6%
associate-*r*73.6%
fma-define73.6%
*-commutative73.6%
associate-*l*73.6%
metadata-eval73.6%
*-commutative73.6%
associate-/r/73.6%
associate-*l/73.6%
associate-/l*71.2%
Simplified71.2%
if 1.2499999999999999e-130 < d Initial program 66.9%
Simplified64.7%
*-commutative64.7%
sqrt-div69.5%
sqrt-div82.4%
frac-times82.5%
add-sqr-sqrt82.7%
Applied egg-rr82.7%
associate-*r/90.4%
associate-*l/90.4%
div-inv90.4%
metadata-eval90.4%
*-commutative90.4%
unpow-prod-down90.4%
metadata-eval90.4%
clear-num89.3%
un-div-inv89.3%
Applied egg-rr89.3%
Final simplification82.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
(let* ((t_0 (* (sqrt l) (sqrt h))))
(if (<= d -9e+198)
(/ (- d) (sqrt (* l h)))
(if (<= d -5e-310)
(*
(sqrt (/ d l))
(*
(/ (sqrt (- d)) (sqrt (- h)))
(+ 1.0 (* (/ h l) (* (pow (* D (/ (/ M_m 2.0) d)) 2.0) -0.5)))))
(if (<= d 1.35e-118)
(*
d
(/
(fma (* -0.125 (pow (/ 1.0 (/ d (* M_m D))) 2.0)) (/ h l) 1.0)
t_0))
(*
(/ d t_0)
(- 1.0 (* 0.5 (/ (* h (* 0.25 (pow (/ M_m (/ d D)) 2.0))) 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 = sqrt(l) * sqrt(h);
double tmp;
if (d <= -9e+198) {
tmp = -d / sqrt((l * h));
} else if (d <= -5e-310) {
tmp = sqrt((d / l)) * ((sqrt(-d) / sqrt(-h)) * (1.0 + ((h / l) * (pow((D * ((M_m / 2.0) / d)), 2.0) * -0.5))));
} else if (d <= 1.35e-118) {
tmp = d * (fma((-0.125 * pow((1.0 / (d / (M_m * D))), 2.0)), (h / l), 1.0) / t_0);
} else {
tmp = (d / t_0) * (1.0 - (0.5 * ((h * (0.25 * pow((M_m / (d / D)), 2.0))) / 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(sqrt(l) * sqrt(h)) tmp = 0.0 if (d <= -9e+198) tmp = Float64(Float64(-d) / sqrt(Float64(l * h))); elseif (d <= -5e-310) tmp = Float64(sqrt(Float64(d / l)) * Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(D * Float64(Float64(M_m / 2.0) / d)) ^ 2.0) * -0.5))))); elseif (d <= 1.35e-118) tmp = Float64(d * Float64(fma(Float64(-0.125 * (Float64(1.0 / Float64(d / Float64(M_m * D))) ^ 2.0)), Float64(h / l), 1.0) / t_0)); else tmp = Float64(Float64(d / t_0) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * Float64(0.25 * (Float64(M_m / Float64(d / D)) ^ 2.0))) / l)))); 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_] := Block[{t$95$0 = N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -9e+198], N[((-d) / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-310], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(D * N[(N[(M$95$m / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.35e-118], N[(d * N[(N[(N[(-0.125 * N[Power[N[(1.0 / N[(d / N[(M$95$m * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(d / t$95$0), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[(0.25 * N[Power[N[(M$95$m / N[(d / D), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 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 := \sqrt{\ell} \cdot \sqrt{h}\\
\mathbf{if}\;d \leq -9 \cdot 10^{+198}:\\
\;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(D \cdot \frac{\frac{M\_m}{2}}{d}\right)}^{2} \cdot -0.5\right)\right)\right)\\
\mathbf{elif}\;d \leq 1.35 \cdot 10^{-118}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\left(\frac{1}{\frac{d}{M\_m \cdot D}}\right)}^{2}, \frac{h}{\ell}, 1\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_0} \cdot \left(1 - 0.5 \cdot \frac{h \cdot \left(0.25 \cdot {\left(\frac{M\_m}{\frac{d}{D}}\right)}^{2}\right)}{\ell}\right)\\
\end{array}
\end{array}
if d < -9.00000000000000003e198Initial program 54.8%
Simplified58.9%
Taylor expanded in M around 0 36.0%
associate-*r/36.0%
associate-*r*43.9%
associate-*r*43.9%
associate-*l/43.9%
associate-*r/43.9%
*-commutative43.9%
+-commutative43.9%
fma-undefine43.9%
Simplified67.6%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt92.2%
neg-mul-192.2%
distribute-rgt-neg-in92.2%
unpow1/292.2%
rem-exp-log90.3%
exp-neg90.3%
exp-prod90.3%
distribute-lft-neg-out90.3%
exp-neg90.3%
exp-to-pow92.2%
unpow1/292.2%
associate-*l/92.2%
*-lft-identity92.2%
distribute-frac-neg292.2%
Simplified92.2%
if -9.00000000000000003e198 < d < -4.999999999999985e-310Initial program 67.3%
Simplified65.8%
frac-2neg69.3%
sqrt-div85.9%
Applied egg-rr80.7%
if -4.999999999999985e-310 < d < 1.34999999999999997e-118Initial program 42.4%
Simplified40.1%
pow140.1%
associate-*r*40.1%
sqrt-div49.5%
sqrt-div51.7%
frac-times51.8%
add-sqr-sqrt51.8%
unpow-prod-down51.8%
metadata-eval51.8%
clear-num51.8%
un-div-inv54.1%
Applied egg-rr54.1%
unpow154.1%
associate-*l/73.1%
associate-/l*73.1%
fma-define73.1%
associate-*r*73.1%
fma-define73.1%
*-commutative73.1%
associate-*l*73.1%
metadata-eval73.1%
*-commutative73.1%
associate-/r/73.1%
associate-*l/75.4%
associate-/l*70.9%
Simplified70.9%
associate-*r/75.4%
clear-num75.4%
Applied egg-rr75.4%
if 1.34999999999999997e-118 < d Initial program 66.8%
Simplified64.6%
*-commutative64.6%
sqrt-div69.6%
sqrt-div83.0%
frac-times83.0%
add-sqr-sqrt83.3%
Applied egg-rr83.3%
associate-*r/91.1%
associate-*l/91.1%
div-inv91.1%
metadata-eval91.1%
*-commutative91.1%
unpow-prod-down91.1%
metadata-eval91.1%
clear-num90.1%
un-div-inv90.1%
Applied egg-rr90.1%
Final simplification84.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
(let* ((t_0 (* (sqrt l) (sqrt h))))
(if (<= d -7.4e+196)
(/ (- d) (sqrt (* l h)))
(if (<= d -8.5e-203)
(*
(* (sqrt (/ d l)) (/ 1.0 (sqrt (/ h d))))
(- 1.0 (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M_m 2.0)) 2.0)))))
(if (<= d -5e-310)
(*
(sqrt (/ h (pow l 3.0)))
(* -0.125 (* (pow D 2.0) (/ (pow M_m 2.0) (- d)))))
(if (<= d 8.6e-197)
(* d (/ (* h (* (/ -0.125 l) (pow (* M_m (/ D d)) 2.0))) t_0))
(*
(/ d t_0)
(-
1.0
(* 0.5 (/ (* h (* 0.25 (pow (/ M_m (/ d D)) 2.0))) 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 = sqrt(l) * sqrt(h);
double tmp;
if (d <= -7.4e+196) {
tmp = -d / sqrt((l * h));
} else if (d <= -8.5e-203) {
tmp = (sqrt((d / l)) * (1.0 / sqrt((h / d)))) * (1.0 - (0.5 * ((h / l) * pow(((D / d) * (M_m / 2.0)), 2.0))));
} else if (d <= -5e-310) {
tmp = sqrt((h / pow(l, 3.0))) * (-0.125 * (pow(D, 2.0) * (pow(M_m, 2.0) / -d)));
} else if (d <= 8.6e-197) {
tmp = d * ((h * ((-0.125 / l) * pow((M_m * (D / d)), 2.0))) / t_0);
} else {
tmp = (d / t_0) * (1.0 - (0.5 * ((h * (0.25 * pow((M_m / (d / D)), 2.0))) / 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) :: tmp
t_0 = sqrt(l) * sqrt(h)
if (d <= (-7.4d+196)) then
tmp = -d / sqrt((l * h))
else if (d <= (-8.5d-203)) then
tmp = (sqrt((d / l)) * (1.0d0 / sqrt((h / d)))) * (1.0d0 - (0.5d0 * ((h / l) * (((d_1 / d) * (m_m / 2.0d0)) ** 2.0d0))))
else if (d <= (-5d-310)) then
tmp = sqrt((h / (l ** 3.0d0))) * ((-0.125d0) * ((d_1 ** 2.0d0) * ((m_m ** 2.0d0) / -d)))
else if (d <= 8.6d-197) then
tmp = d * ((h * (((-0.125d0) / l) * ((m_m * (d_1 / d)) ** 2.0d0))) / t_0)
else
tmp = (d / t_0) * (1.0d0 - (0.5d0 * ((h * (0.25d0 * ((m_m / (d / d_1)) ** 2.0d0))) / 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 = Math.sqrt(l) * Math.sqrt(h);
double tmp;
if (d <= -7.4e+196) {
tmp = -d / Math.sqrt((l * h));
} else if (d <= -8.5e-203) {
tmp = (Math.sqrt((d / l)) * (1.0 / Math.sqrt((h / d)))) * (1.0 - (0.5 * ((h / l) * Math.pow(((D / d) * (M_m / 2.0)), 2.0))));
} else if (d <= -5e-310) {
tmp = Math.sqrt((h / Math.pow(l, 3.0))) * (-0.125 * (Math.pow(D, 2.0) * (Math.pow(M_m, 2.0) / -d)));
} else if (d <= 8.6e-197) {
tmp = d * ((h * ((-0.125 / l) * Math.pow((M_m * (D / d)), 2.0))) / t_0);
} else {
tmp = (d / t_0) * (1.0 - (0.5 * ((h * (0.25 * Math.pow((M_m / (d / D)), 2.0))) / 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 = math.sqrt(l) * math.sqrt(h) tmp = 0 if d <= -7.4e+196: tmp = -d / math.sqrt((l * h)) elif d <= -8.5e-203: tmp = (math.sqrt((d / l)) * (1.0 / math.sqrt((h / d)))) * (1.0 - (0.5 * ((h / l) * math.pow(((D / d) * (M_m / 2.0)), 2.0)))) elif d <= -5e-310: tmp = math.sqrt((h / math.pow(l, 3.0))) * (-0.125 * (math.pow(D, 2.0) * (math.pow(M_m, 2.0) / -d))) elif d <= 8.6e-197: tmp = d * ((h * ((-0.125 / l) * math.pow((M_m * (D / d)), 2.0))) / t_0) else: tmp = (d / t_0) * (1.0 - (0.5 * ((h * (0.25 * math.pow((M_m / (d / D)), 2.0))) / 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(sqrt(l) * sqrt(h)) tmp = 0.0 if (d <= -7.4e+196) tmp = Float64(Float64(-d) / sqrt(Float64(l * h))); elseif (d <= -8.5e-203) tmp = Float64(Float64(sqrt(Float64(d / l)) * Float64(1.0 / sqrt(Float64(h / d)))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M_m / 2.0)) ^ 2.0))))); elseif (d <= -5e-310) tmp = Float64(sqrt(Float64(h / (l ^ 3.0))) * Float64(-0.125 * Float64((D ^ 2.0) * Float64((M_m ^ 2.0) / Float64(-d))))); elseif (d <= 8.6e-197) tmp = Float64(d * Float64(Float64(h * Float64(Float64(-0.125 / l) * (Float64(M_m * Float64(D / d)) ^ 2.0))) / t_0)); else tmp = Float64(Float64(d / t_0) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * Float64(0.25 * (Float64(M_m / Float64(d / D)) ^ 2.0))) / 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 = sqrt(l) * sqrt(h);
tmp = 0.0;
if (d <= -7.4e+196)
tmp = -d / sqrt((l * h));
elseif (d <= -8.5e-203)
tmp = (sqrt((d / l)) * (1.0 / sqrt((h / d)))) * (1.0 - (0.5 * ((h / l) * (((D / d) * (M_m / 2.0)) ^ 2.0))));
elseif (d <= -5e-310)
tmp = sqrt((h / (l ^ 3.0))) * (-0.125 * ((D ^ 2.0) * ((M_m ^ 2.0) / -d)));
elseif (d <= 8.6e-197)
tmp = d * ((h * ((-0.125 / l) * ((M_m * (D / d)) ^ 2.0))) / t_0);
else
tmp = (d / t_0) * (1.0 - (0.5 * ((h * (0.25 * ((M_m / (d / D)) ^ 2.0))) / 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[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7.4e+196], N[((-d) / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -8.5e-203], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-310], N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-0.125 * N[(N[Power[D, 2.0], $MachinePrecision] * N[(N[Power[M$95$m, 2.0], $MachinePrecision] / (-d)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 8.6e-197], N[(d * N[(N[(h * N[(N[(-0.125 / l), $MachinePrecision] * N[Power[N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(d / t$95$0), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[(0.25 * N[Power[N[(M$95$m / N[(d / D), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 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 := \sqrt{\ell} \cdot \sqrt{h}\\
\mathbf{if}\;d \leq -7.4 \cdot 10^{+196}:\\
\;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\
\mathbf{elif}\;d \leq -8.5 \cdot 10^{-203}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \frac{1}{\sqrt{\frac{h}{d}}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right)\right)\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(-0.125 \cdot \left({D}^{2} \cdot \frac{{M\_m}^{2}}{-d}\right)\right)\\
\mathbf{elif}\;d \leq 8.6 \cdot 10^{-197}:\\
\;\;\;\;d \cdot \frac{h \cdot \left(\frac{-0.125}{\ell} \cdot {\left(M\_m \cdot \frac{D}{d}\right)}^{2}\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_0} \cdot \left(1 - 0.5 \cdot \frac{h \cdot \left(0.25 \cdot {\left(\frac{M\_m}{\frac{d}{D}}\right)}^{2}\right)}{\ell}\right)\\
\end{array}
\end{array}
if d < -7.3999999999999998e196Initial program 54.8%
Simplified58.9%
Taylor expanded in M around 0 36.0%
associate-*r/36.0%
associate-*r*43.9%
associate-*r*43.9%
associate-*l/43.9%
associate-*r/43.9%
*-commutative43.9%
+-commutative43.9%
fma-undefine43.9%
Simplified67.6%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt92.2%
neg-mul-192.2%
distribute-rgt-neg-in92.2%
unpow1/292.2%
rem-exp-log90.3%
exp-neg90.3%
exp-prod90.3%
distribute-lft-neg-out90.3%
exp-neg90.3%
exp-to-pow92.2%
unpow1/292.2%
associate-*l/92.2%
*-lft-identity92.2%
distribute-frac-neg292.2%
Simplified92.2%
if -7.3999999999999998e196 < d < -8.50000000000000031e-203Initial program 74.6%
Simplified75.4%
clear-num75.3%
sqrt-div77.8%
metadata-eval77.8%
Applied egg-rr77.8%
if -8.50000000000000031e-203 < d < -4.999999999999985e-310Initial program 37.2%
Simplified37.3%
pow1/237.3%
pow-to-exp36.5%
Applied egg-rr36.5%
Taylor expanded in h around -inf 0.0%
associate-*r*0.0%
*-commutative0.0%
associate-/l*0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt73.9%
mul-1-neg73.9%
Simplified73.9%
if -4.999999999999985e-310 < d < 8.6000000000000001e-197Initial program 26.3%
Simplified22.1%
pow122.1%
associate-*r*22.1%
sqrt-div35.3%
sqrt-div35.6%
frac-times35.6%
add-sqr-sqrt35.6%
unpow-prod-down35.6%
metadata-eval35.6%
clear-num35.6%
un-div-inv39.8%
Applied egg-rr39.8%
unpow139.8%
associate-*l/70.9%
associate-/l*70.8%
fma-define70.8%
associate-*r*70.8%
fma-define70.8%
*-commutative70.8%
associate-*l*70.8%
metadata-eval70.8%
*-commutative70.8%
associate-/r/70.7%
associate-*l/70.8%
associate-/l*66.7%
Simplified66.7%
Taylor expanded in M around inf 48.7%
associate-*r/48.7%
associate-*r*48.7%
associate-*r*48.7%
associate-*l/48.7%
associate-*r/48.7%
*-commutative48.7%
*-commutative48.7%
associate-*l/48.7%
times-frac48.7%
*-commutative48.7%
associate-/l*49.0%
unpow249.0%
unpow249.0%
unpow249.0%
times-frac62.0%
swap-sqr66.7%
unpow266.7%
Simplified66.7%
if 8.6000000000000001e-197 < d Initial program 65.8%
Simplified63.9%
*-commutative63.9%
sqrt-div68.8%
sqrt-div80.7%
frac-times80.7%
add-sqr-sqrt80.9%
Applied egg-rr80.9%
associate-*r/87.4%
associate-*l/87.4%
div-inv87.4%
metadata-eval87.4%
*-commutative87.4%
unpow-prod-down87.4%
metadata-eval87.4%
clear-num86.5%
un-div-inv86.5%
Applied egg-rr86.5%
Final simplification81.8%
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 (* M_m (/ D d)) 2.0)) (t_1 (* (sqrt l) (sqrt h))))
(if (<= d -5.6e+198)
(/ (- d) (sqrt (* l h)))
(if (<= d -2.1e-43)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (* 0.5 (* h (* 0.25 (/ t_0 l))))))
(if (<= d -5e-310)
(*
(* d (sqrt (/ 1.0 (* l h))))
(+ (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M_m 2.0)) 2.0))) -1.0))
(if (<= d 1.2e-197)
(* d (/ (* h (* (/ -0.125 l) t_0)) t_1))
(*
(/ d t_1)
(-
1.0
(* 0.5 (/ (* h (* 0.25 (pow (/ M_m (/ d D)) 2.0))) 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 = pow((M_m * (D / d)), 2.0);
double t_1 = sqrt(l) * sqrt(h);
double tmp;
if (d <= -5.6e+198) {
tmp = -d / sqrt((l * h));
} else if (d <= -2.1e-43) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * (h * (0.25 * (t_0 / l)))));
} else if (d <= -5e-310) {
tmp = (d * sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0);
} else if (d <= 1.2e-197) {
tmp = d * ((h * ((-0.125 / l) * t_0)) / t_1);
} else {
tmp = (d / t_1) * (1.0 - (0.5 * ((h * (0.25 * pow((M_m / (d / D)), 2.0))) / 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) :: tmp
t_0 = (m_m * (d_1 / d)) ** 2.0d0
t_1 = sqrt(l) * sqrt(h)
if (d <= (-5.6d+198)) then
tmp = -d / sqrt((l * h))
else if (d <= (-2.1d-43)) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - (0.5d0 * (h * (0.25d0 * (t_0 / l)))))
else if (d <= (-5d-310)) then
tmp = (d * sqrt((1.0d0 / (l * h)))) * ((0.5d0 * ((h / l) * (((d_1 / d) * (m_m / 2.0d0)) ** 2.0d0))) + (-1.0d0))
else if (d <= 1.2d-197) then
tmp = d * ((h * (((-0.125d0) / l) * t_0)) / t_1)
else
tmp = (d / t_1) * (1.0d0 - (0.5d0 * ((h * (0.25d0 * ((m_m / (d / d_1)) ** 2.0d0))) / 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 = Math.pow((M_m * (D / d)), 2.0);
double t_1 = Math.sqrt(l) * Math.sqrt(h);
double tmp;
if (d <= -5.6e+198) {
tmp = -d / Math.sqrt((l * h));
} else if (d <= -2.1e-43) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - (0.5 * (h * (0.25 * (t_0 / l)))));
} else if (d <= -5e-310) {
tmp = (d * Math.sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * Math.pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0);
} else if (d <= 1.2e-197) {
tmp = d * ((h * ((-0.125 / l) * t_0)) / t_1);
} else {
tmp = (d / t_1) * (1.0 - (0.5 * ((h * (0.25 * Math.pow((M_m / (d / D)), 2.0))) / 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 = math.pow((M_m * (D / d)), 2.0) t_1 = math.sqrt(l) * math.sqrt(h) tmp = 0 if d <= -5.6e+198: tmp = -d / math.sqrt((l * h)) elif d <= -2.1e-43: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - (0.5 * (h * (0.25 * (t_0 / l))))) elif d <= -5e-310: tmp = (d * math.sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * math.pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0) elif d <= 1.2e-197: tmp = d * ((h * ((-0.125 / l) * t_0)) / t_1) else: tmp = (d / t_1) * (1.0 - (0.5 * ((h * (0.25 * math.pow((M_m / (d / D)), 2.0))) / 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(D / d)) ^ 2.0 t_1 = Float64(sqrt(l) * sqrt(h)) tmp = 0.0 if (d <= -5.6e+198) tmp = Float64(Float64(-d) / sqrt(Float64(l * h))); elseif (d <= -2.1e-43) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(0.5 * Float64(h * Float64(0.25 * Float64(t_0 / l)))))); elseif (d <= -5e-310) tmp = Float64(Float64(d * sqrt(Float64(1.0 / Float64(l * h)))) * Float64(Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M_m / 2.0)) ^ 2.0))) + -1.0)); elseif (d <= 1.2e-197) tmp = Float64(d * Float64(Float64(h * Float64(Float64(-0.125 / l) * t_0)) / t_1)); else tmp = Float64(Float64(d / t_1) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * Float64(0.25 * (Float64(M_m / Float64(d / D)) ^ 2.0))) / 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 * (D / d)) ^ 2.0;
t_1 = sqrt(l) * sqrt(h);
tmp = 0.0;
if (d <= -5.6e+198)
tmp = -d / sqrt((l * h));
elseif (d <= -2.1e-43)
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * (h * (0.25 * (t_0 / l)))));
elseif (d <= -5e-310)
tmp = (d * sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * (((D / d) * (M_m / 2.0)) ^ 2.0))) + -1.0);
elseif (d <= 1.2e-197)
tmp = d * ((h * ((-0.125 / l) * t_0)) / t_1);
else
tmp = (d / t_1) * (1.0 - (0.5 * ((h * (0.25 * ((M_m / (d / D)) ^ 2.0))) / 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[Power[N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.6e+198], N[((-d) / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.1e-43], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(h * N[(0.25 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-310], N[(N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.2e-197], N[(d * N[(N[(h * N[(N[(-0.125 / l), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(d / t$95$1), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[(0.25 * N[Power[N[(M$95$m / N[(d / D), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 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 := {\left(M\_m \cdot \frac{D}{d}\right)}^{2}\\
t_1 := \sqrt{\ell} \cdot \sqrt{h}\\
\mathbf{if}\;d \leq -5.6 \cdot 10^{+198}:\\
\;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\
\mathbf{elif}\;d \leq -2.1 \cdot 10^{-43}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(0.25 \cdot \frac{t\_0}{\ell}\right)\right)\right)\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right) + -1\right)\\
\mathbf{elif}\;d \leq 1.2 \cdot 10^{-197}:\\
\;\;\;\;d \cdot \frac{h \cdot \left(\frac{-0.125}{\ell} \cdot t\_0\right)}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_1} \cdot \left(1 - 0.5 \cdot \frac{h \cdot \left(0.25 \cdot {\left(\frac{M\_m}{\frac{d}{D}}\right)}^{2}\right)}{\ell}\right)\\
\end{array}
\end{array}
if d < -5.59999999999999999e198Initial program 54.8%
Simplified58.9%
Taylor expanded in M around 0 36.0%
associate-*r/36.0%
associate-*r*43.9%
associate-*r*43.9%
associate-*l/43.9%
associate-*r/43.9%
*-commutative43.9%
+-commutative43.9%
fma-undefine43.9%
Simplified67.6%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt92.2%
neg-mul-192.2%
distribute-rgt-neg-in92.2%
unpow1/292.2%
rem-exp-log90.3%
exp-neg90.3%
exp-prod90.3%
distribute-lft-neg-out90.3%
exp-neg90.3%
exp-to-pow92.2%
unpow1/292.2%
associate-*l/92.2%
*-lft-identity92.2%
distribute-frac-neg292.2%
Simplified92.2%
if -5.59999999999999999e198 < d < -2.1000000000000001e-43Initial program 77.8%
Simplified77.8%
Taylor expanded in M around 0 49.9%
associate-*r*51.9%
times-frac52.0%
associate-/l*52.0%
*-commutative52.0%
unpow252.0%
unpow252.0%
times-frac64.9%
unpow264.9%
swap-sqr75.9%
associate-/r/75.9%
associate-/r/77.8%
unpow277.8%
associate-*l*77.8%
*-commutative77.8%
associate-*l/77.9%
associate-/l*81.4%
associate-/l*81.4%
Simplified81.4%
if -2.1000000000000001e-43 < d < -4.999999999999985e-310Initial program 53.6%
Simplified55.0%
clear-num54.9%
sqrt-div54.9%
metadata-eval54.9%
Applied egg-rr54.9%
Taylor expanded in d around -inf 69.4%
if -4.999999999999985e-310 < d < 1.2e-197Initial program 26.3%
Simplified22.1%
pow122.1%
associate-*r*22.1%
sqrt-div35.3%
sqrt-div35.6%
frac-times35.6%
add-sqr-sqrt35.6%
unpow-prod-down35.6%
metadata-eval35.6%
clear-num35.6%
un-div-inv39.8%
Applied egg-rr39.8%
unpow139.8%
associate-*l/70.9%
associate-/l*70.8%
fma-define70.8%
associate-*r*70.8%
fma-define70.8%
*-commutative70.8%
associate-*l*70.8%
metadata-eval70.8%
*-commutative70.8%
associate-/r/70.7%
associate-*l/70.8%
associate-/l*66.7%
Simplified66.7%
Taylor expanded in M around inf 48.7%
associate-*r/48.7%
associate-*r*48.7%
associate-*r*48.7%
associate-*l/48.7%
associate-*r/48.7%
*-commutative48.7%
*-commutative48.7%
associate-*l/48.7%
times-frac48.7%
*-commutative48.7%
associate-/l*49.0%
unpow249.0%
unpow249.0%
unpow249.0%
times-frac62.0%
swap-sqr66.7%
unpow266.7%
Simplified66.7%
if 1.2e-197 < d Initial program 65.8%
Simplified63.9%
*-commutative63.9%
sqrt-div68.8%
sqrt-div80.7%
frac-times80.7%
add-sqr-sqrt80.9%
Applied egg-rr80.9%
associate-*r/87.4%
associate-*l/87.4%
div-inv87.4%
metadata-eval87.4%
*-commutative87.4%
unpow-prod-down87.4%
metadata-eval87.4%
clear-num86.5%
un-div-inv86.5%
Applied egg-rr86.5%
Final simplification81.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
(let* ((t_0 (* (sqrt l) (sqrt h))))
(if (<= d -4.5e+199)
(/ (- d) (sqrt (* l h)))
(if (<= d -5e-310)
(*
(* d (sqrt (/ 1.0 (* l h))))
(+ (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M_m 2.0)) 2.0))) -1.0))
(if (<= d 7.6e-198)
(* d (/ (* h (* (/ -0.125 l) (pow (* M_m (/ D d)) 2.0))) t_0))
(*
(/ d t_0)
(- 1.0 (* 0.5 (/ (* h (* 0.25 (pow (/ M_m (/ d D)) 2.0))) 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 = sqrt(l) * sqrt(h);
double tmp;
if (d <= -4.5e+199) {
tmp = -d / sqrt((l * h));
} else if (d <= -5e-310) {
tmp = (d * sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0);
} else if (d <= 7.6e-198) {
tmp = d * ((h * ((-0.125 / l) * pow((M_m * (D / d)), 2.0))) / t_0);
} else {
tmp = (d / t_0) * (1.0 - (0.5 * ((h * (0.25 * pow((M_m / (d / D)), 2.0))) / 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) :: tmp
t_0 = sqrt(l) * sqrt(h)
if (d <= (-4.5d+199)) then
tmp = -d / sqrt((l * h))
else if (d <= (-5d-310)) then
tmp = (d * sqrt((1.0d0 / (l * h)))) * ((0.5d0 * ((h / l) * (((d_1 / d) * (m_m / 2.0d0)) ** 2.0d0))) + (-1.0d0))
else if (d <= 7.6d-198) then
tmp = d * ((h * (((-0.125d0) / l) * ((m_m * (d_1 / d)) ** 2.0d0))) / t_0)
else
tmp = (d / t_0) * (1.0d0 - (0.5d0 * ((h * (0.25d0 * ((m_m / (d / d_1)) ** 2.0d0))) / 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 = Math.sqrt(l) * Math.sqrt(h);
double tmp;
if (d <= -4.5e+199) {
tmp = -d / Math.sqrt((l * h));
} else if (d <= -5e-310) {
tmp = (d * Math.sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * Math.pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0);
} else if (d <= 7.6e-198) {
tmp = d * ((h * ((-0.125 / l) * Math.pow((M_m * (D / d)), 2.0))) / t_0);
} else {
tmp = (d / t_0) * (1.0 - (0.5 * ((h * (0.25 * Math.pow((M_m / (d / D)), 2.0))) / 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 = math.sqrt(l) * math.sqrt(h) tmp = 0 if d <= -4.5e+199: tmp = -d / math.sqrt((l * h)) elif d <= -5e-310: tmp = (d * math.sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * math.pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0) elif d <= 7.6e-198: tmp = d * ((h * ((-0.125 / l) * math.pow((M_m * (D / d)), 2.0))) / t_0) else: tmp = (d / t_0) * (1.0 - (0.5 * ((h * (0.25 * math.pow((M_m / (d / D)), 2.0))) / 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(sqrt(l) * sqrt(h)) tmp = 0.0 if (d <= -4.5e+199) tmp = Float64(Float64(-d) / sqrt(Float64(l * h))); elseif (d <= -5e-310) tmp = Float64(Float64(d * sqrt(Float64(1.0 / Float64(l * h)))) * Float64(Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M_m / 2.0)) ^ 2.0))) + -1.0)); elseif (d <= 7.6e-198) tmp = Float64(d * Float64(Float64(h * Float64(Float64(-0.125 / l) * (Float64(M_m * Float64(D / d)) ^ 2.0))) / t_0)); else tmp = Float64(Float64(d / t_0) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * Float64(0.25 * (Float64(M_m / Float64(d / D)) ^ 2.0))) / 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 = sqrt(l) * sqrt(h);
tmp = 0.0;
if (d <= -4.5e+199)
tmp = -d / sqrt((l * h));
elseif (d <= -5e-310)
tmp = (d * sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * (((D / d) * (M_m / 2.0)) ^ 2.0))) + -1.0);
elseif (d <= 7.6e-198)
tmp = d * ((h * ((-0.125 / l) * ((M_m * (D / d)) ^ 2.0))) / t_0);
else
tmp = (d / t_0) * (1.0 - (0.5 * ((h * (0.25 * ((M_m / (d / D)) ^ 2.0))) / 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[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.5e+199], N[((-d) / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-310], N[(N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.6e-198], N[(d * N[(N[(h * N[(N[(-0.125 / l), $MachinePrecision] * N[Power[N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(d / t$95$0), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[(0.25 * N[Power[N[(M$95$m / N[(d / D), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 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 := \sqrt{\ell} \cdot \sqrt{h}\\
\mathbf{if}\;d \leq -4.5 \cdot 10^{+199}:\\
\;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right) + -1\right)\\
\mathbf{elif}\;d \leq 7.6 \cdot 10^{-198}:\\
\;\;\;\;d \cdot \frac{h \cdot \left(\frac{-0.125}{\ell} \cdot {\left(M\_m \cdot \frac{D}{d}\right)}^{2}\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_0} \cdot \left(1 - 0.5 \cdot \frac{h \cdot \left(0.25 \cdot {\left(\frac{M\_m}{\frac{d}{D}}\right)}^{2}\right)}{\ell}\right)\\
\end{array}
\end{array}
if d < -4.4999999999999997e199Initial program 56.7%
Simplified61.0%
Taylor expanded in M around 0 37.2%
associate-*r/37.2%
associate-*r*45.4%
associate-*r*45.4%
associate-*l/45.4%
associate-*r/45.4%
*-commutative45.4%
+-commutative45.4%
fma-undefine45.4%
Simplified70.1%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt91.9%
neg-mul-191.9%
distribute-rgt-neg-in91.9%
unpow1/291.9%
rem-exp-log90.0%
exp-neg90.1%
exp-prod90.1%
distribute-lft-neg-out90.1%
exp-neg90.1%
exp-to-pow91.9%
unpow1/291.9%
associate-*l/91.9%
*-lft-identity91.9%
distribute-frac-neg291.9%
Simplified91.9%
if -4.4999999999999997e199 < d < -4.999999999999985e-310Initial program 66.7%
Simplified67.3%
clear-num67.2%
sqrt-div67.2%
metadata-eval67.2%
Applied egg-rr67.2%
Taylor expanded in d around -inf 70.5%
if -4.999999999999985e-310 < d < 7.6000000000000004e-198Initial program 26.3%
Simplified22.1%
pow122.1%
associate-*r*22.1%
sqrt-div35.3%
sqrt-div35.6%
frac-times35.6%
add-sqr-sqrt35.6%
unpow-prod-down35.6%
metadata-eval35.6%
clear-num35.6%
un-div-inv39.8%
Applied egg-rr39.8%
unpow139.8%
associate-*l/70.9%
associate-/l*70.8%
fma-define70.8%
associate-*r*70.8%
fma-define70.8%
*-commutative70.8%
associate-*l*70.8%
metadata-eval70.8%
*-commutative70.8%
associate-/r/70.7%
associate-*l/70.8%
associate-/l*66.7%
Simplified66.7%
Taylor expanded in M around inf 48.7%
associate-*r/48.7%
associate-*r*48.7%
associate-*r*48.7%
associate-*l/48.7%
associate-*r/48.7%
*-commutative48.7%
*-commutative48.7%
associate-*l/48.7%
times-frac48.7%
*-commutative48.7%
associate-/l*49.0%
unpow249.0%
unpow249.0%
unpow249.0%
times-frac62.0%
swap-sqr66.7%
unpow266.7%
Simplified66.7%
if 7.6000000000000004e-198 < d Initial program 65.8%
Simplified63.9%
*-commutative63.9%
sqrt-div68.8%
sqrt-div80.7%
frac-times80.7%
add-sqr-sqrt80.9%
Applied egg-rr80.9%
associate-*r/87.4%
associate-*l/87.4%
div-inv87.4%
metadata-eval87.4%
*-commutative87.4%
unpow-prod-down87.4%
metadata-eval87.4%
clear-num86.5%
un-div-inv86.5%
Applied egg-rr86.5%
Final simplification79.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
(let* ((t_0 (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M_m 2.0)) 2.0))))
(t_1 (* (sqrt l) (sqrt h))))
(if (<= d -3.6e+199)
(/ (- d) (sqrt (* l h)))
(if (<= d -5e-310)
(* (* d (sqrt (/ 1.0 (* l h)))) (+ t_0 -1.0))
(if (<= d 3.2e-196)
(* d (/ (* h (* (/ -0.125 l) (pow (* M_m (/ D d)) 2.0))) t_1))
(* (/ d t_1) (- 1.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 = 0.5 * ((h / l) * pow(((D / d) * (M_m / 2.0)), 2.0));
double t_1 = sqrt(l) * sqrt(h);
double tmp;
if (d <= -3.6e+199) {
tmp = -d / sqrt((l * h));
} else if (d <= -5e-310) {
tmp = (d * sqrt((1.0 / (l * h)))) * (t_0 + -1.0);
} else if (d <= 3.2e-196) {
tmp = d * ((h * ((-0.125 / l) * pow((M_m * (D / d)), 2.0))) / t_1);
} else {
tmp = (d / t_1) * (1.0 - 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) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * ((h / l) * (((d_1 / d) * (m_m / 2.0d0)) ** 2.0d0))
t_1 = sqrt(l) * sqrt(h)
if (d <= (-3.6d+199)) then
tmp = -d / sqrt((l * h))
else if (d <= (-5d-310)) then
tmp = (d * sqrt((1.0d0 / (l * h)))) * (t_0 + (-1.0d0))
else if (d <= 3.2d-196) then
tmp = d * ((h * (((-0.125d0) / l) * ((m_m * (d_1 / d)) ** 2.0d0))) / t_1)
else
tmp = (d / t_1) * (1.0d0 - 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 = 0.5 * ((h / l) * Math.pow(((D / d) * (M_m / 2.0)), 2.0));
double t_1 = Math.sqrt(l) * Math.sqrt(h);
double tmp;
if (d <= -3.6e+199) {
tmp = -d / Math.sqrt((l * h));
} else if (d <= -5e-310) {
tmp = (d * Math.sqrt((1.0 / (l * h)))) * (t_0 + -1.0);
} else if (d <= 3.2e-196) {
tmp = d * ((h * ((-0.125 / l) * Math.pow((M_m * (D / d)), 2.0))) / t_1);
} else {
tmp = (d / t_1) * (1.0 - 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 = 0.5 * ((h / l) * math.pow(((D / d) * (M_m / 2.0)), 2.0)) t_1 = math.sqrt(l) * math.sqrt(h) tmp = 0 if d <= -3.6e+199: tmp = -d / math.sqrt((l * h)) elif d <= -5e-310: tmp = (d * math.sqrt((1.0 / (l * h)))) * (t_0 + -1.0) elif d <= 3.2e-196: tmp = d * ((h * ((-0.125 / l) * math.pow((M_m * (D / d)), 2.0))) / t_1) else: tmp = (d / t_1) * (1.0 - 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(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M_m / 2.0)) ^ 2.0))) t_1 = Float64(sqrt(l) * sqrt(h)) tmp = 0.0 if (d <= -3.6e+199) tmp = Float64(Float64(-d) / sqrt(Float64(l * h))); elseif (d <= -5e-310) tmp = Float64(Float64(d * sqrt(Float64(1.0 / Float64(l * h)))) * Float64(t_0 + -1.0)); elseif (d <= 3.2e-196) tmp = Float64(d * Float64(Float64(h * Float64(Float64(-0.125 / l) * (Float64(M_m * Float64(D / d)) ^ 2.0))) / t_1)); else tmp = Float64(Float64(d / t_1) * Float64(1.0 - 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 = 0.5 * ((h / l) * (((D / d) * (M_m / 2.0)) ^ 2.0));
t_1 = sqrt(l) * sqrt(h);
tmp = 0.0;
if (d <= -3.6e+199)
tmp = -d / sqrt((l * h));
elseif (d <= -5e-310)
tmp = (d * sqrt((1.0 / (l * h)))) * (t_0 + -1.0);
elseif (d <= 3.2e-196)
tmp = d * ((h * ((-0.125 / l) * ((M_m * (D / d)) ^ 2.0))) / t_1);
else
tmp = (d / t_1) * (1.0 - 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[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.6e+199], N[((-d) / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-310], N[(N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.2e-196], N[(d * N[(N[(h * N[(N[(-0.125 / l), $MachinePrecision] * N[Power[N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(d / t$95$1), $MachinePrecision] * N[(1.0 - t$95$0), $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 := 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right)\\
t_1 := \sqrt{\ell} \cdot \sqrt{h}\\
\mathbf{if}\;d \leq -3.6 \cdot 10^{+199}:\\
\;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(t\_0 + -1\right)\\
\mathbf{elif}\;d \leq 3.2 \cdot 10^{-196}:\\
\;\;\;\;d \cdot \frac{h \cdot \left(\frac{-0.125}{\ell} \cdot {\left(M\_m \cdot \frac{D}{d}\right)}^{2}\right)}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_1} \cdot \left(1 - t\_0\right)\\
\end{array}
\end{array}
if d < -3.60000000000000001e199Initial program 56.7%
Simplified61.0%
Taylor expanded in M around 0 37.2%
associate-*r/37.2%
associate-*r*45.4%
associate-*r*45.4%
associate-*l/45.4%
associate-*r/45.4%
*-commutative45.4%
+-commutative45.4%
fma-undefine45.4%
Simplified70.1%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt91.9%
neg-mul-191.9%
distribute-rgt-neg-in91.9%
unpow1/291.9%
rem-exp-log90.0%
exp-neg90.1%
exp-prod90.1%
distribute-lft-neg-out90.1%
exp-neg90.1%
exp-to-pow91.9%
unpow1/291.9%
associate-*l/91.9%
*-lft-identity91.9%
distribute-frac-neg291.9%
Simplified91.9%
if -3.60000000000000001e199 < d < -4.999999999999985e-310Initial program 66.7%
Simplified67.3%
clear-num67.2%
sqrt-div67.2%
metadata-eval67.2%
Applied egg-rr67.2%
Taylor expanded in d around -inf 70.5%
if -4.999999999999985e-310 < d < 3.2e-196Initial program 26.3%
Simplified22.1%
pow122.1%
associate-*r*22.1%
sqrt-div35.3%
sqrt-div35.6%
frac-times35.6%
add-sqr-sqrt35.6%
unpow-prod-down35.6%
metadata-eval35.6%
clear-num35.6%
un-div-inv39.8%
Applied egg-rr39.8%
unpow139.8%
associate-*l/70.9%
associate-/l*70.8%
fma-define70.8%
associate-*r*70.8%
fma-define70.8%
*-commutative70.8%
associate-*l*70.8%
metadata-eval70.8%
*-commutative70.8%
associate-/r/70.7%
associate-*l/70.8%
associate-/l*66.7%
Simplified66.7%
Taylor expanded in M around inf 48.7%
associate-*r/48.7%
associate-*r*48.7%
associate-*r*48.7%
associate-*l/48.7%
associate-*r/48.7%
*-commutative48.7%
*-commutative48.7%
associate-*l/48.7%
times-frac48.7%
*-commutative48.7%
associate-/l*49.0%
unpow249.0%
unpow249.0%
unpow249.0%
times-frac62.0%
swap-sqr66.7%
unpow266.7%
Simplified66.7%
if 3.2e-196 < d Initial program 65.8%
Simplified63.9%
*-commutative63.9%
sqrt-div68.8%
sqrt-div80.7%
frac-times80.7%
add-sqr-sqrt80.9%
Applied egg-rr80.9%
Final simplification76.7%
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 (<= d -7.5e+199)
(/ (- d) t_0)
(if (<= d -5e-310)
(*
(* d (sqrt (/ 1.0 (* l h))))
(+ (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M_m 2.0)) 2.0))) -1.0))
(*
d
(/
(fma -0.5 (* h (/ (pow (* D (/ (/ M_m d) 2.0)) 2.0) l)) 1.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 = sqrt((l * h));
double tmp;
if (d <= -7.5e+199) {
tmp = -d / t_0;
} else if (d <= -5e-310) {
tmp = (d * sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0);
} else {
tmp = d * (fma(-0.5, (h * (pow((D * ((M_m / d) / 2.0)), 2.0) / l)), 1.0) / 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 = sqrt(Float64(l * h)) tmp = 0.0 if (d <= -7.5e+199) tmp = Float64(Float64(-d) / t_0); elseif (d <= -5e-310) tmp = Float64(Float64(d * sqrt(Float64(1.0 / Float64(l * h)))) * Float64(Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M_m / 2.0)) ^ 2.0))) + -1.0)); else tmp = Float64(d * Float64(fma(-0.5, Float64(h * Float64((Float64(D * Float64(Float64(M_m / d) / 2.0)) ^ 2.0) / l)), 1.0) / t_0)); 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_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -7.5e+199], N[((-d) / t$95$0), $MachinePrecision], If[LessEqual[d, -5e-310], N[(N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(-0.5 * N[(h * N[(N[Power[N[(D * N[(N[(M$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $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 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;d \leq -7.5 \cdot 10^{+199}:\\
\;\;\;\;\frac{-d}{t\_0}\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \frac{\frac{M\_m}{d}}{2}\right)}^{2}}{\ell}, 1\right)}{t\_0}\\
\end{array}
\end{array}
if d < -7.49999999999999977e199Initial program 56.7%
Simplified61.0%
Taylor expanded in M around 0 37.2%
associate-*r/37.2%
associate-*r*45.4%
associate-*r*45.4%
associate-*l/45.4%
associate-*r/45.4%
*-commutative45.4%
+-commutative45.4%
fma-undefine45.4%
Simplified70.1%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt91.9%
neg-mul-191.9%
distribute-rgt-neg-in91.9%
unpow1/291.9%
rem-exp-log90.0%
exp-neg90.1%
exp-prod90.1%
distribute-lft-neg-out90.1%
exp-neg90.1%
exp-to-pow91.9%
unpow1/291.9%
associate-*l/91.9%
*-lft-identity91.9%
distribute-frac-neg291.9%
Simplified91.9%
if -7.49999999999999977e199 < d < -4.999999999999985e-310Initial program 66.7%
Simplified67.3%
clear-num67.2%
sqrt-div67.2%
metadata-eval67.2%
Applied egg-rr67.2%
Taylor expanded in d around -inf 70.5%
if -4.999999999999985e-310 < d Initial program 58.9%
Simplified56.7%
*-commutative56.7%
sqrt-div60.8%
sqrt-div72.9%
frac-times72.9%
add-sqr-sqrt73.1%
Applied egg-rr73.1%
associate-*l/79.2%
cancel-sign-sub-inv79.2%
metadata-eval79.2%
*-commutative79.2%
associate-*l/79.2%
sqrt-unprod63.4%
*-commutative63.4%
Applied egg-rr63.4%
associate-/l*63.3%
+-commutative63.3%
fma-define63.3%
associate-*l/70.0%
associate-/l*70.1%
associate-*r/72.3%
*-commutative72.3%
associate-/l*71.6%
associate-/l*71.6%
Simplified71.6%
Final simplification73.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
(let* ((t_0 (* M_m (/ D d))))
(if (<= h -4e-310)
(*
(* d (sqrt (/ 1.0 (* l h))))
(+ (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M_m 2.0)) 2.0))) -1.0))
(if (<= h 1.35e+187)
(/
(* d (+ 1.0 (* -0.5 (* (/ h l) (pow (/ t_0 2.0) 2.0)))))
(sqrt (* l h)))
(* d (/ (* h (* (/ -0.125 l) (pow t_0 2.0))) (* (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 t_0 = M_m * (D / d);
double tmp;
if (h <= -4e-310) {
tmp = (d * sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0);
} else if (h <= 1.35e+187) {
tmp = (d * (1.0 + (-0.5 * ((h / l) * pow((t_0 / 2.0), 2.0))))) / sqrt((l * h));
} else {
tmp = d * ((h * ((-0.125 / l) * pow(t_0, 2.0))) / (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) :: t_0
real(8) :: tmp
t_0 = m_m * (d_1 / d)
if (h <= (-4d-310)) then
tmp = (d * sqrt((1.0d0 / (l * h)))) * ((0.5d0 * ((h / l) * (((d_1 / d) * (m_m / 2.0d0)) ** 2.0d0))) + (-1.0d0))
else if (h <= 1.35d+187) then
tmp = (d * (1.0d0 + ((-0.5d0) * ((h / l) * ((t_0 / 2.0d0) ** 2.0d0))))) / sqrt((l * h))
else
tmp = d * ((h * (((-0.125d0) / l) * (t_0 ** 2.0d0))) / (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 t_0 = M_m * (D / d);
double tmp;
if (h <= -4e-310) {
tmp = (d * Math.sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * Math.pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0);
} else if (h <= 1.35e+187) {
tmp = (d * (1.0 + (-0.5 * ((h / l) * Math.pow((t_0 / 2.0), 2.0))))) / Math.sqrt((l * h));
} else {
tmp = d * ((h * ((-0.125 / l) * Math.pow(t_0, 2.0))) / (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): t_0 = M_m * (D / d) tmp = 0 if h <= -4e-310: tmp = (d * math.sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * math.pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0) elif h <= 1.35e+187: tmp = (d * (1.0 + (-0.5 * ((h / l) * math.pow((t_0 / 2.0), 2.0))))) / math.sqrt((l * h)) else: tmp = d * ((h * ((-0.125 / l) * math.pow(t_0, 2.0))) / (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) t_0 = Float64(M_m * Float64(D / d)) tmp = 0.0 if (h <= -4e-310) tmp = Float64(Float64(d * sqrt(Float64(1.0 / Float64(l * h)))) * Float64(Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M_m / 2.0)) ^ 2.0))) + -1.0)); elseif (h <= 1.35e+187) tmp = Float64(Float64(d * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(t_0 / 2.0) ^ 2.0))))) / sqrt(Float64(l * h))); else tmp = Float64(d * Float64(Float64(h * Float64(Float64(-0.125 / l) * (t_0 ^ 2.0))) / Float64(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)
t_0 = M_m * (D / d);
tmp = 0.0;
if (h <= -4e-310)
tmp = (d * sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * (((D / d) * (M_m / 2.0)) ^ 2.0))) + -1.0);
elseif (h <= 1.35e+187)
tmp = (d * (1.0 + (-0.5 * ((h / l) * ((t_0 / 2.0) ^ 2.0))))) / sqrt((l * h));
else
tmp = d * ((h * ((-0.125 / l) * (t_0 ^ 2.0))) / (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_] := Block[{t$95$0 = N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -4e-310], N[(N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 1.35e+187], N[(N[(d * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(t$95$0 / 2.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(h * N[(N[(-0.125 / l), $MachinePrecision] * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[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 := M\_m \cdot \frac{D}{d}\\
\mathbf{if}\;h \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right) + -1\right)\\
\mathbf{elif}\;h \leq 1.35 \cdot 10^{+187}:\\
\;\;\;\;\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{t\_0}{2}\right)}^{2}\right)\right)}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{h \cdot \left(\frac{-0.125}{\ell} \cdot {t\_0}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if h < -3.999999999999988e-310Initial program 64.7%
Simplified66.0%
clear-num66.0%
sqrt-div66.0%
metadata-eval66.0%
Applied egg-rr66.0%
Taylor expanded in d around -inf 70.8%
if -3.999999999999988e-310 < h < 1.35000000000000004e187Initial program 63.1%
Simplified61.1%
*-commutative61.1%
sqrt-div66.5%
sqrt-div79.3%
frac-times79.4%
add-sqr-sqrt79.6%
Applied egg-rr79.6%
associate-*l/83.6%
cancel-sign-sub-inv83.6%
metadata-eval83.6%
*-commutative83.6%
associate-*l/83.6%
sqrt-unprod72.7%
*-commutative72.7%
Applied egg-rr72.7%
if 1.35000000000000004e187 < h Initial program 45.2%
Simplified42.1%
pow142.1%
associate-*r*42.0%
sqrt-div51.7%
sqrt-div51.7%
frac-times51.7%
add-sqr-sqrt51.7%
unpow-prod-down51.7%
metadata-eval51.7%
clear-num48.5%
un-div-inv48.5%
Applied egg-rr48.5%
unpow148.5%
associate-*l/61.7%
associate-/l*61.7%
fma-define61.7%
associate-*r*61.7%
fma-define61.7%
*-commutative61.7%
associate-*l*61.7%
metadata-eval61.7%
*-commutative61.7%
associate-/r/68.1%
associate-*l/68.1%
associate-/l*64.9%
Simplified64.9%
Taylor expanded in M around inf 33.4%
associate-*r/33.4%
associate-*r*33.6%
associate-*r*33.6%
associate-*l/33.7%
associate-*r/33.7%
*-commutative33.7%
*-commutative33.7%
associate-*l/33.7%
times-frac37.1%
*-commutative37.1%
associate-/l*37.0%
unpow237.0%
unpow237.0%
unpow237.0%
times-frac43.4%
swap-sqr56.1%
unpow256.1%
Simplified56.1%
Final simplification69.8%
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 -2e-310)
(*
(* d (sqrt (/ 1.0 (* l h))))
(+ (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M_m 2.0)) 2.0))) -1.0))
(if (<= l 6e+166)
(/
(* d (+ 1.0 (* -0.5 (* (/ h l) (pow (/ (* M_m (/ D d)) 2.0) 2.0)))))
(sqrt (* 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 (l <= -2e-310) {
tmp = (d * sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0);
} else if (l <= 6e+166) {
tmp = (d * (1.0 + (-0.5 * ((h / l) * pow(((M_m * (D / d)) / 2.0), 2.0))))) / sqrt((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 (l <= (-2d-310)) then
tmp = (d * sqrt((1.0d0 / (l * h)))) * ((0.5d0 * ((h / l) * (((d_1 / d) * (m_m / 2.0d0)) ** 2.0d0))) + (-1.0d0))
else if (l <= 6d+166) then
tmp = (d * (1.0d0 + ((-0.5d0) * ((h / l) * (((m_m * (d_1 / d)) / 2.0d0) ** 2.0d0))))) / sqrt((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 (l <= -2e-310) {
tmp = (d * Math.sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * Math.pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0);
} else if (l <= 6e+166) {
tmp = (d * (1.0 + (-0.5 * ((h / l) * Math.pow(((M_m * (D / d)) / 2.0), 2.0))))) / Math.sqrt((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 l <= -2e-310: tmp = (d * math.sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * math.pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0) elif l <= 6e+166: tmp = (d * (1.0 + (-0.5 * ((h / l) * math.pow(((M_m * (D / d)) / 2.0), 2.0))))) / math.sqrt((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 (l <= -2e-310) tmp = Float64(Float64(d * sqrt(Float64(1.0 / Float64(l * h)))) * Float64(Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M_m / 2.0)) ^ 2.0))) + -1.0)); elseif (l <= 6e+166) tmp = Float64(Float64(d * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(M_m * Float64(D / d)) / 2.0) ^ 2.0))))) / sqrt(Float64(l * h))); else tmp = Float64(d / Float64(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 (l <= -2e-310)
tmp = (d * sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * (((D / d) * (M_m / 2.0)) ^ 2.0))) + -1.0);
elseif (l <= 6e+166)
tmp = (d * (1.0 + (-0.5 * ((h / l) * (((M_m * (D / d)) / 2.0) ^ 2.0))))) / sqrt((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[l, -2e-310], N[(N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6e+166], N[(N[(d * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[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 -2 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right) + -1\right)\\
\mathbf{elif}\;\ell \leq 6 \cdot 10^{+166}:\\
\;\;\;\;\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M\_m \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -1.999999999999994e-310Initial program 64.7%
Simplified66.0%
clear-num66.0%
sqrt-div66.0%
metadata-eval66.0%
Applied egg-rr66.0%
Taylor expanded in d around -inf 70.8%
if -1.999999999999994e-310 < l < 5.99999999999999997e166Initial program 63.0%
Simplified60.0%
*-commutative60.0%
sqrt-div61.8%
sqrt-div73.5%
frac-times73.5%
add-sqr-sqrt73.7%
Applied egg-rr73.7%
associate-*l/78.9%
cancel-sign-sub-inv78.9%
metadata-eval78.9%
*-commutative78.9%
associate-*l/78.9%
sqrt-unprod70.8%
*-commutative70.8%
Applied egg-rr70.8%
if 5.99999999999999997e166 < l Initial program 47.7%
Simplified47.4%
Taylor expanded in d around inf 48.2%
sqrt-div48.2%
metadata-eval48.2%
*-commutative48.2%
sqrt-unprod62.0%
div-inv62.1%
associate-/r*61.9%
Applied egg-rr61.9%
associate-/l/62.1%
*-commutative62.1%
Simplified62.1%
Final simplification69.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+60)
(* (- d) (pow (* l h) -0.5))
(if (<= d -2e-274)
(*
(sqrt (* (/ d l) (/ d h)))
(- 1.0 (* (/ h l) (* 0.125 (pow (* D (/ M_m d)) 2.0)))))
(/
(* d (+ 1.0 (* -0.5 (* (/ h l) (pow (/ (* M_m (/ D d)) 2.0) 2.0)))))
(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 <= -7.2e+60) {
tmp = -d * pow((l * h), -0.5);
} else if (d <= -2e-274) {
tmp = sqrt(((d / l) * (d / h))) * (1.0 - ((h / l) * (0.125 * pow((D * (M_m / d)), 2.0))));
} else {
tmp = (d * (1.0 + (-0.5 * ((h / l) * pow(((M_m * (D / d)) / 2.0), 2.0))))) / 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 <= (-7.2d+60)) then
tmp = -d * ((l * h) ** (-0.5d0))
else if (d <= (-2d-274)) then
tmp = sqrt(((d / l) * (d / h))) * (1.0d0 - ((h / l) * (0.125d0 * ((d_1 * (m_m / d)) ** 2.0d0))))
else
tmp = (d * (1.0d0 + ((-0.5d0) * ((h / l) * (((m_m * (d_1 / d)) / 2.0d0) ** 2.0d0))))) / 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 <= -7.2e+60) {
tmp = -d * Math.pow((l * h), -0.5);
} else if (d <= -2e-274) {
tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 - ((h / l) * (0.125 * Math.pow((D * (M_m / d)), 2.0))));
} else {
tmp = (d * (1.0 + (-0.5 * ((h / l) * Math.pow(((M_m * (D / d)) / 2.0), 2.0))))) / 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 <= -7.2e+60: tmp = -d * math.pow((l * h), -0.5) elif d <= -2e-274: tmp = math.sqrt(((d / l) * (d / h))) * (1.0 - ((h / l) * (0.125 * math.pow((D * (M_m / d)), 2.0)))) else: tmp = (d * (1.0 + (-0.5 * ((h / l) * math.pow(((M_m * (D / d)) / 2.0), 2.0))))) / 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 <= -7.2e+60) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); elseif (d <= -2e-274) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.125 * (Float64(D * Float64(M_m / d)) ^ 2.0))))); else tmp = Float64(Float64(d * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(M_m * Float64(D / d)) / 2.0) ^ 2.0))))) / 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 <= -7.2e+60)
tmp = -d * ((l * h) ^ -0.5);
elseif (d <= -2e-274)
tmp = sqrt(((d / l) * (d / h))) * (1.0 - ((h / l) * (0.125 * ((D * (M_m / d)) ^ 2.0))));
else
tmp = (d * (1.0 + (-0.5 * ((h / l) * (((M_m * (D / d)) / 2.0) ^ 2.0))))) / 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, -7.2e+60], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2e-274], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.125 * N[Power[N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 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 -7.2 \cdot 10^{+60}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{elif}\;d \leq -2 \cdot 10^{-274}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.125 \cdot {\left(D \cdot \frac{M\_m}{d}\right)}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M\_m \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if d < -7.19999999999999935e60Initial program 67.3%
Simplified69.1%
Taylor expanded in d around inf 3.1%
Taylor expanded in h around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt75.1%
mul-1-neg75.1%
unpow1/275.1%
rem-exp-log71.6%
exp-neg71.6%
exp-prod71.6%
distribute-lft-neg-out71.6%
distribute-rgt-neg-in71.6%
metadata-eval71.6%
exp-to-pow75.1%
Simplified75.1%
if -7.19999999999999935e60 < d < -1.99999999999999993e-274Initial program 66.3%
Simplified67.2%
add-sqr-sqrt67.2%
pow267.2%
sqrt-prod67.2%
sqrt-pow171.9%
metadata-eval71.9%
associate-*l/71.9%
div-inv71.9%
metadata-eval71.9%
*-commutative71.9%
pow171.9%
clear-num71.8%
un-div-inv71.9%
Applied egg-rr71.9%
metadata-eval71.9%
pow-prod-up71.9%
associate-*l*71.9%
pow171.9%
div-inv71.9%
clear-num71.9%
associate-*l*71.9%
pow171.9%
div-inv71.8%
clear-num71.9%
Applied egg-rr71.9%
swap-sqr71.9%
metadata-eval71.9%
unpow271.9%
associate-*r/72.5%
*-commutative72.5%
associate-/l*70.1%
associate-*l*70.1%
Simplified70.1%
pow170.1%
sqrt-unprod62.1%
associate-*r*62.1%
metadata-eval62.1%
associate-*r*62.2%
unpow-prod-down57.5%
pow257.5%
add-sqr-sqrt57.6%
Applied egg-rr57.6%
unpow157.6%
*-commutative57.6%
associate-*r*57.6%
Simplified57.6%
if -1.99999999999999993e-274 < d Initial program 57.2%
Simplified55.1%
*-commutative55.1%
sqrt-div59.0%
sqrt-div70.7%
frac-times70.8%
add-sqr-sqrt71.0%
Applied egg-rr71.0%
associate-*l/76.9%
cancel-sign-sub-inv76.9%
metadata-eval76.9%
*-commutative76.9%
associate-*l/76.9%
sqrt-unprod61.5%
*-commutative61.5%
Applied egg-rr61.5%
Final simplification63.7%
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+60)
(* (- d) (pow (* l h) -0.5))
(if (<= d 1e+101)
(*
(sqrt (* (/ d l) (/ d h)))
(- 1.0 (* (/ h l) (* 0.125 (pow (* D (/ M_m d)) 2.0)))))
(/ 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+60) {
tmp = -d * pow((l * h), -0.5);
} else if (d <= 1e+101) {
tmp = sqrt(((d / l) * (d / h))) * (1.0 - ((h / l) * (0.125 * pow((D * (M_m / d)), 2.0))));
} 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+60)) then
tmp = -d * ((l * h) ** (-0.5d0))
else if (d <= 1d+101) then
tmp = sqrt(((d / l) * (d / h))) * (1.0d0 - ((h / l) * (0.125d0 * ((d_1 * (m_m / d)) ** 2.0d0))))
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+60) {
tmp = -d * Math.pow((l * h), -0.5);
} else if (d <= 1e+101) {
tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 - ((h / l) * (0.125 * Math.pow((D * (M_m / d)), 2.0))));
} 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+60: tmp = -d * math.pow((l * h), -0.5) elif d <= 1e+101: tmp = math.sqrt(((d / l) * (d / h))) * (1.0 - ((h / l) * (0.125 * math.pow((D * (M_m / d)), 2.0)))) 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+60) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); elseif (d <= 1e+101) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.125 * (Float64(D * Float64(M_m / d)) ^ 2.0))))); else tmp = Float64(d / Float64(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+60)
tmp = -d * ((l * h) ^ -0.5);
elseif (d <= 1e+101)
tmp = sqrt(((d / l) * (d / h))) * (1.0 - ((h / l) * (0.125 * ((D * (M_m / d)) ^ 2.0))));
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+60], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1e+101], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.125 * N[Power[N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[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 -7.2 \cdot 10^{+60}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{elif}\;d \leq 10^{+101}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.125 \cdot {\left(D \cdot \frac{M\_m}{d}\right)}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if d < -7.19999999999999935e60Initial program 67.3%
Simplified69.1%
Taylor expanded in d around inf 3.1%
Taylor expanded in h around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt75.1%
mul-1-neg75.1%
unpow1/275.1%
rem-exp-log71.6%
exp-neg71.6%
exp-prod71.6%
distribute-lft-neg-out71.6%
distribute-rgt-neg-in71.6%
metadata-eval71.6%
exp-to-pow75.1%
Simplified75.1%
if -7.19999999999999935e60 < d < 9.9999999999999998e100Initial program 58.3%
Simplified58.1%
add-sqr-sqrt58.0%
pow258.0%
sqrt-prod58.1%
sqrt-pow161.3%
metadata-eval61.3%
associate-*l/61.3%
div-inv61.3%
metadata-eval61.3%
*-commutative61.3%
pow161.3%
clear-num61.2%
un-div-inv61.9%
Applied egg-rr61.9%
metadata-eval61.9%
pow-prod-up61.9%
associate-*l*61.9%
pow161.9%
div-inv61.3%
clear-num61.3%
associate-*l*61.3%
pow161.3%
div-inv61.2%
clear-num61.3%
Applied egg-rr61.3%
swap-sqr61.3%
metadata-eval61.3%
unpow261.3%
associate-*r/62.2%
*-commutative62.2%
associate-/l*60.5%
associate-*l*60.5%
Simplified60.5%
pow160.5%
sqrt-unprod51.9%
associate-*r*51.9%
metadata-eval51.9%
associate-*r*51.8%
unpow-prod-down48.7%
pow248.7%
add-sqr-sqrt48.7%
Applied egg-rr48.7%
unpow148.7%
*-commutative48.7%
associate-*r*48.7%
Simplified48.7%
if 9.9999999999999998e100 < d Initial program 65.2%
Simplified60.9%
Taylor expanded in d around inf 60.0%
sqrt-div61.2%
metadata-eval61.2%
*-commutative61.2%
sqrt-unprod73.3%
div-inv73.5%
associate-/r*65.6%
Applied egg-rr65.6%
associate-/l/73.5%
*-commutative73.5%
Simplified73.5%
Final simplification59.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 (<= d -5.2e+39)
(/ (- d) (sqrt (* l h)))
(if (<= d 1.02e-131)
(*
(sqrt (* (/ d l) (/ d h)))
(* (pow (* D (/ M_m d)) 2.0) (* -0.125 (/ h l))))
(/ 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 <= -5.2e+39) {
tmp = -d / sqrt((l * h));
} else if (d <= 1.02e-131) {
tmp = sqrt(((d / l) * (d / h))) * (pow((D * (M_m / d)), 2.0) * (-0.125 * (h / l)));
} 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 <= (-5.2d+39)) then
tmp = -d / sqrt((l * h))
else if (d <= 1.02d-131) then
tmp = sqrt(((d / l) * (d / h))) * (((d_1 * (m_m / d)) ** 2.0d0) * ((-0.125d0) * (h / l)))
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 <= -5.2e+39) {
tmp = -d / Math.sqrt((l * h));
} else if (d <= 1.02e-131) {
tmp = Math.sqrt(((d / l) * (d / h))) * (Math.pow((D * (M_m / d)), 2.0) * (-0.125 * (h / l)));
} 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 <= -5.2e+39: tmp = -d / math.sqrt((l * h)) elif d <= 1.02e-131: tmp = math.sqrt(((d / l) * (d / h))) * (math.pow((D * (M_m / d)), 2.0) * (-0.125 * (h / l))) 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 <= -5.2e+39) tmp = Float64(Float64(-d) / sqrt(Float64(l * h))); elseif (d <= 1.02e-131) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64((Float64(D * Float64(M_m / d)) ^ 2.0) * Float64(-0.125 * Float64(h / l)))); else tmp = Float64(d / Float64(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 <= -5.2e+39)
tmp = -d / sqrt((l * h));
elseif (d <= 1.02e-131)
tmp = sqrt(((d / l) * (d / h))) * (((D * (M_m / d)) ^ 2.0) * (-0.125 * (h / l)));
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, -5.2e+39], N[((-d) / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.02e-131], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Power[N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.125 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[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 -5.2 \cdot 10^{+39}:\\
\;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\
\mathbf{elif}\;d \leq 1.02 \cdot 10^{-131}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left({\left(D \cdot \frac{M\_m}{d}\right)}^{2} \cdot \left(-0.125 \cdot \frac{h}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if d < -5.2e39Initial program 66.9%
Simplified68.7%
Taylor expanded in M around 0 37.2%
associate-*r/37.2%
associate-*r*43.9%
associate-*r*43.9%
associate-*l/43.9%
associate-*r/43.9%
*-commutative43.9%
+-commutative43.9%
fma-undefine43.9%
Simplified74.1%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt74.4%
neg-mul-174.4%
distribute-rgt-neg-in74.4%
unpow1/274.4%
rem-exp-log70.9%
exp-neg71.0%
exp-prod71.0%
distribute-lft-neg-out71.0%
exp-neg71.0%
exp-to-pow74.4%
unpow1/274.4%
associate-*l/74.4%
*-lft-identity74.4%
distribute-frac-neg274.4%
Simplified74.4%
if -5.2e39 < d < 1.02000000000000001e-131Initial program 53.8%
Simplified53.4%
add-sqr-sqrt53.4%
pow253.4%
sqrt-prod53.4%
sqrt-pow157.2%
metadata-eval57.2%
associate-*l/57.2%
div-inv57.2%
metadata-eval57.2%
*-commutative57.2%
pow157.2%
clear-num57.2%
un-div-inv58.2%
Applied egg-rr58.2%
Taylor expanded in M around inf 28.2%
associate-/l*30.2%
times-frac31.1%
associate-*r*29.4%
associate-/l*29.6%
*-commutative29.6%
associate-/l*29.7%
unpow229.7%
unpow229.7%
unpow229.7%
times-frac34.8%
swap-sqr38.7%
unpow238.7%
*-commutative38.7%
associate-*r/39.6%
*-commutative39.6%
associate-/l*38.6%
Simplified38.6%
pow138.6%
sqrt-unprod33.6%
associate-*r*33.6%
Applied egg-rr33.6%
unpow133.6%
*-commutative33.6%
*-commutative33.6%
Simplified33.6%
if 1.02000000000000001e-131 < d Initial program 66.9%
Simplified64.6%
Taylor expanded in d around inf 51.8%
sqrt-div52.5%
metadata-eval52.5%
*-commutative52.5%
sqrt-unprod61.9%
div-inv62.1%
associate-/r*58.0%
Applied egg-rr58.0%
associate-/l/62.1%
*-commutative62.1%
Simplified62.1%
Final simplification53.7%
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 -5.5e-52)
(/ (- d) (sqrt (* l h)))
(if (<= d -5e-310)
(* d (exp (* (log1p (+ (* l h) -1.0)) (- 0.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 (d <= -5.5e-52) {
tmp = -d / sqrt((l * h));
} else if (d <= -5e-310) {
tmp = d * exp((log1p(((l * h) + -1.0)) * -0.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 (d <= -5.5e-52) {
tmp = -d / Math.sqrt((l * h));
} else if (d <= -5e-310) {
tmp = d * Math.exp((Math.log1p(((l * h) + -1.0)) * -0.5));
} 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 <= -5.5e-52: tmp = -d / math.sqrt((l * h)) elif d <= -5e-310: tmp = d * math.exp((math.log1p(((l * h) + -1.0)) * -0.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 (d <= -5.5e-52) tmp = Float64(Float64(-d) / sqrt(Float64(l * h))); elseif (d <= -5e-310) tmp = Float64(d * exp(Float64(log1p(Float64(Float64(l * h) + -1.0)) * Float64(-0.5)))); else tmp = Float64(d / Float64(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[d, -5.5e-52], N[((-d) / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-310], N[(d * N[Exp[N[(N[Log[1 + N[(N[(l * h), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] * (-0.5)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[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 -5.5 \cdot 10^{-52}:\\
\;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot e^{\mathsf{log1p}\left(\ell \cdot h + -1\right) \cdot \left(-0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if d < -5.5e-52Initial program 69.9%
Simplified71.2%
Taylor expanded in M around 0 44.4%
associate-*r/44.4%
associate-*r*48.2%
associate-*r*48.2%
associate-*l/49.4%
associate-*r/49.4%
*-commutative49.4%
+-commutative49.4%
fma-undefine49.4%
Simplified76.4%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt62.2%
neg-mul-162.2%
distribute-rgt-neg-in62.2%
unpow1/262.2%
rem-exp-log59.1%
exp-neg59.1%
exp-prod59.1%
distribute-lft-neg-out59.1%
exp-neg59.1%
exp-to-pow62.2%
unpow1/262.2%
associate-*l/62.3%
*-lft-identity62.3%
distribute-frac-neg262.3%
Simplified62.3%
if -5.5e-52 < d < -4.999999999999985e-310Initial program 53.7%
Simplified55.2%
Taylor expanded in d around inf 12.5%
pow1/212.5%
pow-to-exp12.5%
log-rec10.1%
Applied egg-rr10.1%
log1p-expm1-u39.0%
expm1-undefine39.0%
add-exp-log39.0%
Applied egg-rr39.0%
if -4.999999999999985e-310 < d Initial program 58.9%
Simplified56.7%
Taylor expanded in d around inf 41.1%
sqrt-div41.6%
metadata-eval41.6%
*-commutative41.6%
sqrt-unprod48.9%
div-inv49.0%
associate-/r*46.2%
Applied egg-rr46.2%
associate-/l/49.0%
*-commutative49.0%
Simplified49.0%
Final simplification51.7%
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 9.6e-200) (/ (- d) (sqrt (* 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 <= 9.6e-200) {
tmp = -d / sqrt((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 <= 9.6d-200) then
tmp = -d / sqrt((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 <= 9.6e-200) {
tmp = -d / Math.sqrt((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 <= 9.6e-200: tmp = -d / math.sqrt((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 <= 9.6e-200) tmp = Float64(Float64(-d) / sqrt(Float64(l * h))); else tmp = Float64(d / Float64(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 <= 9.6e-200)
tmp = -d / sqrt((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, 9.6e-200], N[((-d) / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[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 9.6 \cdot 10^{-200}:\\
\;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if d < 9.60000000000000006e-200Initial program 59.0%
Simplified59.5%
Taylor expanded in M around 0 37.2%
associate-*r/37.2%
associate-*r*40.1%
associate-*r*40.1%
associate-*l/40.8%
associate-*r/40.8%
*-commutative40.8%
+-commutative40.8%
fma-undefine40.8%
Simplified62.0%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt44.7%
neg-mul-144.7%
distribute-rgt-neg-in44.7%
unpow1/244.7%
rem-exp-log42.6%
exp-neg42.6%
exp-prod42.6%
distribute-lft-neg-out42.6%
exp-neg42.6%
exp-to-pow44.7%
unpow1/244.7%
associate-*l/44.7%
*-lft-identity44.7%
distribute-frac-neg244.7%
Simplified44.7%
if 9.60000000000000006e-200 < d Initial program 65.2%
Simplified63.3%
Taylor expanded in d around inf 47.2%
sqrt-div47.8%
metadata-eval47.8%
*-commutative47.8%
sqrt-unprod56.5%
div-inv56.6%
associate-/r*53.2%
Applied egg-rr53.2%
associate-/l/56.6%
*-commutative56.6%
Simplified56.6%
Final simplification49.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 (sqrt (* l h)))) (if (<= l 4.1e-225) (/ (- d) t_0) (/ d 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 = sqrt((l * h));
double tmp;
if (l <= 4.1e-225) {
tmp = -d / t_0;
} else {
tmp = d / 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 = sqrt((l * h))
if (l <= 4.1d-225) then
tmp = -d / t_0
else
tmp = d / 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 = Math.sqrt((l * h));
double tmp;
if (l <= 4.1e-225) {
tmp = -d / t_0;
} else {
tmp = d / 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 = math.sqrt((l * h)) tmp = 0 if l <= 4.1e-225: tmp = -d / t_0 else: tmp = d / 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 = sqrt(Float64(l * h)) tmp = 0.0 if (l <= 4.1e-225) tmp = Float64(Float64(-d) / t_0); else tmp = Float64(d / 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 = sqrt((l * h));
tmp = 0.0;
if (l <= 4.1e-225)
tmp = -d / t_0;
else
tmp = d / 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[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, 4.1e-225], N[((-d) / t$95$0), $MachinePrecision], N[(d / t$95$0), $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 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;\ell \leq 4.1 \cdot 10^{-225}:\\
\;\;\;\;\frac{-d}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_0}\\
\end{array}
\end{array}
if l < 4.10000000000000022e-225Initial program 66.2%
Simplified66.6%
Taylor expanded in M around 0 40.8%
associate-*r/40.8%
associate-*r*43.8%
associate-*r*43.8%
associate-*l/44.5%
associate-*r/44.5%
*-commutative44.5%
+-commutative44.5%
fma-undefine44.5%
Simplified69.3%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt47.1%
neg-mul-147.1%
distribute-rgt-neg-in47.1%
unpow1/247.1%
rem-exp-log44.8%
exp-neg44.8%
exp-prod44.8%
distribute-lft-neg-out44.8%
exp-neg44.9%
exp-to-pow47.0%
unpow1/247.0%
associate-*l/47.1%
*-lft-identity47.1%
distribute-frac-neg247.1%
Simplified47.1%
if 4.10000000000000022e-225 < l Initial program 56.3%
Simplified54.5%
Taylor expanded in M around 0 33.5%
associate-*r/33.5%
associate-*r*33.6%
associate-*r*33.6%
associate-*l/34.4%
associate-*r/34.4%
*-commutative34.4%
+-commutative34.4%
fma-undefine34.4%
Simplified56.6%
Taylor expanded in d around inf 45.2%
*-commutative45.2%
unpow1/245.2%
rem-exp-log43.1%
exp-neg43.1%
exp-prod43.1%
distribute-lft-neg-out43.1%
exp-neg43.1%
exp-to-pow45.3%
unpow1/245.3%
unpow-145.3%
unpow-145.3%
associate-*l/45.4%
*-lft-identity45.4%
Simplified45.4%
Final simplification46.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 (/ 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 61.7%
Simplified61.1%
Taylor expanded in M around 0 37.5%
associate-*r/37.5%
associate-*r*39.2%
associate-*r*39.2%
associate-*l/40.0%
associate-*r/40.0%
*-commutative40.0%
+-commutative40.0%
fma-undefine40.0%
Simplified63.5%
Taylor expanded in d around inf 24.6%
*-commutative24.6%
unpow1/224.6%
rem-exp-log23.7%
exp-neg23.7%
exp-prod23.5%
distribute-lft-neg-out23.5%
exp-neg23.5%
exp-to-pow24.5%
unpow1/224.5%
unpow-124.5%
unpow-124.5%
associate-*l/24.6%
*-lft-identity24.6%
Simplified24.6%
Final simplification24.6%
herbie shell --seed 2024151
(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)))))