Average Error: 14.5 → 9.7
Time: 13.2s
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 -2.953975599281222 \cdot 10^{-29}:\\ \;\;\;\;w0 \cdot \sqrt{1 - {\left(\sqrt[3]{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{\sqrt[3]{M \cdot D}}{\sqrt[3]{2 \cdot d}}\right)}^{2}\right)}\\ \mathbf{elif}\;\frac{M \cdot D}{2 \cdot d} \leq 1.5031648947369 \cdot 10^{-311}:\\ \;\;\;\;w0 \cdot \sqrt[3]{{\left(\sqrt{1 - \frac{h \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}}{\ell}}\right)}^{3}}\\ \mathbf{elif}\;\frac{M \cdot D}{2 \cdot d} \leq 2.829330713947476 \cdot 10^{+236}:\\ \;\;\;\;w0 \cdot \sqrt{1 - {\left(\sqrt{\frac{M \cdot D}{2 \cdot d}}\right)}^{2} \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{h}{\ell}\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}\;\frac{M \cdot D}{2 \cdot d} \leq -2.953975599281222 \cdot 10^{-29}:\\
\;\;\;\;w0 \cdot \sqrt{1 - {\left(\sqrt[3]{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{\sqrt[3]{M \cdot D}}{\sqrt[3]{2 \cdot d}}\right)}^{2}\right)}\\

\mathbf{elif}\;\frac{M \cdot D}{2 \cdot d} \leq 1.5031648947369 \cdot 10^{-311}:\\
\;\;\;\;w0 \cdot \sqrt[3]{{\left(\sqrt{1 - \frac{h \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}}{\ell}}\right)}^{3}}\\

\mathbf{elif}\;\frac{M \cdot D}{2 \cdot d} \leq 2.829330713947476 \cdot 10^{+236}:\\
\;\;\;\;w0 \cdot \sqrt{1 - {\left(\sqrt{\frac{M \cdot D}{2 \cdot d}}\right)}^{2} \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{h}{\ell}\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 (<= (/ (* M D) (* 2.0 d)) -2.953975599281222e-29)
   (*
    w0
    (sqrt
     (-
      1.0
      (*
       (pow (* (cbrt (/ (* M D) (* 2.0 d))) (cbrt (/ (* M D) (* 2.0 d)))) 2.0)
       (* (/ h l) (pow (/ (cbrt (* M D)) (cbrt (* 2.0 d))) 2.0))))))
   (if (<= (/ (* M D) (* 2.0 d)) 1.5031648947369e-311)
     (*
      w0
      (cbrt
       (pow (sqrt (- 1.0 (/ (* h (pow (* (/ M 2.0) (/ D d)) 2.0)) l))) 3.0)))
     (if (<= (/ (* M D) (* 2.0 d)) 2.829330713947476e+236)
       (*
        w0
        (sqrt
         (-
          1.0
          (*
           (pow (sqrt (/ (* M D) (* 2.0 d))) 2.0)
           (* (/ (* M D) (* 2.0 d)) (/ h l))))))
       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 (((M * D) / (2.0 * d)) <= -2.953975599281222e-29) {
		tmp = w0 * sqrt(1.0 - (pow((cbrt((M * D) / (2.0 * d)) * cbrt((M * D) / (2.0 * d))), 2.0) * ((h / l) * pow((cbrt(M * D) / cbrt(2.0 * d)), 2.0))));
	} else if (((M * D) / (2.0 * d)) <= 1.5031648947369e-311) {
		tmp = w0 * cbrt(pow(sqrt(1.0 - ((h * pow(((M / 2.0) * (D / d)), 2.0)) / l)), 3.0));
	} else if (((M * D) / (2.0 * d)) <= 2.829330713947476e+236) {
		tmp = w0 * sqrt(1.0 - (pow(sqrt((M * D) / (2.0 * d)), 2.0) * (((M * D) / (2.0 * d)) * (h / l))));
	} 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 (*.f64 M D) (*.f64 2 d)) < -2.95399e-29

    1. Initial program 32.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 add-cube-cbrt_binary6432.5

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

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

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

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

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

    if -2.95399e-29 < (/.f64 (*.f64 M D) (*.f64 2 d)) < 1.50317e-311

    1. Initial program 6.9

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\]
    2. Using strategy rm
    3. Applied div-inv_binary646.9

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

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

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

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

    if 1.50317e-311 < (/.f64 (*.f64 M D) (*.f64 2 d)) < 2.82931e236

    1. Initial program 11.0

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt_binary6411.0

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

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

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

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

    if 2.82931e236 < (/.f64 (*.f64 M D) (*.f64 2 d))

    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 55.7

      \[\leadsto \color{blue}{w0}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification9.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{M \cdot D}{2 \cdot d} \leq -2.953975599281222 \cdot 10^{-29}:\\ \;\;\;\;w0 \cdot \sqrt{1 - {\left(\sqrt[3]{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt[3]{\frac{M \cdot D}{2 \cdot d}}\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{\sqrt[3]{M \cdot D}}{\sqrt[3]{2 \cdot d}}\right)}^{2}\right)}\\ \mathbf{elif}\;\frac{M \cdot D}{2 \cdot d} \leq 1.5031648947369 \cdot 10^{-311}:\\ \;\;\;\;w0 \cdot \sqrt[3]{{\left(\sqrt{1 - \frac{h \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}}{\ell}}\right)}^{3}}\\ \mathbf{elif}\;\frac{M \cdot D}{2 \cdot d} \leq 2.829330713947476 \cdot 10^{+236}:\\ \;\;\;\;w0 \cdot \sqrt{1 - {\left(\sqrt{\frac{M \cdot D}{2 \cdot d}}\right)}^{2} \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{h}{\ell}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array}\]

Reproduce

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