\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)\\
\mathbf{if}\;t_2 \leq -1.159428635004307 \cdot 10^{-246}:\\
\;\;\;\;t_0 \cdot \left(2 \cdot \frac{c0 \cdot {d}^{2}}{\left(w \cdot h\right) \cdot {D}^{2}}\right)\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;0.25 \cdot \frac{D \cdot \left(D \cdot \left(h \cdot {M}^{2}\right)\right)}{{d}^{2}}\\
\mathbf{elif}\;t_2 \leq 9.4628482599256 \cdot 10^{+191}:\\
\;\;\;\;t_0 \cdot \left(t_1 + \sqrt{t_1 + M} \cdot \sqrt{t_1 - M}\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \frac{h \cdot \left(M \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)))))))
(if (<= t_2 -1.159428635004307e-246)
(* t_0 (* 2.0 (/ (* c0 (pow d 2.0)) (* (* w h) (pow D 2.0)))))
(if (<= t_2 0.0)
(* 0.25 (/ (* D (* D (* h (pow M 2.0)))) (pow d 2.0)))
(if (<= t_2 9.4628482599256e+191)
(* t_0 (+ t_1 (* (sqrt (+ t_1 M)) (sqrt (- t_1 M)))))
(*
0.25
(*
(/ D (* (cbrt d) (cbrt d)))
(* (/ D (cbrt d)) (/ (* h (* M 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 tmp;
if (t_2 <= -1.159428635004307e-246) {
tmp = t_0 * (2.0 * ((c0 * pow(d, 2.0)) / ((w * h) * pow(D, 2.0))));
} else if (t_2 <= 0.0) {
tmp = 0.25 * ((D * (D * (h * pow(M, 2.0)))) / pow(d, 2.0));
} else if (t_2 <= 9.4628482599256e+191) {
tmp = t_0 * (t_1 + (sqrt(t_1 + M) * sqrt(t_1 - M)));
} else {
tmp = 0.25 * ((D / (cbrt(d) * cbrt(d))) * ((D / cbrt(d)) * ((h * (M * 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))))) < -1.15942863500430704e-246Initial program 50.0
Taylor expanded in c0 around inf 44.6
if -1.15942863500430704e-246 < (*.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 26.8
Taylor expanded in c0 around -inf 26.2
Taylor expanded in c0 around 0 22.8
Applied unpow2_binary6422.8
Applied associate-*l*_binary6420.9
if -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))))) < 9.4628482599255995e191Initial program 8.9
Applied difference-of-squares_binary648.9
Applied sqrt-prod_binary646.5
if 9.4628482599255995e191 < (*.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 42.4
Taylor expanded in c0 around 0 35.1
Applied add-sqr-sqrt_binary6449.3
Applied unpow-prod-down_binary6449.3
Applied times-frac_binary6447.5
Simplified47.5
Simplified31.4
Applied add-cube-cbrt_binary6431.5
Applied times-frac_binary6428.1
Applied associate-*l*_binary6426.5
Final simplification27.0
herbie shell --seed 2022088
(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))))))