Average Error: 26.3 → 15.5
Time: 15.9s
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} t_0 := \sqrt{\frac{d}{\sqrt[3]{\ell}}}\\ t_1 := \left|\sqrt[3]{d}\right| \cdot \sqrt{\frac{\sqrt[3]{d}}{h}}\\ t_2 := \sqrt[3]{\ell} \cdot \sqrt[3]{\ell}\\ \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 1.9647037253344812 \cdot 10^{+79}:\\ \;\;\;\;\frac{\left(t_1 \cdot t_0\right) \cdot \mathsf{fma}\left({\left(\frac{M}{\frac{d}{\frac{D}{2}}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)}{\sqrt{t_2}}\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(t_0 \cdot \sqrt{\frac{1}{t_2}}\right)\\ \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}
t_0 := \sqrt{\frac{d}{\sqrt[3]{\ell}}}\\
t_1 := \left|\sqrt[3]{d}\right| \cdot \sqrt{\frac{\sqrt[3]{d}}{h}}\\
t_2 := \sqrt[3]{\ell} \cdot \sqrt[3]{\ell}\\
\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 1.9647037253344812 \cdot 10^{+79}:\\
\;\;\;\;\frac{\left(t_1 \cdot t_0\right) \cdot \mathsf{fma}\left({\left(\frac{M}{\frac{d}{\frac{D}{2}}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)}{\sqrt{t_2}}\\

\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(t_0 \cdot \sqrt{\frac{1}{t_2}}\right)\\


\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
 (let* ((t_0 (sqrt (/ d (cbrt l))))
        (t_1 (* (fabs (cbrt d)) (sqrt (/ (cbrt d) h))))
        (t_2 (* (cbrt l) (cbrt l))))
   (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))))
        1.9647037253344812e+79)
     (/
      (*
       (* t_1 t_0)
       (fma (pow (/ M (/ d (/ D 2.0))) 2.0) (* (/ h l) -0.5) 1.0))
      (sqrt t_2))
     (* t_1 (* t_0 (sqrt (/ 1.0 t_2)))))))
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 t_0 = sqrt(d / cbrt(l));
	double t_1 = fabs(cbrt(d)) * sqrt(cbrt(d) / h);
	double t_2 = cbrt(l) * cbrt(l);
	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)))) <= 1.9647037253344812e+79) {
		tmp = ((t_1 * t_0) * fma(pow((M / (d / (D / 2.0))), 2.0), ((h / l) * -0.5), 1.0)) / sqrt(t_2);
	} else {
		tmp = t_1 * (t_0 * sqrt(1.0 / t_2));
	}
	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)))) < 1.9647037253344812e79

    1. Initial program 16.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. Simplified16.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. Applied *-un-lft-identity_binary6416.0

      \[\leadsto \left(\sqrt{\frac{d}{\color{blue}{1 \cdot 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_binary6416.3

      \[\leadsto \left(\sqrt{\frac{\color{blue}{\left(\sqrt[3]{d} \cdot \sqrt[3]{d}\right) \cdot \sqrt[3]{d}}}{1 \cdot 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_binary6416.3

      \[\leadsto \left(\sqrt{\color{blue}{\frac{\sqrt[3]{d} \cdot \sqrt[3]{d}}{1} \cdot \frac{\sqrt[3]{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) \]
    6. Applied sqrt-prod_binary6415.0

      \[\leadsto \left(\color{blue}{\left(\sqrt{\frac{\sqrt[3]{d} \cdot \sqrt[3]{d}}{1}} \cdot \sqrt{\frac{\sqrt[3]{d}}{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. Simplified15.0

      \[\leadsto \left(\left(\color{blue}{\left|\sqrt[3]{d}\right|} \cdot \sqrt{\frac{\sqrt[3]{d}}{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 add-cube-cbrt_binary6415.1

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

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

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

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

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

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

      \[\leadsto \left(\left(\left|\sqrt[3]{d}\right| \cdot \sqrt{\frac{\sqrt[3]{d}}{h}}\right) \cdot \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}}}} \cdot \sqrt{\frac{d}{\sqrt[3]{\ell}}}\right)\right) \cdot \mathsf{fma}\left({\left(\frac{M}{\frac{d}{\frac{D}{2}}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
    15. Applied associate-*l/_binary6411.4

      \[\leadsto \left(\left(\left|\sqrt[3]{d}\right| \cdot \sqrt{\frac{\sqrt[3]{d}}{h}}\right) \cdot \color{blue}{\frac{\sqrt{1} \cdot \sqrt{\frac{d}{\sqrt[3]{\ell}}}}{\sqrt{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}}}}\right) \cdot \mathsf{fma}\left({\left(\frac{M}{\frac{d}{\frac{D}{2}}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
    16. Applied associate-*r/_binary6411.5

      \[\leadsto \color{blue}{\frac{\left(\left|\sqrt[3]{d}\right| \cdot \sqrt{\frac{\sqrt[3]{d}}{h}}\right) \cdot \left(\sqrt{1} \cdot \sqrt{\frac{d}{\sqrt[3]{\ell}}}\right)}{\sqrt{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}}}} \cdot \mathsf{fma}\left({\left(\frac{M}{\frac{d}{\frac{D}{2}}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
    17. Applied associate-*l/_binary6411.2

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

    if 1.9647037253344812e79 < (*.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 39.6

      \[\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. Simplified39.6

      \[\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 *-un-lft-identity_binary6439.6

      \[\leadsto \left(\sqrt{\frac{d}{\color{blue}{1 \cdot 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_binary6439.8

      \[\leadsto \left(\sqrt{\frac{\color{blue}{\left(\sqrt[3]{d} \cdot \sqrt[3]{d}\right) \cdot \sqrt[3]{d}}}{1 \cdot 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_binary6439.8

      \[\leadsto \left(\sqrt{\color{blue}{\frac{\sqrt[3]{d} \cdot \sqrt[3]{d}}{1} \cdot \frac{\sqrt[3]{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) \]
    6. Applied sqrt-prod_binary6431.0

      \[\leadsto \left(\color{blue}{\left(\sqrt{\frac{\sqrt[3]{d} \cdot \sqrt[3]{d}}{1}} \cdot \sqrt{\frac{\sqrt[3]{d}}{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. Simplified31.0

      \[\leadsto \left(\left(\color{blue}{\left|\sqrt[3]{d}\right|} \cdot \sqrt{\frac{\sqrt[3]{d}}{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 add-cube-cbrt_binary6431.1

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

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

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

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

      \[\leadsto \left(\left(\left|\sqrt[3]{d}\right| \cdot \sqrt{\frac{\sqrt[3]{d}}{h}}\right) \cdot \left(\sqrt{\frac{1}{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}}} \cdot \sqrt{\frac{d}{\sqrt[3]{\ell}}}\right)\right) \cdot \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification15.5

    \[\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 1.9647037253344812 \cdot 10^{+79}:\\ \;\;\;\;\frac{\left(\left(\left|\sqrt[3]{d}\right| \cdot \sqrt{\frac{\sqrt[3]{d}}{h}}\right) \cdot \sqrt{\frac{d}{\sqrt[3]{\ell}}}\right) \cdot \mathsf{fma}\left({\left(\frac{M}{\frac{d}{\frac{D}{2}}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)}{\sqrt{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}}}\\ \mathbf{else}:\\ \;\;\;\;\left(\left|\sqrt[3]{d}\right| \cdot \sqrt{\frac{\sqrt[3]{d}}{h}}\right) \cdot \left(\sqrt{\frac{d}{\sqrt[3]{\ell}}} \cdot \sqrt{\frac{1}{\sqrt[3]{\ell} \cdot \sqrt[3]{\ell}}}\right)\\ \end{array} \]

Reproduce

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