(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 h) 0.25))
(t_1 (sqrt (/ l h)))
(t_2 (pow (/ d l) 0.5))
(t_3 (* d (sqrt (/ 1.0 (* h l)))))
(t_4 (* (pow (/ d h) 0.5) t_2))
(t_5
(* t_4 (+ 1.0 (* (/ h l) (* (pow (/ (* M D) (* d 2.0)) 2.0) -0.5)))))
(t_6 (* 0.5 (/ (* M D) d))))
(if (<= t_5 -1e-247)
(* (* t_2 (* t_0 t_0)) (- 1.0 (* 0.5 (pow (/ t_6 t_1) 2.0))))
(if (<= t_5 0.0)
t_3
(if (<= t_5 2e+290)
(* t_4 (- 1.0 (pow (/ (* t_6 (sqrt 0.5)) t_1) 2.0)))
(if (<= t_5 INFINITY)
t_3
(*
t_4
(+
1.0
(/ (* (* (* M M) (/ (* D (* h D)) (* d d))) -0.125) 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 / h), 0.25);
double t_1 = sqrt((l / h));
double t_2 = pow((d / l), 0.5);
double t_3 = d * sqrt((1.0 / (h * l)));
double t_4 = pow((d / h), 0.5) * t_2;
double t_5 = t_4 * (1.0 + ((h / l) * (pow(((M * D) / (d * 2.0)), 2.0) * -0.5)));
double t_6 = 0.5 * ((M * D) / d);
double tmp;
if (t_5 <= -1e-247) {
tmp = (t_2 * (t_0 * t_0)) * (1.0 - (0.5 * pow((t_6 / t_1), 2.0)));
} else if (t_5 <= 0.0) {
tmp = t_3;
} else if (t_5 <= 2e+290) {
tmp = t_4 * (1.0 - pow(((t_6 * sqrt(0.5)) / t_1), 2.0));
} else if (t_5 <= ((double) INFINITY)) {
tmp = t_3;
} else {
tmp = t_4 * (1.0 + ((((M * M) * ((D * (h * D)) / (d * d))) * -0.125) / 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((d / h), 0.25);
double t_1 = Math.sqrt((l / h));
double t_2 = Math.pow((d / l), 0.5);
double t_3 = d * Math.sqrt((1.0 / (h * l)));
double t_4 = Math.pow((d / h), 0.5) * t_2;
double t_5 = t_4 * (1.0 + ((h / l) * (Math.pow(((M * D) / (d * 2.0)), 2.0) * -0.5)));
double t_6 = 0.5 * ((M * D) / d);
double tmp;
if (t_5 <= -1e-247) {
tmp = (t_2 * (t_0 * t_0)) * (1.0 - (0.5 * Math.pow((t_6 / t_1), 2.0)));
} else if (t_5 <= 0.0) {
tmp = t_3;
} else if (t_5 <= 2e+290) {
tmp = t_4 * (1.0 - Math.pow(((t_6 * Math.sqrt(0.5)) / t_1), 2.0));
} else if (t_5 <= Double.POSITIVE_INFINITY) {
tmp = t_3;
} else {
tmp = t_4 * (1.0 + ((((M * M) * ((D * (h * D)) / (d * d))) * -0.125) / l));
}
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 = math.pow((d / h), 0.25) t_1 = math.sqrt((l / h)) t_2 = math.pow((d / l), 0.5) t_3 = d * math.sqrt((1.0 / (h * l))) t_4 = math.pow((d / h), 0.5) * t_2 t_5 = t_4 * (1.0 + ((h / l) * (math.pow(((M * D) / (d * 2.0)), 2.0) * -0.5))) t_6 = 0.5 * ((M * D) / d) tmp = 0 if t_5 <= -1e-247: tmp = (t_2 * (t_0 * t_0)) * (1.0 - (0.5 * math.pow((t_6 / t_1), 2.0))) elif t_5 <= 0.0: tmp = t_3 elif t_5 <= 2e+290: tmp = t_4 * (1.0 - math.pow(((t_6 * math.sqrt(0.5)) / t_1), 2.0)) elif t_5 <= math.inf: tmp = t_3 else: tmp = t_4 * (1.0 + ((((M * M) * ((D * (h * D)) / (d * d))) * -0.125) / 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 / h) ^ 0.25 t_1 = sqrt(Float64(l / h)) t_2 = Float64(d / l) ^ 0.5 t_3 = Float64(d * sqrt(Float64(1.0 / Float64(h * l)))) t_4 = Float64((Float64(d / h) ^ 0.5) * t_2) t_5 = Float64(t_4 * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0) * -0.5)))) t_6 = Float64(0.5 * Float64(Float64(M * D) / d)) tmp = 0.0 if (t_5 <= -1e-247) tmp = Float64(Float64(t_2 * Float64(t_0 * t_0)) * Float64(1.0 - Float64(0.5 * (Float64(t_6 / t_1) ^ 2.0)))); elseif (t_5 <= 0.0) tmp = t_3; elseif (t_5 <= 2e+290) tmp = Float64(t_4 * Float64(1.0 - (Float64(Float64(t_6 * sqrt(0.5)) / t_1) ^ 2.0))); elseif (t_5 <= Inf) tmp = t_3; else tmp = Float64(t_4 * Float64(1.0 + Float64(Float64(Float64(Float64(M * M) * Float64(Float64(D * Float64(h * D)) / Float64(d * d))) * -0.125) / l))); 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 = (d / h) ^ 0.25; t_1 = sqrt((l / h)); t_2 = (d / l) ^ 0.5; t_3 = d * sqrt((1.0 / (h * l))); t_4 = ((d / h) ^ 0.5) * t_2; t_5 = t_4 * (1.0 + ((h / l) * ((((M * D) / (d * 2.0)) ^ 2.0) * -0.5))); t_6 = 0.5 * ((M * D) / d); tmp = 0.0; if (t_5 <= -1e-247) tmp = (t_2 * (t_0 * t_0)) * (1.0 - (0.5 * ((t_6 / t_1) ^ 2.0))); elseif (t_5 <= 0.0) tmp = t_3; elseif (t_5 <= 2e+290) tmp = t_4 * (1.0 - (((t_6 * sqrt(0.5)) / t_1) ^ 2.0)); elseif (t_5 <= Inf) tmp = t_3; else tmp = t_4 * (1.0 + ((((M * M) * ((D * (h * D)) / (d * d))) * -0.125) / l)); 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[Power[N[(d / h), $MachinePrecision], 0.25], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(l / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$3 = N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 * 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]), $MachinePrecision]}, Block[{t$95$6 = N[(0.5 * N[(N[(M * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$5, -1e-247], N[(N[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[Power[N[(t$95$6 / t$95$1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 0.0], t$95$3, If[LessEqual[t$95$5, 2e+290], N[(t$95$4 * N[(1.0 - N[Power[N[(N[(t$95$6 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, Infinity], t$95$3, N[(t$95$4 * N[(1.0 + N[(N[(N[(N[(M * M), $MachinePrecision] * N[(N[(D * N[(h * D), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $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{d}{h}\right)}^{0.25}\\
t_1 := \sqrt{\frac{\ell}{h}}\\
t_2 := {\left(\frac{d}{\ell}\right)}^{0.5}\\
t_3 := d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\
t_4 := {\left(\frac{d}{h}\right)}^{0.5} \cdot t_2\\
t_5 := t_4 \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot -0.5\right)\right)\\
t_6 := 0.5 \cdot \frac{M \cdot D}{d}\\
\mathbf{if}\;t_5 \leq -1 \cdot 10^{-247}:\\
\;\;\;\;\left(t_2 \cdot \left(t_0 \cdot t_0\right)\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{t_6}{t_1}\right)}^{2}\right)\\
\mathbf{elif}\;t_5 \leq 0:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_5 \leq 2 \cdot 10^{+290}:\\
\;\;\;\;t_4 \cdot \left(1 - {\left(\frac{t_6 \cdot \sqrt{0.5}}{t_1}\right)}^{2}\right)\\
\mathbf{elif}\;t_5 \leq \infty:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;t_4 \cdot \left(1 + \frac{\left(\left(M \cdot M\right) \cdot \frac{D \cdot \left(h \cdot D\right)}{d \cdot d}\right) \cdot -0.125}{\ell}\right)\\
\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)))) < -1e-247Initial program 29.2
Applied egg-rr31.2
Applied egg-rr29.4
Applied egg-rr29.4
Applied egg-rr21.0
if -1e-247 < (*.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.0 or 2.00000000000000012e290 < (*.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 51.8
Taylor expanded in d around inf 31.4
Simplified31.4
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)))) < 2.00000000000000012e290Initial program 0.9
Applied egg-rr1.0
Applied egg-rr0.9
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)))) Initial program 64.0
Applied egg-rr57.3
Taylor expanded in M around 0 57.7
Simplified56.7
Final simplification20.1
herbie shell --seed 2022325
(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)))))