Average Error: 14.3 → 8.9
Time: 11.7s
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}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}}{\ell}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -4.980188831542472 \cdot 10^{-251}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M \cdot D}{2 \cdot d} \cdot \left(\frac{h}{\ell} \cdot \frac{M \cdot D}{2 \cdot d}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot \sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right)}{\frac{\ell}{{\left(\sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right)}^{2}}}}\\ \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}\;\frac{h}{\ell} \leq -\infty:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}}{\ell}}\\

\mathbf{elif}\;\frac{h}{\ell} \leq -4.980188831542472 \cdot 10^{-251}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{M \cdot D}{2 \cdot d} \cdot \left(\frac{h}{\ell} \cdot \frac{M \cdot D}{2 \cdot d}\right)}\\

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

\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 (<= (/ h l) (- INFINITY))
   (* w0 (sqrt (- 1.0 (/ (* h (pow (* (/ M 2.0) (/ D d)) 2.0)) l))))
   (if (<= (/ h l) -4.980188831542472e-251)
     (*
      w0
      (sqrt
       (- 1.0 (* (/ (* M D) (* 2.0 d)) (* (/ h l) (/ (* M D) (* 2.0 d)))))))
     (*
      w0
      (sqrt
       (-
        1.0
        (/
         (* h (* (/ (* M D) (* 2.0 d)) (cbrt (/ (* M D) (* 2.0 d)))))
         (/ l (pow (cbrt (/ (* M D) (* 2.0 d))) 2.0)))))))))
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 ((h / l) <= -((double) INFINITY)) {
		tmp = w0 * sqrt(1.0 - ((h * pow(((M / 2.0) * (D / d)), 2.0)) / l));
	} else if ((h / l) <= -4.980188831542472e-251) {
		tmp = w0 * sqrt(1.0 - (((M * D) / (2.0 * d)) * ((h / l) * ((M * D) / (2.0 * d)))));
	} else {
		tmp = w0 * sqrt(1.0 - ((h * (((M * D) / (2.0 * d)) * cbrt((M * D) / (2.0 * d)))) / (l / pow(cbrt((M * D) / (2.0 * d)), 2.0))));
	}
	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 h l) < -inf.0

    1. Initial program 64.0

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\]
    2. Using strategy rm
    3. Applied associate-*r/_binary6427.0

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

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

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

    if -inf.0 < (/.f64 h l) < -4.98018883154247169e-251

    1. Initial program 14.8

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

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

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

    if -4.98018883154247169e-251 < (/.f64 h l)

    1. Initial program 8.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 associate-*r/_binary645.2

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \frac{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}}{\ell}}\]
    7. Applied unpow-prod-down_binary645.2

      \[\leadsto w0 \cdot \sqrt{1 - \frac{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)}}{\ell}}\]
    8. Applied associate-*r*_binary643.9

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\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}}}{\ell}}\]
    9. Simplified3.9

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\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}}{\ell}}\]
    10. Using strategy rm
    11. Applied associate-/l*_binary643.7

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{h \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot \sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right)}{\frac{\ell}{{\left(\sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right)}^{2}}}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification8.9

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

Reproduce

herbie shell --seed 2021168 
(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))))))