
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= l -1e-309)
(*
(* (/ (sqrt (- d)) (sqrt (- h))) (sqrt (/ d l)))
(- 1.0 (* 0.5 (/ (pow (* (* D M_m) (/ 0.5 d)) 2.0) (/ l h)))))
(*
d
(/
(fma h (* (pow (* M_m (/ D (* d 2.0))) 2.0) (/ -0.5 l)) 1.0)
(* (sqrt l) (sqrt h))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -1e-309) {
tmp = ((sqrt(-d) / sqrt(-h)) * sqrt((d / l))) * (1.0 - (0.5 * (pow(((D * M_m) * (0.5 / d)), 2.0) / (l / h))));
} else {
tmp = d * (fma(h, (pow((M_m * (D / (d * 2.0))), 2.0) * (-0.5 / l)), 1.0) / (sqrt(l) * sqrt(h)));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= -1e-309) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * Float64((Float64(Float64(D * M_m) * Float64(0.5 / d)) ^ 2.0) / Float64(l / h))))); else tmp = Float64(d * Float64(fma(h, Float64((Float64(M_m * Float64(D / Float64(d * 2.0))) ^ 2.0) * Float64(-0.5 / l)), 1.0) / Float64(sqrt(l) * sqrt(h)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, -1e-309], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[Power[N[(N[(D * M$95$m), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / N[(l / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(h * N[(N[Power[N[(M$95$m * N[(D / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(\left(D \cdot M\_m\right) \cdot \frac{0.5}{d}\right)}^{2}}{\frac{\ell}{h}}\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(h, {\left(M\_m \cdot \frac{D}{d \cdot 2}\right)}^{2} \cdot \frac{-0.5}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -1.000000000000002e-309Initial program 70.5%
Simplified69.1%
clear-num69.1%
un-div-inv69.1%
frac-times70.5%
associate-/l*69.1%
*-un-lft-identity69.1%
times-frac69.1%
metadata-eval69.1%
Applied egg-rr69.1%
associate-*r*69.1%
associate-/l*70.5%
*-commutative70.5%
associate-*r*70.5%
associate-/l*70.5%
Simplified70.5%
frac-2neg70.5%
sqrt-div80.3%
Applied egg-rr80.3%
if -1.000000000000002e-309 < l Initial program 70.3%
Simplified68.9%
Applied egg-rr73.5%
*-lft-identity73.5%
distribute-rgt-in82.4%
associate-*l/84.6%
associate-/l*84.5%
Simplified87.6%
Final simplification84.2%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= h -2e-310)
(*
(sqrt (/ d l))
(*
(/ (sqrt (- d)) (sqrt (- h)))
(+ 1.0 (* (/ h l) (* -0.5 (pow (* D (/ (/ M_m 2.0) d)) 2.0))))))
(*
d
(/
(fma h (* (pow (* M_m (/ D (* d 2.0))) 2.0) (/ -0.5 l)) 1.0)
(* (sqrt l) (sqrt h))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (h <= -2e-310) {
tmp = sqrt((d / l)) * ((sqrt(-d) / sqrt(-h)) * (1.0 + ((h / l) * (-0.5 * pow((D * ((M_m / 2.0) / d)), 2.0)))));
} else {
tmp = d * (fma(h, (pow((M_m * (D / (d * 2.0))), 2.0) * (-0.5 / l)), 1.0) / (sqrt(l) * sqrt(h)));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (h <= -2e-310) tmp = Float64(sqrt(Float64(d / l)) * Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(D * Float64(Float64(M_m / 2.0) / d)) ^ 2.0)))))); else tmp = Float64(d * Float64(fma(h, Float64((Float64(M_m * Float64(D / Float64(d * 2.0))) ^ 2.0) * Float64(-0.5 / l)), 1.0) / Float64(sqrt(l) * sqrt(h)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[h, -2e-310], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(D * N[(N[(M$95$m / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(h * N[(N[Power[N[(M$95$m * N[(D / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{\frac{M\_m}{2}}{d}\right)}^{2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(h, {\left(M\_m \cdot \frac{D}{d \cdot 2}\right)}^{2} \cdot \frac{-0.5}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if h < -1.999999999999994e-310Initial program 70.5%
Simplified70.4%
frac-2neg70.5%
sqrt-div80.3%
Applied egg-rr81.1%
if -1.999999999999994e-310 < h Initial program 70.3%
Simplified68.9%
Applied egg-rr73.5%
*-lft-identity73.5%
distribute-rgt-in82.4%
associate-*l/84.6%
associate-/l*84.5%
Simplified87.6%
Final simplification84.5%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= h -2e-310)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (* 0.5 (/ (* h (pow (* M_m (* 0.5 (/ D d))) 2.0)) l))))
(*
d
(/
(fma h (* (pow (* M_m (/ D (* d 2.0))) 2.0) (/ -0.5 l)) 1.0)
(* (sqrt l) (sqrt h))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (h <= -2e-310) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * ((h * pow((M_m * (0.5 * (D / d))), 2.0)) / l)));
} else {
tmp = d * (fma(h, (pow((M_m * (D / (d * 2.0))), 2.0) * (-0.5 / l)), 1.0) / (sqrt(l) * sqrt(h)));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (h <= -2e-310) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(M_m * Float64(0.5 * Float64(D / d))) ^ 2.0)) / l)))); else tmp = Float64(d * Float64(fma(h, Float64((Float64(M_m * Float64(D / Float64(d * 2.0))) ^ 2.0) * Float64(-0.5 / l)), 1.0) / Float64(sqrt(l) * sqrt(h)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[h, -2e-310], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(M$95$m * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(h * N[(N[Power[N[(M$95$m * N[(D / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(M\_m \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(h, {\left(M\_m \cdot \frac{D}{d \cdot 2}\right)}^{2} \cdot \frac{-0.5}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if h < -1.999999999999994e-310Initial program 70.5%
Simplified69.1%
associate-*r/71.4%
frac-times72.8%
associate-/l*71.4%
*-un-lft-identity71.4%
times-frac71.4%
metadata-eval71.4%
Applied egg-rr71.4%
if -1.999999999999994e-310 < h Initial program 70.3%
Simplified68.9%
Applied egg-rr73.5%
*-lft-identity73.5%
distribute-rgt-in82.4%
associate-*l/84.6%
associate-/l*84.5%
Simplified87.6%
Final simplification80.0%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= d -2.2e-219)
(*
(sqrt (* (/ d l) (/ d h)))
(- 1.0 (* (/ 0.5 l) (* h (pow (* M_m (* D (/ 0.5 d))) 2.0)))))
(if (<= d 3.5e-308)
(* d (sqrt (log1p (expm1 (/ 1.0 (* l h))))))
(*
(+ 1.0 (* (pow (* (* D M_m) (/ 0.5 d)) 2.0) (* -0.5 (/ h l))))
(/ (/ d (sqrt l)) (sqrt h))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (d <= -2.2e-219) {
tmp = sqrt(((d / l) * (d / h))) * (1.0 - ((0.5 / l) * (h * pow((M_m * (D * (0.5 / d))), 2.0))));
} else if (d <= 3.5e-308) {
tmp = d * sqrt(log1p(expm1((1.0 / (l * h)))));
} else {
tmp = (1.0 + (pow(((D * M_m) * (0.5 / d)), 2.0) * (-0.5 * (h / l)))) * ((d / sqrt(l)) / sqrt(h));
}
return tmp;
}
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (d <= -2.2e-219) {
tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 - ((0.5 / l) * (h * Math.pow((M_m * (D * (0.5 / d))), 2.0))));
} else if (d <= 3.5e-308) {
tmp = d * Math.sqrt(Math.log1p(Math.expm1((1.0 / (l * h)))));
} else {
tmp = (1.0 + (Math.pow(((D * M_m) * (0.5 / d)), 2.0) * (-0.5 * (h / l)))) * ((d / Math.sqrt(l)) / Math.sqrt(h));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if d <= -2.2e-219: tmp = math.sqrt(((d / l) * (d / h))) * (1.0 - ((0.5 / l) * (h * math.pow((M_m * (D * (0.5 / d))), 2.0)))) elif d <= 3.5e-308: tmp = d * math.sqrt(math.log1p(math.expm1((1.0 / (l * h))))) else: tmp = (1.0 + (math.pow(((D * M_m) * (0.5 / d)), 2.0) * (-0.5 * (h / l)))) * ((d / math.sqrt(l)) / math.sqrt(h)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (d <= -2.2e-219) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 - Float64(Float64(0.5 / l) * Float64(h * (Float64(M_m * Float64(D * Float64(0.5 / d))) ^ 2.0))))); elseif (d <= 3.5e-308) tmp = Float64(d * sqrt(log1p(expm1(Float64(1.0 / Float64(l * h)))))); else tmp = Float64(Float64(1.0 + Float64((Float64(Float64(D * M_m) * Float64(0.5 / d)) ^ 2.0) * Float64(-0.5 * Float64(h / l)))) * Float64(Float64(d / sqrt(l)) / sqrt(h))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[d, -2.2e-219], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(0.5 / l), $MachinePrecision] * N[(h * N[Power[N[(M$95$m * N[(D * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.5e-308], N[(d * N[Sqrt[N[Log[1 + N[(Exp[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[Power[N[(N[(D * M$95$m), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.2 \cdot 10^{-219}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \frac{0.5}{\ell} \cdot \left(h \cdot {\left(M\_m \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2}\right)\right)\\
\mathbf{elif}\;d \leq 3.5 \cdot 10^{-308}:\\
\;\;\;\;d \cdot \sqrt{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\ell \cdot h}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + {\left(\left(D \cdot M\_m\right) \cdot \frac{0.5}{d}\right)}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right)\right) \cdot \frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if d < -2.1999999999999999e-219Initial program 76.4%
Simplified74.7%
clear-num74.7%
un-div-inv74.7%
frac-times76.4%
associate-/l*74.7%
*-un-lft-identity74.7%
times-frac74.7%
metadata-eval74.7%
Applied egg-rr74.7%
associate-*r*74.7%
associate-/l*76.4%
*-commutative76.4%
associate-*r*76.4%
associate-/l*76.4%
Simplified76.4%
clear-num76.4%
inv-pow76.4%
Applied egg-rr76.4%
unpow-176.4%
associate-/l/79.2%
associate-*l*79.2%
Simplified79.2%
pow179.2%
sqrt-unprod70.0%
un-div-inv70.0%
*-commutative70.0%
associate-*r*70.0%
*-commutative70.0%
Applied egg-rr70.0%
unpow170.0%
associate-/r/70.0%
associate-*r*69.0%
Simplified69.0%
if -2.1999999999999999e-219 < d < 3.5e-308Initial program 40.3%
Simplified40.3%
Applied egg-rr0.0%
Taylor expanded in d around inf 2.5%
associate-/l/2.5%
Simplified2.5%
associate-/l/2.5%
*-commutative2.5%
inv-pow2.5%
metadata-eval2.5%
pow-prod-up2.5%
log1p-expm1-u42.6%
pow-prod-up42.6%
metadata-eval42.6%
inv-pow42.6%
*-commutative42.6%
Applied egg-rr42.6%
if 3.5e-308 < d Initial program 70.9%
Simplified69.4%
Applied egg-rr74.1%
distribute-rgt1-in83.0%
+-commutative83.0%
associate-*r*83.0%
associate-*r*83.0%
associate-/l*84.5%
*-commutative84.5%
associate-*r*84.5%
associate-/l*84.5%
associate-/r*84.5%
Simplified84.5%
Final simplification74.8%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= l 1e-307)
(*
(sqrt (/ d l))
(*
(+ 1.0 (* (/ h l) (* -0.5 (pow (* D (/ (/ M_m 2.0) d)) 2.0))))
(sqrt (/ d h))))
(*
(+ 1.0 (* (pow (* (* D M_m) (/ 0.5 d)) 2.0) (* -0.5 (/ h l))))
(/ (/ d (sqrt l)) (sqrt h)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= 1e-307) {
tmp = sqrt((d / l)) * ((1.0 + ((h / l) * (-0.5 * pow((D * ((M_m / 2.0) / d)), 2.0)))) * sqrt((d / h)));
} else {
tmp = (1.0 + (pow(((D * M_m) * (0.5 / d)), 2.0) * (-0.5 * (h / l)))) * ((d / sqrt(l)) / sqrt(h));
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= 1d-307) then
tmp = sqrt((d / l)) * ((1.0d0 + ((h / l) * ((-0.5d0) * ((d_1 * ((m_m / 2.0d0) / d)) ** 2.0d0)))) * sqrt((d / h)))
else
tmp = (1.0d0 + ((((d_1 * m_m) * (0.5d0 / d)) ** 2.0d0) * ((-0.5d0) * (h / l)))) * ((d / sqrt(l)) / sqrt(h))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= 1e-307) {
tmp = Math.sqrt((d / l)) * ((1.0 + ((h / l) * (-0.5 * Math.pow((D * ((M_m / 2.0) / d)), 2.0)))) * Math.sqrt((d / h)));
} else {
tmp = (1.0 + (Math.pow(((D * M_m) * (0.5 / d)), 2.0) * (-0.5 * (h / l)))) * ((d / Math.sqrt(l)) / Math.sqrt(h));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if l <= 1e-307: tmp = math.sqrt((d / l)) * ((1.0 + ((h / l) * (-0.5 * math.pow((D * ((M_m / 2.0) / d)), 2.0)))) * math.sqrt((d / h))) else: tmp = (1.0 + (math.pow(((D * M_m) * (0.5 / d)), 2.0) * (-0.5 * (h / l)))) * ((d / math.sqrt(l)) / math.sqrt(h)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= 1e-307) tmp = Float64(sqrt(Float64(d / l)) * Float64(Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(D * Float64(Float64(M_m / 2.0) / d)) ^ 2.0)))) * sqrt(Float64(d / h)))); else tmp = Float64(Float64(1.0 + Float64((Float64(Float64(D * M_m) * Float64(0.5 / d)) ^ 2.0) * Float64(-0.5 * Float64(h / l)))) * Float64(Float64(d / sqrt(l)) / sqrt(h))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (l <= 1e-307)
tmp = sqrt((d / l)) * ((1.0 + ((h / l) * (-0.5 * ((D * ((M_m / 2.0) / d)) ^ 2.0)))) * sqrt((d / h)));
else
tmp = (1.0 + ((((D * M_m) * (0.5 / d)) ^ 2.0) * (-0.5 * (h / l)))) * ((d / sqrt(l)) / sqrt(h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, 1e-307], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(D * N[(N[(M$95$m / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[Power[N[(N[(D * M$95$m), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 10^{-307}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{\frac{M\_m}{2}}{d}\right)}^{2}\right)\right) \cdot \sqrt{\frac{d}{h}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + {\left(\left(D \cdot M\_m\right) \cdot \frac{0.5}{d}\right)}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right)\right) \cdot \frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if l < 9.99999999999999909e-308Initial program 70.5%
Simplified70.4%
if 9.99999999999999909e-308 < l Initial program 70.3%
Simplified68.9%
Applied egg-rr73.5%
distribute-rgt1-in82.4%
+-commutative82.4%
associate-*r*82.4%
associate-*r*82.4%
associate-/l*83.9%
*-commutative83.9%
associate-*r*83.9%
associate-/l*83.9%
associate-/r*83.9%
Simplified83.9%
Final simplification77.5%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= l -1e-309)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (* 0.5 (* (/ h l) (pow (* (/ M_m 2.0) (/ D d)) 2.0)))))
(*
(+ 1.0 (* (pow (* (* D M_m) (/ 0.5 d)) 2.0) (* -0.5 (/ h l))))
(/ (/ d (sqrt l)) (sqrt h)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -1e-309) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * ((h / l) * pow(((M_m / 2.0) * (D / d)), 2.0))));
} else {
tmp = (1.0 + (pow(((D * M_m) * (0.5 / d)), 2.0) * (-0.5 * (h / l)))) * ((d / sqrt(l)) / sqrt(h));
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= (-1d-309)) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - (0.5d0 * ((h / l) * (((m_m / 2.0d0) * (d_1 / d)) ** 2.0d0))))
else
tmp = (1.0d0 + ((((d_1 * m_m) * (0.5d0 / d)) ** 2.0d0) * ((-0.5d0) * (h / l)))) * ((d / sqrt(l)) / sqrt(h))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -1e-309) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - (0.5 * ((h / l) * Math.pow(((M_m / 2.0) * (D / d)), 2.0))));
} else {
tmp = (1.0 + (Math.pow(((D * M_m) * (0.5 / d)), 2.0) * (-0.5 * (h / l)))) * ((d / Math.sqrt(l)) / Math.sqrt(h));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if l <= -1e-309: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - (0.5 * ((h / l) * math.pow(((M_m / 2.0) * (D / d)), 2.0)))) else: tmp = (1.0 + (math.pow(((D * M_m) * (0.5 / d)), 2.0) * (-0.5 * (h / l)))) * ((d / math.sqrt(l)) / math.sqrt(h)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= -1e-309) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(M_m / 2.0) * Float64(D / d)) ^ 2.0))))); else tmp = Float64(Float64(1.0 + Float64((Float64(Float64(D * M_m) * Float64(0.5 / d)) ^ 2.0) * Float64(-0.5 * Float64(h / l)))) * Float64(Float64(d / sqrt(l)) / sqrt(h))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (l <= -1e-309)
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * ((h / l) * (((M_m / 2.0) * (D / d)) ^ 2.0))));
else
tmp = (1.0 + ((((D * M_m) * (0.5 / d)) ^ 2.0) * (-0.5 * (h / l)))) * ((d / sqrt(l)) / sqrt(h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, -1e-309], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $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 / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[Power[N[(N[(D * M$95$m), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M\_m}{2} \cdot \frac{D}{d}\right)}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + {\left(\left(D \cdot M\_m\right) \cdot \frac{0.5}{d}\right)}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right)\right) \cdot \frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if l < -1.000000000000002e-309Initial program 70.5%
Simplified69.1%
if -1.000000000000002e-309 < l Initial program 70.3%
Simplified68.9%
Applied egg-rr73.5%
distribute-rgt1-in82.4%
+-commutative82.4%
associate-*r*82.4%
associate-*r*82.4%
associate-/l*83.9%
*-commutative83.9%
associate-*r*83.9%
associate-/l*83.9%
associate-/r*83.9%
Simplified83.9%
Final simplification76.9%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= l 2e-309)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (* 0.5 (/ (* h (pow (* M_m (* 0.5 (/ D d))) 2.0)) l))))
(*
(+ 1.0 (* (pow (* (* D M_m) (/ 0.5 d)) 2.0) (* -0.5 (/ h l))))
(/ (/ d (sqrt l)) (sqrt h)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= 2e-309) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * ((h * pow((M_m * (0.5 * (D / d))), 2.0)) / l)));
} else {
tmp = (1.0 + (pow(((D * M_m) * (0.5 / d)), 2.0) * (-0.5 * (h / l)))) * ((d / sqrt(l)) / sqrt(h));
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= 2d-309) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - (0.5d0 * ((h * ((m_m * (0.5d0 * (d_1 / d))) ** 2.0d0)) / l)))
else
tmp = (1.0d0 + ((((d_1 * m_m) * (0.5d0 / d)) ** 2.0d0) * ((-0.5d0) * (h / l)))) * ((d / sqrt(l)) / sqrt(h))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= 2e-309) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - (0.5 * ((h * Math.pow((M_m * (0.5 * (D / d))), 2.0)) / l)));
} else {
tmp = (1.0 + (Math.pow(((D * M_m) * (0.5 / d)), 2.0) * (-0.5 * (h / l)))) * ((d / Math.sqrt(l)) / Math.sqrt(h));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if l <= 2e-309: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - (0.5 * ((h * math.pow((M_m * (0.5 * (D / d))), 2.0)) / l))) else: tmp = (1.0 + (math.pow(((D * M_m) * (0.5 / d)), 2.0) * (-0.5 * (h / l)))) * ((d / math.sqrt(l)) / math.sqrt(h)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= 2e-309) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(M_m * Float64(0.5 * Float64(D / d))) ^ 2.0)) / l)))); else tmp = Float64(Float64(1.0 + Float64((Float64(Float64(D * M_m) * Float64(0.5 / d)) ^ 2.0) * Float64(-0.5 * Float64(h / l)))) * Float64(Float64(d / sqrt(l)) / sqrt(h))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (l <= 2e-309)
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * ((h * ((M_m * (0.5 * (D / d))) ^ 2.0)) / l)));
else
tmp = (1.0 + ((((D * M_m) * (0.5 / d)) ^ 2.0) * (-0.5 * (h / l)))) * ((d / sqrt(l)) / sqrt(h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, 2e-309], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(M$95$m * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[Power[N[(N[(D * M$95$m), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2 \cdot 10^{-309}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(M\_m \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + {\left(\left(D \cdot M\_m\right) \cdot \frac{0.5}{d}\right)}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right)\right) \cdot \frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if l < 1.9999999999999988e-309Initial program 70.5%
Simplified69.1%
associate-*r/71.4%
frac-times72.8%
associate-/l*71.4%
*-un-lft-identity71.4%
times-frac71.4%
metadata-eval71.4%
Applied egg-rr71.4%
if 1.9999999999999988e-309 < l Initial program 70.3%
Simplified68.9%
Applied egg-rr73.5%
distribute-rgt1-in82.4%
+-commutative82.4%
associate-*r*82.4%
associate-*r*82.4%
associate-/l*83.9%
*-commutative83.9%
associate-*r*83.9%
associate-/l*83.9%
associate-/r*83.9%
Simplified83.9%
Final simplification78.0%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= l -1.7e-102)
(* d (- (sqrt (/ (/ 1.0 l) h))))
(if (<= l -1e-309)
(* d (cbrt (pow (/ 1.0 (* l h)) 1.5)))
(if (<= l 1.3e+189)
(*
(+ 1.0 (* (pow (* (* D M_m) (/ 0.5 d)) 2.0) (* -0.5 (/ h l))))
(/ d (sqrt (* l h))))
(* d (/ (sqrt (/ 1.0 l)) (sqrt h)))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -1.7e-102) {
tmp = d * -sqrt(((1.0 / l) / h));
} else if (l <= -1e-309) {
tmp = d * cbrt(pow((1.0 / (l * h)), 1.5));
} else if (l <= 1.3e+189) {
tmp = (1.0 + (pow(((D * M_m) * (0.5 / d)), 2.0) * (-0.5 * (h / l)))) * (d / sqrt((l * h)));
} else {
tmp = d * (sqrt((1.0 / l)) / sqrt(h));
}
return tmp;
}
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -1.7e-102) {
tmp = d * -Math.sqrt(((1.0 / l) / h));
} else if (l <= -1e-309) {
tmp = d * Math.cbrt(Math.pow((1.0 / (l * h)), 1.5));
} else if (l <= 1.3e+189) {
tmp = (1.0 + (Math.pow(((D * M_m) * (0.5 / d)), 2.0) * (-0.5 * (h / l)))) * (d / Math.sqrt((l * h)));
} else {
tmp = d * (Math.sqrt((1.0 / l)) / Math.sqrt(h));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= -1.7e-102) tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / l) / h)))); elseif (l <= -1e-309) tmp = Float64(d * cbrt((Float64(1.0 / Float64(l * h)) ^ 1.5))); elseif (l <= 1.3e+189) tmp = Float64(Float64(1.0 + Float64((Float64(Float64(D * M_m) * Float64(0.5 / d)) ^ 2.0) * Float64(-0.5 * Float64(h / l)))) * Float64(d / sqrt(Float64(l * h)))); else tmp = Float64(d * Float64(sqrt(Float64(1.0 / l)) / sqrt(h))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, -1.7e-102], N[(d * (-N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[l, -1e-309], N[(d * N[Power[N[Power[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.3e+189], N[(N[(1.0 + N[(N[Power[N[(N[(D * M$95$m), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.7 \cdot 10^{-102}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\
\mathbf{elif}\;\ell \leq -1 \cdot 10^{-309}:\\
\;\;\;\;d \cdot \sqrt[3]{{\left(\frac{1}{\ell \cdot h}\right)}^{1.5}}\\
\mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+189}:\\
\;\;\;\;\left(1 + {\left(\left(D \cdot M\_m\right) \cdot \frac{0.5}{d}\right)}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right)\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if l < -1.70000000000000006e-102Initial program 67.6%
Simplified67.6%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt48.2%
neg-mul-148.2%
Simplified48.2%
Taylor expanded in l around 0 48.2%
associate-/l/48.8%
Simplified48.8%
if -1.70000000000000006e-102 < l < -1.000000000000002e-309Initial program 75.0%
Simplified71.4%
Applied egg-rr0.0%
Taylor expanded in d around inf 20.8%
associate-/l/20.8%
Simplified20.8%
add-cbrt-cube31.2%
add-sqr-sqrt31.2%
pow131.2%
pow1/231.2%
pow-prod-up31.2%
associate-/l/31.2%
metadata-eval31.2%
Applied egg-rr31.2%
if -1.000000000000002e-309 < l < 1.29999999999999991e189Initial program 77.2%
Simplified74.4%
Applied egg-rr74.8%
distribute-rgt1-in86.5%
+-commutative86.5%
associate-*r*86.5%
associate-*r*86.5%
associate-/l*89.4%
*-commutative89.4%
associate-*r*89.4%
associate-/l*89.4%
associate-/r*89.4%
Simplified89.4%
*-un-lft-identity89.4%
associate-/l/89.4%
pow1/289.4%
pow1/289.4%
pow-prod-down82.0%
*-commutative82.0%
pow1/282.0%
*-commutative82.0%
Applied egg-rr82.0%
*-lft-identity82.0%
Simplified82.0%
if 1.29999999999999991e189 < l Initial program 49.2%
Simplified52.0%
Applied egg-rr63.3%
Taylor expanded in d around inf 53.1%
associate-/l/53.2%
Simplified53.2%
sqrt-div67.6%
Applied egg-rr67.6%
Final simplification61.2%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= l -1e-309)
(*
(sqrt (* (/ d l) (/ d h)))
(- 1.0 (* (/ 0.5 l) (* h (pow (* M_m (* D (/ 0.5 d))) 2.0)))))
(if (<= l 1e+189)
(*
(+ 1.0 (* (pow (* (* D M_m) (/ 0.5 d)) 2.0) (* -0.5 (/ h l))))
(/ d (sqrt (* l h))))
(* d (/ (sqrt (/ 1.0 l)) (sqrt h))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -1e-309) {
tmp = sqrt(((d / l) * (d / h))) * (1.0 - ((0.5 / l) * (h * pow((M_m * (D * (0.5 / d))), 2.0))));
} else if (l <= 1e+189) {
tmp = (1.0 + (pow(((D * M_m) * (0.5 / d)), 2.0) * (-0.5 * (h / l)))) * (d / sqrt((l * h)));
} else {
tmp = d * (sqrt((1.0 / l)) / sqrt(h));
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= (-1d-309)) then
tmp = sqrt(((d / l) * (d / h))) * (1.0d0 - ((0.5d0 / l) * (h * ((m_m * (d_1 * (0.5d0 / d))) ** 2.0d0))))
else if (l <= 1d+189) then
tmp = (1.0d0 + ((((d_1 * m_m) * (0.5d0 / d)) ** 2.0d0) * ((-0.5d0) * (h / l)))) * (d / sqrt((l * h)))
else
tmp = d * (sqrt((1.0d0 / l)) / sqrt(h))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -1e-309) {
tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 - ((0.5 / l) * (h * Math.pow((M_m * (D * (0.5 / d))), 2.0))));
} else if (l <= 1e+189) {
tmp = (1.0 + (Math.pow(((D * M_m) * (0.5 / d)), 2.0) * (-0.5 * (h / l)))) * (d / Math.sqrt((l * h)));
} else {
tmp = d * (Math.sqrt((1.0 / l)) / Math.sqrt(h));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if l <= -1e-309: tmp = math.sqrt(((d / l) * (d / h))) * (1.0 - ((0.5 / l) * (h * math.pow((M_m * (D * (0.5 / d))), 2.0)))) elif l <= 1e+189: tmp = (1.0 + (math.pow(((D * M_m) * (0.5 / d)), 2.0) * (-0.5 * (h / l)))) * (d / math.sqrt((l * h))) else: tmp = d * (math.sqrt((1.0 / l)) / math.sqrt(h)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= -1e-309) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 - Float64(Float64(0.5 / l) * Float64(h * (Float64(M_m * Float64(D * Float64(0.5 / d))) ^ 2.0))))); elseif (l <= 1e+189) tmp = Float64(Float64(1.0 + Float64((Float64(Float64(D * M_m) * Float64(0.5 / d)) ^ 2.0) * Float64(-0.5 * Float64(h / l)))) * Float64(d / sqrt(Float64(l * h)))); else tmp = Float64(d * Float64(sqrt(Float64(1.0 / l)) / sqrt(h))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (l <= -1e-309)
tmp = sqrt(((d / l) * (d / h))) * (1.0 - ((0.5 / l) * (h * ((M_m * (D * (0.5 / d))) ^ 2.0))));
elseif (l <= 1e+189)
tmp = (1.0 + ((((D * M_m) * (0.5 / d)) ^ 2.0) * (-0.5 * (h / l)))) * (d / sqrt((l * h)));
else
tmp = d * (sqrt((1.0 / l)) / sqrt(h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, -1e-309], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(0.5 / l), $MachinePrecision] * N[(h * N[Power[N[(M$95$m * N[(D * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1e+189], N[(N[(1.0 + N[(N[Power[N[(N[(D * M$95$m), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \frac{0.5}{\ell} \cdot \left(h \cdot {\left(M\_m \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2}\right)\right)\\
\mathbf{elif}\;\ell \leq 10^{+189}:\\
\;\;\;\;\left(1 + {\left(\left(D \cdot M\_m\right) \cdot \frac{0.5}{d}\right)}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right)\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if l < -1.000000000000002e-309Initial program 70.5%
Simplified69.1%
clear-num69.1%
un-div-inv69.1%
frac-times70.5%
associate-/l*69.1%
*-un-lft-identity69.1%
times-frac69.1%
metadata-eval69.1%
Applied egg-rr69.1%
associate-*r*69.1%
associate-/l*70.5%
*-commutative70.5%
associate-*r*70.5%
associate-/l*70.5%
Simplified70.5%
clear-num70.4%
inv-pow70.4%
Applied egg-rr70.4%
unpow-170.4%
associate-/l/72.8%
associate-*l*72.8%
Simplified72.8%
pow172.8%
sqrt-unprod61.2%
un-div-inv61.2%
*-commutative61.2%
associate-*r*61.2%
*-commutative61.2%
Applied egg-rr61.2%
unpow161.2%
associate-/r/61.2%
associate-*r*60.4%
Simplified60.4%
if -1.000000000000002e-309 < l < 1e189Initial program 77.2%
Simplified74.4%
Applied egg-rr74.8%
distribute-rgt1-in86.5%
+-commutative86.5%
associate-*r*86.5%
associate-*r*86.5%
associate-/l*89.4%
*-commutative89.4%
associate-*r*89.4%
associate-/l*89.4%
associate-/r*89.4%
Simplified89.4%
*-un-lft-identity89.4%
associate-/l/89.4%
pow1/289.4%
pow1/289.4%
pow-prod-down82.0%
*-commutative82.0%
pow1/282.0%
*-commutative82.0%
Applied egg-rr82.0%
*-lft-identity82.0%
Simplified82.0%
if 1e189 < l Initial program 49.2%
Simplified52.0%
Applied egg-rr63.3%
Taylor expanded in d around inf 53.1%
associate-/l/53.2%
Simplified53.2%
sqrt-div67.6%
Applied egg-rr67.6%
Final simplification69.9%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (cbrt (pow (/ 1.0 (* l h)) 1.5))))
(if (<= l -2.52e-104)
(* d (- (sqrt (/ (/ 1.0 l) h))))
(if (<= l -6e-250)
(* d t_0)
(if (<= l 2.3e-155)
(* (- d) t_0)
(* d (/ (sqrt (/ 1.0 l)) (sqrt h))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = cbrt(pow((1.0 / (l * h)), 1.5));
double tmp;
if (l <= -2.52e-104) {
tmp = d * -sqrt(((1.0 / l) / h));
} else if (l <= -6e-250) {
tmp = d * t_0;
} else if (l <= 2.3e-155) {
tmp = -d * t_0;
} else {
tmp = d * (sqrt((1.0 / l)) / sqrt(h));
}
return tmp;
}
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = Math.cbrt(Math.pow((1.0 / (l * h)), 1.5));
double tmp;
if (l <= -2.52e-104) {
tmp = d * -Math.sqrt(((1.0 / l) / h));
} else if (l <= -6e-250) {
tmp = d * t_0;
} else if (l <= 2.3e-155) {
tmp = -d * t_0;
} else {
tmp = d * (Math.sqrt((1.0 / l)) / Math.sqrt(h));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = cbrt((Float64(1.0 / Float64(l * h)) ^ 1.5)) tmp = 0.0 if (l <= -2.52e-104) tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / l) / h)))); elseif (l <= -6e-250) tmp = Float64(d * t_0); elseif (l <= 2.3e-155) tmp = Float64(Float64(-d) * t_0); else tmp = Float64(d * Float64(sqrt(Float64(1.0 / l)) / sqrt(h))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Power[N[Power[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[l, -2.52e-104], N[(d * (-N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[l, -6e-250], N[(d * t$95$0), $MachinePrecision], If[LessEqual[l, 2.3e-155], N[((-d) * t$95$0), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt[3]{{\left(\frac{1}{\ell \cdot h}\right)}^{1.5}}\\
\mathbf{if}\;\ell \leq -2.52 \cdot 10^{-104}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\
\mathbf{elif}\;\ell \leq -6 \cdot 10^{-250}:\\
\;\;\;\;d \cdot t\_0\\
\mathbf{elif}\;\ell \leq 2.3 \cdot 10^{-155}:\\
\;\;\;\;\left(-d\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if l < -2.52e-104Initial program 67.6%
Simplified67.6%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt48.2%
neg-mul-148.2%
Simplified48.2%
Taylor expanded in l around 0 48.2%
associate-/l/48.8%
Simplified48.8%
if -2.52e-104 < l < -6.00000000000000032e-250Initial program 75.5%
Simplified73.6%
Applied egg-rr0.0%
Taylor expanded in d around inf 21.1%
associate-/l/21.1%
Simplified21.1%
add-cbrt-cube31.9%
add-sqr-sqrt31.9%
pow131.9%
pow1/231.9%
pow-prod-up31.9%
associate-/l/31.9%
metadata-eval31.9%
Applied egg-rr31.9%
if -6.00000000000000032e-250 < l < 2.30000000000000005e-155Initial program 76.6%
Simplified70.7%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt29.8%
neg-mul-129.8%
Simplified29.8%
add-cbrt-cube37.4%
pow1/337.4%
add-sqr-sqrt37.4%
pow137.4%
pow1/237.4%
pow-prod-up37.4%
associate-/r*37.4%
metadata-eval37.4%
Applied egg-rr37.4%
unpow1/337.4%
associate-/l/37.4%
Simplified37.4%
if 2.30000000000000005e-155 < l Initial program 67.4%
Simplified67.4%
Applied egg-rr52.9%
Taylor expanded in d around inf 46.8%
associate-/l/46.9%
Simplified46.9%
sqrt-div54.7%
Applied egg-rr54.7%
Final simplification46.4%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= l -1.02e-103)
(* d (- (sqrt (/ (/ 1.0 l) h))))
(if (<= l -5.3e-250)
(* d (cbrt (pow (/ 1.0 (* l h)) 1.5)))
(if (<= l 5.5e-268)
(* d (- (pow (* l h) -0.5)))
(* d (/ (sqrt (/ 1.0 l)) (sqrt h)))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -1.02e-103) {
tmp = d * -sqrt(((1.0 / l) / h));
} else if (l <= -5.3e-250) {
tmp = d * cbrt(pow((1.0 / (l * h)), 1.5));
} else if (l <= 5.5e-268) {
tmp = d * -pow((l * h), -0.5);
} else {
tmp = d * (sqrt((1.0 / l)) / sqrt(h));
}
return tmp;
}
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -1.02e-103) {
tmp = d * -Math.sqrt(((1.0 / l) / h));
} else if (l <= -5.3e-250) {
tmp = d * Math.cbrt(Math.pow((1.0 / (l * h)), 1.5));
} else if (l <= 5.5e-268) {
tmp = d * -Math.pow((l * h), -0.5);
} else {
tmp = d * (Math.sqrt((1.0 / l)) / Math.sqrt(h));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= -1.02e-103) tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / l) / h)))); elseif (l <= -5.3e-250) tmp = Float64(d * cbrt((Float64(1.0 / Float64(l * h)) ^ 1.5))); elseif (l <= 5.5e-268) tmp = Float64(d * Float64(-(Float64(l * h) ^ -0.5))); else tmp = Float64(d * Float64(sqrt(Float64(1.0 / l)) / sqrt(h))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, -1.02e-103], N[(d * (-N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[l, -5.3e-250], N[(d * N[Power[N[Power[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.5e-268], N[(d * (-N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision])), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.02 \cdot 10^{-103}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\
\mathbf{elif}\;\ell \leq -5.3 \cdot 10^{-250}:\\
\;\;\;\;d \cdot \sqrt[3]{{\left(\frac{1}{\ell \cdot h}\right)}^{1.5}}\\
\mathbf{elif}\;\ell \leq 5.5 \cdot 10^{-268}:\\
\;\;\;\;d \cdot \left(-{\left(\ell \cdot h\right)}^{-0.5}\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if l < -1.01999999999999998e-103Initial program 67.6%
Simplified67.6%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt48.2%
neg-mul-148.2%
Simplified48.2%
Taylor expanded in l around 0 48.2%
associate-/l/48.8%
Simplified48.8%
if -1.01999999999999998e-103 < l < -5.3000000000000001e-250Initial program 75.5%
Simplified73.6%
Applied egg-rr0.0%
Taylor expanded in d around inf 21.1%
associate-/l/21.1%
Simplified21.1%
add-cbrt-cube31.9%
add-sqr-sqrt31.9%
pow131.9%
pow1/231.9%
pow-prod-up31.9%
associate-/l/31.9%
metadata-eval31.9%
Applied egg-rr31.9%
if -5.3000000000000001e-250 < l < 5.4999999999999997e-268Initial program 78.5%
Simplified74.2%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt40.4%
neg-mul-140.4%
Simplified40.4%
pow1/240.4%
inv-pow40.4%
pow-pow40.4%
metadata-eval40.4%
Applied egg-rr40.4%
if 5.4999999999999997e-268 < l Initial program 69.1%
Simplified67.5%
Applied egg-rr45.3%
Taylor expanded in d around inf 40.1%
associate-/l/40.1%
Simplified40.1%
sqrt-div47.7%
Applied egg-rr47.7%
Final simplification45.1%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (if (<= h 1e-302) (* d (- (pow (* l h) -0.5))) (* d (/ (sqrt (/ 1.0 l)) (sqrt h)))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (h <= 1e-302) {
tmp = d * -pow((l * h), -0.5);
} else {
tmp = d * (sqrt((1.0 / l)) / sqrt(h));
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (h <= 1d-302) then
tmp = d * -((l * h) ** (-0.5d0))
else
tmp = d * (sqrt((1.0d0 / l)) / sqrt(h))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (h <= 1e-302) {
tmp = d * -Math.pow((l * h), -0.5);
} else {
tmp = d * (Math.sqrt((1.0 / l)) / Math.sqrt(h));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if h <= 1e-302: tmp = d * -math.pow((l * h), -0.5) else: tmp = d * (math.sqrt((1.0 / l)) / math.sqrt(h)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (h <= 1e-302) tmp = Float64(d * Float64(-(Float64(l * h) ^ -0.5))); else tmp = Float64(d * Float64(sqrt(Float64(1.0 / l)) / sqrt(h))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (h <= 1e-302)
tmp = d * -((l * h) ^ -0.5);
else
tmp = d * (sqrt((1.0 / l)) / sqrt(h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[h, 1e-302], N[(d * (-N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision])), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq 10^{-302}:\\
\;\;\;\;d \cdot \left(-{\left(\ell \cdot h\right)}^{-0.5}\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if h < 9.9999999999999996e-303Initial program 70.7%
Simplified69.3%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt38.5%
neg-mul-138.5%
Simplified38.5%
pow1/238.5%
inv-pow38.5%
pow-pow39.2%
metadata-eval39.2%
Applied egg-rr39.2%
if 9.9999999999999996e-303 < h Initial program 70.1%
Simplified68.7%
Applied egg-rr42.4%
Taylor expanded in d around inf 37.6%
associate-/l/37.6%
Simplified37.6%
sqrt-div44.5%
Applied egg-rr44.5%
Final simplification42.0%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (let* ((t_0 (pow (* l h) -0.5))) (if (<= d 1.65e-260) (* d (- t_0)) (* d t_0))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = pow((l * h), -0.5);
double tmp;
if (d <= 1.65e-260) {
tmp = d * -t_0;
} else {
tmp = d * t_0;
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = (l * h) ** (-0.5d0)
if (d <= 1.65d-260) then
tmp = d * -t_0
else
tmp = d * t_0
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = Math.pow((l * h), -0.5);
double tmp;
if (d <= 1.65e-260) {
tmp = d * -t_0;
} else {
tmp = d * t_0;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = math.pow((l * h), -0.5) tmp = 0 if d <= 1.65e-260: tmp = d * -t_0 else: tmp = d * t_0 return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(l * h) ^ -0.5 tmp = 0.0 if (d <= 1.65e-260) tmp = Float64(d * Float64(-t_0)); else tmp = Float64(d * t_0); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (l * h) ^ -0.5;
tmp = 0.0;
if (d <= 1.65e-260)
tmp = d * -t_0;
else
tmp = d * t_0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]}, If[LessEqual[d, 1.65e-260], N[(d * (-t$95$0)), $MachinePrecision], N[(d * t$95$0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;d \leq 1.65 \cdot 10^{-260}:\\
\;\;\;\;d \cdot \left(-t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\
\end{array}
\end{array}
if d < 1.6499999999999999e-260Initial program 66.0%
Simplified64.7%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt36.8%
neg-mul-136.8%
Simplified36.8%
pow1/236.8%
inv-pow36.8%
pow-pow37.3%
metadata-eval37.3%
Applied egg-rr37.3%
if 1.6499999999999999e-260 < d Initial program 75.5%
Simplified73.8%
clear-num73.9%
un-div-inv73.9%
frac-times75.5%
associate-/l*73.9%
*-un-lft-identity73.9%
times-frac73.9%
metadata-eval73.9%
Applied egg-rr73.9%
associate-*r*73.9%
associate-/l*75.5%
*-commutative75.5%
associate-*r*75.5%
associate-/l*75.5%
Simplified75.5%
clear-num75.5%
inv-pow75.5%
Applied egg-rr75.5%
unpow-175.5%
associate-/l/74.0%
associate-*l*73.2%
Simplified73.2%
Taylor expanded in d around inf 40.4%
unpow-140.4%
metadata-eval40.4%
pow-sqr40.4%
rem-sqrt-square41.1%
metadata-eval41.1%
pow-sqr41.0%
fabs-sqr41.0%
pow-sqr41.1%
metadata-eval41.1%
Simplified41.1%
Final simplification39.1%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (* d (sqrt (/ 1.0 (* l h)))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
return d * sqrt((1.0 / (l * h)));
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
code = d * sqrt((1.0d0 / (l * h)))
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
return d * Math.sqrt((1.0 / (l * h)));
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): return d * math.sqrt((1.0 / (l * h)))
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) return Float64(d * sqrt(Float64(1.0 / Float64(l * h)))) end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
tmp = d * sqrt((1.0 / (l * h)));
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
d \cdot \sqrt{\frac{1}{\ell \cdot h}}
\end{array}
Initial program 70.4%
Simplified69.0%
Taylor expanded in d around inf 25.0%
*-commutative25.0%
Simplified25.0%
Final simplification25.0%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (* d (sqrt (/ (/ 1.0 l) h))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
return d * sqrt(((1.0 / l) / h));
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
code = d * sqrt(((1.0d0 / l) / h))
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
return d * Math.sqrt(((1.0 / l) / h));
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): return d * math.sqrt(((1.0 / l) / h))
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) return Float64(d * sqrt(Float64(Float64(1.0 / l) / h))) end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
tmp = d * sqrt(((1.0 / l) / h));
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}
\end{array}
Initial program 70.4%
Simplified69.0%
Applied egg-rr22.2%
Taylor expanded in d around inf 25.0%
associate-/l/25.0%
Simplified25.0%
Final simplification25.0%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (* d (pow (* l h) -0.5)))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
return d * pow((l * h), -0.5);
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
code = d * ((l * h) ** (-0.5d0))
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
return d * Math.pow((l * h), -0.5);
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): return d * math.pow((l * h), -0.5)
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) return Float64(d * (Float64(l * h) ^ -0.5)) end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
tmp = d * ((l * h) ^ -0.5);
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
d \cdot {\left(\ell \cdot h\right)}^{-0.5}
\end{array}
Initial program 70.4%
Simplified69.0%
clear-num69.0%
un-div-inv69.0%
frac-times70.4%
associate-/l*69.0%
*-un-lft-identity69.0%
times-frac69.0%
metadata-eval69.0%
Applied egg-rr69.0%
associate-*r*69.0%
associate-/l*70.4%
*-commutative70.4%
associate-*r*70.4%
associate-/l*70.4%
Simplified70.4%
clear-num70.4%
inv-pow70.4%
Applied egg-rr70.4%
unpow-170.4%
associate-/l/70.8%
associate-*l*70.4%
Simplified70.4%
Taylor expanded in d around inf 25.0%
unpow-125.0%
metadata-eval25.0%
pow-sqr25.0%
rem-sqrt-square24.6%
metadata-eval24.6%
pow-sqr24.5%
fabs-sqr24.5%
pow-sqr24.6%
metadata-eval24.6%
Simplified24.6%
Final simplification24.6%
herbie shell --seed 2024053
(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)))))