Average Error: 14.6 → 9.4
Time: 8.8s
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}\;h \leq 7.231662027084009 \cdot 10^{-205}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(h \cdot \left(\frac{M}{2} \cdot \frac{D}{d}\right)\right) \cdot \frac{\frac{M}{2} \cdot \frac{D}{d}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{2 \cdot d} \cdot \left(h \cdot \frac{M \cdot D}{2 \cdot d}\right)}{\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}\;h \leq 7.231662027084009 \cdot 10^{-205}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(h \cdot \left(\frac{M}{2} \cdot \frac{D}{d}\right)\right) \cdot \frac{\frac{M}{2} \cdot \frac{D}{d}}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{2 \cdot d} \cdot \left(h \cdot \frac{M \cdot D}{2 \cdot d}\right)}{\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 (<= h 7.231662027084009e-205)
   (*
    w0
    (sqrt (- 1.0 (* (* h (* (/ M 2.0) (/ D d))) (/ (* (/ M 2.0) (/ D d)) l)))))
   (*
    w0
    (sqrt
     (- 1.0 (/ (* (/ (* M D) (* 2.0 d)) (* h (/ (* M D) (* 2.0 d)))) 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 (h <= 7.231662027084009e-205) {
		tmp = w0 * sqrt(1.0 - ((h * ((M / 2.0) * (D / d))) * (((M / 2.0) * (D / d)) / l)));
	} else {
		tmp = w0 * sqrt(1.0 - ((((M * D) / (2.0 * d)) * (h * ((M * D) / (2.0 * d)))) / 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 h < 7.231662027084009e-205

    1. Initial program 14.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 associate-*r/_binary64_138411.4

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{h \cdot \frac{M \cdot D}{2 \cdot d}}{1} \cdot \frac{\frac{M}{2} \cdot \frac{D}{d}}{\ell}}}\]
    13. Simplified9.0

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

    if 7.231662027084009e-205 < h

    1. Initial program 14.9

      \[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/_binary64_138410.6

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

      \[\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 unpow2_binary64_150710.6

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

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

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

Reproduce

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