
(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 19 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)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (- d)))
(t_1 (sqrt (/ d h)))
(t_2 (* D_m (/ M_m (* d 2.0)))))
(if (<= l -3.8e+171)
(*
t_1
(*
(/ t_0 (sqrt (- l)))
(+ 1.0 (* (/ h l) (* -0.5 (pow (* (/ M_m 2.0) (/ D_m d)) 2.0))))))
(if (<= l -5e-310)
(*
(* (/ t_0 (sqrt (- h))) (sqrt (/ d l)))
(- 1.0 (* 0.5 (/ (* h (pow (* (/ D_m d) (* M_m 0.5)) 2.0)) l))))
(if (<= l 3.6e+66)
(*
(fma (/ h l) (* -0.5 (pow t_2 2.0)) 1.0)
(/ d (* (sqrt h) (sqrt l))))
(*
(* t_1 (/ (sqrt d) (sqrt l)))
(- 1.0 (* 0.5 (pow (* t_2 (sqrt (/ h l))) 2.0)))))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt(-d);
double t_1 = sqrt((d / h));
double t_2 = D_m * (M_m / (d * 2.0));
double tmp;
if (l <= -3.8e+171) {
tmp = t_1 * ((t_0 / sqrt(-l)) * (1.0 + ((h / l) * (-0.5 * pow(((M_m / 2.0) * (D_m / d)), 2.0)))));
} else if (l <= -5e-310) {
tmp = ((t_0 / sqrt(-h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h * pow(((D_m / d) * (M_m * 0.5)), 2.0)) / l)));
} else if (l <= 3.6e+66) {
tmp = fma((h / l), (-0.5 * pow(t_2, 2.0)), 1.0) * (d / (sqrt(h) * sqrt(l)));
} else {
tmp = (t_1 * (sqrt(d) / sqrt(l))) * (1.0 - (0.5 * pow((t_2 * sqrt((h / l))), 2.0)));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(-d)) t_1 = sqrt(Float64(d / h)) t_2 = Float64(D_m * Float64(M_m / Float64(d * 2.0))) tmp = 0.0 if (l <= -3.8e+171) tmp = Float64(t_1 * Float64(Float64(t_0 / sqrt(Float64(-l))) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(Float64(M_m / 2.0) * Float64(D_m / d)) ^ 2.0)))))); elseif (l <= -5e-310) tmp = Float64(Float64(Float64(t_0 / sqrt(Float64(-h))) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(D_m / d) * Float64(M_m * 0.5)) ^ 2.0)) / l)))); elseif (l <= 3.6e+66) tmp = Float64(fma(Float64(h / l), Float64(-0.5 * (t_2 ^ 2.0)), 1.0) * Float64(d / Float64(sqrt(h) * sqrt(l)))); else tmp = Float64(Float64(t_1 * Float64(sqrt(d) / sqrt(l))) * Float64(1.0 - Float64(0.5 * (Float64(t_2 * sqrt(Float64(h / l))) ^ 2.0)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[(-d)], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(D$95$m * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.8e+171], N[(t$95$1 * N[(N[(t$95$0 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-310], N[(N[(N[(t$95$0 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.6e+66], N[(N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[Power[N[(t$95$2 * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{-d}\\
t_1 := \sqrt{\frac{d}{h}}\\
t_2 := D_m \cdot \frac{M_m}{d \cdot 2}\\
\mathbf{if}\;\ell \leq -3.8 \cdot 10^{+171}:\\
\;\;\;\;t_1 \cdot \left(\frac{t_0}{\sqrt{-\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{M_m}{2} \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\right)\\
\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\frac{t_0}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D_m}{d} \cdot \left(M_m \cdot 0.5\right)\right)}^{2}}{\ell}\right)\\
\mathbf{elif}\;\ell \leq 3.6 \cdot 10^{+66}:\\
\;\;\;\;\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {t_2}^{2}, 1\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\left(t_1 \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(t_2 \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\\
\end{array}
\end{array}
if l < -3.8000000000000002e171Initial program 51.3%
Simplified51.3%
frac-2neg51.3%
sqrt-div78.9%
Applied egg-rr78.9%
if -3.8000000000000002e171 < l < -4.999999999999985e-310Initial program 75.3%
Simplified75.3%
associate-*r/77.8%
add-sqr-sqrt49.1%
add-sqr-sqrt77.8%
div-inv77.8%
metadata-eval77.8%
Applied egg-rr77.8%
frac-2neg77.8%
sqrt-div90.8%
Applied egg-rr90.8%
if -4.999999999999985e-310 < l < 3.6e66Initial program 71.2%
Simplified72.5%
Applied egg-rr25.3%
expm1-def34.4%
expm1-log1p84.7%
*-commutative84.7%
Simplified84.7%
if 3.6e66 < l Initial program 55.2%
Simplified53.4%
add-sqr-sqrt53.3%
pow253.3%
sqrt-prod53.3%
unpow253.3%
sqrt-prod44.9%
add-sqr-sqrt60.7%
div-inv60.7%
metadata-eval60.7%
Applied egg-rr60.7%
*-commutative60.7%
/-rgt-identity60.7%
associate-/l*60.7%
metadata-eval60.7%
times-frac62.7%
associate-*r/64.1%
*-commutative64.1%
Simplified64.1%
sqrt-div69.3%
Applied egg-rr69.3%
Final simplification83.3%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (- d))))
(if (<= l -6e+173)
(*
(sqrt (/ d h))
(*
(/ t_0 (sqrt (- l)))
(+ 1.0 (* (/ h l) (* -0.5 (pow (* (/ M_m 2.0) (/ D_m d)) 2.0))))))
(if (<= l -5e-310)
(*
(* (/ t_0 (sqrt (- h))) (sqrt (/ d l)))
(- 1.0 (* 0.5 (/ (* h (pow (* (/ D_m d) (* M_m 0.5)) 2.0)) l))))
(*
(fma (/ h l) (* -0.5 (pow (* D_m (/ M_m (* d 2.0))) 2.0)) 1.0)
(/ d (* (sqrt h) (sqrt l))))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt(-d);
double tmp;
if (l <= -6e+173) {
tmp = sqrt((d / h)) * ((t_0 / sqrt(-l)) * (1.0 + ((h / l) * (-0.5 * pow(((M_m / 2.0) * (D_m / d)), 2.0)))));
} else if (l <= -5e-310) {
tmp = ((t_0 / sqrt(-h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h * pow(((D_m / d) * (M_m * 0.5)), 2.0)) / l)));
} else {
tmp = fma((h / l), (-0.5 * pow((D_m * (M_m / (d * 2.0))), 2.0)), 1.0) * (d / (sqrt(h) * sqrt(l)));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(-d)) tmp = 0.0 if (l <= -6e+173) tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(t_0 / sqrt(Float64(-l))) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(Float64(M_m / 2.0) * Float64(D_m / d)) ^ 2.0)))))); elseif (l <= -5e-310) tmp = Float64(Float64(Float64(t_0 / sqrt(Float64(-h))) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(D_m / d) * Float64(M_m * 0.5)) ^ 2.0)) / l)))); else tmp = Float64(fma(Float64(h / l), Float64(-0.5 * (Float64(D_m * Float64(M_m / Float64(d * 2.0))) ^ 2.0)), 1.0) * Float64(d / Float64(sqrt(h) * sqrt(l)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[l, -6e+173], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(t$95$0 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-310], N[(N[(N[(t$95$0 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(D$95$m * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{-d}\\
\mathbf{if}\;\ell \leq -6 \cdot 10^{+173}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{t_0}{\sqrt{-\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{M_m}{2} \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\right)\\
\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\frac{t_0}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D_m}{d} \cdot \left(M_m \cdot 0.5\right)\right)}^{2}}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(D_m \cdot \frac{M_m}{d \cdot 2}\right)}^{2}, 1\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < -5.9999999999999995e173Initial program 51.3%
Simplified51.3%
frac-2neg51.3%
sqrt-div78.9%
Applied egg-rr78.9%
if -5.9999999999999995e173 < l < -4.999999999999985e-310Initial program 75.3%
Simplified75.3%
associate-*r/77.8%
add-sqr-sqrt49.1%
add-sqr-sqrt77.8%
div-inv77.8%
metadata-eval77.8%
Applied egg-rr77.8%
frac-2neg77.8%
sqrt-div90.8%
Applied egg-rr90.8%
if -4.999999999999985e-310 < l Initial program 65.2%
Simplified65.2%
Applied egg-rr26.5%
expm1-def41.1%
expm1-log1p76.2%
*-commutative76.2%
Simplified76.9%
Final simplification82.2%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -8.5e+261)
(* (- d) (pow (* l h) -0.5))
(if (<= l 4e-239)
(*
(sqrt (/ d l))
(/
(fma -0.5 (/ 1.0 (/ l (* h (pow (* (/ D_m 2.0) (/ M_m d)) 2.0)))) 1.0)
(sqrt (/ h d))))
(*
(fma (/ h l) (* -0.5 (pow (* D_m (/ M_m (* d 2.0))) 2.0)) 1.0)
(/ d (* (sqrt h) (sqrt l)))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -8.5e+261) {
tmp = -d * pow((l * h), -0.5);
} else if (l <= 4e-239) {
tmp = sqrt((d / l)) * (fma(-0.5, (1.0 / (l / (h * pow(((D_m / 2.0) * (M_m / d)), 2.0)))), 1.0) / sqrt((h / d)));
} else {
tmp = fma((h / l), (-0.5 * pow((D_m * (M_m / (d * 2.0))), 2.0)), 1.0) * (d / (sqrt(h) * sqrt(l)));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -8.5e+261) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); elseif (l <= 4e-239) tmp = Float64(sqrt(Float64(d / l)) * Float64(fma(-0.5, Float64(1.0 / Float64(l / Float64(h * (Float64(Float64(D_m / 2.0) * Float64(M_m / d)) ^ 2.0)))), 1.0) / sqrt(Float64(h / d)))); else tmp = Float64(fma(Float64(h / l), Float64(-0.5 * (Float64(D_m * Float64(M_m / Float64(d * 2.0))) ^ 2.0)), 1.0) * Float64(d / Float64(sqrt(h) * sqrt(l)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -8.5e+261], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4e-239], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(-0.5 * N[(1.0 / N[(l / N[(h * N[Power[N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(D$95$m * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -8.5 \cdot 10^{+261}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{elif}\;\ell \leq 4 \cdot 10^{-239}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{\mathsf{fma}\left(-0.5, \frac{1}{\frac{\ell}{h \cdot {\left(\frac{D_m}{2} \cdot \frac{M_m}{d}\right)}^{2}}}, 1\right)}{\sqrt{\frac{h}{d}}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(D_m \cdot \frac{M_m}{d \cdot 2}\right)}^{2}, 1\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < -8.5000000000000005e261Initial program 35.9%
Simplified35.9%
clear-num35.9%
sqrt-div35.7%
metadata-eval35.7%
Applied egg-rr35.7%
Taylor expanded in d around -inf 83.4%
associate-*r*83.4%
*-commutative83.4%
unpow-183.4%
metadata-eval83.4%
pow-sqr83.4%
rem-sqrt-square83.4%
rem-square-sqrt83.2%
fabs-sqr83.2%
rem-square-sqrt83.4%
mul-1-neg83.4%
Simplified83.4%
if -8.5000000000000005e261 < l < 4.0000000000000003e-239Initial program 74.2%
Simplified74.2%
add-sqr-sqrt74.2%
pow274.2%
sqrt-prod74.2%
unpow274.2%
sqrt-prod46.9%
add-sqr-sqrt75.0%
div-inv75.0%
metadata-eval75.0%
Applied egg-rr75.0%
*-commutative75.0%
/-rgt-identity75.0%
associate-/l*75.0%
metadata-eval75.0%
times-frac75.8%
associate-*r/75.0%
associate-*l*75.0%
*-commutative75.0%
Simplified75.0%
clear-num75.0%
sqrt-div75.0%
metadata-eval75.0%
Applied egg-rr75.0%
expm1-log1p-u35.1%
expm1-udef25.4%
Applied egg-rr25.4%
expm1-def35.9%
expm1-log1p74.2%
*-commutative74.2%
associate-*l/74.2%
*-lft-identity74.2%
times-frac74.2%
/-rgt-identity74.2%
Simplified74.2%
associate-*l/77.9%
clear-num77.9%
associate-*l/77.9%
*-commutative77.9%
times-frac77.1%
Applied egg-rr77.1%
if 4.0000000000000003e-239 < l Initial program 64.5%
Simplified64.6%
Applied egg-rr26.4%
expm1-def42.3%
expm1-log1p76.5%
*-commutative76.5%
Simplified77.3%
Final simplification77.5%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -5.2e+95)
(*
(sqrt (/ d h))
(*
(/ (sqrt (- d)) (sqrt (- l)))
(+ 1.0 (* (/ h l) (* -0.5 (pow (* (/ M_m 2.0) (/ D_m d)) 2.0))))))
(if (<= l 1.75e-237)
(*
(sqrt (/ d l))
(/
(fma -0.5 (/ 1.0 (/ l (* h (pow (* (/ D_m 2.0) (/ M_m d)) 2.0)))) 1.0)
(sqrt (/ h d))))
(*
(fma (/ h l) (* -0.5 (pow (* D_m (/ M_m (* d 2.0))) 2.0)) 1.0)
(/ d (* (sqrt h) (sqrt l)))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -5.2e+95) {
tmp = sqrt((d / h)) * ((sqrt(-d) / sqrt(-l)) * (1.0 + ((h / l) * (-0.5 * pow(((M_m / 2.0) * (D_m / d)), 2.0)))));
} else if (l <= 1.75e-237) {
tmp = sqrt((d / l)) * (fma(-0.5, (1.0 / (l / (h * pow(((D_m / 2.0) * (M_m / d)), 2.0)))), 1.0) / sqrt((h / d)));
} else {
tmp = fma((h / l), (-0.5 * pow((D_m * (M_m / (d * 2.0))), 2.0)), 1.0) * (d / (sqrt(h) * sqrt(l)));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -5.2e+95) tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-l))) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(Float64(M_m / 2.0) * Float64(D_m / d)) ^ 2.0)))))); elseif (l <= 1.75e-237) tmp = Float64(sqrt(Float64(d / l)) * Float64(fma(-0.5, Float64(1.0 / Float64(l / Float64(h * (Float64(Float64(D_m / 2.0) * Float64(M_m / d)) ^ 2.0)))), 1.0) / sqrt(Float64(h / d)))); else tmp = Float64(fma(Float64(h / l), Float64(-0.5 * (Float64(D_m * Float64(M_m / Float64(d * 2.0))) ^ 2.0)), 1.0) * Float64(d / Float64(sqrt(h) * sqrt(l)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -5.2e+95], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.75e-237], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(-0.5 * N[(1.0 / N[(l / N[(h * N[Power[N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(D$95$m * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5.2 \cdot 10^{+95}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{M_m}{2} \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\right)\\
\mathbf{elif}\;\ell \leq 1.75 \cdot 10^{-237}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{\mathsf{fma}\left(-0.5, \frac{1}{\frac{\ell}{h \cdot {\left(\frac{D_m}{2} \cdot \frac{M_m}{d}\right)}^{2}}}, 1\right)}{\sqrt{\frac{h}{d}}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(D_m \cdot \frac{M_m}{d \cdot 2}\right)}^{2}, 1\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < -5.19999999999999981e95Initial program 60.8%
Simplified60.8%
frac-2neg60.8%
sqrt-div81.5%
Applied egg-rr81.5%
if -5.19999999999999981e95 < l < 1.74999999999999992e-237Initial program 73.9%
Simplified73.9%
add-sqr-sqrt73.9%
pow273.9%
sqrt-prod73.9%
unpow273.9%
sqrt-prod44.2%
add-sqr-sqrt74.9%
div-inv74.9%
metadata-eval74.9%
Applied egg-rr74.9%
*-commutative74.9%
/-rgt-identity74.9%
associate-/l*74.9%
metadata-eval74.9%
times-frac75.8%
associate-*r/74.8%
associate-*l*74.8%
*-commutative74.8%
Simplified74.8%
clear-num74.8%
sqrt-div74.8%
metadata-eval74.8%
Applied egg-rr74.8%
expm1-log1p-u28.1%
expm1-udef23.3%
Applied egg-rr23.3%
expm1-def29.1%
expm1-log1p73.9%
*-commutative73.9%
associate-*l/73.9%
*-lft-identity73.9%
times-frac73.9%
/-rgt-identity73.9%
Simplified73.9%
associate-*l/78.3%
clear-num78.3%
associate-*l/78.3%
*-commutative78.3%
times-frac77.4%
Applied egg-rr77.4%
if 1.74999999999999992e-237 < l Initial program 64.5%
Simplified64.6%
Applied egg-rr26.4%
expm1-def42.3%
expm1-log1p76.5%
*-commutative76.5%
Simplified77.3%
Final simplification77.8%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -1.9e+263)
(* (- d) (pow (* l h) -0.5))
(if (<= l 3e-208)
(*
(- 1.0 (* 0.5 (/ (* h (pow (* (/ D_m d) (* M_m 0.5)) 2.0)) l)))
(* (sqrt (/ d h)) (sqrt (/ d l))))
(*
(/ d (sqrt h))
(/
(fma (pow (* D_m (/ M_m (* d 2.0))) 2.0) (* (/ h l) -0.5) 1.0)
(sqrt l))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -1.9e+263) {
tmp = -d * pow((l * h), -0.5);
} else if (l <= 3e-208) {
tmp = (1.0 - (0.5 * ((h * pow(((D_m / d) * (M_m * 0.5)), 2.0)) / l))) * (sqrt((d / h)) * sqrt((d / l)));
} else {
tmp = (d / sqrt(h)) * (fma(pow((D_m * (M_m / (d * 2.0))), 2.0), ((h / l) * -0.5), 1.0) / sqrt(l));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -1.9e+263) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); elseif (l <= 3e-208) tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(D_m / d) * Float64(M_m * 0.5)) ^ 2.0)) / l))) * Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)))); else tmp = Float64(Float64(d / sqrt(h)) * Float64(fma((Float64(D_m * Float64(M_m / Float64(d * 2.0))) ^ 2.0), Float64(Float64(h / l) * -0.5), 1.0) / sqrt(l))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -1.9e+263], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3e-208], N[(N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Power[N[(D$95$m * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] + 1.0), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.9 \cdot 10^{+263}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{elif}\;\ell \leq 3 \cdot 10^{-208}:\\
\;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D_m}{d} \cdot \left(M_m \cdot 0.5\right)\right)}^{2}}{\ell}\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h}} \cdot \frac{\mathsf{fma}\left({\left(D_m \cdot \frac{M_m}{d \cdot 2}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < -1.9e263Initial program 35.9%
Simplified35.9%
clear-num35.9%
sqrt-div35.7%
metadata-eval35.7%
Applied egg-rr35.7%
Taylor expanded in d around -inf 83.4%
associate-*r*83.4%
*-commutative83.4%
unpow-183.4%
metadata-eval83.4%
pow-sqr83.4%
rem-sqrt-square83.4%
rem-square-sqrt83.2%
fabs-sqr83.2%
rem-square-sqrt83.4%
mul-1-neg83.4%
Simplified83.4%
if -1.9e263 < l < 2.99999999999999986e-208Initial program 73.8%
Simplified73.8%
associate-*r/77.5%
add-sqr-sqrt49.0%
add-sqr-sqrt77.5%
div-inv77.5%
metadata-eval77.5%
Applied egg-rr77.5%
if 2.99999999999999986e-208 < l Initial program 64.4%
Simplified64.5%
Applied egg-rr26.9%
Simplified77.0%
Final simplification77.5%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -1.26e+255)
(* (- d) (pow (* l h) -0.5))
(if (<= l 7e-239)
(*
(- 1.0 (* 0.5 (/ (* h (pow (* (/ D_m d) (* M_m 0.5)) 2.0)) l)))
(* (sqrt (/ d h)) (sqrt (/ d l))))
(*
(fma (/ h l) (* -0.5 (pow (* D_m (/ M_m (* d 2.0))) 2.0)) 1.0)
(/ d (* (sqrt h) (sqrt l)))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -1.26e+255) {
tmp = -d * pow((l * h), -0.5);
} else if (l <= 7e-239) {
tmp = (1.0 - (0.5 * ((h * pow(((D_m / d) * (M_m * 0.5)), 2.0)) / l))) * (sqrt((d / h)) * sqrt((d / l)));
} else {
tmp = fma((h / l), (-0.5 * pow((D_m * (M_m / (d * 2.0))), 2.0)), 1.0) * (d / (sqrt(h) * sqrt(l)));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -1.26e+255) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); elseif (l <= 7e-239) tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(D_m / d) * Float64(M_m * 0.5)) ^ 2.0)) / l))) * Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)))); else tmp = Float64(fma(Float64(h / l), Float64(-0.5 * (Float64(D_m * Float64(M_m / Float64(d * 2.0))) ^ 2.0)), 1.0) * Float64(d / Float64(sqrt(h) * sqrt(l)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -1.26e+255], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 7e-239], N[(N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(D$95$m * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.26 \cdot 10^{+255}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{elif}\;\ell \leq 7 \cdot 10^{-239}:\\
\;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D_m}{d} \cdot \left(M_m \cdot 0.5\right)\right)}^{2}}{\ell}\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(D_m \cdot \frac{M_m}{d \cdot 2}\right)}^{2}, 1\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < -1.26e255Initial program 35.9%
Simplified35.9%
clear-num35.9%
sqrt-div35.7%
metadata-eval35.7%
Applied egg-rr35.7%
Taylor expanded in d around -inf 83.4%
associate-*r*83.4%
*-commutative83.4%
unpow-183.4%
metadata-eval83.4%
pow-sqr83.4%
rem-sqrt-square83.4%
rem-square-sqrt83.2%
fabs-sqr83.2%
rem-square-sqrt83.4%
mul-1-neg83.4%
Simplified83.4%
if -1.26e255 < l < 7.00000000000000011e-239Initial program 74.2%
Simplified74.2%
associate-*r/78.0%
add-sqr-sqrt49.7%
add-sqr-sqrt78.0%
div-inv78.0%
metadata-eval78.0%
Applied egg-rr78.0%
if 7.00000000000000011e-239 < l Initial program 64.5%
Simplified64.6%
Applied egg-rr26.4%
expm1-def42.3%
expm1-log1p76.5%
*-commutative76.5%
Simplified77.3%
Final simplification77.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -3.2e+256)
(* (- d) (pow (* l h) -0.5))
(*
(sqrt (/ d h))
(*
(+ 1.0 (* (/ h l) (* -0.5 (pow (* (/ M_m 2.0) (/ D_m d)) 2.0))))
(sqrt (/ d l))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -3.2e+256) {
tmp = -d * pow((l * h), -0.5);
} else {
tmp = sqrt((d / h)) * ((1.0 + ((h / l) * (-0.5 * pow(((M_m / 2.0) * (D_m / d)), 2.0)))) * sqrt((d / l)));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
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_m
real(8) :: tmp
if (l <= (-3.2d+256)) then
tmp = -d * ((l * h) ** (-0.5d0))
else
tmp = sqrt((d / h)) * ((1.0d0 + ((h / l) * ((-0.5d0) * (((m_m / 2.0d0) * (d_m / d)) ** 2.0d0)))) * sqrt((d / l)))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -3.2e+256) {
tmp = -d * Math.pow((l * h), -0.5);
} else {
tmp = Math.sqrt((d / h)) * ((1.0 + ((h / l) * (-0.5 * Math.pow(((M_m / 2.0) * (D_m / d)), 2.0)))) * Math.sqrt((d / l)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if l <= -3.2e+256: tmp = -d * math.pow((l * h), -0.5) else: tmp = math.sqrt((d / h)) * ((1.0 + ((h / l) * (-0.5 * math.pow(((M_m / 2.0) * (D_m / d)), 2.0)))) * math.sqrt((d / l))) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -3.2e+256) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); else tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(Float64(M_m / 2.0) * Float64(D_m / d)) ^ 2.0)))) * sqrt(Float64(d / l)))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (l <= -3.2e+256)
tmp = -d * ((l * h) ^ -0.5);
else
tmp = sqrt((d / h)) * ((1.0 + ((h / l) * (-0.5 * (((M_m / 2.0) * (D_m / d)) ^ 2.0)))) * sqrt((d / l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -3.2e+256], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.2 \cdot 10^{+256}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{M_m}{2} \cdot \frac{D_m}{d}\right)}^{2}\right)\right) \cdot \sqrt{\frac{d}{\ell}}\right)\\
\end{array}
\end{array}
if l < -3.19999999999999996e256Initial program 35.9%
Simplified35.9%
clear-num35.9%
sqrt-div35.7%
metadata-eval35.7%
Applied egg-rr35.7%
Taylor expanded in d around -inf 83.4%
associate-*r*83.4%
*-commutative83.4%
unpow-183.4%
metadata-eval83.4%
pow-sqr83.4%
rem-sqrt-square83.4%
rem-square-sqrt83.2%
fabs-sqr83.2%
rem-square-sqrt83.4%
mul-1-neg83.4%
Simplified83.4%
if -3.19999999999999996e256 < l Initial program 69.2%
Simplified69.2%
Final simplification69.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -1.26e+261)
(* (- d) (pow (* l h) -0.5))
(*
(* (sqrt (/ d h)) (sqrt (/ d l)))
(- 1.0 (* 0.5 (* (/ h l) (pow (* D_m (/ M_m (* d 2.0))) 2.0)))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -1.26e+261) {
tmp = -d * pow((l * h), -0.5);
} else {
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h / l) * pow((D_m * (M_m / (d * 2.0))), 2.0))));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
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_m
real(8) :: tmp
if (l <= (-1.26d+261)) then
tmp = -d * ((l * h) ** (-0.5d0))
else
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0d0 - (0.5d0 * ((h / l) * ((d_m * (m_m / (d * 2.0d0))) ** 2.0d0))))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -1.26e+261) {
tmp = -d * Math.pow((l * h), -0.5);
} else {
tmp = (Math.sqrt((d / h)) * Math.sqrt((d / l))) * (1.0 - (0.5 * ((h / l) * Math.pow((D_m * (M_m / (d * 2.0))), 2.0))));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if l <= -1.26e+261: tmp = -d * math.pow((l * h), -0.5) else: tmp = (math.sqrt((d / h)) * math.sqrt((d / l))) * (1.0 - (0.5 * ((h / l) * math.pow((D_m * (M_m / (d * 2.0))), 2.0)))) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -1.26e+261) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); else tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(D_m * Float64(M_m / Float64(d * 2.0))) ^ 2.0))))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (l <= -1.26e+261)
tmp = -d * ((l * h) ^ -0.5);
else
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h / l) * ((D_m * (M_m / (d * 2.0))) ^ 2.0))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -1.26e+261], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(D$95$m * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.26 \cdot 10^{+261}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D_m \cdot \frac{M_m}{d \cdot 2}\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if l < -1.25999999999999991e261Initial program 35.9%
Simplified35.9%
clear-num35.9%
sqrt-div35.7%
metadata-eval35.7%
Applied egg-rr35.7%
Taylor expanded in d around -inf 83.4%
associate-*r*83.4%
*-commutative83.4%
unpow-183.4%
metadata-eval83.4%
pow-sqr83.4%
rem-sqrt-square83.4%
rem-square-sqrt83.2%
fabs-sqr83.2%
rem-square-sqrt83.4%
mul-1-neg83.4%
Simplified83.4%
if -1.25999999999999991e261 < l Initial program 69.2%
Simplified69.2%
Taylor expanded in M around 0 69.2%
*-commutative69.2%
*-commutative69.2%
metadata-eval69.2%
times-frac69.2%
*-rgt-identity69.2%
associate-*l/69.2%
*-commutative69.2%
*-commutative69.2%
Simplified69.2%
Final simplification69.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -1.02e+257)
(* (- d) (pow (* l h) -0.5))
(*
(- 1.0 (* 0.5 (/ (* h (pow (* (/ D_m d) (* M_m 0.5)) 2.0)) l)))
(* (sqrt (/ d h)) (sqrt (/ d l))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -1.02e+257) {
tmp = -d * pow((l * h), -0.5);
} else {
tmp = (1.0 - (0.5 * ((h * pow(((D_m / d) * (M_m * 0.5)), 2.0)) / l))) * (sqrt((d / h)) * sqrt((d / l)));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
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_m
real(8) :: tmp
if (l <= (-1.02d+257)) then
tmp = -d * ((l * h) ** (-0.5d0))
else
tmp = (1.0d0 - (0.5d0 * ((h * (((d_m / d) * (m_m * 0.5d0)) ** 2.0d0)) / l))) * (sqrt((d / h)) * sqrt((d / l)))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -1.02e+257) {
tmp = -d * Math.pow((l * h), -0.5);
} else {
tmp = (1.0 - (0.5 * ((h * Math.pow(((D_m / d) * (M_m * 0.5)), 2.0)) / l))) * (Math.sqrt((d / h)) * Math.sqrt((d / l)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if l <= -1.02e+257: tmp = -d * math.pow((l * h), -0.5) else: tmp = (1.0 - (0.5 * ((h * math.pow(((D_m / d) * (M_m * 0.5)), 2.0)) / l))) * (math.sqrt((d / h)) * math.sqrt((d / l))) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -1.02e+257) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); else tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(D_m / d) * Float64(M_m * 0.5)) ^ 2.0)) / l))) * Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (l <= -1.02e+257)
tmp = -d * ((l * h) ^ -0.5);
else
tmp = (1.0 - (0.5 * ((h * (((D_m / d) * (M_m * 0.5)) ^ 2.0)) / l))) * (sqrt((d / h)) * sqrt((d / l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -1.02e+257], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.02 \cdot 10^{+257}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D_m}{d} \cdot \left(M_m \cdot 0.5\right)\right)}^{2}}{\ell}\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\\
\end{array}
\end{array}
if l < -1.02e257Initial program 35.9%
Simplified35.9%
clear-num35.9%
sqrt-div35.7%
metadata-eval35.7%
Applied egg-rr35.7%
Taylor expanded in d around -inf 83.4%
associate-*r*83.4%
*-commutative83.4%
unpow-183.4%
metadata-eval83.4%
pow-sqr83.4%
rem-sqrt-square83.4%
rem-square-sqrt83.2%
fabs-sqr83.2%
rem-square-sqrt83.4%
mul-1-neg83.4%
Simplified83.4%
if -1.02e257 < l Initial program 69.2%
Simplified69.2%
associate-*r/70.7%
add-sqr-sqrt43.3%
add-sqr-sqrt70.7%
div-inv70.7%
metadata-eval70.7%
Applied egg-rr70.7%
Final simplification71.3%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= M_m 3.1e-245)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(*
(fma -0.5 (* h (/ (pow (* M_m (* (/ D_m d) 0.5)) 2.0) l)) 1.0)
(sqrt (* (/ d h) (/ d l))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (M_m <= 3.1e-245) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else {
tmp = fma(-0.5, (h * (pow((M_m * ((D_m / d) * 0.5)), 2.0) / l)), 1.0) * sqrt(((d / h) * (d / l)));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (M_m <= 3.1e-245) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); else tmp = Float64(fma(-0.5, Float64(h * Float64((Float64(M_m * Float64(Float64(D_m / d) * 0.5)) ^ 2.0) / l)), 1.0) * sqrt(Float64(Float64(d / h) * Float64(d / l)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[M$95$m, 3.1e-245], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(h * N[(N[Power[N[(M$95$m * N[(N[(D$95$m / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M_m \leq 3.1 \cdot 10^{-245}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(M_m \cdot \left(\frac{D_m}{d} \cdot 0.5\right)\right)}^{2}}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\
\end{array}
\end{array}
if M < 3.10000000000000003e-245Initial program 69.9%
Simplified70.6%
Taylor expanded in h around 0 44.8%
if 3.10000000000000003e-245 < M Initial program 65.4%
Simplified65.4%
associate-*r/67.1%
add-sqr-sqrt40.0%
add-sqr-sqrt67.1%
div-inv67.1%
metadata-eval67.1%
Applied egg-rr67.1%
expm1-log1p-u28.8%
expm1-udef19.6%
Applied egg-rr15.4%
expm1-def22.1%
expm1-log1p57.6%
*-commutative57.6%
+-commutative57.6%
fma-def57.6%
associate-/r/58.6%
*-commutative58.6%
Simplified58.6%
Final simplification51.6%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* d (exp (* -0.5 (log1p (+ (* l h) -1.0))))))
(t_1 (* (- d) (pow (* l h) -0.5))))
(if (<= d -4.5e-86)
t_1
(if (<= d -1.35e-155)
t_0
(if (<= d -1.1e-234)
t_1
(if (<= d -5e-310) t_0 (* d (* (pow l -0.5) (pow h -0.5)))))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = d * exp((-0.5 * log1p(((l * h) + -1.0))));
double t_1 = -d * pow((l * h), -0.5);
double tmp;
if (d <= -4.5e-86) {
tmp = t_1;
} else if (d <= -1.35e-155) {
tmp = t_0;
} else if (d <= -1.1e-234) {
tmp = t_1;
} else if (d <= -5e-310) {
tmp = t_0;
} else {
tmp = d * (pow(l, -0.5) * pow(h, -0.5));
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = d * Math.exp((-0.5 * Math.log1p(((l * h) + -1.0))));
double t_1 = -d * Math.pow((l * h), -0.5);
double tmp;
if (d <= -4.5e-86) {
tmp = t_1;
} else if (d <= -1.35e-155) {
tmp = t_0;
} else if (d <= -1.1e-234) {
tmp = t_1;
} else if (d <= -5e-310) {
tmp = t_0;
} else {
tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = d * math.exp((-0.5 * math.log1p(((l * h) + -1.0)))) t_1 = -d * math.pow((l * h), -0.5) tmp = 0 if d <= -4.5e-86: tmp = t_1 elif d <= -1.35e-155: tmp = t_0 elif d <= -1.1e-234: tmp = t_1 elif d <= -5e-310: tmp = t_0 else: tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5)) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(d * exp(Float64(-0.5 * log1p(Float64(Float64(l * h) + -1.0))))) t_1 = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)) tmp = 0.0 if (d <= -4.5e-86) tmp = t_1; elseif (d <= -1.35e-155) tmp = t_0; elseif (d <= -1.1e-234) tmp = t_1; elseif (d <= -5e-310) tmp = t_0; else tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(d * N[Exp[N[(-0.5 * N[Log[1 + N[(N[(l * h), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.5e-86], t$95$1, If[LessEqual[d, -1.35e-155], t$95$0, If[LessEqual[d, -1.1e-234], t$95$1, If[LessEqual[d, -5e-310], t$95$0, N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := d \cdot e^{-0.5 \cdot \mathsf{log1p}\left(\ell \cdot h + -1\right)}\\
t_1 := \left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;d \leq -4.5 \cdot 10^{-86}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -1.35 \cdot 10^{-155}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -1.1 \cdot 10^{-234}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\
\end{array}
\end{array}
if d < -4.4999999999999998e-86 or -1.34999999999999991e-155 < d < -1.1e-234Initial program 76.5%
Simplified76.5%
clear-num76.4%
sqrt-div76.5%
metadata-eval76.5%
Applied egg-rr76.5%
Taylor expanded in d around -inf 54.6%
associate-*r*54.6%
*-commutative54.6%
unpow-154.6%
metadata-eval54.6%
pow-sqr54.6%
rem-sqrt-square54.9%
rem-square-sqrt54.7%
fabs-sqr54.7%
rem-square-sqrt54.9%
mul-1-neg54.9%
Simplified54.9%
if -4.4999999999999998e-86 < d < -1.34999999999999991e-155 or -1.1e-234 < d < -4.999999999999985e-310Initial program 54.2%
Simplified54.2%
add-sqr-sqrt54.1%
pow254.1%
sqrt-prod54.1%
unpow254.1%
sqrt-prod37.9%
add-sqr-sqrt57.3%
div-inv57.3%
metadata-eval57.3%
Applied egg-rr57.3%
*-commutative57.3%
/-rgt-identity57.3%
associate-/l*57.3%
metadata-eval57.3%
times-frac57.3%
associate-*r/57.2%
*-commutative57.2%
Simplified57.2%
Taylor expanded in d around inf 21.4%
unpow-121.4%
metadata-eval21.4%
pow-sqr21.4%
rem-sqrt-square21.4%
rem-square-sqrt21.4%
fabs-sqr21.4%
rem-square-sqrt21.4%
Simplified21.4%
Taylor expanded in h around -inf 6.1%
Applied egg-rr55.1%
if -4.999999999999985e-310 < d Initial program 65.2%
Simplified65.2%
add-sqr-sqrt65.2%
pow265.2%
sqrt-prod65.2%
unpow265.2%
sqrt-prod39.9%
add-sqr-sqrt68.0%
div-inv68.0%
metadata-eval68.0%
Applied egg-rr68.0%
*-commutative68.0%
/-rgt-identity68.0%
associate-/l*68.0%
metadata-eval68.0%
times-frac68.0%
associate-*r/69.3%
*-commutative69.3%
Simplified69.3%
Taylor expanded in d around inf 41.0%
unpow-141.0%
metadata-eval41.0%
pow-sqr41.0%
rem-sqrt-square41.0%
rem-square-sqrt40.8%
fabs-sqr40.8%
rem-square-sqrt41.0%
Simplified41.0%
*-commutative41.0%
unpow-prod-down46.5%
Applied egg-rr46.5%
Final simplification50.4%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= M_m 8.2e-171)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(*
(sqrt (* (/ d h) (/ d l)))
(+ 1.0 (* -0.5 (* (/ h l) (pow (* (/ M_m 2.0) (/ D_m d)) 2.0)))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (M_m <= 8.2e-171) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else {
tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * pow(((M_m / 2.0) * (D_m / d)), 2.0))));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
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_m
real(8) :: tmp
if (m_m <= 8.2d-171) then
tmp = sqrt((d / h)) * sqrt((d / l))
else
tmp = sqrt(((d / h) * (d / l))) * (1.0d0 + ((-0.5d0) * ((h / l) * (((m_m / 2.0d0) * (d_m / d)) ** 2.0d0))))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (M_m <= 8.2e-171) {
tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
} else {
tmp = Math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * Math.pow(((M_m / 2.0) * (D_m / d)), 2.0))));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if M_m <= 8.2e-171: tmp = math.sqrt((d / h)) * math.sqrt((d / l)) else: tmp = math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * math.pow(((M_m / 2.0) * (D_m / d)), 2.0)))) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (M_m <= 8.2e-171) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); else tmp = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(M_m / 2.0) * Float64(D_m / d)) ^ 2.0))))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (M_m <= 8.2e-171)
tmp = sqrt((d / h)) * sqrt((d / l));
else
tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * (((M_m / 2.0) * (D_m / d)) ^ 2.0))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[M$95$m, 8.2e-171], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M_m \leq 8.2 \cdot 10^{-171}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M_m}{2} \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if M < 8.2e-171Initial program 68.3%
Simplified69.0%
Taylor expanded in h around 0 44.8%
if 8.2e-171 < M Initial program 66.8%
Simplified66.8%
add-sqr-sqrt66.8%
pow266.8%
sqrt-prod66.8%
unpow266.8%
sqrt-prod39.6%
add-sqr-sqrt67.7%
div-inv67.7%
metadata-eval67.7%
Applied egg-rr67.7%
*-commutative67.7%
/-rgt-identity67.7%
associate-/l*67.7%
metadata-eval67.7%
times-frac68.5%
associate-*r/67.6%
*-commutative67.6%
Simplified67.6%
Applied egg-rr14.3%
expm1-def20.9%
expm1-log1p59.0%
times-frac59.0%
Simplified59.0%
Final simplification51.2%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= d 8.8e-241) (* d (- (sqrt (/ (/ 1.0 h) l)))) (* d (* (pow l -0.5) (pow h -0.5)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= 8.8e-241) {
tmp = d * -sqrt(((1.0 / h) / l));
} else {
tmp = d * (pow(l, -0.5) * pow(h, -0.5));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
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_m
real(8) :: tmp
if (d <= 8.8d-241) then
tmp = d * -sqrt(((1.0d0 / h) / l))
else
tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= 8.8e-241) {
tmp = d * -Math.sqrt(((1.0 / h) / l));
} else {
tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if d <= 8.8e-241: tmp = d * -math.sqrt(((1.0 / h) / l)) else: tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5)) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (d <= 8.8e-241) tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / h) / l)))); else tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (d <= 8.8e-241)
tmp = d * -sqrt(((1.0 / h) / l));
else
tmp = d * ((l ^ -0.5) * (h ^ -0.5));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, 8.8e-241], N[(d * (-N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 8.8 \cdot 10^{-241}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\
\end{array}
\end{array}
if d < 8.7999999999999997e-241Initial program 65.1%
Simplified65.2%
add-sqr-sqrt65.2%
pow265.2%
sqrt-prod65.2%
unpow265.2%
sqrt-prod44.0%
add-sqr-sqrt66.0%
div-inv66.0%
metadata-eval66.0%
Applied egg-rr66.0%
*-commutative66.0%
/-rgt-identity66.0%
associate-/l*66.0%
metadata-eval66.0%
times-frac66.6%
associate-*r/65.9%
associate-*l*65.8%
*-commutative65.8%
Simplified65.8%
clear-num65.8%
sqrt-div65.9%
metadata-eval65.9%
Applied egg-rr65.9%
Taylor expanded in d around -inf 38.7%
mul-1-neg38.7%
distribute-rgt-neg-in38.7%
associate-/r*38.7%
Simplified38.7%
if 8.7999999999999997e-241 < d Initial program 70.6%
Simplified70.6%
add-sqr-sqrt70.6%
pow270.6%
sqrt-prod70.6%
unpow270.6%
sqrt-prod42.8%
add-sqr-sqrt73.7%
div-inv73.7%
metadata-eval73.7%
Applied egg-rr73.7%
*-commutative73.7%
/-rgt-identity73.7%
associate-/l*73.7%
metadata-eval73.7%
times-frac73.7%
associate-*r/75.3%
*-commutative75.3%
Simplified75.3%
Taylor expanded in d around inf 46.4%
unpow-146.4%
metadata-eval46.4%
pow-sqr46.4%
rem-sqrt-square46.4%
rem-square-sqrt46.2%
fabs-sqr46.2%
rem-square-sqrt46.4%
Simplified46.4%
*-commutative46.4%
unpow-prod-down52.8%
Applied egg-rr52.8%
Final simplification45.2%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= d 2.7e-236) (* d (- (sqrt (/ (/ 1.0 h) l)))) (* d (/ (pow l -0.5) (sqrt h)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= 2.7e-236) {
tmp = d * -sqrt(((1.0 / h) / l));
} else {
tmp = d * (pow(l, -0.5) / sqrt(h));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
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_m
real(8) :: tmp
if (d <= 2.7d-236) then
tmp = d * -sqrt(((1.0d0 / h) / l))
else
tmp = d * ((l ** (-0.5d0)) / sqrt(h))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= 2.7e-236) {
tmp = d * -Math.sqrt(((1.0 / h) / l));
} else {
tmp = d * (Math.pow(l, -0.5) / Math.sqrt(h));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if d <= 2.7e-236: tmp = d * -math.sqrt(((1.0 / h) / l)) else: tmp = d * (math.pow(l, -0.5) / math.sqrt(h)) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (d <= 2.7e-236) tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / h) / l)))); else tmp = Float64(d * Float64((l ^ -0.5) / sqrt(h))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (d <= 2.7e-236)
tmp = d * -sqrt(((1.0 / h) / l));
else
tmp = d * ((l ^ -0.5) / sqrt(h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, 2.7e-236], N[(d * (-N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 2.7 \cdot 10^{-236}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\
\end{array}
\end{array}
if d < 2.7e-236Initial program 65.1%
Simplified65.2%
add-sqr-sqrt65.2%
pow265.2%
sqrt-prod65.2%
unpow265.2%
sqrt-prod44.0%
add-sqr-sqrt66.0%
div-inv66.0%
metadata-eval66.0%
Applied egg-rr66.0%
*-commutative66.0%
/-rgt-identity66.0%
associate-/l*66.0%
metadata-eval66.0%
times-frac66.6%
associate-*r/65.9%
associate-*l*65.8%
*-commutative65.8%
Simplified65.8%
clear-num65.8%
sqrt-div65.9%
metadata-eval65.9%
Applied egg-rr65.9%
Taylor expanded in d around -inf 38.7%
mul-1-neg38.7%
distribute-rgt-neg-in38.7%
associate-/r*38.7%
Simplified38.7%
if 2.7e-236 < d Initial program 70.6%
Simplified70.6%
Taylor expanded in d around inf 46.4%
*-commutative46.4%
associate-/r*47.6%
Simplified47.6%
sqrt-div52.7%
clear-num52.7%
inv-pow52.7%
sqrt-pow152.7%
metadata-eval52.7%
Applied egg-rr52.7%
associate-/l*52.8%
*-lft-identity52.8%
Simplified52.8%
Final simplification45.2%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= h -1e-17) (* d (sqrt (/ h l))) (* d (sqrt (/ 1.0 (* l h))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (h <= -1e-17) {
tmp = d * sqrt((h / l));
} else {
tmp = d * sqrt((1.0 / (l * h)));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
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_m
real(8) :: tmp
if (h <= (-1d-17)) then
tmp = d * sqrt((h / l))
else
tmp = d * sqrt((1.0d0 / (l * h)))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (h <= -1e-17) {
tmp = d * Math.sqrt((h / l));
} else {
tmp = d * Math.sqrt((1.0 / (l * h)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if h <= -1e-17: tmp = d * math.sqrt((h / l)) else: tmp = d * math.sqrt((1.0 / (l * h))) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (h <= -1e-17) tmp = Float64(d * sqrt(Float64(h / l))); else tmp = Float64(d * sqrt(Float64(1.0 / Float64(l * h)))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (h <= -1e-17)
tmp = d * sqrt((h / l));
else
tmp = d * sqrt((1.0 / (l * h)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[h, -1e-17], N[(d * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -1 \cdot 10^{-17}:\\
\;\;\;\;d \cdot \sqrt{\frac{h}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\end{array}
\end{array}
if h < -1.00000000000000007e-17Initial program 65.0%
Simplified65.0%
Taylor expanded in d around inf 6.5%
*-commutative6.5%
associate-/r*6.5%
Simplified6.5%
expm1-log1p-u6.5%
expm1-udef6.3%
Applied egg-rr23.4%
expm1-def21.7%
expm1-log1p21.7%
Simplified21.7%
if -1.00000000000000007e-17 < h Initial program 68.4%
Simplified68.4%
Taylor expanded in d around inf 32.3%
Final simplification29.9%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= h -8.8e-21) (* d (sqrt (/ h l))) (* d (sqrt (/ (/ 1.0 l) h)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (h <= -8.8e-21) {
tmp = d * sqrt((h / l));
} else {
tmp = d * sqrt(((1.0 / l) / h));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
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_m
real(8) :: tmp
if (h <= (-8.8d-21)) then
tmp = d * sqrt((h / l))
else
tmp = d * sqrt(((1.0d0 / l) / h))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (h <= -8.8e-21) {
tmp = d * Math.sqrt((h / l));
} else {
tmp = d * Math.sqrt(((1.0 / l) / h));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if h <= -8.8e-21: tmp = d * math.sqrt((h / l)) else: tmp = d * math.sqrt(((1.0 / l) / h)) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (h <= -8.8e-21) tmp = Float64(d * sqrt(Float64(h / l))); else tmp = Float64(d * sqrt(Float64(Float64(1.0 / l) / h))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (h <= -8.8e-21)
tmp = d * sqrt((h / l));
else
tmp = d * sqrt(((1.0 / l) / h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[h, -8.8e-21], N[(d * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -8.8 \cdot 10^{-21}:\\
\;\;\;\;d \cdot \sqrt{\frac{h}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\
\end{array}
\end{array}
if h < -8.8000000000000002e-21Initial program 65.0%
Simplified65.0%
Taylor expanded in d around inf 6.5%
*-commutative6.5%
associate-/r*6.5%
Simplified6.5%
expm1-log1p-u6.5%
expm1-udef6.3%
Applied egg-rr23.4%
expm1-def21.7%
expm1-log1p21.7%
Simplified21.7%
if -8.8000000000000002e-21 < h Initial program 68.4%
Simplified68.4%
Taylor expanded in d around inf 32.3%
*-commutative32.3%
associate-/r*33.0%
Simplified33.0%
Final simplification30.5%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= d -6.2e-235) (* (- d) (pow (* l h) -0.5)) (* d (sqrt (/ (/ 1.0 l) h)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= -6.2e-235) {
tmp = -d * pow((l * h), -0.5);
} else {
tmp = d * sqrt(((1.0 / l) / h));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
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_m
real(8) :: tmp
if (d <= (-6.2d-235)) then
tmp = -d * ((l * h) ** (-0.5d0))
else
tmp = d * sqrt(((1.0d0 / l) / h))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= -6.2e-235) {
tmp = -d * Math.pow((l * h), -0.5);
} else {
tmp = d * Math.sqrt(((1.0 / l) / h));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if d <= -6.2e-235: tmp = -d * math.pow((l * h), -0.5) else: tmp = d * math.sqrt(((1.0 / l) / h)) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (d <= -6.2e-235) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); else tmp = Float64(d * sqrt(Float64(Float64(1.0 / l) / h))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (d <= -6.2e-235)
tmp = -d * ((l * h) ^ -0.5);
else
tmp = d * sqrt(((1.0 / l) / h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, -6.2e-235], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -6.2 \cdot 10^{-235}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\
\end{array}
\end{array}
if d < -6.2e-235Initial program 74.9%
Simplified74.9%
clear-num74.8%
sqrt-div74.8%
metadata-eval74.8%
Applied egg-rr74.8%
Taylor expanded in d around -inf 47.2%
associate-*r*47.2%
*-commutative47.2%
unpow-147.2%
metadata-eval47.2%
pow-sqr47.3%
rem-sqrt-square47.5%
rem-square-sqrt47.3%
fabs-sqr47.3%
rem-square-sqrt47.5%
mul-1-neg47.5%
Simplified47.5%
if -6.2e-235 < d Initial program 62.9%
Simplified63.0%
Taylor expanded in d around inf 40.3%
*-commutative40.3%
associate-/r*41.2%
Simplified41.2%
Final simplification43.7%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= h -3.5e-25) (* d (sqrt (/ h l))) (* d (pow (* l h) -0.5))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (h <= -3.5e-25) {
tmp = d * sqrt((h / l));
} else {
tmp = d * pow((l * h), -0.5);
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
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_m
real(8) :: tmp
if (h <= (-3.5d-25)) then
tmp = d * sqrt((h / l))
else
tmp = d * ((l * h) ** (-0.5d0))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (h <= -3.5e-25) {
tmp = d * Math.sqrt((h / l));
} else {
tmp = d * Math.pow((l * h), -0.5);
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if h <= -3.5e-25: tmp = d * math.sqrt((h / l)) else: tmp = d * math.pow((l * h), -0.5) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (h <= -3.5e-25) tmp = Float64(d * sqrt(Float64(h / l))); else tmp = Float64(d * (Float64(l * h) ^ -0.5)); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (h <= -3.5e-25)
tmp = d * sqrt((h / l));
else
tmp = d * ((l * h) ^ -0.5);
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[h, -3.5e-25], N[(d * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -3.5 \cdot 10^{-25}:\\
\;\;\;\;d \cdot \sqrt{\frac{h}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\end{array}
\end{array}
if h < -3.5000000000000002e-25Initial program 65.0%
Simplified65.0%
Taylor expanded in d around inf 6.5%
*-commutative6.5%
associate-/r*6.5%
Simplified6.5%
expm1-log1p-u6.5%
expm1-udef6.3%
Applied egg-rr23.4%
expm1-def21.7%
expm1-log1p21.7%
Simplified21.7%
if -3.5000000000000002e-25 < h Initial program 68.4%
Simplified68.4%
add-sqr-sqrt68.4%
pow268.4%
sqrt-prod68.4%
unpow268.4%
sqrt-prod42.4%
add-sqr-sqrt70.9%
div-inv70.9%
metadata-eval70.9%
Applied egg-rr70.9%
*-commutative70.9%
/-rgt-identity70.9%
associate-/l*70.9%
metadata-eval70.9%
times-frac71.3%
associate-*r/72.2%
*-commutative72.2%
Simplified72.2%
Taylor expanded in d around inf 32.3%
unpow-132.3%
metadata-eval32.3%
pow-sqr32.3%
rem-sqrt-square32.3%
rem-square-sqrt32.2%
fabs-sqr32.2%
rem-square-sqrt32.3%
Simplified32.3%
Final simplification29.9%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (* d (sqrt (/ h l))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
return d * sqrt((h / l));
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
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_m
code = d * sqrt((h / l))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
return d * Math.sqrt((h / l));
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): return d * math.sqrt((h / l))
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) return Float64(d * sqrt(Float64(h / l))) end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
tmp = d * sqrt((h / l));
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
d \cdot \sqrt{\frac{h}{\ell}}
\end{array}
Initial program 67.6%
Simplified67.7%
Taylor expanded in d around inf 26.5%
*-commutative26.5%
associate-/r*27.1%
Simplified27.1%
expm1-log1p-u26.6%
expm1-udef17.5%
Applied egg-rr8.1%
expm1-def7.9%
expm1-log1p7.9%
Simplified7.9%
Final simplification7.9%
herbie shell --seed 2024021
(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)))))