Average Error: 14.2 → 8.3
Time: 15.4s
Precision: binary64
Cost: 8321
\[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\]
\[\begin{array}{l} \mathbf{if}\;M \cdot D \leq 3.290089053137994 \cdot 10^{+109}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M \cdot D}{2 \cdot d} \cdot \frac{\frac{M \cdot D}{2 \cdot d} \cdot h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M}{\frac{2}{\frac{D}{d}}} \cdot \left(\frac{M}{\frac{2}{\frac{D}{d}}} \cdot \frac{h}{\ell}\right)}\\ \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}\;M \cdot D \leq 3.290089053137994 \cdot 10^{+109}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{M \cdot D}{2 \cdot d} \cdot \frac{\frac{M \cdot D}{2 \cdot d} \cdot h}{\ell}}\\

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

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

Alternatives

Alternative 1
Error8.8
Cost8770
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{2 \cdot d} \cdot h}{\ell} \cdot \left(\frac{D}{d} \cdot \frac{M}{2}\right)}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -1.0888595826745536 \cdot 10^{-265}:\\ \;\;\;\;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\\ \end{array}\]
Alternative 2
Error9.1
Cost8770
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -1.0542698896827244 \cdot 10^{+38}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{2 \cdot d} \cdot h}{\ell} \cdot \left(\frac{D}{d} \cdot \frac{M}{2}\right)}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -1.0888595826745536 \cdot 10^{-265}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M \cdot D}{2 \cdot d} \cdot \frac{\left(M \cdot D\right) \cdot \frac{h}{\ell}}{2 \cdot d}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array}\]
Alternative 3
Error10.2
Cost8770
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -1.1819453427345535 \cdot 10^{+234}:\\ \;\;\;\;w0\\ \mathbf{elif}\;\frac{h}{\ell} \leq -1.0888595826745536 \cdot 10^{-265}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M \cdot D}{2 \cdot d} \cdot \frac{\left(M \cdot D\right) \cdot \frac{h}{\ell}}{2 \cdot d}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array}\]
Alternative 4
Error13.7
Cost8386
\[\begin{array}{l} \mathbf{if}\;d \leq 2.1017646892466287 \cdot 10^{-156}:\\ \;\;\;\;w0\\ \mathbf{elif}\;d \leq 2.8623882925274497 \cdot 10^{+137}:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{h \cdot \left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right)}{\ell \cdot \left(d \cdot d\right)}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array}\]
Alternative 5
Error13.8
Cost64
\[w0\]
Alternative 6
Error61.8
Cost64
\[1\]

Error

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 M D) < 3.29008905313799419e109

    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 unpow2_binary64_82512.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*_binary64_70111.1

      \[\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. Using strategy rm
    6. Applied associate-*r/_binary64_7026.6

      \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot D}{2 \cdot d} \cdot \color{blue}{\frac{\frac{M \cdot D}{2 \cdot d} \cdot h}{\ell}}}\]
    7. Simplified6.6

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

    if 3.29008905313799419e109 < (*.f64 M D)

    1. Initial program 33.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-/l*_binary64_70530.6

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

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

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

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

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

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

Reproduce

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