Average Error: 26.2 → 15.4
Time: 20.3s
Precision: binary64
\[\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 := {\left(\frac{d}{h}\right)}^{0.5}\\ t_1 := 0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\\ t_2 := 1 - \frac{h \cdot t_1}{\ell}\\ t_3 := \sqrt{-d}\\ t_4 := 1 - {\left(0.5 \cdot \left(\frac{\left(M \cdot D\right) \cdot \sqrt{0.5}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\\ t_5 := {\left(\frac{d}{\ell}\right)}^{0.5}\\ t_6 := \left(t_5 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot t_4\\ t_7 := t_0 \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\\ \mathbf{if}\;\ell \leq -1.4693568850199418 \cdot 10^{-48}:\\ \;\;\;\;\left(\frac{t_3}{\sqrt{-h}} \cdot t_5\right) \cdot \left(1 - t_1 \cdot \frac{h}{\ell}\right)\\ \mathbf{elif}\;\ell \leq -5.3271081112533 \cdot 10^{-310}:\\ \;\;\;\;\left(t_0 \cdot \frac{t_3}{\sqrt{-\ell}}\right) \cdot t_2\\ \mathbf{elif}\;\ell \leq 2.7669274764063216 \cdot 10^{-116}:\\ \;\;\;\;t_2 \cdot t_7\\ \mathbf{elif}\;\ell \leq 2.962503803557255 \cdot 10^{+178}:\\ \;\;\;\;t_6\\ \mathbf{elif}\;\ell \leq 1.6302922045807467 \cdot 10^{+252}:\\ \;\;\;\;t_7 \cdot t_4\\ \mathbf{else}:\\ \;\;\;\;t_6\\ \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 := {\left(\frac{d}{h}\right)}^{0.5}\\
t_1 := 0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\\
t_2 := 1 - \frac{h \cdot t_1}{\ell}\\
t_3 := \sqrt{-d}\\
t_4 := 1 - {\left(0.5 \cdot \left(\frac{\left(M \cdot D\right) \cdot \sqrt{0.5}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\\
t_5 := {\left(\frac{d}{\ell}\right)}^{0.5}\\
t_6 := \left(t_5 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot t_4\\
t_7 := t_0 \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\\
\mathbf{if}\;\ell \leq -1.4693568850199418 \cdot 10^{-48}:\\
\;\;\;\;\left(\frac{t_3}{\sqrt{-h}} \cdot t_5\right) \cdot \left(1 - t_1 \cdot \frac{h}{\ell}\right)\\

\mathbf{elif}\;\ell \leq -5.3271081112533 \cdot 10^{-310}:\\
\;\;\;\;\left(t_0 \cdot \frac{t_3}{\sqrt{-\ell}}\right) \cdot t_2\\

\mathbf{elif}\;\ell \leq 2.7669274764063216 \cdot 10^{-116}:\\
\;\;\;\;t_2 \cdot t_7\\

\mathbf{elif}\;\ell \leq 2.962503803557255 \cdot 10^{+178}:\\
\;\;\;\;t_6\\

\mathbf{elif}\;\ell \leq 1.6302922045807467 \cdot 10^{+252}:\\
\;\;\;\;t_7 \cdot t_4\\

\mathbf{else}:\\
\;\;\;\;t_6\\


\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 (pow (/ d h) 0.5))
        (t_1 (* 0.5 (pow (/ (* M D) (* d 2.0)) 2.0)))
        (t_2 (- 1.0 (/ (* h t_1) l)))
        (t_3 (sqrt (- d)))
        (t_4
         (-
          1.0
          (pow (* 0.5 (* (/ (* (* M D) (sqrt 0.5)) d) (sqrt (/ h l)))) 2.0)))
        (t_5 (pow (/ d l) 0.5))
        (t_6 (* (* t_5 (/ (sqrt d) (sqrt h))) t_4))
        (t_7 (* t_0 (/ (sqrt d) (sqrt l)))))
   (if (<= l -1.4693568850199418e-48)
     (* (* (/ t_3 (sqrt (- h))) t_5) (- 1.0 (* t_1 (/ h l))))
     (if (<= l -5.3271081112533e-310)
       (* (* t_0 (/ t_3 (sqrt (- l)))) t_2)
       (if (<= l 2.7669274764063216e-116)
         (* t_2 t_7)
         (if (<= l 2.962503803557255e+178)
           t_6
           (if (<= l 1.6302922045807467e+252) (* t_7 t_4) t_6)))))))
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 = pow((d / h), 0.5);
	double t_1 = 0.5 * pow(((M * D) / (d * 2.0)), 2.0);
	double t_2 = 1.0 - ((h * t_1) / l);
	double t_3 = sqrt(-d);
	double t_4 = 1.0 - pow((0.5 * ((((M * D) * sqrt(0.5)) / d) * sqrt((h / l)))), 2.0);
	double t_5 = pow((d / l), 0.5);
	double t_6 = (t_5 * (sqrt(d) / sqrt(h))) * t_4;
	double t_7 = t_0 * (sqrt(d) / sqrt(l));
	double tmp;
	if (l <= -1.4693568850199418e-48) {
		tmp = ((t_3 / sqrt(-h)) * t_5) * (1.0 - (t_1 * (h / l)));
	} else if (l <= -5.3271081112533e-310) {
		tmp = (t_0 * (t_3 / sqrt(-l))) * t_2;
	} else if (l <= 2.7669274764063216e-116) {
		tmp = t_2 * t_7;
	} else if (l <= 2.962503803557255e+178) {
		tmp = t_6;
	} else if (l <= 1.6302922045807467e+252) {
		tmp = t_7 * t_4;
	} else {
		tmp = t_6;
	}
	return tmp;
}

Error

Bits error versus d

Bits error versus h

Bits error versus l

Bits error versus M

Bits error versus D

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 5 regimes
  2. if l < -1.46935688501994175e-48

    1. Initial program 24.9

      \[\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. Applied egg-rr17.0

      \[\leadsto \left(\color{blue}{\frac{\sqrt{-d}}{\sqrt{-h}}} \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) \]

    if -1.46935688501994175e-48 < l < -5.327108111253303e-310

    1. Initial program 28.9

      \[\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. Applied egg-rr23.3

      \[\leadsto \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 - \color{blue}{\frac{\left(0.5 \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot h}{\ell}}\right) \]
    3. Applied egg-rr11.2

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

    if -5.327108111253303e-310 < l < 2.7669274764063216e-116

    1. Initial program 33.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. Applied egg-rr27.9

      \[\leadsto \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 - \color{blue}{\frac{\left(0.5 \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot h}{\ell}}\right) \]
    3. Applied egg-rr12.1

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

    if 2.7669274764063216e-116 < l < 2.96250380355725493e178 or 1.63029220458074675e252 < l

    1. Initial program 23.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. Applied egg-rr23.8

      \[\leadsto \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 - \color{blue}{\frac{\left(0.5 \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot h}{\ell}}\right) \]
    3. Applied egg-rr21.7

      \[\leadsto \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 - \color{blue}{{\left(\frac{\frac{M \cdot D}{d \cdot 2} \cdot \sqrt{0.5}}{\sqrt{\frac{\ell}{h}}}\right)}^{2}}\right) \]
    4. Taylor expanded in M around inf 21.7

      \[\leadsto \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 - {\color{blue}{\left(0.5 \cdot \left(\frac{\sqrt{0.5} \cdot \left(D \cdot M\right)}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    5. Applied egg-rr15.0

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

    if 2.96250380355725493e178 < l < 1.63029220458074675e252

    1. Initial program 29.4

      \[\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. Applied egg-rr30.8

      \[\leadsto \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 - \color{blue}{\frac{\left(0.5 \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot h}{\ell}}\right) \]
    3. Applied egg-rr28.3

      \[\leadsto \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 - \color{blue}{{\left(\frac{\frac{M \cdot D}{d \cdot 2} \cdot \sqrt{0.5}}{\sqrt{\frac{\ell}{h}}}\right)}^{2}}\right) \]
    4. Taylor expanded in M around inf 28.1

      \[\leadsto \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 - {\color{blue}{\left(0.5 \cdot \left(\frac{\sqrt{0.5} \cdot \left(D \cdot M\right)}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    5. Applied egg-rr20.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.4693568850199418 \cdot 10^{-48}:\\ \;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \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)\\ \mathbf{elif}\;\ell \leq -5.3271081112533 \cdot 10^{-310}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\right) \cdot \left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right)}{\ell}\right)\\ \mathbf{elif}\;\ell \leq 2.7669274764063216 \cdot 10^{-116}:\\ \;\;\;\;\left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right)}{\ell}\right) \cdot \left({\left(\frac{d}{h}\right)}^{0.5} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right)\\ \mathbf{elif}\;\ell \leq 2.962503803557255 \cdot 10^{+178}:\\ \;\;\;\;\left({\left(\frac{d}{\ell}\right)}^{0.5} \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot \left(1 - {\left(0.5 \cdot \left(\frac{\left(M \cdot D\right) \cdot \sqrt{0.5}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\\ \mathbf{elif}\;\ell \leq 1.6302922045807467 \cdot 10^{+252}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right) \cdot \left(1 - {\left(0.5 \cdot \left(\frac{\left(M \cdot D\right) \cdot \sqrt{0.5}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\left({\left(\frac{d}{\ell}\right)}^{0.5} \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot \left(1 - {\left(0.5 \cdot \left(\frac{\left(M \cdot D\right) \cdot \sqrt{0.5}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\\ \end{array} \]

Reproduce

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