\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}
\mathbf{if}\;M \cdot M \leq 1.143943990463084 \cdot 10^{+295}:\\
\;\;\;\;0.25 \cdot \left(D \cdot \left(\left(h \cdot \frac{D}{d}\right) \cdot \frac{M \cdot M}{d}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(D \cdot \left(\frac{D}{d} \cdot \frac{M \cdot \left(M \cdot h\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 (if (<= (* M M) 1.143943990463084e+295) (* 0.25 (* D (* (* h (/ D d)) (/ (* M M) d)))) (* 0.25 (* D (* (/ D d) (/ (* M (* M h)) 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 tmp;
if ((M * M) <= 1.143943990463084e+295) {
tmp = 0.25 * (D * ((h * (D / d)) * ((M * M) / d)));
} else {
tmp = 0.25 * (D * ((D / d) * ((M * (M * h)) / 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 M M) < 1.14394399046308391e295Initial program 58.7
Taylor expanded in c0 around -inf 31.7
Applied add-sqr-sqrt_binary6448.4
Applied unpow-prod-down_binary6448.4
Applied times-frac_binary6446.4
Simplified46.4
Simplified28.0
Applied *-un-lft-identity_binary6428.0
Applied times-frac_binary6424.4
Applied associate-*l*_binary6423.2
Applied *-un-lft-identity_binary6423.2
Applied times-frac_binary6422.4
Applied associate-*r*_binary6421.7
Simplified21.7
if 1.14394399046308391e295 < (*.f64 M M) Initial program 64.0
Taylor expanded in c0 around -inf 62.9
Applied add-sqr-sqrt_binary6463.3
Applied unpow-prod-down_binary6463.3
Applied times-frac_binary6463.3
Simplified63.3
Simplified62.5
Applied *-un-lft-identity_binary6462.5
Applied times-frac_binary6462.4
Applied associate-*l*_binary6462.3
Applied associate-*r*_binary6446.4
Final simplification25.2
herbie shell --seed 2022103
(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))))))