\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.5686412308433192 \cdot 10^{-223} \lor \neg \left(M \cdot M \leq 4.320050410870869 \cdot 10^{+270}\right):\\
\;\;\;\;\log 1\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{\left(M \cdot M\right) \cdot \left(\left(D \cdot D\right) \cdot h\right)}{d \cdot d}\\
\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 (or (<= (* M M) 1.5686412308433192e-223)
(not (<= (* M M) 4.320050410870869e+270)))
(log 1.0)
(* 0.25 (/ (* (* M M) (* (* D D) h)) (* d 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.5686412308433192e-223) || !((M * M) <= 4.320050410870869e+270)) {
tmp = log(1.0);
} else {
tmp = 0.25 * (((M * M) * ((D * D) * h)) / (d * 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.5686412308433192e-223 or 4.3200504108708686e270 < (*.f64 M M) Initial program 58.4
Taylor expanded around -inf 44.1
Simplified44.9
rmApplied add-log-exp_binary64_114045.2
Simplified35.9
Taylor expanded around inf 30.4
if 1.5686412308433192e-223 < (*.f64 M M) < 4.3200504108708686e270Initial program 61.5
Taylor expanded around -inf 38.4
Simplified38.9
Taylor expanded around 0 30.0
Simplified30.0
Final simplification30.2
herbie shell --seed 2021023
(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))))))