(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)))))
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (/ 1.0 (sqrt (/ l d))))
(t_1 (pow (/ d h) 0.5))
(t_2 (* (/ M (/ (* d 2.0) D)) (sqrt 0.5)))
(t_3 (- 1.0 (pow (* (sqrt (/ h l)) t_2) 2.0)))
(t_4 (sqrt (- d))))
(if (<= d -1e-105)
(* (* (/ t_4 (sqrt (- h))) t_0) t_3)
(if (<= d 0.0)
(* t_3 (* t_1 (/ 1.0 (/ (sqrt (- l)) t_4))))
(if (<= d 1e-50)
(* t_3 (* t_1 (* (sqrt d) (sqrt (/ 1.0 l)))))
(if (<= d 2.6e+200)
(* t_3 (* t_0 (/ (sqrt d) (sqrt h))))
(if (<= d 3.5e+303)
(* d (sqrt (/ 1.0 (* h l))))
(*
(* t_1 (pow (/ d l) 0.5))
(- 1.0 (pow (* t_2 (/ (sqrt h) (sqrt l))) 2.0))))))))))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)));
}
double code(double d, double h, double l, double M, double D) {
double t_0 = 1.0 / sqrt((l / d));
double t_1 = pow((d / h), 0.5);
double t_2 = (M / ((d * 2.0) / D)) * sqrt(0.5);
double t_3 = 1.0 - pow((sqrt((h / l)) * t_2), 2.0);
double t_4 = sqrt(-d);
double tmp;
if (d <= -1e-105) {
tmp = ((t_4 / sqrt(-h)) * t_0) * t_3;
} else if (d <= 0.0) {
tmp = t_3 * (t_1 * (1.0 / (sqrt(-l) / t_4)));
} else if (d <= 1e-50) {
tmp = t_3 * (t_1 * (sqrt(d) * sqrt((1.0 / l))));
} else if (d <= 2.6e+200) {
tmp = t_3 * (t_0 * (sqrt(d) / sqrt(h)));
} else if (d <= 3.5e+303) {
tmp = d * sqrt((1.0 / (h * l)));
} else {
tmp = (t_1 * pow((d / l), 0.5)) * (1.0 - pow((t_2 * (sqrt(h) / sqrt(l))), 2.0));
}
return tmp;
}
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
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
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = 1.0d0 / sqrt((l / d))
t_1 = (d / h) ** 0.5d0
t_2 = (m / ((d * 2.0d0) / d_1)) * sqrt(0.5d0)
t_3 = 1.0d0 - ((sqrt((h / l)) * t_2) ** 2.0d0)
t_4 = sqrt(-d)
if (d <= (-1d-105)) then
tmp = ((t_4 / sqrt(-h)) * t_0) * t_3
else if (d <= 0.0d0) then
tmp = t_3 * (t_1 * (1.0d0 / (sqrt(-l) / t_4)))
else if (d <= 1d-50) then
tmp = t_3 * (t_1 * (sqrt(d) * sqrt((1.0d0 / l))))
else if (d <= 2.6d+200) then
tmp = t_3 * (t_0 * (sqrt(d) / sqrt(h)))
else if (d <= 3.5d+303) then
tmp = d * sqrt((1.0d0 / (h * l)))
else
tmp = (t_1 * ((d / l) ** 0.5d0)) * (1.0d0 - ((t_2 * (sqrt(h) / sqrt(l))) ** 2.0d0))
end if
code = tmp
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)));
}
public static double code(double d, double h, double l, double M, double D) {
double t_0 = 1.0 / Math.sqrt((l / d));
double t_1 = Math.pow((d / h), 0.5);
double t_2 = (M / ((d * 2.0) / D)) * Math.sqrt(0.5);
double t_3 = 1.0 - Math.pow((Math.sqrt((h / l)) * t_2), 2.0);
double t_4 = Math.sqrt(-d);
double tmp;
if (d <= -1e-105) {
tmp = ((t_4 / Math.sqrt(-h)) * t_0) * t_3;
} else if (d <= 0.0) {
tmp = t_3 * (t_1 * (1.0 / (Math.sqrt(-l) / t_4)));
} else if (d <= 1e-50) {
tmp = t_3 * (t_1 * (Math.sqrt(d) * Math.sqrt((1.0 / l))));
} else if (d <= 2.6e+200) {
tmp = t_3 * (t_0 * (Math.sqrt(d) / Math.sqrt(h)));
} else if (d <= 3.5e+303) {
tmp = d * Math.sqrt((1.0 / (h * l)));
} else {
tmp = (t_1 * Math.pow((d / l), 0.5)) * (1.0 - Math.pow((t_2 * (Math.sqrt(h) / Math.sqrt(l))), 2.0));
}
return tmp;
}
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)))
def code(d, h, l, M, D): t_0 = 1.0 / math.sqrt((l / d)) t_1 = math.pow((d / h), 0.5) t_2 = (M / ((d * 2.0) / D)) * math.sqrt(0.5) t_3 = 1.0 - math.pow((math.sqrt((h / l)) * t_2), 2.0) t_4 = math.sqrt(-d) tmp = 0 if d <= -1e-105: tmp = ((t_4 / math.sqrt(-h)) * t_0) * t_3 elif d <= 0.0: tmp = t_3 * (t_1 * (1.0 / (math.sqrt(-l) / t_4))) elif d <= 1e-50: tmp = t_3 * (t_1 * (math.sqrt(d) * math.sqrt((1.0 / l)))) elif d <= 2.6e+200: tmp = t_3 * (t_0 * (math.sqrt(d) / math.sqrt(h))) elif d <= 3.5e+303: tmp = d * math.sqrt((1.0 / (h * l))) else: tmp = (t_1 * math.pow((d / l), 0.5)) * (1.0 - math.pow((t_2 * (math.sqrt(h) / math.sqrt(l))), 2.0)) return tmp
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 code(d, h, l, M, D) t_0 = Float64(1.0 / sqrt(Float64(l / d))) t_1 = Float64(d / h) ^ 0.5 t_2 = Float64(Float64(M / Float64(Float64(d * 2.0) / D)) * sqrt(0.5)) t_3 = Float64(1.0 - (Float64(sqrt(Float64(h / l)) * t_2) ^ 2.0)) t_4 = sqrt(Float64(-d)) tmp = 0.0 if (d <= -1e-105) tmp = Float64(Float64(Float64(t_4 / sqrt(Float64(-h))) * t_0) * t_3); elseif (d <= 0.0) tmp = Float64(t_3 * Float64(t_1 * Float64(1.0 / Float64(sqrt(Float64(-l)) / t_4)))); elseif (d <= 1e-50) tmp = Float64(t_3 * Float64(t_1 * Float64(sqrt(d) * sqrt(Float64(1.0 / l))))); elseif (d <= 2.6e+200) tmp = Float64(t_3 * Float64(t_0 * Float64(sqrt(d) / sqrt(h)))); elseif (d <= 3.5e+303) tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * l)))); else tmp = Float64(Float64(t_1 * (Float64(d / l) ^ 0.5)) * Float64(1.0 - (Float64(t_2 * Float64(sqrt(h) / sqrt(l))) ^ 2.0))); end return tmp 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
function tmp_2 = code(d, h, l, M, D) t_0 = 1.0 / sqrt((l / d)); t_1 = (d / h) ^ 0.5; t_2 = (M / ((d * 2.0) / D)) * sqrt(0.5); t_3 = 1.0 - ((sqrt((h / l)) * t_2) ^ 2.0); t_4 = sqrt(-d); tmp = 0.0; if (d <= -1e-105) tmp = ((t_4 / sqrt(-h)) * t_0) * t_3; elseif (d <= 0.0) tmp = t_3 * (t_1 * (1.0 / (sqrt(-l) / t_4))); elseif (d <= 1e-50) tmp = t_3 * (t_1 * (sqrt(d) * sqrt((1.0 / l)))); elseif (d <= 2.6e+200) tmp = t_3 * (t_0 * (sqrt(d) / sqrt(h))); elseif (d <= 3.5e+303) tmp = d * sqrt((1.0 / (h * l))); else tmp = (t_1 * ((d / l) ^ 0.5)) * (1.0 - ((t_2 * (sqrt(h) / sqrt(l))) ^ 2.0)); end tmp_2 = tmp; 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]
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[N[(l / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$2 = N[(N[(M / N[(N[(d * 2.0), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 - N[Power[N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[d, -1e-105], N[(N[(N[(t$95$4 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$3), $MachinePrecision], If[LessEqual[d, 0.0], N[(t$95$3 * N[(t$95$1 * N[(1.0 / N[(N[Sqrt[(-l)], $MachinePrecision] / t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1e-50], N[(t$95$3 * N[(t$95$1 * N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.6e+200], N[(t$95$3 * N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.5e+303], N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[Power[N[(t$95$2 * N[(N[Sqrt[h], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\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)
\begin{array}{l}
t_0 := \frac{1}{\sqrt{\frac{\ell}{d}}}\\
t_1 := {\left(\frac{d}{h}\right)}^{0.5}\\
t_2 := \frac{M}{\frac{d \cdot 2}{D}} \cdot \sqrt{0.5}\\
t_3 := 1 - {\left(\sqrt{\frac{h}{\ell}} \cdot t_2\right)}^{2}\\
t_4 := \sqrt{-d}\\
\mathbf{if}\;d \leq -1 \cdot 10^{-105}:\\
\;\;\;\;\left(\frac{t_4}{\sqrt{-h}} \cdot t_0\right) \cdot t_3\\
\mathbf{elif}\;d \leq 0:\\
\;\;\;\;t_3 \cdot \left(t_1 \cdot \frac{1}{\frac{\sqrt{-\ell}}{t_4}}\right)\\
\mathbf{elif}\;d \leq 10^{-50}:\\
\;\;\;\;t_3 \cdot \left(t_1 \cdot \left(\sqrt{d} \cdot \sqrt{\frac{1}{\ell}}\right)\right)\\
\mathbf{elif}\;d \leq 2.6 \cdot 10^{+200}:\\
\;\;\;\;t_3 \cdot \left(t_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\
\mathbf{elif}\;d \leq 3.5 \cdot 10^{+303}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\
\mathbf{else}:\\
\;\;\;\;\left(t_1 \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - {\left(t_2 \cdot \frac{\sqrt{h}}{\sqrt{\ell}}\right)}^{2}\right)\\
\end{array}
Results
if d < -9.99999999999999965e-106Initial program 21.7
Applied egg-rr20.2
Applied egg-rr20.1
Applied egg-rr12.0
if -9.99999999999999965e-106 < d < 0.0Initial program 36.4
Applied egg-rr36.7
Applied egg-rr37.0
Applied egg-rr28.7
if 0.0 < d < 1.00000000000000001e-50Initial program 33.6
Applied egg-rr32.5
Applied egg-rr26.3
if 1.00000000000000001e-50 < d < 2.6000000000000001e200Initial program 19.8
Applied egg-rr18.2
Applied egg-rr18.2
Applied egg-rr10.5
if 2.6000000000000001e200 < d < 3.50000000000000015e303Initial program 32.6
Applied egg-rr30.9
Applied egg-rr30.2
Taylor expanded in d around inf 14.7
Simplified14.7
if 3.50000000000000015e303 < d Initial program 27.1
Applied egg-rr20.6
Applied egg-rr20.7
Final simplification17.1
herbie shell --seed 2022210
(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)))))