(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 (/ (* M D) (* d 2.0)) 2.0))
(t_1 (* (pow (/ d h) 0.5) (pow (/ d l) 0.5))))
(if (<= (* t_1 (+ 1.0 (* (/ h l) (* t_0 -0.5)))) 2e+238)
(* t_1 (- 1.0 (/ (pow (cbrt (* 0.5 (* h t_0))) 3.0) l)))
(* 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(((M * D) / (d * 2.0)), 2.0);
double t_1 = pow((d / h), 0.5) * pow((d / l), 0.5);
double tmp;
if ((t_1 * (1.0 + ((h / l) * (t_0 * -0.5)))) <= 2e+238) {
tmp = t_1 * (1.0 - (pow(cbrt((0.5 * (h * t_0))), 3.0) / l));
} else {
tmp = d * sqrt(((1.0 / h) / l));
}
return tmp;
}
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 = Math.pow(((M * D) / (d * 2.0)), 2.0);
double t_1 = Math.pow((d / h), 0.5) * Math.pow((d / l), 0.5);
double tmp;
if ((t_1 * (1.0 + ((h / l) * (t_0 * -0.5)))) <= 2e+238) {
tmp = t_1 * (1.0 - (Math.pow(Math.cbrt((0.5 * (h * t_0))), 3.0) / l));
} else {
tmp = d * Math.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(Float64(M * D) / Float64(d * 2.0)) ^ 2.0 t_1 = Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) tmp = 0.0 if (Float64(t_1 * Float64(1.0 + Float64(Float64(h / l) * Float64(t_0 * -0.5)))) <= 2e+238) tmp = Float64(t_1 * Float64(1.0 - Float64((cbrt(Float64(0.5 * Float64(h * t_0))) ^ 3.0) / l))); else tmp = Float64(d * sqrt(Float64(Float64(1.0 / 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[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(t$95$0 * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+238], N[(t$95$1 * N[(1.0 - N[(N[Power[N[Power[N[(0.5 * N[(h * t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $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{M \cdot D}{d \cdot 2}\right)}^{2}\\
t_1 := {\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\\
\mathbf{if}\;t_1 \cdot \left(1 + \frac{h}{\ell} \cdot \left(t_0 \cdot -0.5\right)\right) \leq 2 \cdot 10^{+238}:\\
\;\;\;\;t_1 \cdot \left(1 - \frac{{\left(\sqrt[3]{0.5 \cdot \left(h \cdot t_0\right)}\right)}^{3}}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\
\end{array}
Results
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)))) < 2.0000000000000001e238Initial program 12.9
Applied egg-rr14.2
Applied egg-rr13.6
if 2.0000000000000001e238 < (*.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.3
Applied egg-rr60.3
Taylor expanded in d around inf 43.9
Simplified43.9
Final simplification22.5
herbie shell --seed 2022212
(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)))))