
(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 13 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 (pow (* D_m (* M_m (/ 0.5 d))) 2.0)) (t_1 (sqrt (- d))))
(if (<= h -6e-27)
(*
(/ t_1 (sqrt (- l)))
(* (sqrt (/ d h)) (+ 1.0 (* h (* t_0 (/ -0.5 l))))))
(if (<= h -3.9e-306)
(*
(* (/ t_1 (sqrt (- h))) (sqrt (/ d l)))
(- 1.0 (* 0.5 (* (pow (/ (* M_m (* D_m 0.5)) d) 2.0) (/ h l)))))
(* d (/ (fma (/ h l) (* t_0 -0.5) 1.0) (* (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 t_0 = pow((D_m * (M_m * (0.5 / d))), 2.0);
double t_1 = sqrt(-d);
double tmp;
if (h <= -6e-27) {
tmp = (t_1 / sqrt(-l)) * (sqrt((d / h)) * (1.0 + (h * (t_0 * (-0.5 / l)))));
} else if (h <= -3.9e-306) {
tmp = ((t_1 / sqrt(-h)) * sqrt((d / l))) * (1.0 - (0.5 * (pow(((M_m * (D_m * 0.5)) / d), 2.0) * (h / l))));
} else {
tmp = d * (fma((h / l), (t_0 * -0.5), 1.0) / (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) t_0 = Float64(D_m * Float64(M_m * Float64(0.5 / d))) ^ 2.0 t_1 = sqrt(Float64(-d)) tmp = 0.0 if (h <= -6e-27) tmp = Float64(Float64(t_1 / sqrt(Float64(-l))) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(h * Float64(t_0 * Float64(-0.5 / l)))))); elseif (h <= -3.9e-306) tmp = Float64(Float64(Float64(t_1 / sqrt(Float64(-h))) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * Float64((Float64(Float64(M_m * Float64(D_m * 0.5)) / d) ^ 2.0) * Float64(h / l))))); else tmp = Float64(d * Float64(fma(Float64(h / l), Float64(t_0 * -0.5), 1.0) / Float64(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_] := Block[{t$95$0 = N[Power[N[(D$95$m * N[(M$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[h, -6e-27], N[(N[(t$95$1 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(t$95$0 * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -3.9e-306], N[(N[(N[(t$95$1 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[Power[N[(N[(M$95$m * N[(D$95$m * 0.5), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(N[(h / l), $MachinePrecision] * N[(t$95$0 * -0.5), $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_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(D\_m \cdot \left(M\_m \cdot \frac{0.5}{d}\right)\right)}^{2}\\
t_1 := \sqrt{-d}\\
\mathbf{if}\;h \leq -6 \cdot 10^{-27}:\\
\;\;\;\;\frac{t\_1}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + h \cdot \left(t\_0 \cdot \frac{-0.5}{\ell}\right)\right)\right)\\
\mathbf{elif}\;h \leq -3.9 \cdot 10^{-306}:\\
\;\;\;\;\left(\frac{t\_1}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M\_m \cdot \left(D\_m \cdot 0.5\right)}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell}, t\_0 \cdot -0.5, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if h < -6.0000000000000002e-27Initial program 57.5%
Simplified57.5%
clear-num57.5%
associate-*l/57.5%
*-un-lft-identity57.5%
frac-times57.6%
associate-/l*57.5%
*-un-lft-identity57.5%
times-frac57.5%
metadata-eval57.5%
Applied egg-rr57.5%
associate-/r/67.8%
*-commutative67.8%
associate-/l*67.8%
associate-*r*67.8%
associate-*r/67.8%
*-commutative67.8%
associate-/l*67.7%
associate-/l*67.7%
Simplified67.7%
frac-2neg67.7%
sqrt-div74.0%
Applied egg-rr74.0%
if -6.0000000000000002e-27 < h < -3.9e-306Initial program 80.5%
Simplified75.8%
frac-2neg75.8%
sqrt-div85.4%
Applied egg-rr85.4%
associate-*r/90.2%
div-inv90.2%
associate-*l*90.2%
metadata-eval90.2%
Applied egg-rr90.2%
if -3.9e-306 < h Initial program 72.3%
Applied egg-rr73.3%
distribute-rgt1-in81.9%
+-commutative81.9%
*-commutative81.9%
associate-*l/84.9%
associate-/l*84.8%
Simplified86.2%
Final simplification84.4%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (/ d l))) (t_1 (pow (* D_m (* M_m (/ 0.5 d))) 2.0)))
(if (<= l -1.1e+42)
(*
(* (/ (sqrt (- d)) (sqrt (- h))) t_0)
(- 1.0 (* 0.5 (* (/ h l) (pow (* (/ M_m 2.0) (/ D_m d)) 2.0)))))
(if (<= l 1.35e-304)
(* (* (sqrt (/ d h)) (+ 1.0 (* h (* t_1 (/ -0.5 l))))) t_0)
(* d (/ (fma (/ h l) (* t_1 -0.5) 1.0) (* (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 t_0 = sqrt((d / l));
double t_1 = pow((D_m * (M_m * (0.5 / d))), 2.0);
double tmp;
if (l <= -1.1e+42) {
tmp = ((sqrt(-d) / sqrt(-h)) * t_0) * (1.0 - (0.5 * ((h / l) * pow(((M_m / 2.0) * (D_m / d)), 2.0))));
} else if (l <= 1.35e-304) {
tmp = (sqrt((d / h)) * (1.0 + (h * (t_1 * (-0.5 / l))))) * t_0;
} else {
tmp = d * (fma((h / l), (t_1 * -0.5), 1.0) / (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) t_0 = sqrt(Float64(d / l)) t_1 = Float64(D_m * Float64(M_m * Float64(0.5 / d))) ^ 2.0 tmp = 0.0 if (l <= -1.1e+42) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_0) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(M_m / 2.0) * Float64(D_m / d)) ^ 2.0))))); elseif (l <= 1.35e-304) tmp = Float64(Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(h * Float64(t_1 * Float64(-0.5 / l))))) * t_0); else tmp = Float64(d * Float64(fma(Float64(h / l), Float64(t_1 * -0.5), 1.0) / Float64(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_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(D$95$m * N[(M$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[l, -1.1e+42], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$0), $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], If[LessEqual[l, 1.35e-304], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(t$95$1 * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(d * N[(N[(N[(h / l), $MachinePrecision] * N[(t$95$1 * -0.5), $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_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{\frac{d}{\ell}}\\
t_1 := {\left(D\_m \cdot \left(M\_m \cdot \frac{0.5}{d}\right)\right)}^{2}\\
\mathbf{if}\;\ell \leq -1.1 \cdot 10^{+42}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t\_0\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{elif}\;\ell \leq 1.35 \cdot 10^{-304}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \left(1 + h \cdot \left(t\_1 \cdot \frac{-0.5}{\ell}\right)\right)\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell}, t\_1 \cdot -0.5, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -1.1000000000000001e42Initial program 60.7%
Simplified60.6%
frac-2neg60.6%
sqrt-div72.7%
Applied egg-rr72.7%
if -1.1000000000000001e42 < l < 1.35000000000000005e-304Initial program 72.1%
Simplified68.4%
clear-num68.3%
associate-*l/68.3%
*-un-lft-identity68.3%
frac-times72.1%
associate-/l*68.3%
*-un-lft-identity68.3%
times-frac68.3%
metadata-eval68.3%
Applied egg-rr68.3%
associate-/r/76.6%
*-commutative76.6%
associate-/l*76.6%
associate-*r*76.6%
associate-*r/79.2%
*-commutative79.2%
associate-/l*79.1%
associate-/l*79.1%
Simplified79.1%
if 1.35000000000000005e-304 < l Initial program 73.7%
Applied egg-rr75.5%
distribute-rgt1-in83.6%
+-commutative83.6%
*-commutative83.6%
associate-*l/86.7%
associate-/l*86.5%
Simplified88.0%
Final simplification82.6%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= h -3.9e-306)
(*
(* (/ (sqrt (- d)) (sqrt (- h))) (sqrt (/ d l)))
(- 1.0 (* 0.5 (* (pow (/ (* M_m (* D_m 0.5)) d) 2.0) (/ h l)))))
(*
d
(/
(fma (/ h l) (* (pow (* D_m (* M_m (/ 0.5 d))) 2.0) -0.5) 1.0)
(* (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 <= -3.9e-306) {
tmp = ((sqrt(-d) / sqrt(-h)) * sqrt((d / l))) * (1.0 - (0.5 * (pow(((M_m * (D_m * 0.5)) / d), 2.0) * (h / l))));
} else {
tmp = d * (fma((h / l), (pow((D_m * (M_m * (0.5 / d))), 2.0) * -0.5), 1.0) / (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 <= -3.9e-306) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * Float64((Float64(Float64(M_m * Float64(D_m * 0.5)) / d) ^ 2.0) * Float64(h / l))))); else tmp = Float64(d * Float64(fma(Float64(h / l), Float64((Float64(D_m * Float64(M_m * Float64(0.5 / d))) ^ 2.0) * -0.5), 1.0) / Float64(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, -3.9e-306], 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[(M$95$m * N[(D$95$m * 0.5), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(D$95$m * N[(M$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $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_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -3.9 \cdot 10^{-306}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M\_m \cdot \left(D\_m \cdot 0.5\right)}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell}, {\left(D\_m \cdot \left(M\_m \cdot \frac{0.5}{d}\right)\right)}^{2} \cdot -0.5, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if h < -3.9e-306Initial program 69.1%
Simplified66.7%
frac-2neg66.7%
sqrt-div75.0%
Applied egg-rr75.0%
associate-*r/77.4%
div-inv77.4%
associate-*l*77.4%
metadata-eval77.4%
Applied egg-rr77.4%
if -3.9e-306 < h Initial program 72.3%
Applied egg-rr73.3%
distribute-rgt1-in81.9%
+-commutative81.9%
*-commutative81.9%
associate-*l/84.9%
associate-/l*84.8%
Simplified86.2%
Final simplification82.2%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (pow (* D_m (* M_m (/ 0.5 d))) 2.0)))
(if (<= l 1.9e-304)
(* (* (sqrt (/ d h)) (+ 1.0 (* h (* t_0 (/ -0.5 l))))) (sqrt (/ d l)))
(* d (/ (fma (/ h l) (* t_0 -0.5) 1.0) (* (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 t_0 = pow((D_m * (M_m * (0.5 / d))), 2.0);
double tmp;
if (l <= 1.9e-304) {
tmp = (sqrt((d / h)) * (1.0 + (h * (t_0 * (-0.5 / l))))) * sqrt((d / l));
} else {
tmp = d * (fma((h / l), (t_0 * -0.5), 1.0) / (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) t_0 = Float64(D_m * Float64(M_m * Float64(0.5 / d))) ^ 2.0 tmp = 0.0 if (l <= 1.9e-304) tmp = Float64(Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(h * Float64(t_0 * Float64(-0.5 / l))))) * sqrt(Float64(d / l))); else tmp = Float64(d * Float64(fma(Float64(h / l), Float64(t_0 * -0.5), 1.0) / Float64(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_] := Block[{t$95$0 = N[Power[N[(D$95$m * N[(M$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[l, 1.9e-304], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(t$95$0 * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(N[(h / l), $MachinePrecision] * N[(t$95$0 * -0.5), $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_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(D\_m \cdot \left(M\_m \cdot \frac{0.5}{d}\right)\right)}^{2}\\
\mathbf{if}\;\ell \leq 1.9 \cdot 10^{-304}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \left(1 + h \cdot \left(t\_0 \cdot \frac{-0.5}{\ell}\right)\right)\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell}, t\_0 \cdot -0.5, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < 1.8999999999999998e-304Initial program 67.7%
Simplified65.4%
clear-num65.3%
associate-*l/65.3%
*-un-lft-identity65.3%
frac-times67.7%
associate-/l*65.3%
*-un-lft-identity65.3%
times-frac65.3%
metadata-eval65.3%
Applied egg-rr65.3%
associate-/r/70.4%
*-commutative70.4%
associate-/l*70.4%
associate-*r*70.4%
associate-*r/72.0%
*-commutative72.0%
associate-/l*71.9%
associate-/l*71.9%
Simplified71.9%
if 1.8999999999999998e-304 < l Initial program 73.7%
Applied egg-rr75.5%
distribute-rgt1-in83.6%
+-commutative83.6%
*-commutative83.6%
associate-*l/86.7%
associate-/l*86.5%
Simplified88.0%
Final simplification80.4%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -9e-86)
(* d (- (sqrt (/ 1.0 (* h l)))))
(if (<= l -5e-310)
(* d (exp (* (log1p (+ (* h l) -1.0)) (- 0.5))))
(*
(+ 1.0 (* h (/ (* -0.5 (pow (* D_m (/ (* M_m 0.5) d)) 2.0)) l)))
(/ (/ 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 (l <= -9e-86) {
tmp = d * -sqrt((1.0 / (h * l)));
} else if (l <= -5e-310) {
tmp = d * exp((log1p(((h * l) + -1.0)) * -0.5));
} else {
tmp = (1.0 + (h * ((-0.5 * pow((D_m * ((M_m * 0.5) / d)), 2.0)) / l))) * ((d / sqrt(l)) / sqrt(h));
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -9e-86) {
tmp = d * -Math.sqrt((1.0 / (h * l)));
} else if (l <= -5e-310) {
tmp = d * Math.exp((Math.log1p(((h * l) + -1.0)) * -0.5));
} else {
tmp = (1.0 + (h * ((-0.5 * Math.pow((D_m * ((M_m * 0.5) / d)), 2.0)) / l))) * ((d / Math.sqrt(l)) / Math.sqrt(h));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if l <= -9e-86: tmp = d * -math.sqrt((1.0 / (h * l))) elif l <= -5e-310: tmp = d * math.exp((math.log1p(((h * l) + -1.0)) * -0.5)) else: tmp = (1.0 + (h * ((-0.5 * math.pow((D_m * ((M_m * 0.5) / d)), 2.0)) / l))) * ((d / math.sqrt(l)) / math.sqrt(h)) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -9e-86) tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(h * l))))); elseif (l <= -5e-310) tmp = Float64(d * exp(Float64(log1p(Float64(Float64(h * l) + -1.0)) * Float64(-0.5)))); else tmp = Float64(Float64(1.0 + Float64(h * Float64(Float64(-0.5 * (Float64(D_m * Float64(Float64(M_m * 0.5) / d)) ^ 2.0)) / l))) * 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[l, -9e-86], N[(d * (-N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[l, -5e-310], N[(d * N[Exp[N[(N[Log[1 + N[(N[(h * l), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] * (-0.5)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(h * N[(N[(-0.5 * N[Power[N[(D$95$m * N[(N[(M$95$m * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $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_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 \cdot 10^{-86}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{h \cdot \ell}}\right)\\
\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot e^{\mathsf{log1p}\left(h \cdot \ell + -1\right) \cdot \left(-0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + h \cdot \frac{-0.5 \cdot {\left(D\_m \cdot \frac{M\_m \cdot 0.5}{d}\right)}^{2}}{\ell}\right) \cdot \frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if l < -8.9999999999999995e-86Initial program 65.5%
Applied egg-rr27.6%
associate-*l/27.6%
associate-/l*27.7%
associate-*r*27.7%
associate-*r/27.8%
*-commutative27.8%
associate-/l*27.7%
Simplified27.7%
Taylor expanded in d around -inf 50.1%
associate-*r*50.1%
neg-mul-150.1%
Simplified50.1%
if -8.9999999999999995e-86 < l < -4.999999999999985e-310Initial program 73.5%
Taylor expanded in d around inf 26.9%
pow1/226.9%
pow-to-exp26.9%
log-rec24.7%
Applied egg-rr24.7%
log1p-expm1-u54.5%
expm1-undefine54.5%
add-exp-log54.5%
Applied egg-rr54.5%
if -4.999999999999985e-310 < l Initial program 72.9%
Applied egg-rr73.8%
distribute-rgt1-in82.5%
+-commutative82.5%
associate-*l/84.8%
associate-/l*84.1%
associate-*r*84.1%
associate-*r/87.0%
*-commutative87.0%
associate-/l*85.6%
associate-/r*83.5%
Simplified83.5%
Final simplification68.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -5e-310)
(*
(*
(sqrt (/ d h))
(+ 1.0 (* h (* (pow (* D_m (* M_m (/ 0.5 d))) 2.0) (/ -0.5 l)))))
(sqrt (/ d l)))
(*
(+ 1.0 (* h (/ (* -0.5 (pow (* D_m (/ (* M_m 0.5) d)) 2.0)) l)))
(/ (/ 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 (l <= -5e-310) {
tmp = (sqrt((d / h)) * (1.0 + (h * (pow((D_m * (M_m * (0.5 / d))), 2.0) * (-0.5 / l))))) * sqrt((d / l));
} else {
tmp = (1.0 + (h * ((-0.5 * pow((D_m * ((M_m * 0.5) / d)), 2.0)) / l))) * ((d / sqrt(l)) / sqrt(h));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (l <= (-5d-310)) then
tmp = (sqrt((d / h)) * (1.0d0 + (h * (((d_m * (m_m * (0.5d0 / d))) ** 2.0d0) * ((-0.5d0) / l))))) * sqrt((d / l))
else
tmp = (1.0d0 + (h * (((-0.5d0) * ((d_m * ((m_m * 0.5d0) / d)) ** 2.0d0)) / l))) * ((d / sqrt(l)) / sqrt(h))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -5e-310) {
tmp = (Math.sqrt((d / h)) * (1.0 + (h * (Math.pow((D_m * (M_m * (0.5 / d))), 2.0) * (-0.5 / l))))) * Math.sqrt((d / l));
} else {
tmp = (1.0 + (h * ((-0.5 * Math.pow((D_m * ((M_m * 0.5) / d)), 2.0)) / l))) * ((d / Math.sqrt(l)) / Math.sqrt(h));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if l <= -5e-310: tmp = (math.sqrt((d / h)) * (1.0 + (h * (math.pow((D_m * (M_m * (0.5 / d))), 2.0) * (-0.5 / l))))) * math.sqrt((d / l)) else: tmp = (1.0 + (h * ((-0.5 * math.pow((D_m * ((M_m * 0.5) / d)), 2.0)) / l))) * ((d / math.sqrt(l)) / math.sqrt(h)) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -5e-310) tmp = Float64(Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(h * Float64((Float64(D_m * Float64(M_m * Float64(0.5 / d))) ^ 2.0) * Float64(-0.5 / l))))) * sqrt(Float64(d / l))); else tmp = Float64(Float64(1.0 + Float64(h * Float64(Float64(-0.5 * (Float64(D_m * Float64(Float64(M_m * 0.5) / d)) ^ 2.0)) / l))) * Float64(Float64(d / sqrt(l)) / sqrt(h))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (l <= -5e-310)
tmp = (sqrt((d / h)) * (1.0 + (h * (((D_m * (M_m * (0.5 / d))) ^ 2.0) * (-0.5 / l))))) * sqrt((d / l));
else
tmp = (1.0 + (h * ((-0.5 * ((D_m * ((M_m * 0.5) / d)) ^ 2.0)) / l))) * ((d / sqrt(l)) / sqrt(h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -5e-310], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(N[Power[N[(D$95$m * N[(M$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(h * N[(N[(-0.5 * N[Power[N[(D$95$m * N[(N[(M$95$m * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $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_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}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \left(1 + h \cdot \left({\left(D\_m \cdot \left(M\_m \cdot \frac{0.5}{d}\right)\right)}^{2} \cdot \frac{-0.5}{\ell}\right)\right)\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + h \cdot \frac{-0.5 \cdot {\left(D\_m \cdot \frac{M\_m \cdot 0.5}{d}\right)}^{2}}{\ell}\right) \cdot \frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if l < -4.999999999999985e-310Initial program 68.5%
Simplified66.2%
clear-num66.2%
associate-*l/66.1%
*-un-lft-identity66.1%
frac-times68.5%
associate-/l*66.1%
*-un-lft-identity66.1%
times-frac66.1%
metadata-eval66.1%
Applied egg-rr66.1%
associate-/r/70.4%
*-commutative70.4%
associate-/l*70.4%
associate-*r*70.4%
associate-*r/72.1%
*-commutative72.1%
associate-/l*72.0%
associate-/l*72.0%
Simplified72.0%
if -4.999999999999985e-310 < l Initial program 72.9%
Applied egg-rr73.8%
distribute-rgt1-in82.5%
+-commutative82.5%
associate-*l/84.8%
associate-/l*84.1%
associate-*r*84.1%
associate-*r/87.0%
*-commutative87.0%
associate-/l*85.6%
associate-/r*83.5%
Simplified83.5%
Final simplification78.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.7e-84)
(* d (- (sqrt (/ 1.0 (* h l)))))
(if (<= l -5e-310)
(* d (exp (* (log1p (+ (* h l) -1.0)) (- 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 (l <= -2.7e-84) {
tmp = d * -sqrt((1.0 / (h * l)));
} else if (l <= -5e-310) {
tmp = d * exp((log1p(((h * l) + -1.0)) * -0.5));
} else {
tmp = d * (pow(h, -0.5) / sqrt(l));
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -2.7e-84) {
tmp = d * -Math.sqrt((1.0 / (h * l)));
} else if (l <= -5e-310) {
tmp = d * Math.exp((Math.log1p(((h * l) + -1.0)) * -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 l <= -2.7e-84: tmp = d * -math.sqrt((1.0 / (h * l))) elif l <= -5e-310: tmp = d * math.exp((math.log1p(((h * l) + -1.0)) * -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 (l <= -2.7e-84) tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(h * l))))); elseif (l <= -5e-310) tmp = Float64(d * exp(Float64(log1p(Float64(Float64(h * l) + -1.0)) * Float64(-0.5)))); else tmp = Float64(d * Float64((h ^ -0.5) / sqrt(l))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -2.7e-84], N[(d * (-N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[l, -5e-310], N[(d * N[Exp[N[(N[Log[1 + N[(N[(h * l), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] * (-0.5)), $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.7 \cdot 10^{-84}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{h \cdot \ell}}\right)\\
\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot e^{\mathsf{log1p}\left(h \cdot \ell + -1\right) \cdot \left(-0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < -2.6999999999999999e-84Initial program 65.5%
Applied egg-rr27.6%
associate-*l/27.6%
associate-/l*27.7%
associate-*r*27.7%
associate-*r/27.8%
*-commutative27.8%
associate-/l*27.7%
Simplified27.7%
Taylor expanded in d around -inf 50.1%
associate-*r*50.1%
neg-mul-150.1%
Simplified50.1%
if -2.6999999999999999e-84 < l < -4.999999999999985e-310Initial program 73.5%
Taylor expanded in d around inf 26.9%
pow1/226.9%
pow-to-exp26.9%
log-rec24.7%
Applied egg-rr24.7%
log1p-expm1-u54.5%
expm1-undefine54.5%
add-exp-log54.5%
Applied egg-rr54.5%
if -4.999999999999985e-310 < l Initial program 72.9%
Taylor expanded in d around inf 47.2%
pow1/247.2%
pow-to-exp44.8%
log-rec44.8%
Applied egg-rr44.8%
neg-log44.8%
*-commutative44.8%
associate-/l/44.8%
pow-to-exp47.2%
pow1/247.2%
*-un-lft-identity47.2%
sqrt-div53.1%
sqrt-div53.1%
metadata-eval53.1%
pow1/253.1%
pow-flip53.2%
metadata-eval53.2%
Applied egg-rr53.2%
*-lft-identity53.2%
Simplified53.2%
Final simplification52.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 -3.8e-183)
(* (- d) (pow (* h l) -0.5))
(if (<= l -5e-310)
(* d (pow (/ 1.0 (pow (* h l) 3.0)) 0.16666666666666666))
(* 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 <= -3.8e-183) {
tmp = -d * pow((h * l), -0.5);
} else if (l <= -5e-310) {
tmp = d * pow((1.0 / pow((h * l), 3.0)), 0.16666666666666666);
} 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 <= (-3.8d-183)) then
tmp = -d * ((h * l) ** (-0.5d0))
else if (l <= (-5d-310)) then
tmp = d * ((1.0d0 / ((h * l) ** 3.0d0)) ** 0.16666666666666666d0)
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 <= -3.8e-183) {
tmp = -d * Math.pow((h * l), -0.5);
} else if (l <= -5e-310) {
tmp = d * Math.pow((1.0 / Math.pow((h * l), 3.0)), 0.16666666666666666);
} 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 <= -3.8e-183: tmp = -d * math.pow((h * l), -0.5) elif l <= -5e-310: tmp = d * math.pow((1.0 / math.pow((h * l), 3.0)), 0.16666666666666666) 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 <= -3.8e-183) tmp = Float64(Float64(-d) * (Float64(h * l) ^ -0.5)); elseif (l <= -5e-310) tmp = Float64(d * (Float64(1.0 / (Float64(h * l) ^ 3.0)) ^ 0.16666666666666666)); 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 <= -3.8e-183)
tmp = -d * ((h * l) ^ -0.5);
elseif (l <= -5e-310)
tmp = d * ((1.0 / ((h * l) ^ 3.0)) ^ 0.16666666666666666);
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, -3.8e-183], N[((-d) * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-310], N[(d * N[Power[N[(1.0 / N[Power[N[(h * l), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision], 0.16666666666666666], $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.8 \cdot 10^{-183}:\\
\;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\
\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot {\left(\frac{1}{{\left(h \cdot \ell\right)}^{3}}\right)}^{0.16666666666666666}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < -3.7999999999999996e-183Initial program 66.6%
Applied egg-rr24.2%
associate-*l/25.3%
associate-/l*25.4%
associate-*r*25.4%
associate-*r/25.5%
*-commutative25.5%
associate-/l*25.4%
Simplified25.4%
Taylor expanded in d around -inf 46.5%
mul-1-neg46.5%
distribute-rgt-neg-in46.5%
unpow-146.5%
metadata-eval46.5%
pow-sqr46.5%
rem-sqrt-square46.5%
rem-square-sqrt46.3%
fabs-sqr46.3%
rem-square-sqrt46.5%
Simplified46.5%
if -3.7999999999999996e-183 < l < -4.999999999999985e-310Initial program 77.1%
Taylor expanded in d around inf 34.4%
pow1/234.4%
pow-to-exp34.4%
log-rec30.0%
Applied egg-rr30.0%
neg-log34.4%
*-commutative34.4%
associate-/l/34.4%
pow-to-exp34.4%
metadata-eval34.4%
metadata-eval34.4%
pow-pow64.7%
associate-/l/64.7%
*-commutative64.7%
cube-div64.7%
metadata-eval64.7%
metadata-eval64.7%
Applied egg-rr64.7%
if -4.999999999999985e-310 < l Initial program 72.9%
Taylor expanded in d around inf 47.2%
pow1/247.2%
pow-to-exp44.8%
log-rec44.8%
Applied egg-rr44.8%
neg-log44.8%
*-commutative44.8%
associate-/l/44.8%
pow-to-exp47.2%
pow1/247.2%
*-un-lft-identity47.2%
sqrt-div53.1%
sqrt-div53.1%
metadata-eval53.1%
pow1/253.1%
pow-flip53.2%
metadata-eval53.2%
Applied egg-rr53.2%
*-lft-identity53.2%
Simplified53.2%
Final simplification51.6%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -8.5e-183)
(* (- d) (pow (* h l) -0.5))
(if (<= l -5e-310)
(* d (cbrt (pow (/ (/ 1.0 h) l) 1.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 (l <= -8.5e-183) {
tmp = -d * pow((h * l), -0.5);
} else if (l <= -5e-310) {
tmp = d * cbrt(pow(((1.0 / h) / l), 1.5));
} else {
tmp = d * (pow(h, -0.5) / sqrt(l));
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -8.5e-183) {
tmp = -d * Math.pow((h * l), -0.5);
} else if (l <= -5e-310) {
tmp = d * Math.cbrt(Math.pow(((1.0 / h) / l), 1.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 (l <= -8.5e-183) tmp = Float64(Float64(-d) * (Float64(h * l) ^ -0.5)); elseif (l <= -5e-310) tmp = Float64(d * cbrt((Float64(Float64(1.0 / h) / l) ^ 1.5))); else tmp = Float64(d * Float64((h ^ -0.5) / sqrt(l))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -8.5e-183], N[((-d) * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-310], N[(d * N[Power[N[Power[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $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 -8.5 \cdot 10^{-183}:\\
\;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\
\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \sqrt[3]{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < -8.49999999999999973e-183Initial program 66.6%
Applied egg-rr24.2%
associate-*l/25.3%
associate-/l*25.4%
associate-*r*25.4%
associate-*r/25.5%
*-commutative25.5%
associate-/l*25.4%
Simplified25.4%
Taylor expanded in d around -inf 46.5%
mul-1-neg46.5%
distribute-rgt-neg-in46.5%
unpow-146.5%
metadata-eval46.5%
pow-sqr46.5%
rem-sqrt-square46.5%
rem-square-sqrt46.3%
fabs-sqr46.3%
rem-square-sqrt46.5%
Simplified46.5%
if -8.49999999999999973e-183 < l < -4.999999999999985e-310Initial program 77.1%
Taylor expanded in d around inf 34.4%
add-cbrt-cube47.4%
add-sqr-sqrt47.4%
pow147.4%
pow1/247.4%
pow-prod-up47.4%
associate-/r*47.4%
metadata-eval47.4%
Applied egg-rr47.4%
if -4.999999999999985e-310 < l Initial program 72.9%
Taylor expanded in d around inf 47.2%
pow1/247.2%
pow-to-exp44.8%
log-rec44.8%
Applied egg-rr44.8%
neg-log44.8%
*-commutative44.8%
associate-/l/44.8%
pow-to-exp47.2%
pow1/247.2%
*-un-lft-identity47.2%
sqrt-div53.1%
sqrt-div53.1%
metadata-eval53.1%
pow1/253.1%
pow-flip53.2%
metadata-eval53.2%
Applied egg-rr53.2%
*-lft-identity53.2%
Simplified53.2%
Final simplification50.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 -4.2e-182)
(* (- d) (pow (* h l) -0.5))
(if (<= l -5e-310)
(* d (sqrt (/ 1.0 (* h 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 <= -4.2e-182) {
tmp = -d * pow((h * l), -0.5);
} else if (l <= -5e-310) {
tmp = d * sqrt((1.0 / (h * 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 <= (-4.2d-182)) then
tmp = -d * ((h * l) ** (-0.5d0))
else if (l <= (-5d-310)) then
tmp = d * sqrt((1.0d0 / (h * 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 <= -4.2e-182) {
tmp = -d * Math.pow((h * l), -0.5);
} else if (l <= -5e-310) {
tmp = d * Math.sqrt((1.0 / (h * 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 <= -4.2e-182: tmp = -d * math.pow((h * l), -0.5) elif l <= -5e-310: tmp = d * math.sqrt((1.0 / (h * 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 <= -4.2e-182) tmp = Float64(Float64(-d) * (Float64(h * l) ^ -0.5)); elseif (l <= -5e-310) tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * 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 <= -4.2e-182)
tmp = -d * ((h * l) ^ -0.5);
elseif (l <= -5e-310)
tmp = d * sqrt((1.0 / (h * 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, -4.2e-182], N[((-d) * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-310], N[(d * N[Sqrt[N[(1.0 / N[(h * 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 -4.2 \cdot 10^{-182}:\\
\;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\
\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < -4.2000000000000001e-182Initial program 66.6%
Applied egg-rr24.2%
associate-*l/25.3%
associate-/l*25.4%
associate-*r*25.4%
associate-*r/25.5%
*-commutative25.5%
associate-/l*25.4%
Simplified25.4%
Taylor expanded in d around -inf 46.5%
mul-1-neg46.5%
distribute-rgt-neg-in46.5%
unpow-146.5%
metadata-eval46.5%
pow-sqr46.5%
rem-sqrt-square46.5%
rem-square-sqrt46.3%
fabs-sqr46.3%
rem-square-sqrt46.5%
Simplified46.5%
if -4.2000000000000001e-182 < l < -4.999999999999985e-310Initial program 77.1%
Taylor expanded in d around inf 34.4%
if -4.999999999999985e-310 < l Initial program 72.9%
Taylor expanded in d around inf 47.2%
pow1/247.2%
pow-to-exp44.8%
log-rec44.8%
Applied egg-rr44.8%
neg-log44.8%
*-commutative44.8%
associate-/l/44.8%
pow-to-exp47.2%
pow1/247.2%
*-un-lft-identity47.2%
sqrt-div53.1%
sqrt-div53.1%
metadata-eval53.1%
pow1/253.1%
pow-flip53.2%
metadata-eval53.2%
Applied egg-rr53.2%
*-lft-identity53.2%
Simplified53.2%
Final simplification49.0%
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 (* h l) -0.5))) (if (<= l -1.8e-183) (* (- 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((h * l), -0.5);
double tmp;
if (l <= -1.8e-183) {
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 = (h * l) ** (-0.5d0)
if (l <= (-1.8d-183)) 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((h * l), -0.5);
double tmp;
if (l <= -1.8e-183) {
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((h * l), -0.5) tmp = 0 if l <= -1.8e-183: 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(h * l) ^ -0.5 tmp = 0.0 if (l <= -1.8e-183) 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 = (h * l) ^ -0.5;
tmp = 0.0;
if (l <= -1.8e-183)
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[(h * l), $MachinePrecision], -0.5], $MachinePrecision]}, If[LessEqual[l, -1.8e-183], 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(h \cdot \ell\right)}^{-0.5}\\
\mathbf{if}\;\ell \leq -1.8 \cdot 10^{-183}:\\
\;\;\;\;\left(-d\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\
\end{array}
\end{array}
if l < -1.8000000000000001e-183Initial program 66.6%
Applied egg-rr24.2%
associate-*l/25.3%
associate-/l*25.4%
associate-*r*25.4%
associate-*r/25.5%
*-commutative25.5%
associate-/l*25.4%
Simplified25.4%
Taylor expanded in d around -inf 46.5%
mul-1-neg46.5%
distribute-rgt-neg-in46.5%
unpow-146.5%
metadata-eval46.5%
pow-sqr46.5%
rem-sqrt-square46.5%
rem-square-sqrt46.3%
fabs-sqr46.3%
rem-square-sqrt46.5%
Simplified46.5%
if -1.8000000000000001e-183 < l Initial program 73.5%
Applied egg-rr21.7%
associate-*l/23.0%
associate-/l*23.0%
associate-*r*23.0%
associate-*r/24.3%
*-commutative24.3%
associate-/l*23.7%
Simplified23.7%
Taylor expanded in d around inf 45.5%
unpow-145.5%
metadata-eval45.5%
pow-sqr45.4%
rem-sqrt-square44.8%
rem-square-sqrt44.8%
fabs-sqr44.8%
rem-square-sqrt44.8%
Simplified44.8%
Final simplification45.4%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= l -2.3e-176) (* (- d) (pow (* h l) -0.5)) (* d (sqrt (/ 1.0 (* h l))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -2.3e-176) {
tmp = -d * pow((h * l), -0.5);
} else {
tmp = d * sqrt((1.0 / (h * 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.3d-176)) then
tmp = -d * ((h * l) ** (-0.5d0))
else
tmp = d * sqrt((1.0d0 / (h * 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.3e-176) {
tmp = -d * Math.pow((h * l), -0.5);
} else {
tmp = d * Math.sqrt((1.0 / (h * 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.3e-176: tmp = -d * math.pow((h * l), -0.5) else: tmp = d * math.sqrt((1.0 / (h * 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.3e-176) tmp = Float64(Float64(-d) * (Float64(h * l) ^ -0.5)); else tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * 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.3e-176)
tmp = -d * ((h * l) ^ -0.5);
else
tmp = d * sqrt((1.0 / (h * 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.3e-176], N[((-d) * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.3 \cdot 10^{-176}:\\
\;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\
\end{array}
\end{array}
if l < -2.3000000000000001e-176Initial program 66.6%
Applied egg-rr24.2%
associate-*l/25.3%
associate-/l*25.4%
associate-*r*25.4%
associate-*r/25.5%
*-commutative25.5%
associate-/l*25.4%
Simplified25.4%
Taylor expanded in d around -inf 46.5%
mul-1-neg46.5%
distribute-rgt-neg-in46.5%
unpow-146.5%
metadata-eval46.5%
pow-sqr46.5%
rem-sqrt-square46.5%
rem-square-sqrt46.3%
fabs-sqr46.3%
rem-square-sqrt46.5%
Simplified46.5%
if -2.3000000000000001e-176 < l Initial program 73.5%
Taylor expanded in d around inf 45.5%
Final simplification45.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 (* d (pow (* h 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) {
return d * pow((h * l), -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 * ((h * l) ** (-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((h * l), -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((h * l), -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(h * l) ^ -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 * ((h * l) ^ -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[(h * l), $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(h \cdot \ell\right)}^{-0.5}
\end{array}
Initial program 70.9%
Applied egg-rr22.6%
associate-*l/23.9%
associate-/l*23.9%
associate-*r*23.9%
associate-*r/24.7%
*-commutative24.7%
associate-/l*24.3%
Simplified24.3%
Taylor expanded in d around inf 32.1%
unpow-132.1%
metadata-eval32.1%
pow-sqr32.1%
rem-sqrt-square31.7%
rem-square-sqrt31.6%
fabs-sqr31.6%
rem-square-sqrt31.7%
Simplified31.7%
Final simplification31.7%
herbie shell --seed 2024043
(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)))))