Average Error: 14.2 → 7.9
Time: 20.0s
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} t_0 := \frac{M \cdot D}{2 \cdot d}\\ t_1 := {t_0}^{2}\\ t_2 := 1 - t_1 \cdot \frac{h}{\ell}\\ \mathbf{if}\;t_2 \leq 2.351012843031625 \cdot 10^{+277}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{t_1}{\frac{\ell}{h}}}\\ \mathbf{elif}\;t_2 \leq \infty:\\ \;\;\;\;w0 \cdot \left(D \cdot \sqrt{-0.25 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M}{d}\right)}^{2}\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{t_0 \cdot h}{\frac{\ell}{t_0}}}\\ \end{array} \]
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\begin{array}{l}
t_0 := \frac{M \cdot D}{2 \cdot d}\\
t_1 := {t_0}^{2}\\
t_2 := 1 - t_1 \cdot \frac{h}{\ell}\\
\mathbf{if}\;t_2 \leq 2.351012843031625 \cdot 10^{+277}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{t_1}{\frac{\ell}{h}}}\\

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

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{t_0 \cdot h}{\frac{\ell}{t_0}}}\\


\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
 (let* ((t_0 (/ (* M D) (* 2.0 d)))
        (t_1 (pow t_0 2.0))
        (t_2 (- 1.0 (* t_1 (/ h l)))))
   (if (<= t_2 2.351012843031625e+277)
     (* w0 (sqrt (- 1.0 (/ t_1 (/ l h)))))
     (if (<= t_2 INFINITY)
       (* w0 (* D (sqrt (* -0.25 (* (/ h l) (pow (/ M d) 2.0))))))
       (* w0 (sqrt (- 1.0 (/ (* t_0 h) (/ l t_0)))))))))
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 t_0 = (M * D) / (2.0 * d);
	double t_1 = pow(t_0, 2.0);
	double t_2 = 1.0 - (t_1 * (h / l));
	double tmp;
	if (t_2 <= 2.351012843031625e+277) {
		tmp = w0 * sqrt(1.0 - (t_1 / (l / h)));
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = w0 * (D * sqrt(-0.25 * ((h / l) * pow((M / d), 2.0))));
	} else {
		tmp = w0 * sqrt(1.0 - ((t_0 * h) / (l / t_0)));
	}
	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 3 regimes
  2. if (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))) < 2.351012843031625e277

    1. Initial program 0.2

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

      \[\leadsto w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\color{blue}{\left(\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}\right) \cdot \sqrt[3]{\ell}}}} \]
    3. Applied *-un-lft-identity_binary640.3

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{{\left(\frac{D \cdot M}{2 \cdot d}\right)}^{2}}{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}}} \cdot \frac{h}{\sqrt[3]{\ell}}} \]
    7. Applied *-un-lft-identity_binary640.7

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

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

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

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

    1. Initial program 62.5

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

      \[\leadsto w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\color{blue}{\left(\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}\right) \cdot \sqrt[3]{\ell}}}} \]
    3. Applied *-un-lft-identity_binary6462.5

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

      \[\leadsto w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \color{blue}{\left(\frac{1}{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}} \cdot \frac{h}{\sqrt[3]{\ell}}\right)}} \]
    5. Applied associate-*r*_binary6459.8

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{{\left(\frac{D \cdot M}{2 \cdot d}\right)}^{2}}{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}}} \cdot \frac{h}{\sqrt[3]{\ell}}} \]
    7. Taylor expanded in D around inf 56.5

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

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

    if +inf.0 < (-.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. Applied add-cube-cbrt_binary6464.0

      \[\leadsto w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\color{blue}{\left(\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}\right) \cdot \sqrt[3]{\ell}}}} \]
    3. Applied *-un-lft-identity_binary6464.0

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

      \[\leadsto w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \color{blue}{\left(\frac{1}{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}} \cdot \frac{h}{\sqrt[3]{\ell}}\right)}} \]
    5. Applied associate-*r*_binary6436.8

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{D \cdot M}{2 \cdot d} \cdot \frac{D \cdot M}{2 \cdot d}}}{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}} \cdot \frac{h}{\sqrt[3]{\ell}}} \]
    8. Applied associate-/l*_binary6428.7

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{D \cdot M}{2 \cdot d}}{\frac{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}}{\frac{D \cdot M}{2 \cdot d}}}} \cdot \frac{h}{\sqrt[3]{\ell}}} \]
    9. Applied *-un-lft-identity_binary6428.7

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{D \cdot M}{2 \cdot d}}{\color{blue}{1 \cdot \frac{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}}{\frac{D \cdot M}{2 \cdot d}}}} \cdot \frac{h}{\sqrt[3]{\ell}}} \]
    10. Applied *-un-lft-identity_binary6428.7

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{1 \cdot \frac{D \cdot M}{2 \cdot d}}}{1 \cdot \frac{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}}{\frac{D \cdot M}{2 \cdot d}}} \cdot \frac{h}{\sqrt[3]{\ell}}} \]
    11. Applied times-frac_binary6428.7

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

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

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

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

Reproduce

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