Average Error: 14.1 → 8.9
Time: 22.6s
Precision: binary64
\[[M, D]=\mathsf{sort}([M, D])\]
\[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\]
\[\begin{array}{l} \mathbf{if}\;w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq -\infty:\\ \;\;\;\;\left(w0 \cdot \sqrt{\frac{h \cdot {D}^{2}}{\ell \cdot {d}^{2}} \cdot -0.25}\right) \cdot \left(-M\right)\\ \mathbf{elif}\;w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 3.261737883153086 \cdot 10^{+299}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{-M \cdot D}{d \cdot -2}\right)}^{2}}\\ \mathbf{elif}\;w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq \infty:\\ \;\;\;\;w0 \cdot \left(\sqrt{\left(\frac{h}{\ell} \cdot {\left(\frac{D}{d}\right)}^{2}\right) \cdot -0.25} \cdot \left(-M\right)\right)\\ \mathbf{else}:\\ \;\;\;\;w0\\ \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}\;w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq -\infty:\\
\;\;\;\;\left(w0 \cdot \sqrt{\frac{h \cdot {D}^{2}}{\ell \cdot {d}^{2}} \cdot -0.25}\right) \cdot \left(-M\right)\\

\mathbf{elif}\;w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 3.261737883153086 \cdot 10^{+299}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{-M \cdot D}{d \cdot -2}\right)}^{2}}\\

\mathbf{elif}\;w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq \infty:\\
\;\;\;\;w0 \cdot \left(\sqrt{\left(\frac{h}{\ell} \cdot {\left(\frac{D}{d}\right)}^{2}\right) \cdot -0.25} \cdot \left(-M\right)\right)\\

\mathbf{else}:\\
\;\;\;\;w0\\

\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 (<=
      (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)))))
      (- INFINITY))
   (* (* w0 (sqrt (* (/ (* h (pow D 2.0)) (* l (pow d 2.0))) -0.25))) (- M))
   (if (<=
        (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)))))
        3.261737883153086e+299)
     (* w0 (sqrt (- 1.0 (* (/ h l) (pow (/ (- (* M D)) (* d -2.0)) 2.0)))))
     (if (<=
          (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)))))
          INFINITY)
       (* w0 (* (sqrt (* (* (/ h l) (pow (/ D d) 2.0)) -0.25)) (- M)))
       w0))))
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 ((w0 * sqrt(1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l)))) <= -((double) INFINITY)) {
		tmp = (w0 * sqrt(((h * pow(D, 2.0)) / (l * pow(d, 2.0))) * -0.25)) * -M;
	} else if ((w0 * sqrt(1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l)))) <= 3.261737883153086e+299) {
		tmp = w0 * sqrt(1.0 - ((h / l) * pow((-(M * D) / (d * -2.0)), 2.0)));
	} else if ((w0 * sqrt(1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l)))) <= ((double) INFINITY)) {
		tmp = w0 * (sqrt(((h / l) * pow((D / d), 2.0)) * -0.25) * -M);
	} else {
		tmp = w0;
	}
	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 4 regimes
  2. if (*.f64 w0 (sqrt.f64 (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 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. Taylor expanded around -inf 56.9

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

    if -inf.0 < (*.f64 w0 (sqrt.f64 (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))))) < 3.26173788315308593e299

    1. Initial program 0.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 frac-2neg_binary64_7710.1

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

    if 3.26173788315308593e299 < (*.f64 w0 (sqrt.f64 (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))))) < +inf.0

    1. Initial program 58.8

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\]
    2. Taylor expanded around -inf 56.0

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

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

    if +inf.0 < (*.f64 w0 (sqrt.f64 (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)))))

    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 0 16.6

      \[\leadsto w0 \cdot \color{blue}{1}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification8.9

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

Reproduce

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