Average Error: 14.3 → 8.5
Time: 12.6s
Precision: binary64
\[[M, D]=\mathsf{sort}([M, D])\]
\[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 1.1891624526792194 \cdot 10^{+188}:\\ \;\;\;\;w0 \cdot {\left(1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)}^{0.5}\\ \mathbf{elif}\;1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq \infty:\\ \;\;\;\;w0 \cdot \left(\sqrt{\left(\frac{h}{\ell} \cdot {\left(\frac{D}{d}\right)}^{2}\right) \cdot -0.25} \cdot \left(-M\right)\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(\left(h \cdot {\left(\sqrt[3]{\sqrt[3]{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt[3]{\frac{M \cdot D}{2 \cdot d}}}\right)}^{4}\right) \cdot {\left(\sqrt[3]{\sqrt[3]{\frac{M \cdot D}{2 \cdot d}}}\right)}^{4}\right) \cdot \frac{{\left(\sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right)}^{2}}{\ell}}\\ \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 1.1891624526792194 \cdot 10^{+188}:\\
\;\;\;\;w0 \cdot {\left(1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)}^{0.5}\\

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

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

\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)))
      1.1891624526792194e+188)
   (* w0 (pow (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))) 0.5))
   (if (<= (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))) INFINITY)
     (* w0 (* (sqrt (* (* (/ h l) (pow (/ D d) 2.0)) -0.25)) (- M)))
     (*
      w0
      (sqrt
       (-
        1.0
        (*
         (*
          (*
           h
           (pow
            (cbrt
             (* (cbrt (/ (* M D) (* 2.0 d))) (cbrt (/ (* M D) (* 2.0 d)))))
            4.0))
          (pow (cbrt (cbrt (/ (* M D) (* 2.0 d)))) 4.0))
         (/ (pow (cbrt (/ (* M D) (* 2.0 d))) 2.0) l))))))))
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))) <= 1.1891624526792194e+188) {
		tmp = w0 * pow((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))), 0.5);
	} else if ((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))) <= ((double) INFINITY)) {
		tmp = w0 * (sqrt(((h / l) * pow((D / d), 2.0)) * -0.25) * -M);
	} else {
		tmp = w0 * sqrt(1.0 - (((h * pow(cbrt(cbrt((M * D) / (2.0 * d)) * cbrt((M * D) / (2.0 * d))), 4.0)) * pow(cbrt(cbrt((M * D) / (2.0 * d))), 4.0)) * (pow(cbrt((M * D) / (2.0 * d)), 2.0) / l)));
	}
	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))) < 1.18916245267921937e188

    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 pow1/2_binary640.2

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

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

    1. Initial program 57.1

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

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

      \[\leadsto w0 \cdot \color{blue}{\left(\sqrt{\left(\frac{h}{\ell} \cdot {\left(\frac{D}{d}\right)}^{2}\right) \cdot -0.25} \cdot \left(-M\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. Using strategy rm
    3. Applied associate-*r/_binary6426.9

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

      \[\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_binary6426.9

      \[\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_binary6426.9

      \[\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*_binary6415.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. Simplified15.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 *-un-lft-identity_binary6415.9

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\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}}{\color{blue}{1 \cdot \ell}}}\]
    12. Applied times-frac_binary6415.5

      \[\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)}{1} \cdot \frac{{\left(\sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right)}^{2}}{\ell}}}\]
    13. Simplified15.5

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(h \cdot {\left(\sqrt[3]{\sqrt[3]{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt[3]{\frac{M \cdot D}{d \cdot 2}}}\right)}^{4}\right) \cdot {\left(\sqrt[3]{\sqrt[3]{\frac{M \cdot D}{d \cdot 2}}}\right)}^{4}\right)} \cdot \frac{{\left(\sqrt[3]{\frac{M \cdot D}{d \cdot 2}}\right)}^{2}}{\ell}}\]
  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 1.1891624526792194 \cdot 10^{+188}:\\ \;\;\;\;w0 \cdot {\left(1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)}^{0.5}\\ \mathbf{elif}\;1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq \infty:\\ \;\;\;\;w0 \cdot \left(\sqrt{\left(\frac{h}{\ell} \cdot {\left(\frac{D}{d}\right)}^{2}\right) \cdot -0.25} \cdot \left(-M\right)\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(\left(h \cdot {\left(\sqrt[3]{\sqrt[3]{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt[3]{\frac{M \cdot D}{2 \cdot d}}}\right)}^{4}\right) \cdot {\left(\sqrt[3]{\sqrt[3]{\frac{M \cdot D}{2 \cdot d}}}\right)}^{4}\right) \cdot \frac{{\left(\sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right)}^{2}}{\ell}}\\ \end{array}\]

Alternatives

Reproduce

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