Average Error: 14.2 → 9.4
Time: 18.7s
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{h}{\ell} \leq -1.7768538554841292 \cdot 10^{+308}:\\ \;\;\;\;w0\\ \mathbf{elif}\;\frac{h}{\ell} \leq -3.7513845546157 \cdot 10^{-280}:\\ \;\;\;\;\begin{array}{l} t_0 := \frac{M \cdot D}{2 \cdot d}\\ w0 \cdot \sqrt{1 - t_0 \cdot \left(\frac{h}{\ell} \cdot t_0\right)} \end{array}\\ \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}\;\frac{h}{\ell} \leq -1.7768538554841292 \cdot 10^{+308}:\\
\;\;\;\;w0\\

\mathbf{elif}\;\frac{h}{\ell} \leq -3.7513845546157 \cdot 10^{-280}:\\
\;\;\;\;\begin{array}{l}
t_0 := \frac{M \cdot D}{2 \cdot d}\\
w0 \cdot \sqrt{1 - t_0 \cdot \left(\frac{h}{\ell} \cdot t_0\right)}
\end{array}\\

\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 (<= (/ h l) -1.7768538554841292e+308)
   w0
   (if (<= (/ h l) -3.7513845546157e-280)
     (let* ((t_0 (/ (* M D) (* 2.0 d))))
       (* w0 (sqrt (- 1.0 (* t_0 (* (/ h l) t_0))))))
     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 ((h / l) <= -1.7768538554841292e+308) {
		tmp = w0;
	} else if ((h / l) <= -3.7513845546157e-280) {
		double t_0 = (M * D) / (2.0 * d);
		tmp = w0 * sqrt(1.0 - (t_0 * ((h / l) * t_0)));
	} 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 2 regimes
  2. if (/.f64 h l) < -1.77685385548412923e308 or -3.75138455461570006e-280 < (/.f64 h l)

    1. Initial program 13.6

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

      \[\leadsto w0 \cdot \color{blue}{1} \]

    if -1.77685385548412923e308 < (/.f64 h l) < -3.75138455461570006e-280

    1. Initial program 15.0

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Applied unpow2_binary6415.0

      \[\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}} \]
    3. Applied associate-*l*_binary6413.2

      \[\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)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification9.4

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

Reproduce

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