\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)
\begin{array}{l}
t_0 := \frac{c0}{2 \cdot w}\\
t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
t_2 := t_0 \cdot \left(t_1 + \sqrt{t_1 \cdot t_1 - M \cdot M}\right)\\
t_3 := t_0 \cdot \left(2 \cdot \frac{c0 \cdot {d}^{2}}{\left(w \cdot h\right) \cdot {D}^{2}}\right)\\
\mathbf{if}\;t_2 \leq -7.130962801645547 \cdot 10^{-182}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;0.25 \cdot \left(\left(\frac{D \cdot D}{d} \cdot \left(h \cdot M\right)\right) \cdot \frac{M}{d}\right)\\
\mathbf{elif}\;t_2 \leq 1.1298573201221567 \cdot 10^{+246}:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \frac{M \cdot \left(h \cdot M\right)}{d}\right)\right)\\
\end{array}
(FPCore (c0 w h D d M)
:precision binary64
(*
(/ c0 (* 2.0 w))
(+
(/ (* c0 (* d d)) (* (* w h) (* D D)))
(sqrt
(-
(*
(/ (* c0 (* d d)) (* (* w h) (* D D)))
(/ (* c0 (* d d)) (* (* w h) (* D D))))
(* M M))))))(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ c0 (* 2.0 w)))
(t_1 (/ (* c0 (* d d)) (* (* w h) (* D D))))
(t_2 (* t_0 (+ t_1 (sqrt (- (* t_1 t_1) (* M M))))))
(t_3 (* t_0 (* 2.0 (/ (* c0 (pow d 2.0)) (* (* w h) (pow D 2.0)))))))
(if (<= t_2 -7.130962801645547e-182)
t_3
(if (<= t_2 0.0)
(* 0.25 (* (* (/ (* D D) d) (* h M)) (/ M d)))
(if (<= t_2 1.1298573201221567e+246)
t_3
(*
0.25
(*
(/ D (* (cbrt d) (cbrt d)))
(* (/ D (cbrt d)) (/ (* M (* h M)) d)))))))))double code(double c0, double w, double h, double D, double d, double M) {
return (c0 / (2.0 * w)) * (((c0 * (d * d)) / ((w * h) * (D * D))) + sqrt((((c0 * (d * d)) / ((w * h) * (D * D))) * ((c0 * (d * d)) / ((w * h) * (D * D)))) - (M * M)));
}
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 / (2.0 * w);
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_2 = t_0 * (t_1 + sqrt((t_1 * t_1) - (M * M)));
double t_3 = t_0 * (2.0 * ((c0 * pow(d, 2.0)) / ((w * h) * pow(D, 2.0))));
double tmp;
if (t_2 <= -7.130962801645547e-182) {
tmp = t_3;
} else if (t_2 <= 0.0) {
tmp = 0.25 * ((((D * D) / d) * (h * M)) * (M / d));
} else if (t_2 <= 1.1298573201221567e+246) {
tmp = t_3;
} else {
tmp = 0.25 * ((D / (cbrt(d) * cbrt(d))) * ((D / cbrt(d)) * ((M * (h * M)) / d)));
}
return tmp;
}



Bits error versus c0



Bits error versus w



Bits error versus h



Bits error versus D



Bits error versus d



Bits error versus M
Results
if (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < -7.13096280164554702e-182 or -0.0 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < 1.12985732012215666e246Initial program 37.9
Taylor expanded in c0 around inf 34.6
if -7.13096280164554702e-182 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < -0.0Initial program 31.4
Taylor expanded in c0 around -inf 26.8
Applied add-sqr-sqrt_binary6444.9
Applied unpow-prod-down_binary6444.9
Applied times-frac_binary6443.8
Simplified43.8
Simplified24.6
Applied associate-*r*_binary6422.4
Applied *-un-lft-identity_binary6422.4
Applied times-frac_binary6420.8
Applied associate-*r*_binary6418.6
Simplified18.6
if 1.12985732012215666e246 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) Initial program 63.9
Taylor expanded in c0 around -inf 34.6
Applied add-sqr-sqrt_binary6449.3
Applied unpow-prod-down_binary6449.3
Applied times-frac_binary6447.7
Simplified47.7
Simplified31.1
Applied associate-*r*_binary6428.8
Applied add-cube-cbrt_binary6428.8
Applied times-frac_binary6425.0
Applied associate-*l*_binary6422.9
Final simplification23.6
herbie shell --seed 2022097
(FPCore (c0 w h D d M)
:name "Henrywood and Agarwal, Equation (13)"
:precision binary64
(* (/ c0 (* 2.0 w)) (+ (/ (* c0 (* d d)) (* (* w h) (* D D))) (sqrt (- (* (/ (* c0 (* d d)) (* (* w h) (* D D))) (/ (* c0 (* d d)) (* (* w h) (* D D)))) (* M M))))))