Average Error: 14.4 → 8.5
Time: 14.8s
Precision: binary64
\[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\]
\[\begin{array}{l} \mathbf{if}\;1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 9.289331754471127 \cdot 10^{+296}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{1}{\frac{2 \cdot d}{M \cdot D}}\right)}^{2}}\\ \mathbf{elif}\;1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq \infty:\\ \;\;\;\;w0 \cdot \left(-\frac{D \cdot \left(M \cdot \sqrt{0.5}\right)}{d} \cdot \sqrt{\frac{h \cdot {\left(\sqrt[3]{-0.5}\right)}^{3}}{\ell}}\right)\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array}\]
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\begin{array}{l}
\mathbf{if}\;1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 9.289331754471127 \cdot 10^{+296}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{1}{\frac{2 \cdot d}{M \cdot D}}\right)}^{2}}\\

\mathbf{elif}\;1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq \infty:\\
\;\;\;\;w0 \cdot \left(-\frac{D \cdot \left(M \cdot \sqrt{0.5}\right)}{d} \cdot \sqrt{\frac{h \cdot {\left(\sqrt[3]{-0.5}\right)}^{3}}{\ell}}\right)\\

\mathbf{else}:\\
\;\;\;\;w0\\

\end{array}
(FPCore (w0 M D h l d)
 :precision binary64
 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<=
      (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)))
      9.289331754471127e+296)
   (* w0 (sqrt (- 1.0 (* (/ h l) (pow (/ 1.0 (/ (* 2.0 d) (* M D))) 2.0)))))
   (if (<= (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))) INFINITY)
     (*
      w0
      (-
       (*
        (/ (* D (* M (sqrt 0.5))) d)
        (sqrt (/ (* h (pow (cbrt -0.5) 3.0)) l)))))
     w0)))
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt(1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l)));
}
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))) <= 9.289331754471127e+296) {
		tmp = w0 * sqrt(1.0 - ((h / l) * pow((1.0 / ((2.0 * d) / (M * D))), 2.0)));
	} else if ((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))) <= ((double) INFINITY)) {
		tmp = w0 * -(((D * (M * sqrt(0.5))) / d) * sqrt((h * pow(cbrt(-0.5), 3.0)) / l));
	} else {
		tmp = w0;
	}
	return tmp;
}

Error

Bits error versus w0

Bits error versus M

Bits error versus D

Bits error versus h

Bits error versus l

Bits error versus d

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))) < 9.2893317544711272e296

    1. Initial program 0.2

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\]
    2. Using strategy rm
    3. Applied clear-num_binary640.2

      \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{1}{\frac{2 \cdot d}{M \cdot D}}\right)}}^{2} \cdot \frac{h}{\ell}}\]

    if 9.2893317544711272e296 < (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))) < +inf.0

    1. Initial program 63.5

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\]
    2. Using strategy rm
    3. Applied div-inv_binary6463.5

      \[\leadsto w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \color{blue}{\left(h \cdot \frac{1}{\ell}\right)}}\]
    4. Applied associate-*r*_binary6458.9

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot h\right) \cdot \frac{1}{\ell}}}\]
    5. Simplified58.9

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(h \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)} \cdot \frac{1}{\ell}}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt_binary6458.9

      \[\leadsto w0 \cdot \sqrt{1 - \left(h \cdot {\color{blue}{\left(\left(\sqrt[3]{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right) \cdot \sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right)}}^{2}\right) \cdot \frac{1}{\ell}}\]
    8. Applied unpow-prod-down_binary6458.9

      \[\leadsto w0 \cdot \sqrt{1 - \left(h \cdot \color{blue}{\left({\left(\sqrt[3]{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right)}^{2} \cdot {\left(\sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right)}^{2}\right)}\right) \cdot \frac{1}{\ell}}\]
    9. Applied associate-*r*_binary6455.5

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(h \cdot {\left(\sqrt[3]{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right)}^{2}\right) \cdot {\left(\sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right)}^{2}\right)} \cdot \frac{1}{\ell}}\]
    10. Simplified55.4

      \[\leadsto w0 \cdot \sqrt{1 - \left(\color{blue}{\left(h \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot \sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right)\right)} \cdot {\left(\sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right)}^{2}\right) \cdot \frac{1}{\ell}}\]
    11. Taylor expanded around -inf 51.2

      \[\leadsto w0 \cdot \color{blue}{\left(-1 \cdot \left(\frac{D \cdot \left(\sqrt{0.5} \cdot M\right)}{d} \cdot \sqrt{\frac{h \cdot {\left(\sqrt[3]{-0.5}\right)}^{3}}{\ell}}\right)\right)}\]

    if +inf.0 < (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)))

    1. Initial program 64.0

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\]
    2. Taylor expanded around 0 14.6

      \[\leadsto \color{blue}{w0}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification8.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 9.289331754471127 \cdot 10^{+296}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{1}{\frac{2 \cdot d}{M \cdot D}}\right)}^{2}}\\ \mathbf{elif}\;1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq \infty:\\ \;\;\;\;w0 \cdot \left(-\frac{D \cdot \left(M \cdot \sqrt{0.5}\right)}{d} \cdot \sqrt{\frac{h \cdot {\left(\sqrt[3]{-0.5}\right)}^{3}}{\ell}}\right)\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array}\]

Reproduce

herbie shell --seed 2021147 
(FPCore (w0 M D h l d)
  :name "Henrywood and Agarwal, Equation (9a)"
  :precision binary64
  (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))