Average Error: 14.3 → 9.6
Time: 12.4s
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} t_0 := \frac{M \cdot D}{2 \cdot d}\\ \mathbf{if}\;{t_0}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \left(D \cdot \sqrt{\frac{h \cdot \left(M \cdot M\right)}{\ell \cdot \left(d \cdot d\right)} \cdot -0.25}\right)\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_1 := \sqrt[3]{t_0}\\ w0 \cdot \sqrt{1 - \frac{\left(h \cdot \left(t_0 \cdot t_1\right)\right) \cdot {t_1}^{2}}{\ell}} \end{array}\\ \end{array} \]
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\begin{array}{l}
t_0 := \frac{M \cdot D}{2 \cdot d}\\
\mathbf{if}\;{t_0}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\
\;\;\;\;w0 \cdot \left(D \cdot \sqrt{\frac{h \cdot \left(M \cdot M\right)}{\ell \cdot \left(d \cdot d\right)} \cdot -0.25}\right)\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_1 := \sqrt[3]{t_0}\\
w0 \cdot \sqrt{1 - \frac{\left(h \cdot \left(t_0 \cdot t_1\right)\right) \cdot {t_1}^{2}}{\ell}}
\end{array}\\


\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
 (let* ((t_0 (/ (* M D) (* 2.0 d))))
   (if (<= (* (pow t_0 2.0) (/ h l)) (- INFINITY))
     (* w0 (* D (sqrt (* (/ (* h (* M M)) (* l (* d d))) -0.25))))
     (let* ((t_1 (cbrt t_0)))
       (* w0 (sqrt (- 1.0 (/ (* (* h (* t_0 t_1)) (pow t_1 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 t_0 = (M * D) / (2.0 * d);
	double tmp;
	if ((pow(t_0, 2.0) * (h / l)) <= -((double) INFINITY)) {
		tmp = w0 * (D * sqrt(((h * (M * M)) / (l * (d * d))) * -0.25));
	} else {
		double t_1 = cbrt(t_0);
		tmp = w0 * sqrt(1.0 - (((h * (t_0 * t_1)) * pow(t_1, 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 2 regimes
  2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.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. Taylor expanded around inf 56.8

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

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

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

    1. Initial program 6.7

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \left(D \cdot \sqrt{\frac{h \cdot \left(M \cdot M\right)}{\ell \cdot \left(d \cdot d\right)} \cdot -0.25}\right)\\ \mathbf{else}:\\ \;\;\;\;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}}{\ell}}\\ \end{array} \]

Reproduce

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