
(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 18 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))))
(if (<= l -5e-310)
(*
(/ t_0 (sqrt (- h)))
(*
(/ t_0 (sqrt (- l)))
(+ 1.0 (* (/ h l) (* (pow (* (/ M_m 2.0) (/ D_m d)) 2.0) -0.5)))))
(*
(/ d (* (sqrt l) (sqrt h)))
(+ 1.0 (* -0.5 (* (/ h l) (pow (* (/ D_m d) (* M_m 0.5)) 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 tmp;
if (l <= -5e-310) {
tmp = (t_0 / sqrt(-h)) * ((t_0 / sqrt(-l)) * (1.0 + ((h / l) * (pow(((M_m / 2.0) * (D_m / d)), 2.0) * -0.5))));
} else {
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * pow(((D_m / d) * (M_m * 0.5)), 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) :: t_0
real(8) :: tmp
t_0 = sqrt(-d)
if (l <= (-5d-310)) then
tmp = (t_0 / sqrt(-h)) * ((t_0 / sqrt(-l)) * (1.0d0 + ((h / l) * ((((m_m / 2.0d0) * (d_m / d)) ** 2.0d0) * (-0.5d0)))))
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + ((-0.5d0) * ((h / l) * (((d_m / d) * (m_m * 0.5d0)) ** 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 t_0 = Math.sqrt(-d);
double tmp;
if (l <= -5e-310) {
tmp = (t_0 / Math.sqrt(-h)) * ((t_0 / Math.sqrt(-l)) * (1.0 + ((h / l) * (Math.pow(((M_m / 2.0) * (D_m / d)), 2.0) * -0.5))));
} else {
tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * Math.pow(((D_m / d) * (M_m * 0.5)), 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): t_0 = math.sqrt(-d) tmp = 0 if l <= -5e-310: tmp = (t_0 / math.sqrt(-h)) * ((t_0 / math.sqrt(-l)) * (1.0 + ((h / l) * (math.pow(((M_m / 2.0) * (D_m / d)), 2.0) * -0.5)))) else: tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * math.pow(((D_m / d) * (M_m * 0.5)), 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)) tmp = 0.0 if (l <= -5e-310) tmp = Float64(Float64(t_0 / sqrt(Float64(-h))) * Float64(Float64(t_0 / sqrt(Float64(-l))) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(M_m / 2.0) * Float64(D_m / d)) ^ 2.0) * -0.5))))); else tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(D_m / d) * Float64(M_m * 0.5)) ^ 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)
t_0 = sqrt(-d);
tmp = 0.0;
if (l <= -5e-310)
tmp = (t_0 / sqrt(-h)) * ((t_0 / sqrt(-l)) * (1.0 + ((h / l) * ((((M_m / 2.0) * (D_m / d)) ^ 2.0) * -0.5))));
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * (((D_m / d) * (M_m * 0.5)) ^ 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_] := Block[{t$95$0 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[l, -5e-310], N[(N[(t$95$0 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[(t$95$0 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $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}
t_0 := \sqrt{-d}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{t\_0}{\sqrt{-h}} \cdot \left(\frac{t\_0}{\sqrt{-\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M\_m}{2} \cdot \frac{D\_m}{d}\right)}^{2} \cdot -0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D\_m}{d} \cdot \left(M\_m \cdot 0.5\right)\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if l < -4.999999999999985e-310Initial program 66.5%
Simplified65.7%
frac-2neg65.7%
sqrt-div78.9%
Applied egg-rr78.9%
frac-2neg78.9%
sqrt-div89.5%
Applied egg-rr89.5%
if -4.999999999999985e-310 < l Initial program 62.7%
Simplified62.7%
Applied egg-rr77.7%
Final simplification83.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
(let* ((t_0 (sqrt (- d))))
(if (<= l -1.02e+161)
(*
(sqrt (/ d h))
(*
(/ t_0 (sqrt (- l)))
(fma (/ h l) (* -0.5 (pow (/ D_m (* d (/ 2.0 M_m))) 2.0)) 1.0)))
(if (<= l -5e-310)
(*
(/ t_0 (sqrt (- h)))
(*
(+ 1.0 (* (/ h l) (* (pow (* (/ M_m 2.0) (/ D_m d)) 2.0) -0.5)))
(sqrt (/ d l))))
(*
(/ d (* (sqrt l) (sqrt h)))
(+ 1.0 (* -0.5 (* (/ h l) (pow (* (/ D_m d) (* M_m 0.5)) 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 tmp;
if (l <= -1.02e+161) {
tmp = sqrt((d / h)) * ((t_0 / sqrt(-l)) * fma((h / l), (-0.5 * pow((D_m / (d * (2.0 / M_m))), 2.0)), 1.0));
} else if (l <= -5e-310) {
tmp = (t_0 / sqrt(-h)) * ((1.0 + ((h / l) * (pow(((M_m / 2.0) * (D_m / d)), 2.0) * -0.5))) * sqrt((d / l)));
} else {
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * pow(((D_m / d) * (M_m * 0.5)), 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)) tmp = 0.0 if (l <= -1.02e+161) tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(t_0 / sqrt(Float64(-l))) * fma(Float64(h / l), Float64(-0.5 * (Float64(D_m / Float64(d * Float64(2.0 / M_m))) ^ 2.0)), 1.0))); elseif (l <= -5e-310) tmp = Float64(Float64(t_0 / sqrt(Float64(-h))) * Float64(Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(M_m / 2.0) * Float64(D_m / d)) ^ 2.0) * -0.5))) * sqrt(Float64(d / l)))); else tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(D_m / d) * Float64(M_m * 0.5)) ^ 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]}, If[LessEqual[l, -1.02e+161], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(t$95$0 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(D$95$m / N[(d * N[(2.0 / M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-310], N[(N[(t$95$0 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $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}
t_0 := \sqrt{-d}\\
\mathbf{if}\;\ell \leq -1.02 \cdot 10^{+161}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{t\_0}{\sqrt{-\ell}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(\frac{D\_m}{d \cdot \frac{2}{M\_m}}\right)}^{2}, 1\right)\right)\\
\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{t\_0}{\sqrt{-h}} \cdot \left(\left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M\_m}{2} \cdot \frac{D\_m}{d}\right)}^{2} \cdot -0.5\right)\right) \cdot \sqrt{\frac{d}{\ell}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D\_m}{d} \cdot \left(M\_m \cdot 0.5\right)\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if l < -1.02e161Initial program 41.4%
Simplified44.4%
frac-2neg51.2%
sqrt-div85.2%
Applied egg-rr64.6%
if -1.02e161 < l < -4.999999999999985e-310Initial program 73.0%
Simplified71.2%
frac-2neg71.2%
sqrt-div86.1%
Applied egg-rr86.1%
if -4.999999999999985e-310 < l Initial program 62.7%
Simplified62.7%
Applied egg-rr77.7%
Final simplification79.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 (<= h -5.2e+238)
(-
(* (sqrt (/ h (pow l 3.0))) (* 0.125 (/ (pow (* M_m D_m) 2.0) d)))
(* d (pow (* l h) -0.5)))
(if (<= h -1e-310)
(*
(*
(/ (sqrt (- d)) (sqrt (- l)))
(+ 1.0 (* (/ h l) (* (pow (* (/ M_m 2.0) (/ D_m d)) 2.0) -0.5))))
(sqrt (/ d h)))
(*
(/ d (* (sqrt l) (sqrt h)))
(+ 1.0 (* -0.5 (* (/ h l) (pow (* (/ D_m d) (* M_m 0.5)) 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 (h <= -5.2e+238) {
tmp = (sqrt((h / pow(l, 3.0))) * (0.125 * (pow((M_m * D_m), 2.0) / d))) - (d * pow((l * h), -0.5));
} else if (h <= -1e-310) {
tmp = ((sqrt(-d) / sqrt(-l)) * (1.0 + ((h / l) * (pow(((M_m / 2.0) * (D_m / d)), 2.0) * -0.5)))) * sqrt((d / h));
} else {
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * pow(((D_m / d) * (M_m * 0.5)), 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 (h <= (-5.2d+238)) then
tmp = (sqrt((h / (l ** 3.0d0))) * (0.125d0 * (((m_m * d_m) ** 2.0d0) / d))) - (d * ((l * h) ** (-0.5d0)))
else if (h <= (-1d-310)) then
tmp = ((sqrt(-d) / sqrt(-l)) * (1.0d0 + ((h / l) * ((((m_m / 2.0d0) * (d_m / d)) ** 2.0d0) * (-0.5d0))))) * sqrt((d / h))
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + ((-0.5d0) * ((h / l) * (((d_m / d) * (m_m * 0.5d0)) ** 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 (h <= -5.2e+238) {
tmp = (Math.sqrt((h / Math.pow(l, 3.0))) * (0.125 * (Math.pow((M_m * D_m), 2.0) / d))) - (d * Math.pow((l * h), -0.5));
} else if (h <= -1e-310) {
tmp = ((Math.sqrt(-d) / Math.sqrt(-l)) * (1.0 + ((h / l) * (Math.pow(((M_m / 2.0) * (D_m / d)), 2.0) * -0.5)))) * Math.sqrt((d / h));
} else {
tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * Math.pow(((D_m / d) * (M_m * 0.5)), 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 h <= -5.2e+238: tmp = (math.sqrt((h / math.pow(l, 3.0))) * (0.125 * (math.pow((M_m * D_m), 2.0) / d))) - (d * math.pow((l * h), -0.5)) elif h <= -1e-310: tmp = ((math.sqrt(-d) / math.sqrt(-l)) * (1.0 + ((h / l) * (math.pow(((M_m / 2.0) * (D_m / d)), 2.0) * -0.5)))) * math.sqrt((d / h)) else: tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * math.pow(((D_m / d) * (M_m * 0.5)), 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 (h <= -5.2e+238) tmp = Float64(Float64(sqrt(Float64(h / (l ^ 3.0))) * Float64(0.125 * Float64((Float64(M_m * D_m) ^ 2.0) / d))) - Float64(d * (Float64(l * h) ^ -0.5))); elseif (h <= -1e-310) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-l))) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(M_m / 2.0) * Float64(D_m / d)) ^ 2.0) * -0.5)))) * sqrt(Float64(d / h))); else tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(D_m / d) * Float64(M_m * 0.5)) ^ 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 (h <= -5.2e+238)
tmp = (sqrt((h / (l ^ 3.0))) * (0.125 * (((M_m * D_m) ^ 2.0) / d))) - (d * ((l * h) ^ -0.5));
elseif (h <= -1e-310)
tmp = ((sqrt(-d) / sqrt(-l)) * (1.0 + ((h / l) * ((((M_m / 2.0) * (D_m / d)) ^ 2.0) * -0.5)))) * sqrt((d / h));
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * (((D_m / d) * (M_m * 0.5)) ^ 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[h, -5.2e+238], N[(N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(0.125 * N[(N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -1e-310], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $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}\;h \leq -5.2 \cdot 10^{+238}:\\
\;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(0.125 \cdot \frac{{\left(M\_m \cdot D\_m\right)}^{2}}{d}\right) - d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{elif}\;h \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M\_m}{2} \cdot \frac{D\_m}{d}\right)}^{2} \cdot -0.5\right)\right)\right) \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D\_m}{d} \cdot \left(M\_m \cdot 0.5\right)\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if h < -5.1999999999999999e238Initial program 35.3%
Simplified35.2%
frac-2neg35.2%
sqrt-div76.7%
Applied egg-rr76.7%
Taylor expanded in d around -inf 41.5%
+-commutative41.5%
mul-1-neg41.5%
unsub-neg41.5%
associate-*r*41.5%
*-commutative41.5%
unpow241.5%
unpow241.5%
swap-sqr70.7%
unpow270.7%
unpow-170.7%
metadata-eval70.7%
pow-sqr70.7%
rem-sqrt-square70.7%
Simplified70.7%
if -5.1999999999999999e238 < h < -9.999999999999969e-311Initial program 71.0%
Simplified70.1%
frac-2neg79.2%
sqrt-div89.7%
Applied egg-rr78.8%
if -9.999999999999969e-311 < h Initial program 62.7%
Simplified62.7%
Applied egg-rr77.7%
Final simplification77.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 -2.7e+237)
(-
(* (sqrt (/ h (pow l 3.0))) (* 0.125 (/ (pow (* M_m D_m) 2.0) d)))
(* d (pow (* l h) -0.5)))
(if (<= h -1e-310)
(*
(sqrt (/ d h))
(*
(/ (sqrt (- d)) (sqrt (- l)))
(+ 1.0 (* (/ h l) (* -0.5 (pow (/ (/ D_m (/ 2.0 M_m)) d) 2.0))))))
(*
(/ d (* (sqrt l) (sqrt h)))
(+ 1.0 (* -0.5 (* (/ h l) (pow (* (/ D_m d) (* M_m 0.5)) 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 (h <= -2.7e+237) {
tmp = (sqrt((h / pow(l, 3.0))) * (0.125 * (pow((M_m * D_m), 2.0) / d))) - (d * pow((l * h), -0.5));
} else if (h <= -1e-310) {
tmp = sqrt((d / h)) * ((sqrt(-d) / sqrt(-l)) * (1.0 + ((h / l) * (-0.5 * pow(((D_m / (2.0 / M_m)) / d), 2.0)))));
} else {
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * pow(((D_m / d) * (M_m * 0.5)), 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 (h <= (-2.7d+237)) then
tmp = (sqrt((h / (l ** 3.0d0))) * (0.125d0 * (((m_m * d_m) ** 2.0d0) / d))) - (d * ((l * h) ** (-0.5d0)))
else if (h <= (-1d-310)) then
tmp = sqrt((d / h)) * ((sqrt(-d) / sqrt(-l)) * (1.0d0 + ((h / l) * ((-0.5d0) * (((d_m / (2.0d0 / m_m)) / d) ** 2.0d0)))))
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + ((-0.5d0) * ((h / l) * (((d_m / d) * (m_m * 0.5d0)) ** 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 (h <= -2.7e+237) {
tmp = (Math.sqrt((h / Math.pow(l, 3.0))) * (0.125 * (Math.pow((M_m * D_m), 2.0) / d))) - (d * Math.pow((l * h), -0.5));
} else if (h <= -1e-310) {
tmp = Math.sqrt((d / h)) * ((Math.sqrt(-d) / Math.sqrt(-l)) * (1.0 + ((h / l) * (-0.5 * Math.pow(((D_m / (2.0 / M_m)) / d), 2.0)))));
} else {
tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * Math.pow(((D_m / d) * (M_m * 0.5)), 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 h <= -2.7e+237: tmp = (math.sqrt((h / math.pow(l, 3.0))) * (0.125 * (math.pow((M_m * D_m), 2.0) / d))) - (d * math.pow((l * h), -0.5)) elif h <= -1e-310: tmp = math.sqrt((d / h)) * ((math.sqrt(-d) / math.sqrt(-l)) * (1.0 + ((h / l) * (-0.5 * math.pow(((D_m / (2.0 / M_m)) / d), 2.0))))) else: tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * math.pow(((D_m / d) * (M_m * 0.5)), 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 (h <= -2.7e+237) tmp = Float64(Float64(sqrt(Float64(h / (l ^ 3.0))) * Float64(0.125 * Float64((Float64(M_m * D_m) ^ 2.0) / d))) - Float64(d * (Float64(l * h) ^ -0.5))); elseif (h <= -1e-310) 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(D_m / Float64(2.0 / M_m)) / d) ^ 2.0)))))); else tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(D_m / d) * Float64(M_m * 0.5)) ^ 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 (h <= -2.7e+237)
tmp = (sqrt((h / (l ^ 3.0))) * (0.125 * (((M_m * D_m) ^ 2.0) / d))) - (d * ((l * h) ^ -0.5));
elseif (h <= -1e-310)
tmp = sqrt((d / h)) * ((sqrt(-d) / sqrt(-l)) * (1.0 + ((h / l) * (-0.5 * (((D_m / (2.0 / M_m)) / d) ^ 2.0)))));
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * (((D_m / d) * (M_m * 0.5)) ^ 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[h, -2.7e+237], N[(N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(0.125 * N[(N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -1e-310], 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[(D$95$m / N[(2.0 / M$95$m), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $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}\;h \leq -2.7 \cdot 10^{+237}:\\
\;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(0.125 \cdot \frac{{\left(M\_m \cdot D\_m\right)}^{2}}{d}\right) - d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{elif}\;h \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{\frac{D\_m}{\frac{2}{M\_m}}}{d}\right)}^{2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D\_m}{d} \cdot \left(M\_m \cdot 0.5\right)\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if h < -2.6999999999999999e237Initial program 35.3%
Simplified35.2%
frac-2neg35.2%
sqrt-div76.7%
Applied egg-rr76.7%
Taylor expanded in d around -inf 41.5%
+-commutative41.5%
mul-1-neg41.5%
unsub-neg41.5%
associate-*r*41.5%
*-commutative41.5%
unpow241.5%
unpow241.5%
swap-sqr70.7%
unpow270.7%
unpow-170.7%
metadata-eval70.7%
pow-sqr70.7%
rem-sqrt-square70.7%
Simplified70.7%
if -2.6999999999999999e237 < h < -9.999999999999969e-311Initial program 71.0%
Simplified70.1%
clear-num70.1%
frac-times70.9%
*-un-lft-identity70.9%
associate-/r*70.2%
Applied egg-rr70.2%
frac-2neg79.2%
sqrt-div89.7%
Applied egg-rr78.9%
if -9.999999999999969e-311 < h Initial program 62.7%
Simplified62.7%
Applied egg-rr77.7%
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
(let* ((t_0 (pow (* (/ D_m d) (* M_m 0.5)) 2.0)))
(if (<= d -1.78e-93)
(*
(* (/ (sqrt (- d)) (sqrt (- l))) (sqrt (/ d h)))
(- 1.0 (* 0.5 (/ (* h t_0) l))))
(if (<= d 1.15e-306)
(-
(* (sqrt (/ h (pow l 3.0))) (* 0.125 (/ (pow (* M_m D_m) 2.0) d)))
(* d (pow (* l h) -0.5)))
(* (/ d (* (sqrt l) (sqrt h))) (+ 1.0 (* -0.5 (* (/ h l) t_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 = pow(((D_m / d) * (M_m * 0.5)), 2.0);
double tmp;
if (d <= -1.78e-93) {
tmp = ((sqrt(-d) / sqrt(-l)) * sqrt((d / h))) * (1.0 - (0.5 * ((h * t_0) / l)));
} else if (d <= 1.15e-306) {
tmp = (sqrt((h / pow(l, 3.0))) * (0.125 * (pow((M_m * D_m), 2.0) / d))) - (d * pow((l * h), -0.5));
} else {
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * t_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) :: t_0
real(8) :: tmp
t_0 = ((d_m / d) * (m_m * 0.5d0)) ** 2.0d0
if (d <= (-1.78d-93)) then
tmp = ((sqrt(-d) / sqrt(-l)) * sqrt((d / h))) * (1.0d0 - (0.5d0 * ((h * t_0) / l)))
else if (d <= 1.15d-306) then
tmp = (sqrt((h / (l ** 3.0d0))) * (0.125d0 * (((m_m * d_m) ** 2.0d0) / d))) - (d * ((l * h) ** (-0.5d0)))
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + ((-0.5d0) * ((h / l) * t_0)))
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 t_0 = Math.pow(((D_m / d) * (M_m * 0.5)), 2.0);
double tmp;
if (d <= -1.78e-93) {
tmp = ((Math.sqrt(-d) / Math.sqrt(-l)) * Math.sqrt((d / h))) * (1.0 - (0.5 * ((h * t_0) / l)));
} else if (d <= 1.15e-306) {
tmp = (Math.sqrt((h / Math.pow(l, 3.0))) * (0.125 * (Math.pow((M_m * D_m), 2.0) / d))) - (d * Math.pow((l * h), -0.5));
} else {
tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * t_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): t_0 = math.pow(((D_m / d) * (M_m * 0.5)), 2.0) tmp = 0 if d <= -1.78e-93: tmp = ((math.sqrt(-d) / math.sqrt(-l)) * math.sqrt((d / h))) * (1.0 - (0.5 * ((h * t_0) / l))) elif d <= 1.15e-306: tmp = (math.sqrt((h / math.pow(l, 3.0))) * (0.125 * (math.pow((M_m * D_m), 2.0) / d))) - (d * math.pow((l * h), -0.5)) else: tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * t_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 = Float64(Float64(D_m / d) * Float64(M_m * 0.5)) ^ 2.0 tmp = 0.0 if (d <= -1.78e-93) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-l))) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * t_0) / l)))); elseif (d <= 1.15e-306) tmp = Float64(Float64(sqrt(Float64(h / (l ^ 3.0))) * Float64(0.125 * Float64((Float64(M_m * D_m) ^ 2.0) / d))) - Float64(d * (Float64(l * h) ^ -0.5))); else tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * t_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)
t_0 = ((D_m / d) * (M_m * 0.5)) ^ 2.0;
tmp = 0.0;
if (d <= -1.78e-93)
tmp = ((sqrt(-d) / sqrt(-l)) * sqrt((d / h))) * (1.0 - (0.5 * ((h * t_0) / l)));
elseif (d <= 1.15e-306)
tmp = (sqrt((h / (l ^ 3.0))) * (0.125 * (((M_m * D_m) ^ 2.0) / d))) - (d * ((l * h) ^ -0.5));
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * t_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_] := Block[{t$95$0 = N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[d, -1.78e-93], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * t$95$0), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.15e-306], N[(N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(0.125 * N[(N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * t$95$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 := {\left(\frac{D\_m}{d} \cdot \left(M\_m \cdot 0.5\right)\right)}^{2}\\
\mathbf{if}\;d \leq -1.78 \cdot 10^{-93}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot t\_0}{\ell}\right)\\
\mathbf{elif}\;d \leq 1.15 \cdot 10^{-306}:\\
\;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(0.125 \cdot \frac{{\left(M\_m \cdot D\_m\right)}^{2}}{d}\right) - d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot t\_0\right)\right)\\
\end{array}
\end{array}
if d < -1.7799999999999999e-93Initial program 81.8%
Simplified81.7%
associate-*r/82.0%
div-inv82.0%
metadata-eval82.0%
Applied egg-rr82.0%
frac-2neg88.9%
sqrt-div92.9%
Applied egg-rr88.1%
if -1.7799999999999999e-93 < d < 1.14999999999999995e-306Initial program 34.5%
Simplified34.3%
frac-2neg34.3%
sqrt-div56.4%
Applied egg-rr56.4%
Taylor expanded in d around -inf 49.5%
+-commutative49.5%
mul-1-neg49.5%
unsub-neg49.5%
associate-*r*49.5%
*-commutative49.5%
unpow249.5%
unpow249.5%
swap-sqr58.1%
unpow258.1%
unpow-158.1%
metadata-eval58.1%
pow-sqr58.1%
rem-sqrt-square58.1%
Simplified58.1%
if 1.14999999999999995e-306 < d Initial program 63.7%
Simplified63.7%
Applied egg-rr79.0%
Final simplification78.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 (<= l -5e-310)
(*
(/ (sqrt (- d)) (sqrt (- h)))
(*
(+ 1.0 (* (/ h l) (* (pow (* (/ M_m 2.0) (/ D_m d)) 2.0) -0.5)))
(sqrt (/ d l))))
(*
(/ d (* (sqrt l) (sqrt h)))
(+ 1.0 (* -0.5 (* (/ h l) (pow (* (/ D_m d) (* M_m 0.5)) 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 <= -5e-310) {
tmp = (sqrt(-d) / sqrt(-h)) * ((1.0 + ((h / l) * (pow(((M_m / 2.0) * (D_m / d)), 2.0) * -0.5))) * sqrt((d / l)));
} else {
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * pow(((D_m / d) * (M_m * 0.5)), 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 <= (-5d-310)) then
tmp = (sqrt(-d) / sqrt(-h)) * ((1.0d0 + ((h / l) * ((((m_m / 2.0d0) * (d_m / d)) ** 2.0d0) * (-0.5d0)))) * sqrt((d / l)))
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + ((-0.5d0) * ((h / l) * (((d_m / d) * (m_m * 0.5d0)) ** 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 <= -5e-310) {
tmp = (Math.sqrt(-d) / Math.sqrt(-h)) * ((1.0 + ((h / l) * (Math.pow(((M_m / 2.0) * (D_m / d)), 2.0) * -0.5))) * Math.sqrt((d / l)));
} else {
tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * Math.pow(((D_m / d) * (M_m * 0.5)), 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 <= -5e-310: tmp = (math.sqrt(-d) / math.sqrt(-h)) * ((1.0 + ((h / l) * (math.pow(((M_m / 2.0) * (D_m / d)), 2.0) * -0.5))) * math.sqrt((d / l))) else: tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * math.pow(((D_m / d) * (M_m * 0.5)), 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 <= -5e-310) tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(M_m / 2.0) * Float64(D_m / d)) ^ 2.0) * -0.5))) * sqrt(Float64(d / l)))); else tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(D_m / d) * Float64(M_m * 0.5)) ^ 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 <= -5e-310)
tmp = (sqrt(-d) / sqrt(-h)) * ((1.0 + ((h / l) * ((((M_m / 2.0) * (D_m / d)) ^ 2.0) * -0.5))) * sqrt((d / l)));
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * (((D_m / d) * (M_m * 0.5)) ^ 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, -5e-310], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $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 -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M\_m}{2} \cdot \frac{D\_m}{d}\right)}^{2} \cdot -0.5\right)\right) \cdot \sqrt{\frac{d}{\ell}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D\_m}{d} \cdot \left(M\_m \cdot 0.5\right)\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if l < -4.999999999999985e-310Initial program 66.5%
Simplified65.7%
frac-2neg65.7%
sqrt-div78.9%
Applied egg-rr78.9%
if -4.999999999999985e-310 < l Initial program 62.7%
Simplified62.7%
Applied egg-rr77.7%
Final simplification78.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 (<= d -1.75e-93)
(*
(* (sqrt (/ d h)) (sqrt (/ d l)))
(- 1.0 (* 0.5 (* (* h (pow (* (/ D_m d) (* M_m 0.5)) 2.0)) (/ 1.0 l)))))
(if (<= d 1.15e-306)
(-
(* (sqrt (/ h (pow l 3.0))) (* 0.125 (/ (pow (* M_m D_m) 2.0) d)))
(* d (pow (* l h) -0.5)))
(*
(fma (pow (* D_m (/ (* M_m 0.5) d)) 2.0) (* (/ h l) -0.5) 1.0)
(/ (/ d (sqrt l)) (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 <= -1.75e-93) {
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h * pow(((D_m / d) * (M_m * 0.5)), 2.0)) * (1.0 / l))));
} else if (d <= 1.15e-306) {
tmp = (sqrt((h / pow(l, 3.0))) * (0.125 * (pow((M_m * D_m), 2.0) / d))) - (d * pow((l * h), -0.5));
} else {
tmp = fma(pow((D_m * ((M_m * 0.5) / d)), 2.0), ((h / l) * -0.5), 1.0) * ((d / sqrt(l)) / 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 <= -1.75e-93) tmp = Float64(Float64(sqrt(Float64(d / 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)) * Float64(1.0 / l))))); elseif (d <= 1.15e-306) tmp = Float64(Float64(sqrt(Float64(h / (l ^ 3.0))) * Float64(0.125 * Float64((Float64(M_m * D_m) ^ 2.0) / d))) - Float64(d * (Float64(l * h) ^ -0.5))); else tmp = Float64(fma((Float64(D_m * Float64(Float64(M_m * 0.5) / d)) ^ 2.0), Float64(Float64(h / l) * -0.5), 1.0) * Float64(Float64(d / sqrt(l)) / sqrt(h))); 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[d, -1.75e-93], 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 * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.15e-306], N[(N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(0.125 * N[(N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(D$95$m * N[(N[(M$95$m * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(d / N[Sqrt[l], $MachinePrecision]), $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 -1.75 \cdot 10^{-93}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(h \cdot {\left(\frac{D\_m}{d} \cdot \left(M\_m \cdot 0.5\right)\right)}^{2}\right) \cdot \frac{1}{\ell}\right)\right)\\
\mathbf{elif}\;d \leq 1.15 \cdot 10^{-306}:\\
\;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(0.125 \cdot \frac{{\left(M\_m \cdot D\_m\right)}^{2}}{d}\right) - d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({\left(D\_m \cdot \frac{M\_m \cdot 0.5}{d}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \cdot \frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if d < -1.75e-93Initial program 81.8%
Simplified81.7%
associate-*r/82.0%
div-inv82.0%
metadata-eval82.0%
Applied egg-rr82.0%
div-inv82.0%
*-commutative82.0%
*-commutative82.0%
Applied egg-rr82.0%
if -1.75e-93 < d < 1.14999999999999995e-306Initial program 34.5%
Simplified34.3%
frac-2neg34.3%
sqrt-div56.4%
Applied egg-rr56.4%
Taylor expanded in d around -inf 49.5%
+-commutative49.5%
mul-1-neg49.5%
unsub-neg49.5%
associate-*r*49.5%
*-commutative49.5%
unpow249.5%
unpow249.5%
swap-sqr58.1%
unpow258.1%
unpow-158.1%
metadata-eval58.1%
pow-sqr58.1%
rem-sqrt-square58.1%
Simplified58.1%
if 1.14999999999999995e-306 < d Initial program 63.7%
Simplified63.7%
Applied egg-rr27.2%
expm1-def44.4%
expm1-log1p79.0%
*-commutative79.0%
Simplified76.5%
Final simplification75.1%
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 (pow (* (/ D_m d) (* M_m 0.5)) 2.0)))
(if (<= d -1.75e-93)
(*
(* (sqrt (/ d h)) (sqrt (/ d l)))
(- 1.0 (* 0.5 (* (* h t_0) (/ 1.0 l)))))
(if (<= d 1.15e-306)
(-
(* (sqrt (/ h (pow l 3.0))) (* 0.125 (/ (pow (* M_m D_m) 2.0) d)))
(* d (pow (* l h) -0.5)))
(* (/ d (* (sqrt l) (sqrt h))) (+ 1.0 (* -0.5 (* (/ h l) t_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 = pow(((D_m / d) * (M_m * 0.5)), 2.0);
double tmp;
if (d <= -1.75e-93) {
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h * t_0) * (1.0 / l))));
} else if (d <= 1.15e-306) {
tmp = (sqrt((h / pow(l, 3.0))) * (0.125 * (pow((M_m * D_m), 2.0) / d))) - (d * pow((l * h), -0.5));
} else {
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * t_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) :: t_0
real(8) :: tmp
t_0 = ((d_m / d) * (m_m * 0.5d0)) ** 2.0d0
if (d <= (-1.75d-93)) then
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0d0 - (0.5d0 * ((h * t_0) * (1.0d0 / l))))
else if (d <= 1.15d-306) then
tmp = (sqrt((h / (l ** 3.0d0))) * (0.125d0 * (((m_m * d_m) ** 2.0d0) / d))) - (d * ((l * h) ** (-0.5d0)))
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + ((-0.5d0) * ((h / l) * t_0)))
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 t_0 = Math.pow(((D_m / d) * (M_m * 0.5)), 2.0);
double tmp;
if (d <= -1.75e-93) {
tmp = (Math.sqrt((d / h)) * Math.sqrt((d / l))) * (1.0 - (0.5 * ((h * t_0) * (1.0 / l))));
} else if (d <= 1.15e-306) {
tmp = (Math.sqrt((h / Math.pow(l, 3.0))) * (0.125 * (Math.pow((M_m * D_m), 2.0) / d))) - (d * Math.pow((l * h), -0.5));
} else {
tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * t_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): t_0 = math.pow(((D_m / d) * (M_m * 0.5)), 2.0) tmp = 0 if d <= -1.75e-93: tmp = (math.sqrt((d / h)) * math.sqrt((d / l))) * (1.0 - (0.5 * ((h * t_0) * (1.0 / l)))) elif d <= 1.15e-306: tmp = (math.sqrt((h / math.pow(l, 3.0))) * (0.125 * (math.pow((M_m * D_m), 2.0) / d))) - (d * math.pow((l * h), -0.5)) else: tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * t_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 = Float64(Float64(D_m / d) * Float64(M_m * 0.5)) ^ 2.0 tmp = 0.0 if (d <= -1.75e-93) tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * t_0) * Float64(1.0 / l))))); elseif (d <= 1.15e-306) tmp = Float64(Float64(sqrt(Float64(h / (l ^ 3.0))) * Float64(0.125 * Float64((Float64(M_m * D_m) ^ 2.0) / d))) - Float64(d * (Float64(l * h) ^ -0.5))); else tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * t_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)
t_0 = ((D_m / d) * (M_m * 0.5)) ^ 2.0;
tmp = 0.0;
if (d <= -1.75e-93)
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h * t_0) * (1.0 / l))));
elseif (d <= 1.15e-306)
tmp = (sqrt((h / (l ^ 3.0))) * (0.125 * (((M_m * D_m) ^ 2.0) / d))) - (d * ((l * h) ^ -0.5));
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * t_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_] := Block[{t$95$0 = N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[d, -1.75e-93], 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 * t$95$0), $MachinePrecision] * N[(1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.15e-306], N[(N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(0.125 * N[(N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * t$95$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 := {\left(\frac{D\_m}{d} \cdot \left(M\_m \cdot 0.5\right)\right)}^{2}\\
\mathbf{if}\;d \leq -1.75 \cdot 10^{-93}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(h \cdot t\_0\right) \cdot \frac{1}{\ell}\right)\right)\\
\mathbf{elif}\;d \leq 1.15 \cdot 10^{-306}:\\
\;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(0.125 \cdot \frac{{\left(M\_m \cdot D\_m\right)}^{2}}{d}\right) - d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot t\_0\right)\right)\\
\end{array}
\end{array}
if d < -1.75e-93Initial program 81.8%
Simplified81.7%
associate-*r/82.0%
div-inv82.0%
metadata-eval82.0%
Applied egg-rr82.0%
div-inv82.0%
*-commutative82.0%
*-commutative82.0%
Applied egg-rr82.0%
if -1.75e-93 < d < 1.14999999999999995e-306Initial program 34.5%
Simplified34.3%
frac-2neg34.3%
sqrt-div56.4%
Applied egg-rr56.4%
Taylor expanded in d around -inf 49.5%
+-commutative49.5%
mul-1-neg49.5%
unsub-neg49.5%
associate-*r*49.5%
*-commutative49.5%
unpow249.5%
unpow249.5%
swap-sqr58.1%
unpow258.1%
unpow-158.1%
metadata-eval58.1%
pow-sqr58.1%
rem-sqrt-square58.1%
Simplified58.1%
if 1.14999999999999995e-306 < d Initial program 63.7%
Simplified63.7%
Applied egg-rr79.0%
Final simplification76.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 5e-298)
(*
(* (sqrt (/ d h)) (sqrt (/ d l)))
(- 1.0 (* 0.5 (* (* h (pow (* (/ D_m d) (* M_m 0.5)) 2.0)) (/ 1.0 l)))))
(*
(fma (pow (* D_m (/ (* M_m 0.5) d)) 2.0) (* (/ h l) -0.5) 1.0)
(/ (/ d (sqrt l)) (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 (h <= 5e-298) {
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h * pow(((D_m / d) * (M_m * 0.5)), 2.0)) * (1.0 / l))));
} else {
tmp = fma(pow((D_m * ((M_m * 0.5) / d)), 2.0), ((h / l) * -0.5), 1.0) * ((d / sqrt(l)) / 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 (h <= 5e-298) tmp = Float64(Float64(sqrt(Float64(d / 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)) * Float64(1.0 / l))))); else tmp = Float64(fma((Float64(D_m * Float64(Float64(M_m * 0.5) / d)) ^ 2.0), Float64(Float64(h / l) * -0.5), 1.0) * Float64(Float64(d / sqrt(l)) / sqrt(h))); 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[h, 5e-298], 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 * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(D$95$m * N[(N[(M$95$m * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(d / N[Sqrt[l], $MachinePrecision]), $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}\;h \leq 5 \cdot 10^{-298}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(h \cdot {\left(\frac{D\_m}{d} \cdot \left(M\_m \cdot 0.5\right)\right)}^{2}\right) \cdot \frac{1}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({\left(D\_m \cdot \frac{M\_m \cdot 0.5}{d}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \cdot \frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if h < 5.0000000000000002e-298Initial program 66.0%
Simplified65.9%
associate-*r/67.5%
div-inv67.5%
metadata-eval67.5%
Applied egg-rr67.5%
div-inv67.5%
*-commutative67.5%
*-commutative67.5%
Applied egg-rr67.5%
if 5.0000000000000002e-298 < h Initial program 63.3%
Simplified63.2%
Applied egg-rr27.0%
expm1-def44.0%
expm1-log1p78.3%
*-commutative78.3%
Simplified76.0%
Final simplification71.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.15e+151)
(*
(* (sqrt (/ d h)) (sqrt (/ d l)))
(- 1.0 (* 0.5 (* (* h (pow (* (/ D_m d) (* M_m 0.5)) 2.0)) (/ 1.0 l)))))
(* d (/ (pow h -0.5) (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.15e+151) {
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h * pow(((D_m / d) * (M_m * 0.5)), 2.0)) * (1.0 / l))));
} else {
tmp = d * (pow(h, -0.5) / sqrt(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.15d+151) then
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0d0 - (0.5d0 * ((h * (((d_m / d) * (m_m * 0.5d0)) ** 2.0d0)) * (1.0d0 / l))))
else
tmp = d * ((h ** (-0.5d0)) / sqrt(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.15e+151) {
tmp = (Math.sqrt((d / h)) * Math.sqrt((d / l))) * (1.0 - (0.5 * ((h * Math.pow(((D_m / d) * (M_m * 0.5)), 2.0)) * (1.0 / l))));
} else {
tmp = d * (Math.pow(h, -0.5) / Math.sqrt(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.15e+151: tmp = (math.sqrt((d / h)) * math.sqrt((d / l))) * (1.0 - (0.5 * ((h * math.pow(((D_m / d) * (M_m * 0.5)), 2.0)) * (1.0 / l)))) else: tmp = d * (math.pow(h, -0.5) / math.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.15e+151) tmp = Float64(Float64(sqrt(Float64(d / 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)) * Float64(1.0 / l))))); else tmp = Float64(d * Float64((h ^ -0.5) / sqrt(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.15e+151)
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h * (((D_m / d) * (M_m * 0.5)) ^ 2.0)) * (1.0 / l))));
else
tmp = d * ((h ^ -0.5) / sqrt(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.15e+151], 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 * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[h, -0.5], $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.15 \cdot 10^{+151}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(h \cdot {\left(\frac{D\_m}{d} \cdot \left(M\_m \cdot 0.5\right)\right)}^{2}\right) \cdot \frac{1}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < 1.15e151Initial program 67.3%
Simplified67.2%
associate-*r/69.2%
div-inv69.2%
metadata-eval69.2%
Applied egg-rr69.2%
div-inv69.2%
*-commutative69.2%
*-commutative69.2%
Applied egg-rr69.2%
if 1.15e151 < l Initial program 49.6%
Simplified49.6%
associate-*r/44.3%
div-inv44.3%
metadata-eval44.3%
Applied egg-rr44.3%
Taylor expanded in d around inf 49.9%
associate-/r*49.9%
Simplified49.9%
expm1-log1p-u49.6%
expm1-udef17.7%
sqrt-div17.7%
inv-pow17.7%
sqrt-pow117.7%
metadata-eval17.7%
Applied egg-rr17.7%
expm1-def62.1%
expm1-log1p62.5%
Simplified62.5%
Final simplification68.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 2.2e+152)
(*
(sqrt (/ d h))
(*
(+ 1.0 (* (/ h l) (* (pow (* (/ M_m 2.0) (/ D_m d)) 2.0) -0.5)))
(sqrt (/ d l))))
(* d (/ (pow h -0.5) (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 <= 2.2e+152) {
tmp = sqrt((d / h)) * ((1.0 + ((h / l) * (pow(((M_m / 2.0) * (D_m / d)), 2.0) * -0.5))) * sqrt((d / l)));
} else {
tmp = d * (pow(h, -0.5) / sqrt(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 <= 2.2d+152) then
tmp = sqrt((d / h)) * ((1.0d0 + ((h / l) * ((((m_m / 2.0d0) * (d_m / d)) ** 2.0d0) * (-0.5d0)))) * sqrt((d / l)))
else
tmp = d * ((h ** (-0.5d0)) / sqrt(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 <= 2.2e+152) {
tmp = Math.sqrt((d / h)) * ((1.0 + ((h / l) * (Math.pow(((M_m / 2.0) * (D_m / d)), 2.0) * -0.5))) * Math.sqrt((d / l)));
} else {
tmp = d * (Math.pow(h, -0.5) / Math.sqrt(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 <= 2.2e+152: tmp = math.sqrt((d / h)) * ((1.0 + ((h / l) * (math.pow(((M_m / 2.0) * (D_m / d)), 2.0) * -0.5))) * math.sqrt((d / l))) else: tmp = d * (math.pow(h, -0.5) / math.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 <= 2.2e+152) tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(M_m / 2.0) * Float64(D_m / d)) ^ 2.0) * -0.5))) * sqrt(Float64(d / l)))); else tmp = Float64(d * Float64((h ^ -0.5) / sqrt(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 <= 2.2e+152)
tmp = sqrt((d / h)) * ((1.0 + ((h / l) * ((((M_m / 2.0) * (D_m / d)) ^ 2.0) * -0.5))) * sqrt((d / l)));
else
tmp = d * ((h ^ -0.5) / sqrt(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, 2.2e+152], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[h, -0.5], $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 2.2 \cdot 10^{+152}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M\_m}{2} \cdot \frac{D\_m}{d}\right)}^{2} \cdot -0.5\right)\right) \cdot \sqrt{\frac{d}{\ell}}\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < 2.1999999999999998e152Initial program 67.3%
Simplified66.8%
if 2.1999999999999998e152 < l Initial program 49.6%
Simplified49.6%
associate-*r/44.3%
div-inv44.3%
metadata-eval44.3%
Applied egg-rr44.3%
Taylor expanded in d around inf 49.9%
associate-/r*49.9%
Simplified49.9%
expm1-log1p-u49.6%
expm1-udef17.7%
sqrt-div17.7%
inv-pow17.7%
sqrt-pow117.7%
metadata-eval17.7%
Applied egg-rr17.7%
expm1-def62.1%
expm1-log1p62.5%
Simplified62.5%
Final simplification66.1%
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 9.2e+151)
(*
(* (sqrt (/ d h)) (sqrt (/ d l)))
(- 1.0 (* 0.5 (* (/ h l) (pow (* (/ M_m 2.0) (/ D_m d)) 2.0)))))
(* d (/ (pow h -0.5) (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 <= 9.2e+151) {
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h / l) * pow(((M_m / 2.0) * (D_m / d)), 2.0))));
} else {
tmp = d * (pow(h, -0.5) / sqrt(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 <= 9.2d+151) then
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0d0 - (0.5d0 * ((h / l) * (((m_m / 2.0d0) * (d_m / d)) ** 2.0d0))))
else
tmp = d * ((h ** (-0.5d0)) / sqrt(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 <= 9.2e+151) {
tmp = (Math.sqrt((d / h)) * Math.sqrt((d / l))) * (1.0 - (0.5 * ((h / l) * Math.pow(((M_m / 2.0) * (D_m / d)), 2.0))));
} else {
tmp = d * (Math.pow(h, -0.5) / Math.sqrt(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 <= 9.2e+151: tmp = (math.sqrt((d / h)) * math.sqrt((d / l))) * (1.0 - (0.5 * ((h / l) * math.pow(((M_m / 2.0) * (D_m / d)), 2.0)))) else: tmp = d * (math.pow(h, -0.5) / math.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 <= 9.2e+151) tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(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))))); else tmp = Float64(d * Float64((h ^ -0.5) / sqrt(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 <= 9.2e+151)
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h / l) * (((M_m / 2.0) * (D_m / d)) ^ 2.0))));
else
tmp = d * ((h ^ -0.5) / sqrt(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, 9.2e+151], 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[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[h, -0.5], $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 9.2 \cdot 10^{+151}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \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)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < 9.2000000000000003e151Initial program 67.3%
Simplified67.2%
if 9.2000000000000003e151 < l Initial program 49.6%
Simplified49.6%
associate-*r/44.3%
div-inv44.3%
metadata-eval44.3%
Applied egg-rr44.3%
Taylor expanded in d around inf 49.9%
associate-/r*49.9%
Simplified49.9%
expm1-log1p-u49.6%
expm1-udef17.7%
sqrt-div17.7%
inv-pow17.7%
sqrt-pow117.7%
metadata-eval17.7%
Applied egg-rr17.7%
expm1-def62.1%
expm1-log1p62.5%
Simplified62.5%
Final simplification66.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 3e+151)
(*
(- 1.0 (* 0.5 (/ (* h (pow (* (/ D_m d) (* M_m 0.5)) 2.0)) l)))
(* (sqrt (/ d h)) (sqrt (/ d l))))
(* d (/ (pow h -0.5) (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 <= 3e+151) {
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 * (pow(h, -0.5) / sqrt(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 <= 3d+151) then
tmp = (1.0d0 - (0.5d0 * ((h * (((d_m / d) * (m_m * 0.5d0)) ** 2.0d0)) / l))) * (sqrt((d / h)) * sqrt((d / l)))
else
tmp = d * ((h ** (-0.5d0)) / sqrt(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 <= 3e+151) {
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)));
} else {
tmp = d * (Math.pow(h, -0.5) / Math.sqrt(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 <= 3e+151: 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))) else: tmp = d * (math.pow(h, -0.5) / math.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 <= 3e+151) 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(d * Float64((h ^ -0.5) / sqrt(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 <= 3e+151)
tmp = (1.0 - (0.5 * ((h * (((D_m / d) * (M_m * 0.5)) ^ 2.0)) / l))) * (sqrt((d / h)) * sqrt((d / l)));
else
tmp = d * ((h ^ -0.5) / sqrt(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, 3e+151], 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[(d * N[(N[Power[h, -0.5], $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 3 \cdot 10^{+151}:\\
\;\;\;\;\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}:\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < 2.9999999999999999e151Initial program 67.3%
Simplified67.2%
associate-*r/69.2%
div-inv69.2%
metadata-eval69.2%
Applied egg-rr69.2%
if 2.9999999999999999e151 < l Initial program 49.6%
Simplified49.6%
associate-*r/44.3%
div-inv44.3%
metadata-eval44.3%
Applied egg-rr44.3%
Taylor expanded in d around inf 49.9%
associate-/r*49.9%
Simplified49.9%
expm1-log1p-u49.6%
expm1-udef17.7%
sqrt-div17.7%
inv-pow17.7%
sqrt-pow117.7%
metadata-eval17.7%
Applied egg-rr17.7%
expm1-def62.1%
expm1-log1p62.5%
Simplified62.5%
Final simplification68.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 -6.8e-77)
(* (- d) (pow (* l h) -0.5))
(if (<= l 1.1e+142)
(*
(sqrt (* (/ d h) (/ d l)))
(+ 1.0 (* -0.5 (* h (/ (pow (* 0.5 (* M_m (/ D_m d))) 2.0) l)))))
(* d (/ (pow h -0.5) (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 <= -6.8e-77) {
tmp = -d * pow((l * h), -0.5);
} else if (l <= 1.1e+142) {
tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * (h * (pow((0.5 * (M_m * (D_m / d))), 2.0) / l))));
} else {
tmp = d * (pow(h, -0.5) / sqrt(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 <= (-6.8d-77)) then
tmp = -d * ((l * h) ** (-0.5d0))
else if (l <= 1.1d+142) then
tmp = sqrt(((d / h) * (d / l))) * (1.0d0 + ((-0.5d0) * (h * (((0.5d0 * (m_m * (d_m / d))) ** 2.0d0) / l))))
else
tmp = d * ((h ** (-0.5d0)) / sqrt(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 <= -6.8e-77) {
tmp = -d * Math.pow((l * h), -0.5);
} else if (l <= 1.1e+142) {
tmp = Math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * (h * (Math.pow((0.5 * (M_m * (D_m / d))), 2.0) / l))));
} else {
tmp = d * (Math.pow(h, -0.5) / Math.sqrt(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 <= -6.8e-77: tmp = -d * math.pow((l * h), -0.5) elif l <= 1.1e+142: tmp = math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * (h * (math.pow((0.5 * (M_m * (D_m / d))), 2.0) / l)))) else: tmp = d * (math.pow(h, -0.5) / math.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 <= -6.8e-77) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); elseif (l <= 1.1e+142) tmp = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 + Float64(-0.5 * Float64(h * Float64((Float64(0.5 * Float64(M_m * Float64(D_m / d))) ^ 2.0) / l))))); else tmp = Float64(d * Float64((h ^ -0.5) / sqrt(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 <= -6.8e-77)
tmp = -d * ((l * h) ^ -0.5);
elseif (l <= 1.1e+142)
tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * (h * (((0.5 * (M_m * (D_m / d))) ^ 2.0) / l))));
else
tmp = d * ((h ^ -0.5) / sqrt(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, -6.8e-77], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.1e+142], N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(h * N[(N[Power[N[(0.5 * N[(M$95$m * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[h, -0.5], $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 -6.8 \cdot 10^{-77}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+142}:\\
\;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(h \cdot \frac{{\left(0.5 \cdot \left(M\_m \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < -6.79999999999999966e-77Initial program 61.6%
Simplified61.6%
frac-2neg61.6%
sqrt-div72.8%
Applied egg-rr72.8%
Taylor expanded in d around -inf 53.9%
mul-1-neg53.9%
*-commutative53.9%
distribute-rgt-neg-in53.9%
unpow-153.9%
metadata-eval53.9%
pow-sqr53.9%
rem-sqrt-square53.9%
rem-square-sqrt53.7%
fabs-sqr53.7%
rem-square-sqrt53.9%
Simplified53.9%
if -6.79999999999999966e-77 < l < 1.09999999999999993e142Initial program 71.7%
Simplified71.0%
associate-*r/74.2%
div-inv74.2%
metadata-eval74.2%
Applied egg-rr74.2%
expm1-log1p-u36.0%
expm1-udef29.5%
Applied egg-rr24.9%
Simplified64.4%
if 1.09999999999999993e142 < l Initial program 47.4%
Simplified47.2%
associate-*r/42.4%
div-inv42.4%
metadata-eval42.4%
Applied egg-rr42.4%
Taylor expanded in d around inf 45.4%
associate-/r*45.3%
Simplified45.3%
expm1-log1p-u45.0%
expm1-udef16.3%
sqrt-div16.3%
inv-pow16.3%
sqrt-pow116.3%
metadata-eval16.3%
Applied egg-rr16.3%
expm1-def56.3%
expm1-log1p56.7%
Simplified56.7%
Final simplification59.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 9.2e-290) (* (- d) (pow (* l h) -0.5)) (* d (* (pow h -0.5) (pow l -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 <= 9.2e-290) {
tmp = -d * pow((l * h), -0.5);
} else {
tmp = d * (pow(h, -0.5) * pow(l, -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 <= 9.2d-290) then
tmp = -d * ((l * h) ** (-0.5d0))
else
tmp = d * ((h ** (-0.5d0)) * (l ** (-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 <= 9.2e-290) {
tmp = -d * Math.pow((l * h), -0.5);
} else {
tmp = d * (Math.pow(h, -0.5) * Math.pow(l, -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 <= 9.2e-290: tmp = -d * math.pow((l * h), -0.5) else: tmp = d * (math.pow(h, -0.5) * math.pow(l, -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 <= 9.2e-290) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); else tmp = Float64(d * Float64((h ^ -0.5) * (l ^ -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 <= 9.2e-290)
tmp = -d * ((l * h) ^ -0.5);
else
tmp = d * ((h ^ -0.5) * (l ^ -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, 9.2e-290], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[h, -0.5], $MachinePrecision] * N[Power[l, -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}\;h \leq 9.2 \cdot 10^{-290}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\
\end{array}
\end{array}
if h < 9.2000000000000003e-290Initial program 65.5%
Simplified64.8%
frac-2neg64.8%
sqrt-div77.7%
Applied egg-rr77.7%
Taylor expanded in d around -inf 43.2%
mul-1-neg43.2%
*-commutative43.2%
distribute-rgt-neg-in43.2%
unpow-143.2%
metadata-eval43.2%
pow-sqr43.3%
rem-sqrt-square43.7%
rem-square-sqrt43.6%
fabs-sqr43.6%
rem-square-sqrt43.7%
Simplified43.7%
if 9.2000000000000003e-290 < h Initial program 63.8%
Simplified63.7%
associate-*r/63.9%
div-inv63.9%
metadata-eval63.9%
Applied egg-rr63.9%
Taylor expanded in d around inf 42.9%
unpow-142.9%
metadata-eval42.9%
pow-sqr42.9%
rem-sqrt-square43.3%
sqr-pow43.1%
fabs-sqr43.1%
sqr-pow43.3%
Simplified43.3%
*-commutative43.3%
unpow-prod-down48.4%
Applied egg-rr48.4%
Final simplification45.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 9.2e-290) (* (- d) (pow (* l h) -0.5)) (* d (/ (pow h -0.5) (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 (h <= 9.2e-290) {
tmp = -d * pow((l * h), -0.5);
} else {
tmp = d * (pow(h, -0.5) / sqrt(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 (h <= 9.2d-290) then
tmp = -d * ((l * h) ** (-0.5d0))
else
tmp = d * ((h ** (-0.5d0)) / sqrt(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 (h <= 9.2e-290) {
tmp = -d * Math.pow((l * h), -0.5);
} else {
tmp = d * (Math.pow(h, -0.5) / Math.sqrt(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 h <= 9.2e-290: tmp = -d * math.pow((l * h), -0.5) else: tmp = d * (math.pow(h, -0.5) / math.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 (h <= 9.2e-290) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); else tmp = Float64(d * Float64((h ^ -0.5) / sqrt(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 (h <= 9.2e-290)
tmp = -d * ((l * h) ^ -0.5);
else
tmp = d * ((h ^ -0.5) / sqrt(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[h, 9.2e-290], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[h, -0.5], $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}\;h \leq 9.2 \cdot 10^{-290}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if h < 9.2000000000000003e-290Initial program 65.5%
Simplified64.8%
frac-2neg64.8%
sqrt-div77.7%
Applied egg-rr77.7%
Taylor expanded in d around -inf 43.2%
mul-1-neg43.2%
*-commutative43.2%
distribute-rgt-neg-in43.2%
unpow-143.2%
metadata-eval43.2%
pow-sqr43.3%
rem-sqrt-square43.7%
rem-square-sqrt43.6%
fabs-sqr43.6%
rem-square-sqrt43.7%
Simplified43.7%
if 9.2000000000000003e-290 < h Initial program 63.8%
Simplified63.7%
associate-*r/63.9%
div-inv63.9%
metadata-eval63.9%
Applied egg-rr63.9%
Taylor expanded in d around inf 42.9%
associate-/r*42.9%
Simplified42.9%
expm1-log1p-u42.2%
expm1-udef26.0%
sqrt-div27.5%
inv-pow27.5%
sqrt-pow127.5%
metadata-eval27.5%
Applied egg-rr27.5%
expm1-def47.7%
expm1-log1p48.4%
Simplified48.4%
Final simplification45.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 (let* ((t_0 (pow (* l h) -0.5))) (if (<= l 2.2e-290) (* (- d) t_0) (* d t_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 = pow((l * h), -0.5);
double tmp;
if (l <= 2.2e-290) {
tmp = -d * t_0;
} else {
tmp = d * t_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) :: t_0
real(8) :: tmp
t_0 = (l * h) ** (-0.5d0)
if (l <= 2.2d-290) then
tmp = -d * t_0
else
tmp = d * t_0
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 t_0 = Math.pow((l * h), -0.5);
double tmp;
if (l <= 2.2e-290) {
tmp = -d * t_0;
} else {
tmp = d * t_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): t_0 = math.pow((l * h), -0.5) tmp = 0 if l <= 2.2e-290: tmp = -d * t_0 else: tmp = d * t_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 = Float64(l * h) ^ -0.5 tmp = 0.0 if (l <= 2.2e-290) tmp = Float64(Float64(-d) * t_0); else tmp = Float64(d * t_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)
t_0 = (l * h) ^ -0.5;
tmp = 0.0;
if (l <= 2.2e-290)
tmp = -d * t_0;
else
tmp = d * t_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_] := Block[{t$95$0 = N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]}, If[LessEqual[l, 2.2e-290], N[((-d) * t$95$0), $MachinePrecision], N[(d * t$95$0), $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 := {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;\ell \leq 2.2 \cdot 10^{-290}:\\
\;\;\;\;\left(-d\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\
\end{array}
\end{array}
if l < 2.2000000000000001e-290Initial program 67.2%
Simplified66.5%
frac-2neg66.5%
sqrt-div77.2%
Applied egg-rr77.2%
Taylor expanded in d around -inf 44.3%
mul-1-neg44.3%
*-commutative44.3%
distribute-rgt-neg-in44.3%
unpow-144.3%
metadata-eval44.3%
pow-sqr44.3%
rem-sqrt-square44.8%
rem-square-sqrt44.7%
fabs-sqr44.7%
rem-square-sqrt44.8%
Simplified44.8%
if 2.2000000000000001e-290 < l Initial program 61.8%
Simplified61.7%
associate-*r/62.8%
div-inv62.8%
metadata-eval62.8%
Applied egg-rr62.8%
Taylor expanded in d around inf 42.5%
unpow-142.5%
metadata-eval42.5%
pow-sqr42.5%
rem-sqrt-square42.8%
sqr-pow42.6%
fabs-sqr42.6%
sqr-pow42.8%
Simplified42.8%
Final simplification43.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 (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) {
return d * pow((l * h), -0.5);
}
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 * ((l * h) ** (-0.5d0))
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.pow((l * h), -0.5);
}
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.pow((l * h), -0.5)
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 * (Float64(l * h) ^ -0.5)) 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 * ((l * h) ^ -0.5);
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[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])\\
\\
d \cdot {\left(\ell \cdot h\right)}^{-0.5}
\end{array}
Initial program 64.7%
Simplified64.6%
associate-*r/65.6%
div-inv65.6%
metadata-eval65.6%
Applied egg-rr65.6%
Taylor expanded in d around inf 23.1%
unpow-123.1%
metadata-eval23.1%
pow-sqr23.1%
rem-sqrt-square23.3%
sqr-pow23.2%
fabs-sqr23.2%
sqr-pow23.3%
Simplified23.3%
Final simplification23.3%
herbie shell --seed 2024030
(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)))))