(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 (fma (/ h l) (* (pow (* M (/ (/ D d) 2.0)) 2.0) -0.5) 1.0))
(t_1 (* t_0 (sqrt (/ d l))))
(t_2 (sqrt (/ d h)))
(t_3 (* t_1 (* (sqrt d) (sqrt (/ 1.0 h)))))
(t_4 (sqrt (- d))))
(if (<= h -1e-172)
(* t_2 (* (/ t_4 (sqrt (- l))) t_0))
(if (<= h 0.0)
(* (/ t_4 (sqrt (- h))) t_1)
(if (<= h 1e-18)
t_3
(if (<= h 1e+158) (* t_2 (* t_0 (/ (sqrt d) (sqrt l)))) t_3))))))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 = fma((h / l), (pow((M * ((D / d) / 2.0)), 2.0) * -0.5), 1.0);
double t_1 = t_0 * sqrt((d / l));
double t_2 = sqrt((d / h));
double t_3 = t_1 * (sqrt(d) * sqrt((1.0 / h)));
double t_4 = sqrt(-d);
double tmp;
if (h <= -1e-172) {
tmp = t_2 * ((t_4 / sqrt(-l)) * t_0);
} else if (h <= 0.0) {
tmp = (t_4 / sqrt(-h)) * t_1;
} else if (h <= 1e-18) {
tmp = t_3;
} else if (h <= 1e+158) {
tmp = t_2 * (t_0 * (sqrt(d) / sqrt(l)));
} else {
tmp = t_3;
}
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 = fma(Float64(h / l), Float64((Float64(M * Float64(Float64(D / d) / 2.0)) ^ 2.0) * -0.5), 1.0) t_1 = Float64(t_0 * sqrt(Float64(d / l))) t_2 = sqrt(Float64(d / h)) t_3 = Float64(t_1 * Float64(sqrt(d) * sqrt(Float64(1.0 / h)))) t_4 = sqrt(Float64(-d)) tmp = 0.0 if (h <= -1e-172) tmp = Float64(t_2 * Float64(Float64(t_4 / sqrt(Float64(-l))) * t_0)); elseif (h <= 0.0) tmp = Float64(Float64(t_4 / sqrt(Float64(-h))) * t_1); elseif (h <= 1e-18) tmp = t_3; elseif (h <= 1e+158) tmp = Float64(t_2 * Float64(t_0 * Float64(sqrt(d) / sqrt(l)))); else tmp = t_3; 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[(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]}, Block[{t$95$1 = N[(t$95$0 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[h, -1e-172], N[(t$95$2 * N[(N[(t$95$4 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 0.0], N[(N[(t$95$4 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[h, 1e-18], t$95$3, If[LessEqual[h, 1e+158], N[(t$95$2 * N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]]]]
\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 := \mathsf{fma}\left(\frac{h}{\ell}, {\left(M \cdot \frac{\frac{D}{d}}{2}\right)}^{2} \cdot -0.5, 1\right)\\
t_1 := t_0 \cdot \sqrt{\frac{d}{\ell}}\\
t_2 := \sqrt{\frac{d}{h}}\\
t_3 := t_1 \cdot \left(\sqrt{d} \cdot \sqrt{\frac{1}{h}}\right)\\
t_4 := \sqrt{-d}\\
\mathbf{if}\;h \leq -1 \cdot 10^{-172}:\\
\;\;\;\;t_2 \cdot \left(\frac{t_4}{\sqrt{-\ell}} \cdot t_0\right)\\
\mathbf{elif}\;h \leq 0:\\
\;\;\;\;\frac{t_4}{\sqrt{-h}} \cdot t_1\\
\mathbf{elif}\;h \leq 10^{-18}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;h \leq 10^{+158}:\\
\;\;\;\;t_2 \cdot \left(t_0 \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}
if h < -1e-172Initial program 23.4
Simplified23.6
Applied egg-rr20.0
if -1e-172 < h < 0.0Initial program 34.5
Simplified34.9
Applied egg-rr17.1
if 0.0 < h < 1.0000000000000001e-18 or 9.99999999999999953e157 < h Initial program 29.6
Simplified30.1
Applied egg-rr22.2
if 1.0000000000000001e-18 < h < 9.99999999999999953e157Initial program 20.7
Simplified20.7
Applied egg-rr15.2
Final simplification19.8
herbie shell --seed 2022197
(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)))))