Average Error: 13.2 → 8.3
Time: 7.5s
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}\;\ell \leq -2.1608776803958767 \cdot 10^{+226}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M \cdot D}{2 \cdot d} \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{h}{\ell}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot \left(\frac{M}{2} \cdot \frac{D}{d}\right)}{\frac{\ell}{\frac{M}{2} \cdot \frac{D}{d}}}}\\ \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}\;\ell \leq -2.1608776803958767 \cdot 10^{+226}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{M \cdot D}{2 \cdot d} \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{h}{\ell}\right)}\\

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

\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 (<= l -2.1608776803958767e+226)
   (*
    w0
    (sqrt (- 1.0 (* (/ (* M D) (* 2.0 d)) (* (/ (* M D) (* 2.0 d)) (/ h l))))))
   (*
    w0
    (sqrt
     (- 1.0 (/ (* h (* (/ M 2.0) (/ D d))) (/ l (* (/ M 2.0) (/ D d)))))))))
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 (l <= -2.1608776803958767e+226) {
		tmp = w0 * sqrt(1.0 - (((M * D) / (2.0 * d)) * (((M * D) / (2.0 * d)) * (h / l))));
	} else {
		tmp = w0 * sqrt(1.0 - ((h * ((M / 2.0) * (D / d))) / (l / ((M / 2.0) * (D / d)))));
	}
	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 l < -2.1608776803958767e226

    1. Initial program 10.4

      \[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_binary6410.4

      \[\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*_binary647.5

      \[\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)}}\]
    5. Simplified7.5

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

    if -2.1608776803958767e226 < l

    1. Initial program 13.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/_binary649.8

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

      \[\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_binary6410.0

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\frac{\ell}{\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right) \cdot \left(\frac{D}{d} \cdot \frac{M}{2}\right)}}}}\]
    12. Applied *-un-lft-identity_binary6410.1

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

      \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\color{blue}{\frac{1}{\frac{D}{d} \cdot \frac{M}{2}} \cdot \frac{\ell}{\frac{D}{d} \cdot \frac{M}{2}}}}}\]
    14. Applied associate-/r*_binary648.4

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{h}{\frac{1}{\frac{D}{d} \cdot \frac{M}{2}}}}{\frac{\ell}{\frac{D}{d} \cdot \frac{M}{2}}}}}\]
    15. Simplified8.4

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

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

Reproduce

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