Average Error: 14.1 → 8.8
Time: 11.2s
Precision: 64
\[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} = -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{\left(\frac{2}{2}\right)}}{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}} \cdot \frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{\left(\frac{2}{2}\right)} \cdot h}{\sqrt[3]{\ell}}}\\ \mathbf{elif}\;\frac{h}{\ell} \le -2.96376620118470185 \cdot 10^{-234}:\\ \;\;\;\;w0 \cdot \sqrt{1 - {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(\left(\sqrt[3]{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{\left(\frac{2}{2}\right)}}{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}}} \cdot \sqrt[3]{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{\left(\frac{2}{2}\right)}}{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}}}\right) \cdot \sqrt[3]{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{\left(\frac{2}{2}\right)}}{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}}}\right) \cdot \frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{\left(\frac{2}{2}\right)} \cdot h}{\sqrt[3]{\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}\;\frac{h}{\ell} = -\infty:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{\left(\frac{2}{2}\right)}}{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}} \cdot \frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{\left(\frac{2}{2}\right)} \cdot h}{\sqrt[3]{\ell}}}\\

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

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

\end{array}
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 VAR;
	if (((h / l) <= -inf.0)) {
		VAR = (w0 * sqrt((1.0 - ((pow(((M * D) / (2.0 * d)), (2.0 / 2.0)) / (cbrt(l) * cbrt(l))) * ((pow(((M * D) / (2.0 * d)), (2.0 / 2.0)) * h) / cbrt(l))))));
	} else {
		double VAR_1;
		if (((h / l) <= -2.963766201184702e-234)) {
			VAR_1 = (w0 * sqrt((1.0 - (pow(((M / 2.0) * (D / d)), 2.0) * (h / l)))));
		} else {
			VAR_1 = (w0 * sqrt((1.0 - (((cbrt((pow(((M * D) / (2.0 * d)), (2.0 / 2.0)) / (cbrt(l) * cbrt(l)))) * cbrt((pow(((M * D) / (2.0 * d)), (2.0 / 2.0)) / (cbrt(l) * cbrt(l))))) * cbrt((pow(((M * D) / (2.0 * d)), (2.0 / 2.0)) / (cbrt(l) * cbrt(l))))) * ((pow(((M * D) / (2.0 * d)), (2.0 / 2.0)) * h) / cbrt(l))))));
		}
		VAR = VAR_1;
	}
	return VAR;
}

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 (/ 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/28.1

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

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

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

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

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

    if -inf.0 < (/ h l) < -2.963766201184702e-234

    1. Initial program 14.1

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

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

    if -2.963766201184702e-234 < (/ h l)

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

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

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

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

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

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

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

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

Reproduce

herbie shell --seed 2020100 +o rules:numerics
(FPCore (w0 M D h l d)
  :name "Henrywood and Agarwal, Equation (9a)"
  :precision binary64
  (* w0 (sqrt (- 1 (* (pow (/ (* M D) (* 2 d)) 2) (/ h l))))))