Average Error: 26.7 → 17.6
Time: 12.7s
Precision: binary64
\[ \begin{array}{c}[M, D] = \mathsf{sort}([M, D])\\ \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}{\ell}\right)}^{0.5}\\ t_1 := 1 - \frac{h \cdot \left(0.5 \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\\ t_2 := \frac{\sqrt[3]{d}}{\sqrt[3]{\ell}}\\ \mathbf{if}\;\ell \leq -2.3875216497193884 \cdot 10^{-129}:\\ \;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t_0\right) \cdot t_1\\ \mathbf{elif}\;\ell \leq 4.820219395017622 \cdot 10^{-69}:\\ \;\;\;\;t_1 \cdot \left({\left(\frac{d}{h}\right)}^{0.5} \cdot \left({\left({t_2}^{2}\right)}^{0.5} \cdot {t_2}^{0.5}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t_0 \cdot \left(\sqrt{d} \cdot {\left(\frac{1}{h}\right)}^{0.5}\right)\right) \cdot \left(1 - \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}\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 (pow (/ d l) 0.5))
        (t_1 (- 1.0 (/ (* h (* 0.5 (pow (* (/ M 2.0) (/ D d)) 2.0))) l)))
        (t_2 (/ (cbrt d) (cbrt l))))
   (if (<= l -2.3875216497193884e-129)
     (* (* (/ (sqrt (- d)) (sqrt (- h))) t_0) t_1)
     (if (<= l 4.820219395017622e-69)
       (* t_1 (* (pow (/ d h) 0.5) (* (pow (pow t_2 2.0) 0.5) (pow t_2 0.5))))
       (*
        (* t_0 (* (sqrt d) (pow (/ 1.0 h) 0.5)))
        (- 1.0 (* (* 0.5 (pow (/ (* M D) (* d 2.0)) 2.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 t_0 = pow((d / l), 0.5);
	double t_1 = 1.0 - ((h * (0.5 * pow(((M / 2.0) * (D / d)), 2.0))) / l);
	double t_2 = cbrt(d) / cbrt(l);
	double tmp;
	if (l <= -2.3875216497193884e-129) {
		tmp = ((sqrt(-d) / sqrt(-h)) * t_0) * t_1;
	} else if (l <= 4.820219395017622e-69) {
		tmp = t_1 * (pow((d / h), 0.5) * (pow(pow(t_2, 2.0), 0.5) * pow(t_2, 0.5)));
	} else {
		tmp = (t_0 * (sqrt(d) * pow((1.0 / h), 0.5))) * (1.0 - ((0.5 * pow(((M * D) / (d * 2.0)), 2.0)) * (h / l)));
	}
	return tmp;
}
public static double code(double d, double h, double l, double M, double D) {
	return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.pow((d / l), 0.5);
	double t_1 = 1.0 - ((h * (0.5 * Math.pow(((M / 2.0) * (D / d)), 2.0))) / l);
	double t_2 = Math.cbrt(d) / Math.cbrt(l);
	double tmp;
	if (l <= -2.3875216497193884e-129) {
		tmp = ((Math.sqrt(-d) / Math.sqrt(-h)) * t_0) * t_1;
	} else if (l <= 4.820219395017622e-69) {
		tmp = t_1 * (Math.pow((d / h), 0.5) * (Math.pow(Math.pow(t_2, 2.0), 0.5) * Math.pow(t_2, 0.5)));
	} else {
		tmp = (t_0 * (Math.sqrt(d) * Math.pow((1.0 / h), 0.5))) * (1.0 - ((0.5 * Math.pow(((M * D) / (d * 2.0)), 2.0)) * (h / l)));
	}
	return tmp;
}
function code(d, h, l, M, D)
	return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l))))
end
function code(d, h, l, M, D)
	t_0 = Float64(d / l) ^ 0.5
	t_1 = Float64(1.0 - Float64(Float64(h * Float64(0.5 * (Float64(Float64(M / 2.0) * Float64(D / d)) ^ 2.0))) / l))
	t_2 = Float64(cbrt(d) / cbrt(l))
	tmp = 0.0
	if (l <= -2.3875216497193884e-129)
		tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_0) * t_1);
	elseif (l <= 4.820219395017622e-69)
		tmp = Float64(t_1 * Float64((Float64(d / h) ^ 0.5) * Float64(((t_2 ^ 2.0) ^ 0.5) * (t_2 ^ 0.5))));
	else
		tmp = Float64(Float64(t_0 * Float64(sqrt(d) * (Float64(1.0 / h) ^ 0.5))) * Float64(1.0 - Float64(Float64(0.5 * (Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0)) * Float64(h / l))));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(h * N[(0.5 * N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[d, 1/3], $MachinePrecision] / N[Power[l, 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.3875216497193884e-129], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[l, 4.820219395017622e-69], N[(t$95$1 * N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[(N[Power[N[Power[t$95$2, 2.0], $MachinePrecision], 0.5], $MachinePrecision] * N[Power[t$95$2, 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] * N[Power[N[(1.0 / h), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(0.5 * N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\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}{\ell}\right)}^{0.5}\\
t_1 := 1 - \frac{h \cdot \left(0.5 \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\\
t_2 := \frac{\sqrt[3]{d}}{\sqrt[3]{\ell}}\\
\mathbf{if}\;\ell \leq -2.3875216497193884 \cdot 10^{-129}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t_0\right) \cdot t_1\\

\mathbf{elif}\;\ell \leq 4.820219395017622 \cdot 10^{-69}:\\
\;\;\;\;t_1 \cdot \left({\left(\frac{d}{h}\right)}^{0.5} \cdot \left({\left({t_2}^{2}\right)}^{0.5} \cdot {t_2}^{0.5}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(t_0 \cdot \left(\sqrt{d} \cdot {\left(\frac{1}{h}\right)}^{0.5}\right)\right) \cdot \left(1 - \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\


\end{array}

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 3 regimes
  2. if l < -2.38752164971938842e-129

    1. Initial program 25.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-rr26.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}{\frac{\left(0.5 \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right) \cdot h}{\ell}}\right) \]
    3. Applied egg-rr19.1

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

    if -2.38752164971938842e-129 < l < 4.82021939501762216e-69

    1. Initial program 31.7

      \[\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-rr25.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}{2} \cdot \frac{D}{d}\right)}^{2}\right) \cdot h}{\ell}}\right) \]
    3. Applied egg-rr25.6

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

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

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

    if 4.82021939501762216e-69 < l

    1. Initial program 25.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-rr17.9

      \[\leadsto \left(\color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{h}\right)}^{0.5}\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) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification17.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.3875216497193884 \cdot 10^{-129}:\\ \;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\right)\\ \mathbf{elif}\;\ell \leq 4.820219395017622 \cdot 10^{-69}:\\ \;\;\;\;\left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\right) \cdot \left({\left(\frac{d}{h}\right)}^{0.5} \cdot \left({\left({\left(\frac{\sqrt[3]{d}}{\sqrt[3]{\ell}}\right)}^{2}\right)}^{0.5} \cdot {\left(\frac{\sqrt[3]{d}}{\sqrt[3]{\ell}}\right)}^{0.5}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left({\left(\frac{d}{\ell}\right)}^{0.5} \cdot \left(\sqrt{d} \cdot {\left(\frac{1}{h}\right)}^{0.5}\right)\right) \cdot \left(1 - \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\ \end{array} \]

Reproduce

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