Average Error: 26.5 → 15.9
Time: 15.3s
Precision: binary64
\[[M, D]=\mathsf{sort}([M, D])\]
\[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
\[\begin{array}{l} \mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq \infty:\\ \;\;\;\;\begin{array}{l} t_0 := \frac{\sqrt[3]{d}}{\sqrt[3]{h}}\\ \left(\left(\left|t_0\right| \cdot \sqrt{t_0}\right) \cdot \left(\sqrt{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \sqrt{\frac{\sqrt[3]{d}}{\ell}}\right)\right) \cdot \mathsf{fma}\left({\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \end{array}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \end{array} \]
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\begin{array}{l}
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq \infty:\\
\;\;\;\;\begin{array}{l}
t_0 := \frac{\sqrt[3]{d}}{\sqrt[3]{h}}\\
\left(\left(\left|t_0\right| \cdot \sqrt{t_0}\right) \cdot \left(\sqrt{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \sqrt{\frac{\sqrt[3]{d}}{\ell}}\right)\right) \cdot \mathsf{fma}\left({\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)
\end{array}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\


\end{array}
(FPCore (d h l M D)
 :precision binary64
 (*
  (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
  (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
(FPCore (d h l M D)
 :precision binary64
 (if (<=
      (*
       (* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
       (- 1.0 (* (* 0.5 (pow (/ (* M D) (* d 2.0)) 2.0)) (/ h l))))
      INFINITY)
   (let* ((t_0 (/ (cbrt d) (cbrt h))))
     (*
      (*
       (* (fabs t_0) (sqrt t_0))
       (* (sqrt (* (cbrt d) (cbrt d))) (sqrt (/ (cbrt d) l))))
      (fma (pow (* (/ M d) (/ D 2.0)) 2.0) (* (/ h l) -0.5) 1.0)))
   (* d (sqrt (/ 1.0 (* h l))))))
double code(double d, double h, double l, double M, double D) {
	return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (((pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((0.5 * pow(((M * D) / (d * 2.0)), 2.0)) * (h / l)))) <= ((double) INFINITY)) {
		double t_0_1 = cbrt(d) / cbrt(h);
		tmp = ((fabs(t_0_1) * sqrt(t_0_1)) * (sqrt(cbrt(d) * cbrt(d)) * sqrt(cbrt(d) / l))) * fma(pow(((M / d) * (D / 2.0)), 2.0), ((h / l) * -0.5), 1.0);
	} else {
		tmp = d * sqrt(1.0 / (h * l));
	}
	return tmp;
}

Error

Bits error versus d

Bits error versus h

Bits error versus l

Bits error versus M

Bits error versus D

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < +inf.0

    1. Initial program 19.2

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified19.2

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)} \]
    3. Applied add-cube-cbrt_binary6419.5

      \[\leadsto \left(\sqrt{\frac{d}{\color{blue}{\left(\sqrt[3]{h} \cdot \sqrt[3]{h}\right) \cdot \sqrt[3]{h}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
    4. Applied add-cube-cbrt_binary6419.6

      \[\leadsto \left(\sqrt{\frac{\color{blue}{\left(\sqrt[3]{d} \cdot \sqrt[3]{d}\right) \cdot \sqrt[3]{d}}}{\left(\sqrt[3]{h} \cdot \sqrt[3]{h}\right) \cdot \sqrt[3]{h}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
    5. Applied times-frac_binary6419.6

      \[\leadsto \left(\sqrt{\color{blue}{\frac{\sqrt[3]{d} \cdot \sqrt[3]{d}}{\sqrt[3]{h} \cdot \sqrt[3]{h}} \cdot \frac{\sqrt[3]{d}}{\sqrt[3]{h}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
    6. Applied sqrt-prod_binary6413.3

      \[\leadsto \left(\color{blue}{\left(\sqrt{\frac{\sqrt[3]{d} \cdot \sqrt[3]{d}}{\sqrt[3]{h} \cdot \sqrt[3]{h}}} \cdot \sqrt{\frac{\sqrt[3]{d}}{\sqrt[3]{h}}}\right)} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
    7. Simplified12.5

      \[\leadsto \left(\left(\color{blue}{\left|\frac{\sqrt[3]{d}}{\sqrt[3]{h}}\right|} \cdot \sqrt{\frac{\sqrt[3]{d}}{\sqrt[3]{h}}}\right) \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
    8. Applied times-frac_binary6412.8

      \[\leadsto \left(\left(\left|\frac{\sqrt[3]{d}}{\sqrt[3]{h}}\right| \cdot \sqrt{\frac{\sqrt[3]{d}}{\sqrt[3]{h}}}\right) \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\color{blue}{\left(\frac{M}{d} \cdot \frac{D}{2}\right)}}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
    9. Applied *-un-lft-identity_binary6412.8

      \[\leadsto \left(\left(\left|\frac{\sqrt[3]{d}}{\sqrt[3]{h}}\right| \cdot \sqrt{\frac{\sqrt[3]{d}}{\sqrt[3]{h}}}\right) \cdot \sqrt{\frac{d}{\color{blue}{1 \cdot \ell}}}\right) \cdot \mathsf{fma}\left({\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
    10. Applied add-cube-cbrt_binary6413.0

      \[\leadsto \left(\left(\left|\frac{\sqrt[3]{d}}{\sqrt[3]{h}}\right| \cdot \sqrt{\frac{\sqrt[3]{d}}{\sqrt[3]{h}}}\right) \cdot \sqrt{\frac{\color{blue}{\left(\sqrt[3]{d} \cdot \sqrt[3]{d}\right) \cdot \sqrt[3]{d}}}{1 \cdot \ell}}\right) \cdot \mathsf{fma}\left({\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
    11. Applied times-frac_binary6413.0

      \[\leadsto \left(\left(\left|\frac{\sqrt[3]{d}}{\sqrt[3]{h}}\right| \cdot \sqrt{\frac{\sqrt[3]{d}}{\sqrt[3]{h}}}\right) \cdot \sqrt{\color{blue}{\frac{\sqrt[3]{d} \cdot \sqrt[3]{d}}{1} \cdot \frac{\sqrt[3]{d}}{\ell}}}\right) \cdot \mathsf{fma}\left({\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
    12. Applied sqrt-prod_binary648.8

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

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

    1. Initial program 64.0

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

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)} \]
    3. Taylor expanded in d around inf 52.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq \infty:\\ \;\;\;\;\left(\left(\left|\frac{\sqrt[3]{d}}{\sqrt[3]{h}}\right| \cdot \sqrt{\frac{\sqrt[3]{d}}{\sqrt[3]{h}}}\right) \cdot \left(\sqrt{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \sqrt{\frac{\sqrt[3]{d}}{\ell}}\right)\right) \cdot \mathsf{fma}\left({\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \end{array} \]

Reproduce

herbie shell --seed 2021307 
(FPCore (d h l M D)
  :name "Henrywood and Agarwal, Equation (12)"
  :precision binary64
  (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))