Average Error: 14.2 → 8.8
Time: 13.0s
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}\;\frac{M \cdot D}{2 \cdot d} \leq -5.421245450148981 \cdot 10^{+279}:\\ \;\;\;\;M \cdot \left(w0 \cdot \sqrt{\left(\frac{h}{\ell} \cdot {\left(\frac{D}{d}\right)}^{2}\right) \cdot -0.25}\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\frac{M \cdot D}{2 \cdot d} \cdot h\right) \cdot \frac{1}{\frac{2 \cdot d}{M \cdot D}}}{\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{M \cdot D}{2 \cdot d} \leq -5.421245450148981 \cdot 10^{+279}:\\
\;\;\;\;M \cdot \left(w0 \cdot \sqrt{\left(\frac{h}{\ell} \cdot {\left(\frac{D}{d}\right)}^{2}\right) \cdot -0.25}\right)\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\frac{M \cdot D}{2 \cdot d} \cdot h\right) \cdot \frac{1}{\frac{2 \cdot d}{M \cdot D}}}{\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 (<= (/ (* M D) (* 2.0 d)) -5.421245450148981e+279)
   (* M (* w0 (sqrt (* (* (/ h l) (pow (/ D d) 2.0)) -0.25))))
   (*
    w0
    (sqrt
     (-
      1.0
      (/ (* (* (/ (* M D) (* 2.0 d)) h) (/ 1.0 (/ (* 2.0 d) (* M 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 (((M * D) / (2.0 * d)) <= -5.421245450148981e+279) {
		tmp = M * (w0 * sqrt(((h / l) * pow((D / d), 2.0)) * -0.25));
	} else {
		tmp = w0 * sqrt(1.0 - (((((M * D) / (2.0 * d)) * h) * (1.0 / ((2.0 * d) / (M * 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 (/.f64 (*.f64 M D) (*.f64 2 d)) < -5.42124545014898114e279

    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 61.0

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

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

    if -5.42124545014898114e279 < (/.f64 (*.f64 M D) (*.f64 2 d))

    1. Initial program 12.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_7028.8

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot h}{\ell}}}\]
    4. Simplified8.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 unpow2_binary64_8258.8

      \[\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_7007.2

      \[\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 clear-num_binary64_7597.2

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

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

Reproduce

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