(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
(*
(sqrt (/ d l))
(fma (/ h l) (* (pow (* M (/ (/ D d) 2.0)) 2.0) -0.5) 1.0))))
(if (<= d 0.0)
(* (/ (sqrt (- d)) (sqrt (- h))) t_0)
(if (<= d 3e+90)
(*
(* (* (sqrt d) (pow (/ 1.0 h) 0.5)) (pow (/ d l) 0.5))
(- 1.0 (* (/ h l) (* 0.5 (pow (/ (* M D) (* d 2.0)) 2.0)))))
(if (<= d 1.45e+147)
(* d (sqrt (/ (/ 1.0 h) l)))
(if (<= d 3.4e+205)
(* t_0 (/ 1.0 (/ (sqrt h) (sqrt d))))
(* d (sqrt (/ 1.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)));
}
double code(double d, double h, double l, double M, double D) {
double t_0 = sqrt((d / l)) * fma((h / l), (pow((M * ((D / d) / 2.0)), 2.0) * -0.5), 1.0);
double tmp;
if (d <= 0.0) {
tmp = (sqrt(-d) / sqrt(-h)) * t_0;
} else if (d <= 3e+90) {
tmp = ((sqrt(d) * pow((1.0 / h), 0.5)) * pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * pow(((M * D) / (d * 2.0)), 2.0))));
} else if (d <= 1.45e+147) {
tmp = d * sqrt(((1.0 / h) / l));
} else if (d <= 3.4e+205) {
tmp = t_0 * (1.0 / (sqrt(h) / sqrt(d)));
} else {
tmp = d * sqrt((1.0 / (h * l)));
}
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(sqrt(Float64(d / l)) * fma(Float64(h / l), Float64((Float64(M * Float64(Float64(D / d) / 2.0)) ^ 2.0) * -0.5), 1.0)) tmp = 0.0 if (d <= 0.0) tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_0); elseif (d <= 3e+90) tmp = Float64(Float64(Float64(sqrt(d) * (Float64(1.0 / h) ^ 0.5)) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.5 * (Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0))))); elseif (d <= 1.45e+147) tmp = Float64(d * sqrt(Float64(Float64(1.0 / h) / l))); elseif (d <= 3.4e+205) tmp = Float64(t_0 * Float64(1.0 / Float64(sqrt(h) / sqrt(d)))); else tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * l)))); end return 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[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(M * N[(N[(D / d), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, 0.0], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[d, 3e+90], N[(N[(N[(N[Sqrt[d], $MachinePrecision] * N[Power[N[(1.0 / h), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.5 * N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.45e+147], N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.4e+205], N[(t$95$0 * N[(1.0 / N[(N[Sqrt[h], $MachinePrecision] / N[Sqrt[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $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 := \sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(M \cdot \frac{\frac{D}{d}}{2}\right)}^{2} \cdot -0.5, 1\right)\\
\mathbf{if}\;d \leq 0:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t_0\\
\mathbf{elif}\;d \leq 3 \cdot 10^{+90}:\\
\;\;\;\;\left(\left(\sqrt{d} \cdot {\left(\frac{1}{h}\right)}^{0.5}\right) \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right)\\
\mathbf{elif}\;d \leq 1.45 \cdot 10^{+147}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\
\mathbf{elif}\;d \leq 3.4 \cdot 10^{+205}:\\
\;\;\;\;t_0 \cdot \frac{1}{\frac{\sqrt{h}}{\sqrt{d}}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\
\end{array}
if d < 0.0Initial program 26.3
Simplified26.7
Applied egg-rr20.5
if 0.0 < d < 2.99999999999999979e90Initial program 27.0
Applied egg-rr24.9
if 2.99999999999999979e90 < d < 1.4499999999999999e147Initial program 20.3
Applied egg-rr20.5
Taylor expanded in d around inf 16.7
Simplified16.5
if 1.4499999999999999e147 < d < 3.4e205Initial program 27.5
Simplified27.8
Applied egg-rr15.3
if 3.4e205 < d Initial program 33.0
Applied egg-rr33.1
Taylor expanded in d around inf 15.0
Final simplification21.1
herbie shell --seed 2022211
(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)))))