(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 (pow (/ d l) 0.5))
(t_1 (* (pow (/ d h) 0.5) t_0))
(t_2 (+ 1.0 (* (/ h l) (* (pow (/ (* M D) (* d 2.0)) 2.0) -0.5))))
(t_3 (* t_1 t_2))
(t_4 (pow (/ d h) 0.25)))
(if (<= t_3 (- INFINITY))
(* t_1 (+ 1.0 (* (* D (* (/ D d) (/ (* M M) (* d (/ l h))))) -0.125)))
(if (<= t_3 -5e-148)
(* t_2 (* t_0 (* t_4 t_4)))
(if (<= t_3 0.0)
(* d (sqrt (/ (/ 1.0 l) h)))
(if (<= t_3 5e+236)
(*
(sqrt (/ d h))
(*
(sqrt (/ d l))
(fma (/ h l) (* (pow (* M (/ (/ D d) 2.0)) 2.0) -0.5) 1.0)))
(* 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 = pow((d / l), 0.5);
double t_1 = pow((d / h), 0.5) * t_0;
double t_2 = 1.0 + ((h / l) * (pow(((M * D) / (d * 2.0)), 2.0) * -0.5));
double t_3 = t_1 * t_2;
double t_4 = pow((d / h), 0.25);
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = t_1 * (1.0 + ((D * ((D / d) * ((M * M) / (d * (l / h))))) * -0.125));
} else if (t_3 <= -5e-148) {
tmp = t_2 * (t_0 * (t_4 * t_4));
} else if (t_3 <= 0.0) {
tmp = d * sqrt(((1.0 / l) / h));
} else if (t_3 <= 5e+236) {
tmp = sqrt((d / h)) * (sqrt((d / l)) * fma((h / l), (pow((M * ((D / d) / 2.0)), 2.0) * -0.5), 1.0));
} 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(d / l) ^ 0.5 t_1 = Float64((Float64(d / h) ^ 0.5) * t_0) t_2 = Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0) * -0.5))) t_3 = Float64(t_1 * t_2) t_4 = Float64(d / h) ^ 0.25 tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(t_1 * Float64(1.0 + Float64(Float64(D * Float64(Float64(D / d) * Float64(Float64(M * M) / Float64(d * Float64(l / h))))) * -0.125))); elseif (t_3 <= -5e-148) tmp = Float64(t_2 * Float64(t_0 * Float64(t_4 * t_4))); elseif (t_3 <= 0.0) tmp = Float64(d * sqrt(Float64(Float64(1.0 / l) / h))); elseif (t_3 <= 5e+236) tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * fma(Float64(h / l), Float64((Float64(M * Float64(Float64(D / d) / 2.0)) ^ 2.0) * -0.5), 1.0))); 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[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[(d / h), $MachinePrecision], 0.25], $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(t$95$1 * N[(1.0 + N[(N[(D * N[(N[(D / d), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / N[(d * N[(l / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -5e-148], N[(t$95$2 * N[(t$95$0 * N[(t$95$4 * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.0], N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 5e+236], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * 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]), $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 := {\left(\frac{d}{\ell}\right)}^{0.5}\\
t_1 := {\left(\frac{d}{h}\right)}^{0.5} \cdot t_0\\
t_2 := 1 + \frac{h}{\ell} \cdot \left({\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot -0.5\right)\\
t_3 := t_1 \cdot t_2\\
t_4 := {\left(\frac{d}{h}\right)}^{0.25}\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;t_1 \cdot \left(1 + \left(D \cdot \left(\frac{D}{d} \cdot \frac{M \cdot M}{d \cdot \frac{\ell}{h}}\right)\right) \cdot -0.125\right)\\
\mathbf{elif}\;t_3 \leq -5 \cdot 10^{-148}:\\
\;\;\;\;t_2 \cdot \left(t_0 \cdot \left(t_4 \cdot t_4\right)\right)\\
\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\
\mathbf{elif}\;t_3 \leq 5 \cdot 10^{+236}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\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)\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < -inf.0Initial program 64.0
Taylor expanded in M around 0 59.5
Simplified57.8
if -inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < -4.9999999999999999e-148Initial program 1.2
Applied egg-rr1.3
if -4.9999999999999999e-148 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < -0.0Initial program 38.5
Applied egg-rr40.8
Applied egg-rr40.9
Taylor expanded in d around inf 30.0
Simplified29.8
if -0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < 4.9999999999999997e236Initial program 1.0
Simplified1.2
if 4.9999999999999997e236 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) Initial program 60.6
Applied egg-rr56.6
Applied egg-rr56.7
Taylor expanded in d around inf 44.3
Final simplification20.7
herbie shell --seed 2022206
(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)))))