Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.6% → 73.9%
Time: 26.9s
Alternatives: 23
Speedup: 1.5×

Specification

?
\[\begin{array}{l} \\ \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) \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)))))
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)));
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
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)));
}
def code(d, h, l, M, 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)))
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 tmp = code(d, h, l, M, D)
	tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l)));
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]
\begin{array}{l}

\\
\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)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 23 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 66.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \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) \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)))))
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)));
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
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)));
}
def code(d, h, l, M, 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)))
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 tmp = code(d, h, l, M, D)
	tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l)));
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]
\begin{array}{l}

\\
\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)
\end{array}

Alternative 1: 73.9% accurate, 0.6× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{\ell}}\\ t_1 := \mathsf{fma}\left({\left(0.5 \cdot \left(\frac{1}{d} \cdot \left(D \cdot M\right)\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\\ t_2 := \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{if}\;d \leq -5.5 \cdot 10^{+138}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;d \leq -1.36 \cdot 10^{-127}:\\ \;\;\;\;t_0 \cdot \left(\sqrt{\frac{d}{h}} \cdot t_1\right)\\ \mathbf{elif}\;d \leq -7.5 \cdot 10^{-297}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(t_1 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (/ d l)))
        (t_1
         (fma (pow (* 0.5 (* (/ 1.0 d) (* D M))) 2.0) (* -0.5 (/ h l)) 1.0))
        (t_2
         (*
          (* d (pow (* h l) -0.5))
          (- -1.0 (* -0.5 (* (/ h l) (pow (* (/ D d) (* M 0.5)) 2.0)))))))
   (if (<= d -5.5e+138)
     t_2
     (if (<= d -1.36e-127)
       (* t_0 (* (sqrt (/ d h)) t_1))
       (if (<= d -7.5e-297) t_2 (* t_0 (* t_1 (/ (sqrt d) (sqrt h)))))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / l));
	double t_1 = fma(pow((0.5 * ((1.0 / d) * (D * M))), 2.0), (-0.5 * (h / l)), 1.0);
	double t_2 = (d * pow((h * l), -0.5)) * (-1.0 - (-0.5 * ((h / l) * pow(((D / d) * (M * 0.5)), 2.0))));
	double tmp;
	if (d <= -5.5e+138) {
		tmp = t_2;
	} else if (d <= -1.36e-127) {
		tmp = t_0 * (sqrt((d / h)) * t_1);
	} else if (d <= -7.5e-297) {
		tmp = t_2;
	} else {
		tmp = t_0 * (t_1 * (sqrt(d) / sqrt(h)));
	}
	return tmp;
}
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(d / l))
	t_1 = fma((Float64(0.5 * Float64(Float64(1.0 / d) * Float64(D * M))) ^ 2.0), Float64(-0.5 * Float64(h / l)), 1.0)
	t_2 = Float64(Float64(d * (Float64(h * l) ^ -0.5)) * Float64(-1.0 - Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M * 0.5)) ^ 2.0)))))
	tmp = 0.0
	if (d <= -5.5e+138)
		tmp = t_2;
	elseif (d <= -1.36e-127)
		tmp = Float64(t_0 * Float64(sqrt(Float64(d / h)) * t_1));
	elseif (d <= -7.5e-297)
		tmp = t_2;
	else
		tmp = Float64(t_0 * Float64(t_1 * Float64(sqrt(d) / sqrt(h))));
	end
	return tmp
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(0.5 * N[(N[(1.0 / d), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(-1.0 - N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.5e+138], t$95$2, If[LessEqual[d, -1.36e-127], N[(t$95$0 * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -7.5e-297], t$95$2, N[(t$95$0 * N[(t$95$1 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \mathsf{fma}\left({\left(0.5 \cdot \left(\frac{1}{d} \cdot \left(D \cdot M\right)\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\\
t_2 := \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\
\mathbf{if}\;d \leq -5.5 \cdot 10^{+138}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;d \leq -1.36 \cdot 10^{-127}:\\
\;\;\;\;t_0 \cdot \left(\sqrt{\frac{d}{h}} \cdot t_1\right)\\

\mathbf{elif}\;d \leq -7.5 \cdot 10^{-297}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -5.4999999999999999e138 or -1.3599999999999999e-127 < d < -7.4999999999999994e-297

    1. Initial program 55.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. Simplified52.8%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def25.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p45.8%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/38.8%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot \frac{d}{\ell}}{h}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      4. *-commutative38.8%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in d around -inf 70.5%

      \[\leadsto \color{blue}{\left(-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    7. Step-by-step derivation
      1. mul-1-neg70.5%

        \[\leadsto \color{blue}{\left(-d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      2. distribute-rgt-neg-in70.5%

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

        \[\leadsto \left(d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      4. sqr-pow70.6%

        \[\leadsto \left(d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      5. rem-sqrt-square70.6%

        \[\leadsto \left(d \cdot \left(-\color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      6. metadata-eval70.6%

        \[\leadsto \left(d \cdot \left(-\left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right|\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      7. sqr-pow70.5%

        \[\leadsto \left(d \cdot \left(-\left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right|\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      8. fabs-sqr70.5%

        \[\leadsto \left(d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      9. sqr-pow70.6%

        \[\leadsto \left(d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{-0.5}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    8. Simplified70.6%

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

    if -5.4999999999999999e138 < d < -1.3599999999999999e-127

    1. Initial program 75.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. Simplified75.2%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Step-by-step derivation
      1. clear-num75.2%

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

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

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \color{blue}{{\left(\frac{\frac{d}{D}}{M}\right)}^{-1}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right) \]
    5. Step-by-step derivation
      1. unpow-175.2%

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

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

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

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

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

    if -7.4999999999999994e-297 < d

    1. Initial program 64.1%

      \[\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. Simplified63.1%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Step-by-step derivation
      1. clear-num63.1%

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

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

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \color{blue}{{\left(\frac{\frac{d}{D}}{M}\right)}^{-1}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right) \]
    5. Step-by-step derivation
      1. unpow-163.1%

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

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

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \color{blue}{\left(\frac{1}{d} \cdot \left(M \cdot D\right)\right)}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right) \]
      4. *-commutative64.0%

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

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \color{blue}{\left(\frac{1}{d} \cdot \left(D \cdot M\right)\right)}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right) \]
    7. Step-by-step derivation
      1. sqrt-div77.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5.5 \cdot 10^{+138}:\\ \;\;\;\;\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{elif}\;d \leq -1.36 \cdot 10^{-127}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(\frac{1}{d} \cdot \left(D \cdot M\right)\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\\ \mathbf{elif}\;d \leq -7.5 \cdot 10^{-297}:\\ \;\;\;\;\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\mathsf{fma}\left({\left(0.5 \cdot \left(\frac{1}{d} \cdot \left(D \cdot M\right)\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\ \end{array} \]

Alternative 2: 69.6% accurate, 0.3× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right)\right)\\ \mathbf{if}\;t_0 \leq 10^{+297}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq \infty:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.125, \frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \left(D \cdot \frac{D}{\frac{d}{M \cdot M}}\right), d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0
         (*
          (* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
          (- 1.0 (* (/ h l) (* 0.5 (pow (/ (* D M) (* d 2.0)) 2.0)))))))
   (if (<= t_0 1e+297)
     t_0
     (if (<= t_0 INFINITY)
       (* d (sqrt (/ 1.0 (* h l))))
       (fma
        -0.125
        (* (/ (sqrt h) (pow l 1.5)) (* D (/ D (/ d (* M M)))))
        (* d (sqrt (/ (/ 1.0 l) h))))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = (pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * pow(((D * M) / (d * 2.0)), 2.0))));
	double tmp;
	if (t_0 <= 1e+297) {
		tmp = t_0;
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = d * sqrt((1.0 / (h * l)));
	} else {
		tmp = fma(-0.125, ((sqrt(h) / pow(l, 1.5)) * (D * (D / (d / (M * M))))), (d * sqrt(((1.0 / l) / h))));
	}
	return tmp;
}
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.5 * (Float64(Float64(D * M) / Float64(d * 2.0)) ^ 2.0)))))
	tmp = 0.0
	if (t_0 <= 1e+297)
		tmp = t_0;
	elseif (t_0 <= Inf)
		tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * l))));
	else
		tmp = fma(-0.125, Float64(Float64(sqrt(h) / (l ^ 1.5)) * Float64(D * Float64(D / Float64(d / Float64(M * M))))), Float64(d * sqrt(Float64(Float64(1.0 / l) / h))));
	end
	return tmp
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.5 * N[Power[N[(N[(D * M), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+297], t$95$0, If[LessEqual[t$95$0, Infinity], N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-0.125 * N[(N[(N[Sqrt[h], $MachinePrecision] / N[Power[l, 1.5], $MachinePrecision]), $MachinePrecision] * N[(D * N[(D / N[(d / N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right)\right)\\
\mathbf{if}\;t_0 \leq 10^{+297}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, \frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \left(D \cdot \frac{D}{\frac{d}{M \cdot M}}\right), d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 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)))) < 1e297

    1. Initial program 90.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) \]

    if 1e297 < (*.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 34.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. Simplified34.6%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]

    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 0.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. Simplified0.0%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. add-cube-cbrt0.0%

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\sqrt[3]{\sqrt{\frac{d}{\ell}}}\right)}^{3}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Taylor expanded in d around 0 18.9%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) + d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    6. Step-by-step derivation
      1. fma-def18.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}, d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. *-commutative18.9%

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\frac{{D}^{2}}{\frac{d}{M \cdot M}}}, d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      5. *-rgt-identity18.8%

        \[\leadsto \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{\color{blue}{{D}^{2} \cdot 1}}{\frac{d}{M \cdot M}}, d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      6. associate-*r/18.8%

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

        \[\leadsto \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\color{blue}{\left(D \cdot D\right)} \cdot \frac{1}{\frac{d}{M \cdot M}}\right), d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      8. associate-*l*18.9%

        \[\leadsto \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left(D \cdot \left(D \cdot \frac{1}{\frac{d}{M \cdot M}}\right)\right)}, d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      9. associate-*r/18.9%

        \[\leadsto \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(D \cdot \color{blue}{\frac{D \cdot 1}{\frac{d}{M \cdot M}}}\right), d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      10. *-rgt-identity18.9%

        \[\leadsto \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(D \cdot \frac{\color{blue}{D}}{\frac{d}{M \cdot M}}\right), d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      11. *-commutative18.9%

        \[\leadsto \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(D \cdot \frac{D}{\frac{d}{M \cdot M}}\right), d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}}\right) \]
      12. associate-/r*18.9%

        \[\leadsto \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(D \cdot \frac{D}{\frac{d}{M \cdot M}}\right), d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}}\right) \]
    7. Simplified18.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(D \cdot \frac{D}{\frac{d}{M \cdot M}}\right), d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)} \]
    8. Step-by-step derivation
      1. sqrt-div21.2%

        \[\leadsto \mathsf{fma}\left(-0.125, \color{blue}{\frac{\sqrt{h}}{\sqrt{{\ell}^{3}}}} \cdot \left(D \cdot \frac{D}{\frac{d}{M \cdot M}}\right), d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right) \]
    9. Applied egg-rr21.2%

      \[\leadsto \mathsf{fma}\left(-0.125, \color{blue}{\frac{\sqrt{h}}{\sqrt{{\ell}^{3}}}} \cdot \left(D \cdot \frac{D}{\frac{d}{M \cdot M}}\right), d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right) \]
    10. Step-by-step derivation
      1. sqr-pow21.2%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\sqrt{h}}{\sqrt{\color{blue}{{\ell}^{\left(\frac{3}{2}\right)} \cdot {\ell}^{\left(\frac{3}{2}\right)}}}} \cdot \left(D \cdot \frac{D}{\frac{d}{M \cdot M}}\right), d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right) \]
      2. rem-sqrt-square25.8%

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\sqrt{h}}{\left|\color{blue}{{\ell}^{\left(\frac{\frac{3}{2}}{2}\right)} \cdot {\ell}^{\left(\frac{\frac{3}{2}}{2}\right)}}\right|} \cdot \left(D \cdot \frac{D}{\frac{d}{M \cdot M}}\right), d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right) \]
      4. fabs-sqr25.8%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\sqrt{h}}{\color{blue}{{\ell}^{\left(\frac{\frac{3}{2}}{2}\right)} \cdot {\ell}^{\left(\frac{\frac{3}{2}}{2}\right)}}} \cdot \left(D \cdot \frac{D}{\frac{d}{M \cdot M}}\right), d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right) \]
      5. sqr-pow25.8%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\sqrt{h}}{\color{blue}{{\ell}^{\left(\frac{3}{2}\right)}}} \cdot \left(D \cdot \frac{D}{\frac{d}{M \cdot M}}\right), d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right) \]
      6. metadata-eval25.8%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\sqrt{h}}{{\ell}^{\color{blue}{1.5}}} \cdot \left(D \cdot \frac{D}{\frac{d}{M \cdot M}}\right), d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right) \]
    11. Simplified25.8%

      \[\leadsto \mathsf{fma}\left(-0.125, \color{blue}{\frac{\sqrt{h}}{{\ell}^{1.5}}} \cdot \left(D \cdot \frac{D}{\frac{d}{M \cdot M}}\right), d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification71.3%

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

Alternative 3: 73.3% accurate, 0.8× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{\ell}}\\ t_1 := \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{if}\;d \leq -4.6 \cdot 10^{+138}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -1.7 \cdot 10^{-128}:\\ \;\;\;\;t_0 \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(\frac{1}{d} \cdot \left(D \cdot M\right)\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\\ \mathbf{elif}\;d \leq -7.5 \cdot 10^{-297}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\left(t_0 \cdot \left(\sqrt{d} \cdot \sqrt{\frac{1}{h}}\right)\right) \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (/ d l)))
        (t_1
         (*
          (* d (pow (* h l) -0.5))
          (- -1.0 (* -0.5 (* (/ h l) (pow (* (/ D d) (* M 0.5)) 2.0)))))))
   (if (<= d -4.6e+138)
     t_1
     (if (<= d -1.7e-128)
       (*
        t_0
        (*
         (sqrt (/ d h))
         (fma (pow (* 0.5 (* (/ 1.0 d) (* D M))) 2.0) (* -0.5 (/ h l)) 1.0)))
       (if (<= d -7.5e-297)
         t_1
         (*
          (* t_0 (* (sqrt d) (sqrt (/ 1.0 h))))
          (- 1.0 (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M 2.0)) 2.0))))))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / l));
	double t_1 = (d * pow((h * l), -0.5)) * (-1.0 - (-0.5 * ((h / l) * pow(((D / d) * (M * 0.5)), 2.0))));
	double tmp;
	if (d <= -4.6e+138) {
		tmp = t_1;
	} else if (d <= -1.7e-128) {
		tmp = t_0 * (sqrt((d / h)) * fma(pow((0.5 * ((1.0 / d) * (D * M))), 2.0), (-0.5 * (h / l)), 1.0));
	} else if (d <= -7.5e-297) {
		tmp = t_1;
	} else {
		tmp = (t_0 * (sqrt(d) * sqrt((1.0 / h)))) * (1.0 - (0.5 * ((h / l) * pow(((D / d) * (M / 2.0)), 2.0))));
	}
	return tmp;
}
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(d / l))
	t_1 = Float64(Float64(d * (Float64(h * l) ^ -0.5)) * Float64(-1.0 - Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M * 0.5)) ^ 2.0)))))
	tmp = 0.0
	if (d <= -4.6e+138)
		tmp = t_1;
	elseif (d <= -1.7e-128)
		tmp = Float64(t_0 * Float64(sqrt(Float64(d / h)) * fma((Float64(0.5 * Float64(Float64(1.0 / d) * Float64(D * M))) ^ 2.0), Float64(-0.5 * Float64(h / l)), 1.0)));
	elseif (d <= -7.5e-297)
		tmp = t_1;
	else
		tmp = Float64(Float64(t_0 * Float64(sqrt(d) * sqrt(Float64(1.0 / h)))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0)))));
	end
	return tmp
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(-1.0 - N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.6e+138], t$95$1, If[LessEqual[d, -1.7e-128], N[(t$95$0 * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Power[N[(0.5 * N[(N[(1.0 / d), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -7.5e-297], t$95$1, N[(N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\
\mathbf{if}\;d \leq -4.6 \cdot 10^{+138}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;d \leq -1.7 \cdot 10^{-128}:\\
\;\;\;\;t_0 \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(\frac{1}{d} \cdot \left(D \cdot M\right)\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\\

\mathbf{elif}\;d \leq -7.5 \cdot 10^{-297}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -4.60000000000000015e138 or -1.69999999999999987e-128 < d < -7.4999999999999994e-297

    1. Initial program 55.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. Simplified52.8%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def25.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p45.8%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/38.8%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot \frac{d}{\ell}}{h}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      4. *-commutative38.8%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in d around -inf 70.5%

      \[\leadsto \color{blue}{\left(-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    7. Step-by-step derivation
      1. mul-1-neg70.5%

        \[\leadsto \color{blue}{\left(-d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      2. distribute-rgt-neg-in70.5%

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

        \[\leadsto \left(d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      4. sqr-pow70.6%

        \[\leadsto \left(d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      5. rem-sqrt-square70.6%

        \[\leadsto \left(d \cdot \left(-\color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      6. metadata-eval70.6%

        \[\leadsto \left(d \cdot \left(-\left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right|\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      7. sqr-pow70.5%

        \[\leadsto \left(d \cdot \left(-\left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right|\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      8. fabs-sqr70.5%

        \[\leadsto \left(d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      9. sqr-pow70.6%

        \[\leadsto \left(d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{-0.5}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    8. Simplified70.6%

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

    if -4.60000000000000015e138 < d < -1.69999999999999987e-128

    1. Initial program 75.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. Simplified75.2%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Step-by-step derivation
      1. clear-num75.2%

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

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

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \color{blue}{{\left(\frac{\frac{d}{D}}{M}\right)}^{-1}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right) \]
    5. Step-by-step derivation
      1. unpow-175.2%

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

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

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

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

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

    if -7.4999999999999994e-297 < d

    1. Initial program 64.1%

      \[\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. Simplified62.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. pow1/262.9%

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

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

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

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

      \[\leadsto \left(\color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{h}\right)}^{0.5}\right)} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Step-by-step derivation
      1. unpow1/274.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.6 \cdot 10^{+138}:\\ \;\;\;\;\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{elif}\;d \leq -1.7 \cdot 10^{-128}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(\frac{1}{d} \cdot \left(D \cdot M\right)\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\\ \mathbf{elif}\;d \leq -7.5 \cdot 10^{-297}:\\ \;\;\;\;\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{d} \cdot \sqrt{\frac{1}{h}}\right)\right) \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\\ \end{array} \]

Alternative 4: 74.6% accurate, 0.8× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{\ell}}\\ t_1 := {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\\ t_2 := \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot t_1\right)\right)\\ \mathbf{if}\;d \leq -3.5 \cdot 10^{+138}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;d \leq -1.9 \cdot 10^{-129}:\\ \;\;\;\;t_0 \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(\frac{1}{d} \cdot \left(D \cdot M\right)\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\\ \mathbf{elif}\;d \leq -7.5 \cdot 10^{-297}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\left(t_0 \cdot \left(\sqrt{d} \cdot \sqrt{\frac{1}{h}}\right)\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot t_1}{\ell}\right)\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (/ d l)))
        (t_1 (pow (* (/ D d) (* M 0.5)) 2.0))
        (t_2 (* (* d (pow (* h l) -0.5)) (- -1.0 (* -0.5 (* (/ h l) t_1))))))
   (if (<= d -3.5e+138)
     t_2
     (if (<= d -1.9e-129)
       (*
        t_0
        (*
         (sqrt (/ d h))
         (fma (pow (* 0.5 (* (/ 1.0 d) (* D M))) 2.0) (* -0.5 (/ h l)) 1.0)))
       (if (<= d -7.5e-297)
         t_2
         (*
          (* t_0 (* (sqrt d) (sqrt (/ 1.0 h))))
          (- 1.0 (* 0.5 (/ (* h t_1) l)))))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / l));
	double t_1 = pow(((D / d) * (M * 0.5)), 2.0);
	double t_2 = (d * pow((h * l), -0.5)) * (-1.0 - (-0.5 * ((h / l) * t_1)));
	double tmp;
	if (d <= -3.5e+138) {
		tmp = t_2;
	} else if (d <= -1.9e-129) {
		tmp = t_0 * (sqrt((d / h)) * fma(pow((0.5 * ((1.0 / d) * (D * M))), 2.0), (-0.5 * (h / l)), 1.0));
	} else if (d <= -7.5e-297) {
		tmp = t_2;
	} else {
		tmp = (t_0 * (sqrt(d) * sqrt((1.0 / h)))) * (1.0 - (0.5 * ((h * t_1) / l)));
	}
	return tmp;
}
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(d / l))
	t_1 = Float64(Float64(D / d) * Float64(M * 0.5)) ^ 2.0
	t_2 = Float64(Float64(d * (Float64(h * l) ^ -0.5)) * Float64(-1.0 - Float64(-0.5 * Float64(Float64(h / l) * t_1))))
	tmp = 0.0
	if (d <= -3.5e+138)
		tmp = t_2;
	elseif (d <= -1.9e-129)
		tmp = Float64(t_0 * Float64(sqrt(Float64(d / h)) * fma((Float64(0.5 * Float64(Float64(1.0 / d) * Float64(D * M))) ^ 2.0), Float64(-0.5 * Float64(h / l)), 1.0)));
	elseif (d <= -7.5e-297)
		tmp = t_2;
	else
		tmp = Float64(Float64(t_0 * Float64(sqrt(d) * sqrt(Float64(1.0 / h)))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * t_1) / l))));
	end
	return tmp
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(-1.0 - N[(-0.5 * N[(N[(h / l), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.5e+138], t$95$2, If[LessEqual[d, -1.9e-129], N[(t$95$0 * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Power[N[(0.5 * N[(N[(1.0 / d), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -7.5e-297], t$95$2, N[(N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * t$95$1), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\\
t_2 := \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot t_1\right)\right)\\
\mathbf{if}\;d \leq -3.5 \cdot 10^{+138}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;d \leq -1.9 \cdot 10^{-129}:\\
\;\;\;\;t_0 \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(\frac{1}{d} \cdot \left(D \cdot M\right)\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\\

\mathbf{elif}\;d \leq -7.5 \cdot 10^{-297}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -3.4999999999999998e138 or -1.89999999999999992e-129 < d < -7.4999999999999994e-297

    1. Initial program 55.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. Simplified52.8%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def25.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p45.8%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/38.8%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot \frac{d}{\ell}}{h}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      4. *-commutative38.8%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in d around -inf 70.5%

      \[\leadsto \color{blue}{\left(-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    7. Step-by-step derivation
      1. mul-1-neg70.5%

        \[\leadsto \color{blue}{\left(-d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      2. distribute-rgt-neg-in70.5%

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

        \[\leadsto \left(d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      4. sqr-pow70.6%

        \[\leadsto \left(d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      5. rem-sqrt-square70.6%

        \[\leadsto \left(d \cdot \left(-\color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      6. metadata-eval70.6%

        \[\leadsto \left(d \cdot \left(-\left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right|\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      7. sqr-pow70.5%

        \[\leadsto \left(d \cdot \left(-\left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right|\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      8. fabs-sqr70.5%

        \[\leadsto \left(d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      9. sqr-pow70.6%

        \[\leadsto \left(d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{-0.5}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    8. Simplified70.6%

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

    if -3.4999999999999998e138 < d < -1.89999999999999992e-129

    1. Initial program 75.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. Simplified75.2%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Step-by-step derivation
      1. clear-num75.2%

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

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

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \color{blue}{{\left(\frac{\frac{d}{D}}{M}\right)}^{-1}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right) \]
    5. Step-by-step derivation
      1. unpow-175.2%

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

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

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

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

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

    if -7.4999999999999994e-297 < d

    1. Initial program 64.1%

      \[\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. Simplified62.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. pow1/262.9%

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

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

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

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

      \[\leadsto \left(\color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{h}\right)}^{0.5}\right)} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Step-by-step derivation
      1. unpow1/274.8%

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

      \[\leadsto \left(\color{blue}{\left(\sqrt{d} \cdot \sqrt{\frac{1}{h}}\right)} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. Step-by-step derivation
      1. associate-*r/63.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.5 \cdot 10^{+138}:\\ \;\;\;\;\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{elif}\;d \leq -1.9 \cdot 10^{-129}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(\frac{1}{d} \cdot \left(D \cdot M\right)\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\\ \mathbf{elif}\;d \leq -7.5 \cdot 10^{-297}:\\ \;\;\;\;\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{d} \cdot \sqrt{\frac{1}{h}}\right)\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}}{\ell}\right)\\ \end{array} \]

Alternative 5: 73.3% accurate, 0.8× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{\ell}}\\ t_1 := \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{if}\;d \leq -1.95 \cdot 10^{+138}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -1.9 \cdot 10^{-129}:\\ \;\;\;\;t_0 \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(\frac{1}{d} \cdot \left(D \cdot M\right)\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\\ \mathbf{elif}\;d \leq -7.5 \cdot 10^{-297}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right) \cdot \left(t_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (/ d l)))
        (t_1
         (*
          (* d (pow (* h l) -0.5))
          (- -1.0 (* -0.5 (* (/ h l) (pow (* (/ D d) (* M 0.5)) 2.0)))))))
   (if (<= d -1.95e+138)
     t_1
     (if (<= d -1.9e-129)
       (*
        t_0
        (*
         (sqrt (/ d h))
         (fma (pow (* 0.5 (* (/ 1.0 d) (* D M))) 2.0) (* -0.5 (/ h l)) 1.0)))
       (if (<= d -7.5e-297)
         t_1
         (*
          (- 1.0 (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M 2.0)) 2.0))))
          (* t_0 (/ (sqrt d) (sqrt h)))))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / l));
	double t_1 = (d * pow((h * l), -0.5)) * (-1.0 - (-0.5 * ((h / l) * pow(((D / d) * (M * 0.5)), 2.0))));
	double tmp;
	if (d <= -1.95e+138) {
		tmp = t_1;
	} else if (d <= -1.9e-129) {
		tmp = t_0 * (sqrt((d / h)) * fma(pow((0.5 * ((1.0 / d) * (D * M))), 2.0), (-0.5 * (h / l)), 1.0));
	} else if (d <= -7.5e-297) {
		tmp = t_1;
	} else {
		tmp = (1.0 - (0.5 * ((h / l) * pow(((D / d) * (M / 2.0)), 2.0)))) * (t_0 * (sqrt(d) / sqrt(h)));
	}
	return tmp;
}
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(d / l))
	t_1 = Float64(Float64(d * (Float64(h * l) ^ -0.5)) * Float64(-1.0 - Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M * 0.5)) ^ 2.0)))))
	tmp = 0.0
	if (d <= -1.95e+138)
		tmp = t_1;
	elseif (d <= -1.9e-129)
		tmp = Float64(t_0 * Float64(sqrt(Float64(d / h)) * fma((Float64(0.5 * Float64(Float64(1.0 / d) * Float64(D * M))) ^ 2.0), Float64(-0.5 * Float64(h / l)), 1.0)));
	elseif (d <= -7.5e-297)
		tmp = t_1;
	else
		tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0)))) * Float64(t_0 * Float64(sqrt(d) / sqrt(h))));
	end
	return tmp
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(-1.0 - N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.95e+138], t$95$1, If[LessEqual[d, -1.9e-129], N[(t$95$0 * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Power[N[(0.5 * N[(N[(1.0 / d), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -7.5e-297], t$95$1, N[(N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\
\mathbf{if}\;d \leq -1.95 \cdot 10^{+138}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;d \leq -1.9 \cdot 10^{-129}:\\
\;\;\;\;t_0 \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(\frac{1}{d} \cdot \left(D \cdot M\right)\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\\

\mathbf{elif}\;d \leq -7.5 \cdot 10^{-297}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.9499999999999999e138 or -1.89999999999999992e-129 < d < -7.4999999999999994e-297

    1. Initial program 55.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. Simplified52.8%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def25.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p45.8%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/38.8%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot \frac{d}{\ell}}{h}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      4. *-commutative38.8%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in d around -inf 70.5%

      \[\leadsto \color{blue}{\left(-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    7. Step-by-step derivation
      1. mul-1-neg70.5%

        \[\leadsto \color{blue}{\left(-d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      2. distribute-rgt-neg-in70.5%

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

        \[\leadsto \left(d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      4. sqr-pow70.6%

        \[\leadsto \left(d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      5. rem-sqrt-square70.6%

        \[\leadsto \left(d \cdot \left(-\color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      6. metadata-eval70.6%

        \[\leadsto \left(d \cdot \left(-\left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right|\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      7. sqr-pow70.5%

        \[\leadsto \left(d \cdot \left(-\left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right|\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      8. fabs-sqr70.5%

        \[\leadsto \left(d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      9. sqr-pow70.6%

        \[\leadsto \left(d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{-0.5}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    8. Simplified70.6%

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

    if -1.9499999999999999e138 < d < -1.89999999999999992e-129

    1. Initial program 75.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. Simplified75.2%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Step-by-step derivation
      1. clear-num75.2%

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

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

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \color{blue}{{\left(\frac{\frac{d}{D}}{M}\right)}^{-1}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right) \]
    5. Step-by-step derivation
      1. unpow-175.2%

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

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

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

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

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

    if -7.4999999999999994e-297 < d

    1. Initial program 64.1%

      \[\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. Simplified62.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. sqrt-div77.3%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(\frac{1}{d} \cdot \left(D \cdot M\right)\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right) \]
    4. Applied egg-rr74.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.95 \cdot 10^{+138}:\\ \;\;\;\;\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{elif}\;d \leq -1.9 \cdot 10^{-129}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(\frac{1}{d} \cdot \left(D \cdot M\right)\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\\ \mathbf{elif}\;d \leq -7.5 \cdot 10^{-297}:\\ \;\;\;\;\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\ \end{array} \]

Alternative 6: 67.8% accurate, 1.0× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\\ t_1 := -0.5 \cdot \left(\frac{h}{\ell} \cdot t_0\right)\\ t_2 := \sqrt{\frac{d}{\ell}}\\ t_3 := d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{if}\;h \leq -1.45 \cdot 10^{-202}:\\ \;\;\;\;t_3 \cdot \left(-1 - t_1\right)\\ \mathbf{elif}\;h \leq 5.8 \cdot 10^{-212}:\\ \;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot t_0}{\ell}\right) \cdot \left(t_2 \cdot \sqrt{\frac{d}{h}}\right)\\ \mathbf{elif}\;h \leq 5.5 \cdot 10^{+201}:\\ \;\;\;\;\left(1 + t_1\right) \cdot t_3\\ \mathbf{else}:\\ \;\;\;\;t_2 \cdot \left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(-0.125 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{M \cdot M}{\frac{\ell}{h}}\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (pow (* (/ D d) (* M 0.5)) 2.0))
        (t_1 (* -0.5 (* (/ h l) t_0)))
        (t_2 (sqrt (/ d l)))
        (t_3 (* d (pow (* h l) -0.5))))
   (if (<= h -1.45e-202)
     (* t_3 (- -1.0 t_1))
     (if (<= h 5.8e-212)
       (* (- 1.0 (* 0.5 (/ (* h t_0) l))) (* t_2 (sqrt (/ d h))))
       (if (<= h 5.5e+201)
         (* (+ 1.0 t_1) t_3)
         (*
          t_2
          (*
           (/ (sqrt d) (sqrt h))
           (* -0.125 (* (* (/ D d) (/ D d)) (/ (* M M) (/ l h)))))))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = pow(((D / d) * (M * 0.5)), 2.0);
	double t_1 = -0.5 * ((h / l) * t_0);
	double t_2 = sqrt((d / l));
	double t_3 = d * pow((h * l), -0.5);
	double tmp;
	if (h <= -1.45e-202) {
		tmp = t_3 * (-1.0 - t_1);
	} else if (h <= 5.8e-212) {
		tmp = (1.0 - (0.5 * ((h * t_0) / l))) * (t_2 * sqrt((d / h)));
	} else if (h <= 5.5e+201) {
		tmp = (1.0 + t_1) * t_3;
	} else {
		tmp = t_2 * ((sqrt(d) / sqrt(h)) * (-0.125 * (((D / d) * (D / d)) * ((M * M) / (l / h)))));
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = ((d_1 / d) * (m * 0.5d0)) ** 2.0d0
    t_1 = (-0.5d0) * ((h / l) * t_0)
    t_2 = sqrt((d / l))
    t_3 = d * ((h * l) ** (-0.5d0))
    if (h <= (-1.45d-202)) then
        tmp = t_3 * ((-1.0d0) - t_1)
    else if (h <= 5.8d-212) then
        tmp = (1.0d0 - (0.5d0 * ((h * t_0) / l))) * (t_2 * sqrt((d / h)))
    else if (h <= 5.5d+201) then
        tmp = (1.0d0 + t_1) * t_3
    else
        tmp = t_2 * ((sqrt(d) / sqrt(h)) * ((-0.125d0) * (((d_1 / d) * (d_1 / d)) * ((m * m) / (l / h)))))
    end if
    code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.pow(((D / d) * (M * 0.5)), 2.0);
	double t_1 = -0.5 * ((h / l) * t_0);
	double t_2 = Math.sqrt((d / l));
	double t_3 = d * Math.pow((h * l), -0.5);
	double tmp;
	if (h <= -1.45e-202) {
		tmp = t_3 * (-1.0 - t_1);
	} else if (h <= 5.8e-212) {
		tmp = (1.0 - (0.5 * ((h * t_0) / l))) * (t_2 * Math.sqrt((d / h)));
	} else if (h <= 5.5e+201) {
		tmp = (1.0 + t_1) * t_3;
	} else {
		tmp = t_2 * ((Math.sqrt(d) / Math.sqrt(h)) * (-0.125 * (((D / d) * (D / d)) * ((M * M) / (l / h)))));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.pow(((D / d) * (M * 0.5)), 2.0)
	t_1 = -0.5 * ((h / l) * t_0)
	t_2 = math.sqrt((d / l))
	t_3 = d * math.pow((h * l), -0.5)
	tmp = 0
	if h <= -1.45e-202:
		tmp = t_3 * (-1.0 - t_1)
	elif h <= 5.8e-212:
		tmp = (1.0 - (0.5 * ((h * t_0) / l))) * (t_2 * math.sqrt((d / h)))
	elif h <= 5.5e+201:
		tmp = (1.0 + t_1) * t_3
	else:
		tmp = t_2 * ((math.sqrt(d) / math.sqrt(h)) * (-0.125 * (((D / d) * (D / d)) * ((M * M) / (l / h)))))
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(Float64(D / d) * Float64(M * 0.5)) ^ 2.0
	t_1 = Float64(-0.5 * Float64(Float64(h / l) * t_0))
	t_2 = sqrt(Float64(d / l))
	t_3 = Float64(d * (Float64(h * l) ^ -0.5))
	tmp = 0.0
	if (h <= -1.45e-202)
		tmp = Float64(t_3 * Float64(-1.0 - t_1));
	elseif (h <= 5.8e-212)
		tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h * t_0) / l))) * Float64(t_2 * sqrt(Float64(d / h))));
	elseif (h <= 5.5e+201)
		tmp = Float64(Float64(1.0 + t_1) * t_3);
	else
		tmp = Float64(t_2 * Float64(Float64(sqrt(d) / sqrt(h)) * Float64(-0.125 * Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(Float64(M * M) / Float64(l / h))))));
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = ((D / d) * (M * 0.5)) ^ 2.0;
	t_1 = -0.5 * ((h / l) * t_0);
	t_2 = sqrt((d / l));
	t_3 = d * ((h * l) ^ -0.5);
	tmp = 0.0;
	if (h <= -1.45e-202)
		tmp = t_3 * (-1.0 - t_1);
	elseif (h <= 5.8e-212)
		tmp = (1.0 - (0.5 * ((h * t_0) / l))) * (t_2 * sqrt((d / h)));
	elseif (h <= 5.5e+201)
		tmp = (1.0 + t_1) * t_3;
	else
		tmp = t_2 * ((sqrt(d) / sqrt(h)) * (-0.125 * (((D / d) * (D / d)) * ((M * M) / (l / h)))));
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Power[N[(N[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(-0.5 * N[(N[(h / l), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -1.45e-202], N[(t$95$3 * N[(-1.0 - t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 5.8e-212], N[(N[(1.0 - N[(0.5 * N[(N[(h * t$95$0), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$2 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 5.5e+201], N[(N[(1.0 + t$95$1), $MachinePrecision] * t$95$3), $MachinePrecision], N[(t$95$2 * N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(-0.125 * N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / N[(l / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\\
t_1 := -0.5 \cdot \left(\frac{h}{\ell} \cdot t_0\right)\\
t_2 := \sqrt{\frac{d}{\ell}}\\
t_3 := d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\
\mathbf{if}\;h \leq -1.45 \cdot 10^{-202}:\\
\;\;\;\;t_3 \cdot \left(-1 - t_1\right)\\

\mathbf{elif}\;h \leq 5.8 \cdot 10^{-212}:\\
\;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot t_0}{\ell}\right) \cdot \left(t_2 \cdot \sqrt{\frac{d}{h}}\right)\\

\mathbf{elif}\;h \leq 5.5 \cdot 10^{+201}:\\
\;\;\;\;\left(1 + t_1\right) \cdot t_3\\

\mathbf{else}:\\
\;\;\;\;t_2 \cdot \left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(-0.125 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{M \cdot M}{\frac{\ell}{h}}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if h < -1.44999999999999994e-202

    1. Initial program 64.5%

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def30.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p52.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/46.9%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot \frac{d}{\ell}}{h}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      4. *-commutative46.9%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in d around -inf 69.6%

      \[\leadsto \color{blue}{\left(-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    7. Step-by-step derivation
      1. mul-1-neg69.6%

        \[\leadsto \color{blue}{\left(-d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      2. distribute-rgt-neg-in69.6%

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

        \[\leadsto \left(d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      4. sqr-pow69.7%

        \[\leadsto \left(d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      5. rem-sqrt-square69.7%

        \[\leadsto \left(d \cdot \left(-\color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      6. metadata-eval69.7%

        \[\leadsto \left(d \cdot \left(-\left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right|\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      7. sqr-pow69.5%

        \[\leadsto \left(d \cdot \left(-\left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right|\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      8. fabs-sqr69.5%

        \[\leadsto \left(d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      9. sqr-pow69.7%

        \[\leadsto \left(d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{-0.5}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    8. Simplified69.7%

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

    if -1.44999999999999994e-202 < h < 5.7999999999999999e-212

    1. Initial program 67.1%

      \[\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.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. associate-*r/69.3%

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

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

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

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

    if 5.7999999999999999e-212 < h < 5.49999999999999946e201

    1. Initial program 71.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. Simplified71.1%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def28.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p52.7%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/47.1%

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in d around 0 83.5%

      \[\leadsto \color{blue}{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    7. Step-by-step derivation
      1. unpow-183.5%

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

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

        \[\leadsto \left(d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|}\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      4. metadata-eval83.5%

        \[\leadsto \left(d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right|\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      5. sqr-pow83.3%

        \[\leadsto \left(d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right|\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      6. fabs-sqr83.3%

        \[\leadsto \left(d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)}\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      7. sqr-pow83.5%

        \[\leadsto \left(d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}}\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    8. Simplified83.5%

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

    if 5.49999999999999946e201 < h

    1. Initial program 31.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. Simplified26.6%

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

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    4. Step-by-step derivation
      1. times-frac17.8%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(-0.125 \cdot \color{blue}{\left(\frac{{D}^{2}}{{d}^{2}} \cdot \frac{{M}^{2} \cdot h}{\ell}\right)}\right)\right) \]
      2. unpow217.8%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(-0.125 \cdot \left(\frac{\color{blue}{D \cdot D}}{{d}^{2}} \cdot \frac{{M}^{2} \cdot h}{\ell}\right)\right)\right) \]
      3. unpow217.8%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(-0.125 \cdot \left(\frac{D \cdot D}{\color{blue}{d \cdot d}} \cdot \frac{{M}^{2} \cdot h}{\ell}\right)\right)\right) \]
      4. times-frac18.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(-0.125 \cdot \left(\color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)} \cdot \frac{{M}^{2} \cdot h}{\ell}\right)\right)\right) \]
      5. associate-/l*17.7%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(-0.125 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \color{blue}{\frac{{M}^{2}}{\frac{\ell}{h}}}\right)\right)\right) \]
      6. unpow217.7%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(-0.125 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{\color{blue}{M \cdot M}}{\frac{\ell}{h}}\right)\right)\right) \]
    5. Simplified17.7%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(-0.125 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{M \cdot M}{\frac{\ell}{h}}\right)\right)}\right) \]
    6. Step-by-step derivation
      1. sqrt-div66.1%

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

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \left(-0.125 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{M \cdot M}{\frac{\ell}{h}}\right)\right)\right) \]
  3. Recombined 4 regimes into one program.
  4. Final simplification72.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -1.45 \cdot 10^{-202}:\\ \;\;\;\;\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{elif}\;h \leq 5.8 \cdot 10^{-212}:\\ \;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}}{\ell}\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)\\ \mathbf{elif}\;h \leq 5.5 \cdot 10^{+201}:\\ \;\;\;\;\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(-0.125 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{M \cdot M}{\frac{\ell}{h}}\right)\right)\right)\\ \end{array} \]

Alternative 7: 68.0% accurate, 1.0× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\\ t_1 := d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{if}\;h \leq -4.8 \cdot 10^{-235}:\\ \;\;\;\;t_1 \cdot \left(-1 - t_0\right)\\ \mathbf{elif}\;h \leq 5.4 \cdot 10^{-207}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + t_0\right) \cdot t_1\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (* -0.5 (* (/ h l) (pow (* (/ D d) (* M 0.5)) 2.0))))
        (t_1 (* d (pow (* h l) -0.5))))
   (if (<= h -4.8e-235)
     (* t_1 (- -1.0 t_0))
     (if (<= h 5.4e-207)
       (*
        (- 1.0 (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M 2.0)) 2.0))))
        (* (sqrt (/ d l)) (sqrt (/ d h))))
       (* (+ 1.0 t_0) t_1)))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = -0.5 * ((h / l) * pow(((D / d) * (M * 0.5)), 2.0));
	double t_1 = d * pow((h * l), -0.5);
	double tmp;
	if (h <= -4.8e-235) {
		tmp = t_1 * (-1.0 - t_0);
	} else if (h <= 5.4e-207) {
		tmp = (1.0 - (0.5 * ((h / l) * pow(((D / d) * (M / 2.0)), 2.0)))) * (sqrt((d / l)) * sqrt((d / h)));
	} else {
		tmp = (1.0 + t_0) * t_1;
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (-0.5d0) * ((h / l) * (((d_1 / d) * (m * 0.5d0)) ** 2.0d0))
    t_1 = d * ((h * l) ** (-0.5d0))
    if (h <= (-4.8d-235)) then
        tmp = t_1 * ((-1.0d0) - t_0)
    else if (h <= 5.4d-207) then
        tmp = (1.0d0 - (0.5d0 * ((h / l) * (((d_1 / d) * (m / 2.0d0)) ** 2.0d0)))) * (sqrt((d / l)) * sqrt((d / h)))
    else
        tmp = (1.0d0 + t_0) * t_1
    end if
    code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = -0.5 * ((h / l) * Math.pow(((D / d) * (M * 0.5)), 2.0));
	double t_1 = d * Math.pow((h * l), -0.5);
	double tmp;
	if (h <= -4.8e-235) {
		tmp = t_1 * (-1.0 - t_0);
	} else if (h <= 5.4e-207) {
		tmp = (1.0 - (0.5 * ((h / l) * Math.pow(((D / d) * (M / 2.0)), 2.0)))) * (Math.sqrt((d / l)) * Math.sqrt((d / h)));
	} else {
		tmp = (1.0 + t_0) * t_1;
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = -0.5 * ((h / l) * math.pow(((D / d) * (M * 0.5)), 2.0))
	t_1 = d * math.pow((h * l), -0.5)
	tmp = 0
	if h <= -4.8e-235:
		tmp = t_1 * (-1.0 - t_0)
	elif h <= 5.4e-207:
		tmp = (1.0 - (0.5 * ((h / l) * math.pow(((D / d) * (M / 2.0)), 2.0)))) * (math.sqrt((d / l)) * math.sqrt((d / h)))
	else:
		tmp = (1.0 + t_0) * t_1
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M * 0.5)) ^ 2.0)))
	t_1 = Float64(d * (Float64(h * l) ^ -0.5))
	tmp = 0.0
	if (h <= -4.8e-235)
		tmp = Float64(t_1 * Float64(-1.0 - t_0));
	elseif (h <= 5.4e-207)
		tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0)))) * Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))));
	else
		tmp = Float64(Float64(1.0 + t_0) * t_1);
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = -0.5 * ((h / l) * (((D / d) * (M * 0.5)) ^ 2.0));
	t_1 = d * ((h * l) ^ -0.5);
	tmp = 0.0;
	if (h <= -4.8e-235)
		tmp = t_1 * (-1.0 - t_0);
	elseif (h <= 5.4e-207)
		tmp = (1.0 - (0.5 * ((h / l) * (((D / d) * (M / 2.0)) ^ 2.0)))) * (sqrt((d / l)) * sqrt((d / h)));
	else
		tmp = (1.0 + t_0) * t_1;
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -4.8e-235], N[(t$95$1 * N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 5.4e-207], N[(N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\\
t_1 := d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\
\mathbf{if}\;h \leq -4.8 \cdot 10^{-235}:\\
\;\;\;\;t_1 \cdot \left(-1 - t_0\right)\\

\mathbf{elif}\;h \leq 5.4 \cdot 10^{-207}:\\
\;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(1 + t_0\right) \cdot t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -4.80000000000000022e-235

    1. Initial program 63.8%

      \[\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. Simplified62.9%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def30.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p52.4%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/47.6%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot \frac{d}{\ell}}{h}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      4. *-commutative47.6%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in d around -inf 68.6%

      \[\leadsto \color{blue}{\left(-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    7. Step-by-step derivation
      1. mul-1-neg68.6%

        \[\leadsto \color{blue}{\left(-d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      2. distribute-rgt-neg-in68.6%

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

        \[\leadsto \left(d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      4. sqr-pow68.6%

        \[\leadsto \left(d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      5. rem-sqrt-square68.6%

        \[\leadsto \left(d \cdot \left(-\color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      6. metadata-eval68.6%

        \[\leadsto \left(d \cdot \left(-\left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right|\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      7. sqr-pow68.5%

        \[\leadsto \left(d \cdot \left(-\left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right|\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      8. fabs-sqr68.5%

        \[\leadsto \left(d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      9. sqr-pow68.6%

        \[\leadsto \left(d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{-0.5}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    8. Simplified68.6%

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

    if -4.80000000000000022e-235 < h < 5.4e-207

    1. Initial program 70.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. Simplified67.3%

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

    if 5.4e-207 < h

    1. Initial program 63.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. Simplified61.5%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def22.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p44.3%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/39.1%

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in d around 0 72.3%

      \[\leadsto \color{blue}{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    7. Step-by-step derivation
      1. unpow-172.3%

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

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

        \[\leadsto \left(d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|}\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      4. metadata-eval72.3%

        \[\leadsto \left(d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right|\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      5. sqr-pow72.2%

        \[\leadsto \left(d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right|\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      6. fabs-sqr72.2%

        \[\leadsto \left(d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)}\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      7. sqr-pow72.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -4.8 \cdot 10^{-235}:\\ \;\;\;\;\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{elif}\;h \leq 5.4 \cdot 10^{-207}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)\\ \end{array} \]

Alternative 8: 68.2% accurate, 1.0× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\\ t_1 := -0.5 \cdot \left(\frac{h}{\ell} \cdot t_0\right)\\ t_2 := d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{if}\;h \leq -1.45 \cdot 10^{-202}:\\ \;\;\;\;t_2 \cdot \left(-1 - t_1\right)\\ \mathbf{elif}\;h \leq 9.6 \cdot 10^{-207}:\\ \;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot t_0}{\ell}\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + t_1\right) \cdot t_2\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (pow (* (/ D d) (* M 0.5)) 2.0))
        (t_1 (* -0.5 (* (/ h l) t_0)))
        (t_2 (* d (pow (* h l) -0.5))))
   (if (<= h -1.45e-202)
     (* t_2 (- -1.0 t_1))
     (if (<= h 9.6e-207)
       (* (- 1.0 (* 0.5 (/ (* h t_0) l))) (* (sqrt (/ d l)) (sqrt (/ d h))))
       (* (+ 1.0 t_1) t_2)))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = pow(((D / d) * (M * 0.5)), 2.0);
	double t_1 = -0.5 * ((h / l) * t_0);
	double t_2 = d * pow((h * l), -0.5);
	double tmp;
	if (h <= -1.45e-202) {
		tmp = t_2 * (-1.0 - t_1);
	} else if (h <= 9.6e-207) {
		tmp = (1.0 - (0.5 * ((h * t_0) / l))) * (sqrt((d / l)) * sqrt((d / h)));
	} else {
		tmp = (1.0 + t_1) * t_2;
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = ((d_1 / d) * (m * 0.5d0)) ** 2.0d0
    t_1 = (-0.5d0) * ((h / l) * t_0)
    t_2 = d * ((h * l) ** (-0.5d0))
    if (h <= (-1.45d-202)) then
        tmp = t_2 * ((-1.0d0) - t_1)
    else if (h <= 9.6d-207) then
        tmp = (1.0d0 - (0.5d0 * ((h * t_0) / l))) * (sqrt((d / l)) * sqrt((d / h)))
    else
        tmp = (1.0d0 + t_1) * t_2
    end if
    code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.pow(((D / d) * (M * 0.5)), 2.0);
	double t_1 = -0.5 * ((h / l) * t_0);
	double t_2 = d * Math.pow((h * l), -0.5);
	double tmp;
	if (h <= -1.45e-202) {
		tmp = t_2 * (-1.0 - t_1);
	} else if (h <= 9.6e-207) {
		tmp = (1.0 - (0.5 * ((h * t_0) / l))) * (Math.sqrt((d / l)) * Math.sqrt((d / h)));
	} else {
		tmp = (1.0 + t_1) * t_2;
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.pow(((D / d) * (M * 0.5)), 2.0)
	t_1 = -0.5 * ((h / l) * t_0)
	t_2 = d * math.pow((h * l), -0.5)
	tmp = 0
	if h <= -1.45e-202:
		tmp = t_2 * (-1.0 - t_1)
	elif h <= 9.6e-207:
		tmp = (1.0 - (0.5 * ((h * t_0) / l))) * (math.sqrt((d / l)) * math.sqrt((d / h)))
	else:
		tmp = (1.0 + t_1) * t_2
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(Float64(D / d) * Float64(M * 0.5)) ^ 2.0
	t_1 = Float64(-0.5 * Float64(Float64(h / l) * t_0))
	t_2 = Float64(d * (Float64(h * l) ^ -0.5))
	tmp = 0.0
	if (h <= -1.45e-202)
		tmp = Float64(t_2 * Float64(-1.0 - t_1));
	elseif (h <= 9.6e-207)
		tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h * t_0) / l))) * Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))));
	else
		tmp = Float64(Float64(1.0 + t_1) * t_2);
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = ((D / d) * (M * 0.5)) ^ 2.0;
	t_1 = -0.5 * ((h / l) * t_0);
	t_2 = d * ((h * l) ^ -0.5);
	tmp = 0.0;
	if (h <= -1.45e-202)
		tmp = t_2 * (-1.0 - t_1);
	elseif (h <= 9.6e-207)
		tmp = (1.0 - (0.5 * ((h * t_0) / l))) * (sqrt((d / l)) * sqrt((d / h)));
	else
		tmp = (1.0 + t_1) * t_2;
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Power[N[(N[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(-0.5 * N[(N[(h / l), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -1.45e-202], N[(t$95$2 * N[(-1.0 - t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 9.6e-207], N[(N[(1.0 - N[(0.5 * N[(N[(h * t$95$0), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\\
t_1 := -0.5 \cdot \left(\frac{h}{\ell} \cdot t_0\right)\\
t_2 := d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\
\mathbf{if}\;h \leq -1.45 \cdot 10^{-202}:\\
\;\;\;\;t_2 \cdot \left(-1 - t_1\right)\\

\mathbf{elif}\;h \leq 9.6 \cdot 10^{-207}:\\
\;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot t_0}{\ell}\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(1 + t_1\right) \cdot t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -1.44999999999999994e-202

    1. Initial program 64.5%

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def30.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p52.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/46.9%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot \frac{d}{\ell}}{h}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      4. *-commutative46.9%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in d around -inf 69.6%

      \[\leadsto \color{blue}{\left(-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    7. Step-by-step derivation
      1. mul-1-neg69.6%

        \[\leadsto \color{blue}{\left(-d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      2. distribute-rgt-neg-in69.6%

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

        \[\leadsto \left(d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      4. sqr-pow69.7%

        \[\leadsto \left(d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      5. rem-sqrt-square69.7%

        \[\leadsto \left(d \cdot \left(-\color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      6. metadata-eval69.7%

        \[\leadsto \left(d \cdot \left(-\left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right|\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      7. sqr-pow69.5%

        \[\leadsto \left(d \cdot \left(-\left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right|\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      8. fabs-sqr69.5%

        \[\leadsto \left(d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      9. sqr-pow69.7%

        \[\leadsto \left(d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{-0.5}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    8. Simplified69.7%

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

    if -1.44999999999999994e-202 < h < 9.59999999999999956e-207

    1. Initial program 67.1%

      \[\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.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. associate-*r/69.3%

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

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

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

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

    if 9.59999999999999956e-207 < h

    1. Initial program 63.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. Simplified61.5%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def22.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p44.3%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/39.1%

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in d around 0 72.3%

      \[\leadsto \color{blue}{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    7. Step-by-step derivation
      1. unpow-172.3%

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

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

        \[\leadsto \left(d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|}\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      4. metadata-eval72.3%

        \[\leadsto \left(d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right|\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      5. sqr-pow72.2%

        \[\leadsto \left(d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right|\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      6. fabs-sqr72.2%

        \[\leadsto \left(d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)}\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      7. sqr-pow72.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -1.45 \cdot 10^{-202}:\\ \;\;\;\;\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{elif}\;h \leq 9.6 \cdot 10^{-207}:\\ \;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}}{\ell}\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)\\ \end{array} \]

Alternative 9: 52.7% accurate, 1.5× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := -0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(D \cdot \left(M \cdot \left(\frac{D}{d} \cdot M\right)\right)\right)\right)\\ t_1 := \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{if}\;d \leq -2.2 \cdot 10^{+104}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -2.1 \cdot 10^{-140}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\ \mathbf{elif}\;d \leq 6.6 \cdot 10^{-238}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 1.95 \cdot 10^{-150}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;d \leq 5.5 \cdot 10^{-60}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.8 \cdot 10^{+126}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (* -0.125 (* (sqrt (/ h (pow l 3.0))) (* D (* M (* (/ D d) M))))))
        (t_1
         (*
          (sqrt (/ (* d (/ d l)) h))
          (+
           1.0
           (* -0.5 (* (/ 0.25 l) (/ (* D (* D (* M M))) (* d (/ d h)))))))))
   (if (<= d -2.2e+104)
     (* (sqrt (/ d l)) (sqrt (/ d h)))
     (if (<= d -2.1e-140)
       t_1
       (if (<= d -2e-310)
         (/ d (+ (+ 1.0 (sqrt (* h l))) -1.0))
         (if (<= d 6.6e-238)
           t_0
           (if (<= d 1.95e-150)
             (/ d (* (sqrt h) (sqrt l)))
             (if (<= d 5.5e-60)
               t_0
               (if (<= d 2.8e+126)
                 t_1
                 (* d (* (pow h -0.5) (pow l -0.5))))))))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = -0.125 * (sqrt((h / pow(l, 3.0))) * (D * (M * ((D / d) * M))));
	double t_1 = sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	double tmp;
	if (d <= -2.2e+104) {
		tmp = sqrt((d / l)) * sqrt((d / h));
	} else if (d <= -2.1e-140) {
		tmp = t_1;
	} else if (d <= -2e-310) {
		tmp = d / ((1.0 + sqrt((h * l))) + -1.0);
	} else if (d <= 6.6e-238) {
		tmp = t_0;
	} else if (d <= 1.95e-150) {
		tmp = d / (sqrt(h) * sqrt(l));
	} else if (d <= 5.5e-60) {
		tmp = t_0;
	} else if (d <= 2.8e+126) {
		tmp = t_1;
	} else {
		tmp = d * (pow(h, -0.5) * pow(l, -0.5));
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (-0.125d0) * (sqrt((h / (l ** 3.0d0))) * (d_1 * (m * ((d_1 / d) * m))))
    t_1 = sqrt(((d * (d / l)) / h)) * (1.0d0 + ((-0.5d0) * ((0.25d0 / l) * ((d_1 * (d_1 * (m * m))) / (d * (d / h))))))
    if (d <= (-2.2d+104)) then
        tmp = sqrt((d / l)) * sqrt((d / h))
    else if (d <= (-2.1d-140)) then
        tmp = t_1
    else if (d <= (-2d-310)) then
        tmp = d / ((1.0d0 + sqrt((h * l))) + (-1.0d0))
    else if (d <= 6.6d-238) then
        tmp = t_0
    else if (d <= 1.95d-150) then
        tmp = d / (sqrt(h) * sqrt(l))
    else if (d <= 5.5d-60) then
        tmp = t_0
    else if (d <= 2.8d+126) then
        tmp = t_1
    else
        tmp = d * ((h ** (-0.5d0)) * (l ** (-0.5d0)))
    end if
    code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = -0.125 * (Math.sqrt((h / Math.pow(l, 3.0))) * (D * (M * ((D / d) * M))));
	double t_1 = Math.sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	double tmp;
	if (d <= -2.2e+104) {
		tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
	} else if (d <= -2.1e-140) {
		tmp = t_1;
	} else if (d <= -2e-310) {
		tmp = d / ((1.0 + Math.sqrt((h * l))) + -1.0);
	} else if (d <= 6.6e-238) {
		tmp = t_0;
	} else if (d <= 1.95e-150) {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	} else if (d <= 5.5e-60) {
		tmp = t_0;
	} else if (d <= 2.8e+126) {
		tmp = t_1;
	} else {
		tmp = d * (Math.pow(h, -0.5) * Math.pow(l, -0.5));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = -0.125 * (math.sqrt((h / math.pow(l, 3.0))) * (D * (M * ((D / d) * M))))
	t_1 = math.sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))))
	tmp = 0
	if d <= -2.2e+104:
		tmp = math.sqrt((d / l)) * math.sqrt((d / h))
	elif d <= -2.1e-140:
		tmp = t_1
	elif d <= -2e-310:
		tmp = d / ((1.0 + math.sqrt((h * l))) + -1.0)
	elif d <= 6.6e-238:
		tmp = t_0
	elif d <= 1.95e-150:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	elif d <= 5.5e-60:
		tmp = t_0
	elif d <= 2.8e+126:
		tmp = t_1
	else:
		tmp = d * (math.pow(h, -0.5) * math.pow(l, -0.5))
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(-0.125 * Float64(sqrt(Float64(h / (l ^ 3.0))) * Float64(D * Float64(M * Float64(Float64(D / d) * M)))))
	t_1 = Float64(sqrt(Float64(Float64(d * Float64(d / l)) / h)) * Float64(1.0 + Float64(-0.5 * Float64(Float64(0.25 / l) * Float64(Float64(D * Float64(D * Float64(M * M))) / Float64(d * Float64(d / h)))))))
	tmp = 0.0
	if (d <= -2.2e+104)
		tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h)));
	elseif (d <= -2.1e-140)
		tmp = t_1;
	elseif (d <= -2e-310)
		tmp = Float64(d / Float64(Float64(1.0 + sqrt(Float64(h * l))) + -1.0));
	elseif (d <= 6.6e-238)
		tmp = t_0;
	elseif (d <= 1.95e-150)
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	elseif (d <= 5.5e-60)
		tmp = t_0;
	elseif (d <= 2.8e+126)
		tmp = t_1;
	else
		tmp = Float64(d * Float64((h ^ -0.5) * (l ^ -0.5)));
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = -0.125 * (sqrt((h / (l ^ 3.0))) * (D * (M * ((D / d) * M))));
	t_1 = sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	tmp = 0.0;
	if (d <= -2.2e+104)
		tmp = sqrt((d / l)) * sqrt((d / h));
	elseif (d <= -2.1e-140)
		tmp = t_1;
	elseif (d <= -2e-310)
		tmp = d / ((1.0 + sqrt((h * l))) + -1.0);
	elseif (d <= 6.6e-238)
		tmp = t_0;
	elseif (d <= 1.95e-150)
		tmp = d / (sqrt(h) * sqrt(l));
	elseif (d <= 5.5e-60)
		tmp = t_0;
	elseif (d <= 2.8e+126)
		tmp = t_1;
	else
		tmp = d * ((h ^ -0.5) * (l ^ -0.5));
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(-0.125 * N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(D * N[(M * N[(N[(D / d), $MachinePrecision] * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(N[(d * N[(d / l), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(0.25 / l), $MachinePrecision] * N[(N[(D * N[(D * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * N[(d / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.2e+104], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.1e-140], t$95$1, If[LessEqual[d, -2e-310], N[(d / N[(N[(1.0 + N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.6e-238], t$95$0, If[LessEqual[d, 1.95e-150], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.5e-60], t$95$0, If[LessEqual[d, 2.8e+126], t$95$1, N[(d * N[(N[Power[h, -0.5], $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := -0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(D \cdot \left(M \cdot \left(\frac{D}{d} \cdot M\right)\right)\right)\right)\\
t_1 := \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\
\mathbf{if}\;d \leq -2.2 \cdot 10^{+104}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\

\mathbf{elif}\;d \leq -2.1 \cdot 10^{-140}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\

\mathbf{elif}\;d \leq 6.6 \cdot 10^{-238}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq 1.95 \cdot 10^{-150}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\

\mathbf{elif}\;d \leq 5.5 \cdot 10^{-60}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq 2.8 \cdot 10^{+126}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if d < -2.2e104

    1. Initial program 71.3%

      \[\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. Simplified69.0%

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

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{1}\right) \]

    if -2.2e104 < d < -2.10000000000000017e-140 or 5.4999999999999997e-60 < d < 2.80000000000000009e126

    1. Initial program 76.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. Simplified76.0%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def32.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p61.7%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/64.0%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot \frac{d}{\ell}}{h}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      4. *-commutative64.0%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in h around 0 55.0%

      \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    7. Step-by-step derivation
      1. associate-*r/55.0%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{0.25 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}}\right) \]
      2. *-commutative55.0%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \frac{0.25 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{\color{blue}{\ell \cdot {d}^{2}}}\right) \]
      3. times-frac58.7%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(\frac{0.25}{\ell} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}\right)}\right) \]
      4. associate-*r*58.8%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2}}\right)\right) \]
      5. associate-/l*58.8%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}}\right)\right) \]
      6. unpow258.8%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}\right)\right) \]
      7. associate-*l*61.3%

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

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

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{\frac{\color{blue}{d \cdot d}}{h}}\right)\right) \]
      10. associate-*r/61.3%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{\color{blue}{d \cdot \frac{d}{h}}}\right)\right) \]
    8. Simplified61.3%

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

    if -2.10000000000000017e-140 < d < -1.999999999999994e-310

    1. Initial program 41.1%

      \[\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. Simplified38.0%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow129.1%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{1}} \]
      2. sqrt-div26.1%

        \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
      3. metadata-eval26.1%

        \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
    5. Applied egg-rr26.1%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow126.1%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/26.1%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity26.1%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified26.1%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u26.1%

        \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    9. Applied egg-rr26.1%

      \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    10. Step-by-step derivation
      1. expm1-udef47.6%

        \[\leadsto \frac{d}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)} - 1}} \]
      2. log1p-udef47.6%

        \[\leadsto \frac{d}{e^{\color{blue}{\log \left(1 + \sqrt{h \cdot \ell}\right)}} - 1} \]
      3. add-exp-log47.6%

        \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right)} - 1} \]
    11. Applied egg-rr47.6%

      \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right) - 1}} \]

    if -1.999999999999994e-310 < d < 6.59999999999999939e-238 or 1.9500000000000001e-150 < d < 5.4999999999999997e-60

    1. Initial program 58.8%

      \[\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. Simplified56.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. pow1/256.1%

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

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

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

        \[\leadsto \left(\color{blue}{{\left(\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right)}^{0.3333333333333333}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. metadata-eval34.0%

        \[\leadsto \left({\left(\left({\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right)}^{0.3333333333333333} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      6. metadata-eval34.0%

        \[\leadsto \left({\left(\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right)}^{0.3333333333333333} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      7. pow-prod-up34.0%

        \[\leadsto \left({\left(\color{blue}{{\left(\frac{d}{h}\right)}^{\left(0.5 + 0.5\right)}} \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right)}^{0.3333333333333333} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      8. metadata-eval34.0%

        \[\leadsto \left({\left({\left(\frac{d}{h}\right)}^{\color{blue}{1}} \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right)}^{0.3333333333333333} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      9. metadata-eval34.0%

        \[\leadsto \left({\left({\left(\frac{d}{h}\right)}^{1} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}}\right)}^{0.3333333333333333} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      10. pow-prod-up34.0%

        \[\leadsto \left({\color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(1 + 0.5\right)}\right)}}^{0.3333333333333333} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      11. metadata-eval34.0%

        \[\leadsto \left({\left({\left(\frac{d}{h}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    4. Applied egg-rr34.0%

      \[\leadsto \left(\color{blue}{{\left({\left(\frac{d}{h}\right)}^{1.5}\right)}^{0.3333333333333333}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Step-by-step derivation
      1. unpow1/334.5%

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

      \[\leadsto \left(\color{blue}{\sqrt[3]{{\left(\frac{d}{h}\right)}^{1.5}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. Taylor expanded in d around 0 59.8%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    8. Step-by-step derivation
      1. *-commutative59.8%

        \[\leadsto -0.125 \cdot \color{blue}{\left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{{D}^{2} \cdot {M}^{2}}{d}\right)} \]
      2. unpow259.8%

        \[\leadsto -0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}}{d}\right) \]
      3. associate-*l*62.5%

        \[\leadsto -0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{\color{blue}{D \cdot \left(D \cdot {M}^{2}\right)}}{d}\right) \]
      4. associate-*r/65.3%

        \[\leadsto -0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left(D \cdot \frac{D \cdot {M}^{2}}{d}\right)}\right) \]
      5. associate-*l/60.0%

        \[\leadsto -0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(D \cdot \color{blue}{\left(\frac{D}{d} \cdot {M}^{2}\right)}\right)\right) \]
      6. *-commutative60.0%

        \[\leadsto -0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(D \cdot \color{blue}{\left({M}^{2} \cdot \frac{D}{d}\right)}\right)\right) \]
      7. unpow260.0%

        \[\leadsto -0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(D \cdot \left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{D}{d}\right)\right)\right) \]
      8. associate-*l*65.4%

        \[\leadsto -0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(D \cdot \color{blue}{\left(M \cdot \left(M \cdot \frac{D}{d}\right)\right)}\right)\right) \]
    9. Simplified65.4%

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

    if 6.59999999999999939e-238 < d < 1.9500000000000001e-150

    1. Initial program 61.3%

      \[\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. Simplified59.5%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow141.4%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{1}} \]
      2. sqrt-div41.4%

        \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
      3. metadata-eval41.4%

        \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
    5. Applied egg-rr41.4%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow141.4%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/41.3%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity41.3%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified41.3%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. sqrt-prod49.1%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    9. Applied egg-rr49.1%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]

    if 2.80000000000000009e126 < d

    1. Initial program 55.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. Simplified55.7%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow1/275.1%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    5. Applied egg-rr75.1%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    6. Step-by-step derivation
      1. unpow1/275.1%

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
      2. unpow-175.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      3. sqr-pow75.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}} \]
      4. rem-sqrt-square75.1%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|} \]
      5. metadata-eval75.1%

        \[\leadsto d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right| \]
      6. sqr-pow74.7%

        \[\leadsto d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      7. fabs-sqr74.7%

        \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      8. sqr-pow75.1%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    7. Simplified75.1%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. unpow-prod-down81.0%

        \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
    9. Applied egg-rr81.0%

      \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
  3. Recombined 6 regimes into one program.
  4. Final simplification59.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.2 \cdot 10^{+104}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -2.1 \cdot 10^{-140}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\ \mathbf{elif}\;d \leq 6.6 \cdot 10^{-238}:\\ \;\;\;\;-0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(D \cdot \left(M \cdot \left(\frac{D}{d} \cdot M\right)\right)\right)\right)\\ \mathbf{elif}\;d \leq 1.95 \cdot 10^{-150}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;d \leq 5.5 \cdot 10^{-60}:\\ \;\;\;\;-0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(D \cdot \left(M \cdot \left(\frac{D}{d} \cdot M\right)\right)\right)\right)\\ \mathbf{elif}\;d \leq 2.8 \cdot 10^{+126}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\ \end{array} \]

Alternative 10: 52.7% accurate, 1.5× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ t_1 := \sqrt{\frac{h}{{\ell}^{3}}}\\ \mathbf{if}\;d \leq -2.4 \cdot 10^{+103}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -2.95 \cdot 10^{-142}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{-238}:\\ \;\;\;\;-0.125 \cdot \left(t_1 \cdot \left(D \cdot \left(M \cdot \left(\frac{D}{d} \cdot M\right)\right)\right)\right)\\ \mathbf{elif}\;d \leq 2.3 \cdot 10^{-150}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;d \leq 5.4 \cdot 10^{-60}:\\ \;\;\;\;-0.125 \cdot \left(\frac{D \cdot M}{\frac{d}{D}} \cdot \left(M \cdot t_1\right)\right)\\ \mathbf{elif}\;d \leq 3.4 \cdot 10^{+126}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0
         (*
          (sqrt (/ (* d (/ d l)) h))
          (+
           1.0
           (* -0.5 (* (/ 0.25 l) (/ (* D (* D (* M M))) (* d (/ d h))))))))
        (t_1 (sqrt (/ h (pow l 3.0)))))
   (if (<= d -2.4e+103)
     (* (sqrt (/ d l)) (sqrt (/ d h)))
     (if (<= d -2.95e-142)
       t_0
       (if (<= d -2e-310)
         (/ d (+ (+ 1.0 (sqrt (* h l))) -1.0))
         (if (<= d 1.7e-238)
           (* -0.125 (* t_1 (* D (* M (* (/ D d) M)))))
           (if (<= d 2.3e-150)
             (/ d (* (sqrt h) (sqrt l)))
             (if (<= d 5.4e-60)
               (* -0.125 (* (/ (* D M) (/ d D)) (* M t_1)))
               (if (<= d 3.4e+126)
                 t_0
                 (* d (* (pow h -0.5) (pow l -0.5))))))))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	double t_1 = sqrt((h / pow(l, 3.0)));
	double tmp;
	if (d <= -2.4e+103) {
		tmp = sqrt((d / l)) * sqrt((d / h));
	} else if (d <= -2.95e-142) {
		tmp = t_0;
	} else if (d <= -2e-310) {
		tmp = d / ((1.0 + sqrt((h * l))) + -1.0);
	} else if (d <= 1.7e-238) {
		tmp = -0.125 * (t_1 * (D * (M * ((D / d) * M))));
	} else if (d <= 2.3e-150) {
		tmp = d / (sqrt(h) * sqrt(l));
	} else if (d <= 5.4e-60) {
		tmp = -0.125 * (((D * M) / (d / D)) * (M * t_1));
	} else if (d <= 3.4e+126) {
		tmp = t_0;
	} else {
		tmp = d * (pow(h, -0.5) * pow(l, -0.5));
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = sqrt(((d * (d / l)) / h)) * (1.0d0 + ((-0.5d0) * ((0.25d0 / l) * ((d_1 * (d_1 * (m * m))) / (d * (d / h))))))
    t_1 = sqrt((h / (l ** 3.0d0)))
    if (d <= (-2.4d+103)) then
        tmp = sqrt((d / l)) * sqrt((d / h))
    else if (d <= (-2.95d-142)) then
        tmp = t_0
    else if (d <= (-2d-310)) then
        tmp = d / ((1.0d0 + sqrt((h * l))) + (-1.0d0))
    else if (d <= 1.7d-238) then
        tmp = (-0.125d0) * (t_1 * (d_1 * (m * ((d_1 / d) * m))))
    else if (d <= 2.3d-150) then
        tmp = d / (sqrt(h) * sqrt(l))
    else if (d <= 5.4d-60) then
        tmp = (-0.125d0) * (((d_1 * m) / (d / d_1)) * (m * t_1))
    else if (d <= 3.4d+126) then
        tmp = t_0
    else
        tmp = d * ((h ** (-0.5d0)) * (l ** (-0.5d0)))
    end if
    code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	double t_1 = Math.sqrt((h / Math.pow(l, 3.0)));
	double tmp;
	if (d <= -2.4e+103) {
		tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
	} else if (d <= -2.95e-142) {
		tmp = t_0;
	} else if (d <= -2e-310) {
		tmp = d / ((1.0 + Math.sqrt((h * l))) + -1.0);
	} else if (d <= 1.7e-238) {
		tmp = -0.125 * (t_1 * (D * (M * ((D / d) * M))));
	} else if (d <= 2.3e-150) {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	} else if (d <= 5.4e-60) {
		tmp = -0.125 * (((D * M) / (d / D)) * (M * t_1));
	} else if (d <= 3.4e+126) {
		tmp = t_0;
	} else {
		tmp = d * (Math.pow(h, -0.5) * Math.pow(l, -0.5));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))))
	t_1 = math.sqrt((h / math.pow(l, 3.0)))
	tmp = 0
	if d <= -2.4e+103:
		tmp = math.sqrt((d / l)) * math.sqrt((d / h))
	elif d <= -2.95e-142:
		tmp = t_0
	elif d <= -2e-310:
		tmp = d / ((1.0 + math.sqrt((h * l))) + -1.0)
	elif d <= 1.7e-238:
		tmp = -0.125 * (t_1 * (D * (M * ((D / d) * M))))
	elif d <= 2.3e-150:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	elif d <= 5.4e-60:
		tmp = -0.125 * (((D * M) / (d / D)) * (M * t_1))
	elif d <= 3.4e+126:
		tmp = t_0
	else:
		tmp = d * (math.pow(h, -0.5) * math.pow(l, -0.5))
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(sqrt(Float64(Float64(d * Float64(d / l)) / h)) * Float64(1.0 + Float64(-0.5 * Float64(Float64(0.25 / l) * Float64(Float64(D * Float64(D * Float64(M * M))) / Float64(d * Float64(d / h)))))))
	t_1 = sqrt(Float64(h / (l ^ 3.0)))
	tmp = 0.0
	if (d <= -2.4e+103)
		tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h)));
	elseif (d <= -2.95e-142)
		tmp = t_0;
	elseif (d <= -2e-310)
		tmp = Float64(d / Float64(Float64(1.0 + sqrt(Float64(h * l))) + -1.0));
	elseif (d <= 1.7e-238)
		tmp = Float64(-0.125 * Float64(t_1 * Float64(D * Float64(M * Float64(Float64(D / d) * M)))));
	elseif (d <= 2.3e-150)
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	elseif (d <= 5.4e-60)
		tmp = Float64(-0.125 * Float64(Float64(Float64(D * M) / Float64(d / D)) * Float64(M * t_1)));
	elseif (d <= 3.4e+126)
		tmp = t_0;
	else
		tmp = Float64(d * Float64((h ^ -0.5) * (l ^ -0.5)));
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	t_1 = sqrt((h / (l ^ 3.0)));
	tmp = 0.0;
	if (d <= -2.4e+103)
		tmp = sqrt((d / l)) * sqrt((d / h));
	elseif (d <= -2.95e-142)
		tmp = t_0;
	elseif (d <= -2e-310)
		tmp = d / ((1.0 + sqrt((h * l))) + -1.0);
	elseif (d <= 1.7e-238)
		tmp = -0.125 * (t_1 * (D * (M * ((D / d) * M))));
	elseif (d <= 2.3e-150)
		tmp = d / (sqrt(h) * sqrt(l));
	elseif (d <= 5.4e-60)
		tmp = -0.125 * (((D * M) / (d / D)) * (M * t_1));
	elseif (d <= 3.4e+126)
		tmp = t_0;
	else
		tmp = d * ((h ^ -0.5) * (l ^ -0.5));
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Sqrt[N[(N[(d * N[(d / l), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(0.25 / l), $MachinePrecision] * N[(N[(D * N[(D * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * N[(d / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -2.4e+103], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.95e-142], t$95$0, If[LessEqual[d, -2e-310], N[(d / N[(N[(1.0 + N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.7e-238], N[(-0.125 * N[(t$95$1 * N[(D * N[(M * N[(N[(D / d), $MachinePrecision] * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.3e-150], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.4e-60], N[(-0.125 * N[(N[(N[(D * M), $MachinePrecision] / N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(M * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.4e+126], t$95$0, N[(d * N[(N[Power[h, -0.5], $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\
t_1 := \sqrt{\frac{h}{{\ell}^{3}}}\\
\mathbf{if}\;d \leq -2.4 \cdot 10^{+103}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\

\mathbf{elif}\;d \leq -2.95 \cdot 10^{-142}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\

\mathbf{elif}\;d \leq 1.7 \cdot 10^{-238}:\\
\;\;\;\;-0.125 \cdot \left(t_1 \cdot \left(D \cdot \left(M \cdot \left(\frac{D}{d} \cdot M\right)\right)\right)\right)\\

\mathbf{elif}\;d \leq 2.3 \cdot 10^{-150}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\

\mathbf{elif}\;d \leq 5.4 \cdot 10^{-60}:\\
\;\;\;\;-0.125 \cdot \left(\frac{D \cdot M}{\frac{d}{D}} \cdot \left(M \cdot t_1\right)\right)\\

\mathbf{elif}\;d \leq 3.4 \cdot 10^{+126}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 7 regimes
  2. if d < -2.3999999999999998e103

    1. Initial program 71.3%

      \[\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. Simplified69.0%

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

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{1}\right) \]

    if -2.3999999999999998e103 < d < -2.94999999999999983e-142 or 5.40000000000000001e-60 < d < 3.39999999999999989e126

    1. Initial program 76.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. Simplified76.0%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def32.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p61.7%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/64.0%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot \frac{d}{\ell}}{h}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      4. *-commutative64.0%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in h around 0 55.0%

      \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    7. Step-by-step derivation
      1. associate-*r/55.0%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{0.25 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}}\right) \]
      2. *-commutative55.0%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \frac{0.25 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{\color{blue}{\ell \cdot {d}^{2}}}\right) \]
      3. times-frac58.7%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(\frac{0.25}{\ell} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}\right)}\right) \]
      4. associate-*r*58.8%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2}}\right)\right) \]
      5. associate-/l*58.8%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}}\right)\right) \]
      6. unpow258.8%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}\right)\right) \]
      7. associate-*l*61.3%

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

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

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{\frac{\color{blue}{d \cdot d}}{h}}\right)\right) \]
      10. associate-*r/61.3%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{\color{blue}{d \cdot \frac{d}{h}}}\right)\right) \]
    8. Simplified61.3%

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

    if -2.94999999999999983e-142 < d < -1.999999999999994e-310

    1. Initial program 41.1%

      \[\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. Simplified38.0%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow129.1%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{1}} \]
      2. sqrt-div26.1%

        \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
      3. metadata-eval26.1%

        \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
    5. Applied egg-rr26.1%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow126.1%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/26.1%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity26.1%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified26.1%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u26.1%

        \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    9. Applied egg-rr26.1%

      \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    10. Step-by-step derivation
      1. expm1-udef47.6%

        \[\leadsto \frac{d}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)} - 1}} \]
      2. log1p-udef47.6%

        \[\leadsto \frac{d}{e^{\color{blue}{\log \left(1 + \sqrt{h \cdot \ell}\right)}} - 1} \]
      3. add-exp-log47.6%

        \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right)} - 1} \]
    11. Applied egg-rr47.6%

      \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right) - 1}} \]

    if -1.999999999999994e-310 < d < 1.69999999999999992e-238

    1. Initial program 56.8%

      \[\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. Simplified52.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. pow1/252.3%

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

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

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

        \[\leadsto \left(\color{blue}{{\left(\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right)}^{0.3333333333333333}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. metadata-eval38.4%

        \[\leadsto \left({\left(\left({\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right)}^{0.3333333333333333} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      6. metadata-eval38.4%

        \[\leadsto \left({\left(\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right)}^{0.3333333333333333} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      7. pow-prod-up38.4%

        \[\leadsto \left({\left(\color{blue}{{\left(\frac{d}{h}\right)}^{\left(0.5 + 0.5\right)}} \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right)}^{0.3333333333333333} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      8. metadata-eval38.4%

        \[\leadsto \left({\left({\left(\frac{d}{h}\right)}^{\color{blue}{1}} \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right)}^{0.3333333333333333} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      9. metadata-eval38.4%

        \[\leadsto \left({\left({\left(\frac{d}{h}\right)}^{1} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}}\right)}^{0.3333333333333333} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      10. pow-prod-up38.4%

        \[\leadsto \left({\color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(1 + 0.5\right)}\right)}}^{0.3333333333333333} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      11. metadata-eval38.4%

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

      \[\leadsto \left(\color{blue}{{\left({\left(\frac{d}{h}\right)}^{1.5}\right)}^{0.3333333333333333}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Step-by-step derivation
      1. unpow1/338.6%

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

      \[\leadsto \left(\color{blue}{\sqrt[3]{{\left(\frac{d}{h}\right)}^{1.5}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. Taylor expanded in d around 0 73.1%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    8. Step-by-step derivation
      1. *-commutative73.1%

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

        \[\leadsto -0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}}{d}\right) \]
      3. associate-*l*73.0%

        \[\leadsto -0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{\color{blue}{D \cdot \left(D \cdot {M}^{2}\right)}}{d}\right) \]
      4. associate-*r/77.8%

        \[\leadsto -0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left(D \cdot \frac{D \cdot {M}^{2}}{d}\right)}\right) \]
      5. associate-*l/68.9%

        \[\leadsto -0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(D \cdot \color{blue}{\left(\frac{D}{d} \cdot {M}^{2}\right)}\right)\right) \]
      6. *-commutative68.9%

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

        \[\leadsto -0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(D \cdot \left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{D}{d}\right)\right)\right) \]
      8. associate-*l*68.8%

        \[\leadsto -0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(D \cdot \color{blue}{\left(M \cdot \left(M \cdot \frac{D}{d}\right)\right)}\right)\right) \]
    9. Simplified68.8%

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

    if 1.69999999999999992e-238 < d < 2.30000000000000003e-150

    1. Initial program 61.3%

      \[\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. Simplified59.5%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow141.4%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{1}} \]
      2. sqrt-div41.4%

        \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
      3. metadata-eval41.4%

        \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
    5. Applied egg-rr41.4%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow141.4%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/41.3%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity41.3%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified41.3%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. sqrt-prod49.1%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    9. Applied egg-rr49.1%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]

    if 2.30000000000000003e-150 < d < 5.40000000000000001e-60

    1. Initial program 61.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. Simplified61.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. add-cube-cbrt61.7%

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\sqrt[3]{\sqrt{\frac{d}{\ell}}}\right)}^{3}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Taylor expanded in d around 0 40.4%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    6. Step-by-step derivation
      1. unpow240.4%

        \[\leadsto -0.125 \cdot \left(\frac{{D}^{2} \cdot \color{blue}{\left(M \cdot M\right)}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \]
      2. associate-*l/40.4%

        \[\leadsto -0.125 \cdot \left(\color{blue}{\left(\frac{{D}^{2}}{d} \cdot \left(M \cdot M\right)\right)} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \]
      3. unpow240.4%

        \[\leadsto -0.125 \cdot \left(\left(\frac{\color{blue}{D \cdot D}}{d} \cdot \left(M \cdot M\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \]
      4. associate-*r*53.8%

        \[\leadsto -0.125 \cdot \left(\color{blue}{\left(\left(\frac{D \cdot D}{d} \cdot M\right) \cdot M\right)} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \]
      5. associate-*l*53.9%

        \[\leadsto -0.125 \cdot \color{blue}{\left(\left(\frac{D \cdot D}{d} \cdot M\right) \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
      6. associate-/l*53.9%

        \[\leadsto -0.125 \cdot \left(\left(\color{blue}{\frac{D}{\frac{d}{D}}} \cdot M\right) \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right) \]
      7. associate-*l/60.6%

        \[\leadsto -0.125 \cdot \left(\color{blue}{\frac{D \cdot M}{\frac{d}{D}}} \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right) \]
    7. Simplified60.6%

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

    if 3.39999999999999989e126 < d

    1. Initial program 55.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. Simplified55.7%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow1/275.1%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    5. Applied egg-rr75.1%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    6. Step-by-step derivation
      1. unpow1/275.1%

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
      2. unpow-175.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      3. sqr-pow75.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}} \]
      4. rem-sqrt-square75.1%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|} \]
      5. metadata-eval75.1%

        \[\leadsto d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right| \]
      6. sqr-pow74.7%

        \[\leadsto d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      7. fabs-sqr74.7%

        \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      8. sqr-pow75.1%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    7. Simplified75.1%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. unpow-prod-down81.0%

        \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
    9. Applied egg-rr81.0%

      \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
  3. Recombined 7 regimes into one program.
  4. Final simplification59.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.4 \cdot 10^{+103}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -2.95 \cdot 10^{-142}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{-238}:\\ \;\;\;\;-0.125 \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(D \cdot \left(M \cdot \left(\frac{D}{d} \cdot M\right)\right)\right)\right)\\ \mathbf{elif}\;d \leq 2.3 \cdot 10^{-150}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;d \leq 5.4 \cdot 10^{-60}:\\ \;\;\;\;-0.125 \cdot \left(\frac{D \cdot M}{\frac{d}{D}} \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)\\ \mathbf{elif}\;d \leq 3.4 \cdot 10^{+126}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\ \end{array} \]

Alternative 11: 52.3% accurate, 1.5× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ t_1 := \sqrt{\frac{h}{{\ell}^{3}}}\\ \mathbf{if}\;d \leq -2.5 \cdot 10^{+104}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -3.4 \cdot 10^{-136}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -7.5 \cdot 10^{-306}:\\ \;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\ \mathbf{elif}\;d \leq 6.6 \cdot 10^{-238}:\\ \;\;\;\;-0.125 \cdot \frac{t_1 \cdot \left(M \cdot \left(M \cdot \left(D \cdot D\right)\right)\right)}{d}\\ \mathbf{elif}\;d \leq 2 \cdot 10^{-150}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;d \leq 5.4 \cdot 10^{-60}:\\ \;\;\;\;-0.125 \cdot \left(\frac{D \cdot M}{\frac{d}{D}} \cdot \left(M \cdot t_1\right)\right)\\ \mathbf{elif}\;d \leq 2.55 \cdot 10^{+126}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0
         (*
          (sqrt (/ (* d (/ d l)) h))
          (+
           1.0
           (* -0.5 (* (/ 0.25 l) (/ (* D (* D (* M M))) (* d (/ d h))))))))
        (t_1 (sqrt (/ h (pow l 3.0)))))
   (if (<= d -2.5e+104)
     (* (sqrt (/ d l)) (sqrt (/ d h)))
     (if (<= d -3.4e-136)
       t_0
       (if (<= d -7.5e-306)
         (/ d (+ (+ 1.0 (sqrt (* h l))) -1.0))
         (if (<= d 6.6e-238)
           (* -0.125 (/ (* t_1 (* M (* M (* D D)))) d))
           (if (<= d 2e-150)
             (/ d (* (sqrt h) (sqrt l)))
             (if (<= d 5.4e-60)
               (* -0.125 (* (/ (* D M) (/ d D)) (* M t_1)))
               (if (<= d 2.55e+126)
                 t_0
                 (* d (* (pow h -0.5) (pow l -0.5))))))))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	double t_1 = sqrt((h / pow(l, 3.0)));
	double tmp;
	if (d <= -2.5e+104) {
		tmp = sqrt((d / l)) * sqrt((d / h));
	} else if (d <= -3.4e-136) {
		tmp = t_0;
	} else if (d <= -7.5e-306) {
		tmp = d / ((1.0 + sqrt((h * l))) + -1.0);
	} else if (d <= 6.6e-238) {
		tmp = -0.125 * ((t_1 * (M * (M * (D * D)))) / d);
	} else if (d <= 2e-150) {
		tmp = d / (sqrt(h) * sqrt(l));
	} else if (d <= 5.4e-60) {
		tmp = -0.125 * (((D * M) / (d / D)) * (M * t_1));
	} else if (d <= 2.55e+126) {
		tmp = t_0;
	} else {
		tmp = d * (pow(h, -0.5) * pow(l, -0.5));
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = sqrt(((d * (d / l)) / h)) * (1.0d0 + ((-0.5d0) * ((0.25d0 / l) * ((d_1 * (d_1 * (m * m))) / (d * (d / h))))))
    t_1 = sqrt((h / (l ** 3.0d0)))
    if (d <= (-2.5d+104)) then
        tmp = sqrt((d / l)) * sqrt((d / h))
    else if (d <= (-3.4d-136)) then
        tmp = t_0
    else if (d <= (-7.5d-306)) then
        tmp = d / ((1.0d0 + sqrt((h * l))) + (-1.0d0))
    else if (d <= 6.6d-238) then
        tmp = (-0.125d0) * ((t_1 * (m * (m * (d_1 * d_1)))) / d)
    else if (d <= 2d-150) then
        tmp = d / (sqrt(h) * sqrt(l))
    else if (d <= 5.4d-60) then
        tmp = (-0.125d0) * (((d_1 * m) / (d / d_1)) * (m * t_1))
    else if (d <= 2.55d+126) then
        tmp = t_0
    else
        tmp = d * ((h ** (-0.5d0)) * (l ** (-0.5d0)))
    end if
    code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	double t_1 = Math.sqrt((h / Math.pow(l, 3.0)));
	double tmp;
	if (d <= -2.5e+104) {
		tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
	} else if (d <= -3.4e-136) {
		tmp = t_0;
	} else if (d <= -7.5e-306) {
		tmp = d / ((1.0 + Math.sqrt((h * l))) + -1.0);
	} else if (d <= 6.6e-238) {
		tmp = -0.125 * ((t_1 * (M * (M * (D * D)))) / d);
	} else if (d <= 2e-150) {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	} else if (d <= 5.4e-60) {
		tmp = -0.125 * (((D * M) / (d / D)) * (M * t_1));
	} else if (d <= 2.55e+126) {
		tmp = t_0;
	} else {
		tmp = d * (Math.pow(h, -0.5) * Math.pow(l, -0.5));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))))
	t_1 = math.sqrt((h / math.pow(l, 3.0)))
	tmp = 0
	if d <= -2.5e+104:
		tmp = math.sqrt((d / l)) * math.sqrt((d / h))
	elif d <= -3.4e-136:
		tmp = t_0
	elif d <= -7.5e-306:
		tmp = d / ((1.0 + math.sqrt((h * l))) + -1.0)
	elif d <= 6.6e-238:
		tmp = -0.125 * ((t_1 * (M * (M * (D * D)))) / d)
	elif d <= 2e-150:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	elif d <= 5.4e-60:
		tmp = -0.125 * (((D * M) / (d / D)) * (M * t_1))
	elif d <= 2.55e+126:
		tmp = t_0
	else:
		tmp = d * (math.pow(h, -0.5) * math.pow(l, -0.5))
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(sqrt(Float64(Float64(d * Float64(d / l)) / h)) * Float64(1.0 + Float64(-0.5 * Float64(Float64(0.25 / l) * Float64(Float64(D * Float64(D * Float64(M * M))) / Float64(d * Float64(d / h)))))))
	t_1 = sqrt(Float64(h / (l ^ 3.0)))
	tmp = 0.0
	if (d <= -2.5e+104)
		tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h)));
	elseif (d <= -3.4e-136)
		tmp = t_0;
	elseif (d <= -7.5e-306)
		tmp = Float64(d / Float64(Float64(1.0 + sqrt(Float64(h * l))) + -1.0));
	elseif (d <= 6.6e-238)
		tmp = Float64(-0.125 * Float64(Float64(t_1 * Float64(M * Float64(M * Float64(D * D)))) / d));
	elseif (d <= 2e-150)
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	elseif (d <= 5.4e-60)
		tmp = Float64(-0.125 * Float64(Float64(Float64(D * M) / Float64(d / D)) * Float64(M * t_1)));
	elseif (d <= 2.55e+126)
		tmp = t_0;
	else
		tmp = Float64(d * Float64((h ^ -0.5) * (l ^ -0.5)));
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	t_1 = sqrt((h / (l ^ 3.0)));
	tmp = 0.0;
	if (d <= -2.5e+104)
		tmp = sqrt((d / l)) * sqrt((d / h));
	elseif (d <= -3.4e-136)
		tmp = t_0;
	elseif (d <= -7.5e-306)
		tmp = d / ((1.0 + sqrt((h * l))) + -1.0);
	elseif (d <= 6.6e-238)
		tmp = -0.125 * ((t_1 * (M * (M * (D * D)))) / d);
	elseif (d <= 2e-150)
		tmp = d / (sqrt(h) * sqrt(l));
	elseif (d <= 5.4e-60)
		tmp = -0.125 * (((D * M) / (d / D)) * (M * t_1));
	elseif (d <= 2.55e+126)
		tmp = t_0;
	else
		tmp = d * ((h ^ -0.5) * (l ^ -0.5));
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Sqrt[N[(N[(d * N[(d / l), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(0.25 / l), $MachinePrecision] * N[(N[(D * N[(D * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * N[(d / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -2.5e+104], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -3.4e-136], t$95$0, If[LessEqual[d, -7.5e-306], N[(d / N[(N[(1.0 + N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.6e-238], N[(-0.125 * N[(N[(t$95$1 * N[(M * N[(M * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2e-150], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.4e-60], N[(-0.125 * N[(N[(N[(D * M), $MachinePrecision] / N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(M * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.55e+126], t$95$0, N[(d * N[(N[Power[h, -0.5], $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\
t_1 := \sqrt{\frac{h}{{\ell}^{3}}}\\
\mathbf{if}\;d \leq -2.5 \cdot 10^{+104}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\

\mathbf{elif}\;d \leq -3.4 \cdot 10^{-136}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq -7.5 \cdot 10^{-306}:\\
\;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\

\mathbf{elif}\;d \leq 6.6 \cdot 10^{-238}:\\
\;\;\;\;-0.125 \cdot \frac{t_1 \cdot \left(M \cdot \left(M \cdot \left(D \cdot D\right)\right)\right)}{d}\\

\mathbf{elif}\;d \leq 2 \cdot 10^{-150}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\

\mathbf{elif}\;d \leq 5.4 \cdot 10^{-60}:\\
\;\;\;\;-0.125 \cdot \left(\frac{D \cdot M}{\frac{d}{D}} \cdot \left(M \cdot t_1\right)\right)\\

\mathbf{elif}\;d \leq 2.55 \cdot 10^{+126}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 7 regimes
  2. if d < -2.4999999999999998e104

    1. Initial program 71.3%

      \[\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. Simplified69.0%

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

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{1}\right) \]

    if -2.4999999999999998e104 < d < -3.4e-136 or 5.40000000000000001e-60 < d < 2.5500000000000001e126

    1. Initial program 76.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. Simplified76.0%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def32.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p61.7%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/64.0%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot \frac{d}{\ell}}{h}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      4. *-commutative64.0%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in h around 0 55.0%

      \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    7. Step-by-step derivation
      1. associate-*r/55.0%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{0.25 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}}\right) \]
      2. *-commutative55.0%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \frac{0.25 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{\color{blue}{\ell \cdot {d}^{2}}}\right) \]
      3. times-frac58.7%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(\frac{0.25}{\ell} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}\right)}\right) \]
      4. associate-*r*58.8%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2}}\right)\right) \]
      5. associate-/l*58.8%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}}\right)\right) \]
      6. unpow258.8%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}\right)\right) \]
      7. associate-*l*61.3%

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

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

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{\frac{\color{blue}{d \cdot d}}{h}}\right)\right) \]
      10. associate-*r/61.3%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{\color{blue}{d \cdot \frac{d}{h}}}\right)\right) \]
    8. Simplified61.3%

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

    if -3.4e-136 < d < -7.5000000000000003e-306

    1. Initial program 42.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. Simplified39.2%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow130.0%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{1}} \]
      2. sqrt-div26.8%

        \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
      3. metadata-eval26.8%

        \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
    5. Applied egg-rr26.8%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow126.8%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/26.8%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity26.8%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified26.8%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u26.8%

        \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    9. Applied egg-rr26.8%

      \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    10. Step-by-step derivation
      1. expm1-udef49.1%

        \[\leadsto \frac{d}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)} - 1}} \]
      2. log1p-udef49.1%

        \[\leadsto \frac{d}{e^{\color{blue}{\log \left(1 + \sqrt{h \cdot \ell}\right)}} - 1} \]
      3. add-exp-log49.1%

        \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right)} - 1} \]
    11. Applied egg-rr49.1%

      \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right) - 1}} \]

    if -7.5000000000000003e-306 < d < 6.59999999999999939e-238

    1. Initial program 54.3%

      \[\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. Simplified50.1%

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

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    4. Step-by-step derivation
      1. associate-*l/70.0%

        \[\leadsto -0.125 \cdot \color{blue}{\frac{\left({D}^{2} \cdot {M}^{2}\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}}{d}} \]
      2. *-commutative70.0%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{\left({M}^{2} \cdot {D}^{2}\right)} \cdot \sqrt{\frac{h}{{\ell}^{3}}}}{d} \]
      3. unpow270.0%

        \[\leadsto -0.125 \cdot \frac{\left(\color{blue}{\left(M \cdot M\right)} \cdot {D}^{2}\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}}{d} \]
      4. associate-*l*69.9%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{\left(M \cdot \left(M \cdot {D}^{2}\right)\right)} \cdot \sqrt{\frac{h}{{\ell}^{3}}}}{d} \]
      5. unpow269.9%

        \[\leadsto -0.125 \cdot \frac{\left(M \cdot \left(M \cdot \color{blue}{\left(D \cdot D\right)}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}}{d} \]
    5. Simplified69.9%

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

    if 6.59999999999999939e-238 < d < 2.00000000000000001e-150

    1. Initial program 61.3%

      \[\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. Simplified59.5%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow141.4%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{1}} \]
      2. sqrt-div41.4%

        \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
      3. metadata-eval41.4%

        \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
    5. Applied egg-rr41.4%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow141.4%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/41.3%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity41.3%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified41.3%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. sqrt-prod49.1%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    9. Applied egg-rr49.1%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]

    if 2.00000000000000001e-150 < d < 5.40000000000000001e-60

    1. Initial program 61.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. Simplified61.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. add-cube-cbrt61.7%

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\sqrt[3]{\sqrt{\frac{d}{\ell}}}\right)}^{3}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Taylor expanded in d around 0 40.4%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    6. Step-by-step derivation
      1. unpow240.4%

        \[\leadsto -0.125 \cdot \left(\frac{{D}^{2} \cdot \color{blue}{\left(M \cdot M\right)}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \]
      2. associate-*l/40.4%

        \[\leadsto -0.125 \cdot \left(\color{blue}{\left(\frac{{D}^{2}}{d} \cdot \left(M \cdot M\right)\right)} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \]
      3. unpow240.4%

        \[\leadsto -0.125 \cdot \left(\left(\frac{\color{blue}{D \cdot D}}{d} \cdot \left(M \cdot M\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \]
      4. associate-*r*53.8%

        \[\leadsto -0.125 \cdot \left(\color{blue}{\left(\left(\frac{D \cdot D}{d} \cdot M\right) \cdot M\right)} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \]
      5. associate-*l*53.9%

        \[\leadsto -0.125 \cdot \color{blue}{\left(\left(\frac{D \cdot D}{d} \cdot M\right) \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
      6. associate-/l*53.9%

        \[\leadsto -0.125 \cdot \left(\left(\color{blue}{\frac{D}{\frac{d}{D}}} \cdot M\right) \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right) \]
      7. associate-*l/60.6%

        \[\leadsto -0.125 \cdot \left(\color{blue}{\frac{D \cdot M}{\frac{d}{D}}} \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right) \]
    7. Simplified60.6%

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

    if 2.5500000000000001e126 < d

    1. Initial program 55.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. Simplified55.7%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow1/275.1%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    5. Applied egg-rr75.1%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    6. Step-by-step derivation
      1. unpow1/275.1%

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
      2. unpow-175.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      3. sqr-pow75.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}} \]
      4. rem-sqrt-square75.1%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|} \]
      5. metadata-eval75.1%

        \[\leadsto d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right| \]
      6. sqr-pow74.7%

        \[\leadsto d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      7. fabs-sqr74.7%

        \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      8. sqr-pow75.1%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    7. Simplified75.1%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. unpow-prod-down81.0%

        \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
    9. Applied egg-rr81.0%

      \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
  3. Recombined 7 regimes into one program.
  4. Final simplification59.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.5 \cdot 10^{+104}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -3.4 \cdot 10^{-136}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{elif}\;d \leq -7.5 \cdot 10^{-306}:\\ \;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\ \mathbf{elif}\;d \leq 6.6 \cdot 10^{-238}:\\ \;\;\;\;-0.125 \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(M \cdot \left(M \cdot \left(D \cdot D\right)\right)\right)}{d}\\ \mathbf{elif}\;d \leq 2 \cdot 10^{-150}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;d \leq 5.4 \cdot 10^{-60}:\\ \;\;\;\;-0.125 \cdot \left(\frac{D \cdot M}{\frac{d}{D}} \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)\\ \mathbf{elif}\;d \leq 2.55 \cdot 10^{+126}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\ \end{array} \]

Alternative 12: 52.0% accurate, 1.5× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ t_1 := \sqrt{\frac{h}{{\ell}^{3}}}\\ \mathbf{if}\;d \leq -2.8 \cdot 10^{+105}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -2.1 \cdot 10^{-138}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -7.5 \cdot 10^{-306}:\\ \;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\ \mathbf{elif}\;d \leq 6.5 \cdot 10^{-238}:\\ \;\;\;\;-0.125 \cdot \frac{t_1 \cdot \left(\left(M \cdot M\right) \cdot \left(D \cdot D\right)\right)}{d}\\ \mathbf{elif}\;d \leq 4 \cdot 10^{-151}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;d \leq 5.4 \cdot 10^{-60}:\\ \;\;\;\;-0.125 \cdot \left(\frac{D \cdot M}{\frac{d}{D}} \cdot \left(M \cdot t_1\right)\right)\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{+126}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0
         (*
          (sqrt (/ (* d (/ d l)) h))
          (+
           1.0
           (* -0.5 (* (/ 0.25 l) (/ (* D (* D (* M M))) (* d (/ d h))))))))
        (t_1 (sqrt (/ h (pow l 3.0)))))
   (if (<= d -2.8e+105)
     (* (sqrt (/ d l)) (sqrt (/ d h)))
     (if (<= d -2.1e-138)
       t_0
       (if (<= d -7.5e-306)
         (/ d (+ (+ 1.0 (sqrt (* h l))) -1.0))
         (if (<= d 6.5e-238)
           (* -0.125 (/ (* t_1 (* (* M M) (* D D))) d))
           (if (<= d 4e-151)
             (/ d (* (sqrt h) (sqrt l)))
             (if (<= d 5.4e-60)
               (* -0.125 (* (/ (* D M) (/ d D)) (* M t_1)))
               (if (<= d 2.7e+126)
                 t_0
                 (* d (* (pow h -0.5) (pow l -0.5))))))))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	double t_1 = sqrt((h / pow(l, 3.0)));
	double tmp;
	if (d <= -2.8e+105) {
		tmp = sqrt((d / l)) * sqrt((d / h));
	} else if (d <= -2.1e-138) {
		tmp = t_0;
	} else if (d <= -7.5e-306) {
		tmp = d / ((1.0 + sqrt((h * l))) + -1.0);
	} else if (d <= 6.5e-238) {
		tmp = -0.125 * ((t_1 * ((M * M) * (D * D))) / d);
	} else if (d <= 4e-151) {
		tmp = d / (sqrt(h) * sqrt(l));
	} else if (d <= 5.4e-60) {
		tmp = -0.125 * (((D * M) / (d / D)) * (M * t_1));
	} else if (d <= 2.7e+126) {
		tmp = t_0;
	} else {
		tmp = d * (pow(h, -0.5) * pow(l, -0.5));
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = sqrt(((d * (d / l)) / h)) * (1.0d0 + ((-0.5d0) * ((0.25d0 / l) * ((d_1 * (d_1 * (m * m))) / (d * (d / h))))))
    t_1 = sqrt((h / (l ** 3.0d0)))
    if (d <= (-2.8d+105)) then
        tmp = sqrt((d / l)) * sqrt((d / h))
    else if (d <= (-2.1d-138)) then
        tmp = t_0
    else if (d <= (-7.5d-306)) then
        tmp = d / ((1.0d0 + sqrt((h * l))) + (-1.0d0))
    else if (d <= 6.5d-238) then
        tmp = (-0.125d0) * ((t_1 * ((m * m) * (d_1 * d_1))) / d)
    else if (d <= 4d-151) then
        tmp = d / (sqrt(h) * sqrt(l))
    else if (d <= 5.4d-60) then
        tmp = (-0.125d0) * (((d_1 * m) / (d / d_1)) * (m * t_1))
    else if (d <= 2.7d+126) then
        tmp = t_0
    else
        tmp = d * ((h ** (-0.5d0)) * (l ** (-0.5d0)))
    end if
    code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	double t_1 = Math.sqrt((h / Math.pow(l, 3.0)));
	double tmp;
	if (d <= -2.8e+105) {
		tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
	} else if (d <= -2.1e-138) {
		tmp = t_0;
	} else if (d <= -7.5e-306) {
		tmp = d / ((1.0 + Math.sqrt((h * l))) + -1.0);
	} else if (d <= 6.5e-238) {
		tmp = -0.125 * ((t_1 * ((M * M) * (D * D))) / d);
	} else if (d <= 4e-151) {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	} else if (d <= 5.4e-60) {
		tmp = -0.125 * (((D * M) / (d / D)) * (M * t_1));
	} else if (d <= 2.7e+126) {
		tmp = t_0;
	} else {
		tmp = d * (Math.pow(h, -0.5) * Math.pow(l, -0.5));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))))
	t_1 = math.sqrt((h / math.pow(l, 3.0)))
	tmp = 0
	if d <= -2.8e+105:
		tmp = math.sqrt((d / l)) * math.sqrt((d / h))
	elif d <= -2.1e-138:
		tmp = t_0
	elif d <= -7.5e-306:
		tmp = d / ((1.0 + math.sqrt((h * l))) + -1.0)
	elif d <= 6.5e-238:
		tmp = -0.125 * ((t_1 * ((M * M) * (D * D))) / d)
	elif d <= 4e-151:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	elif d <= 5.4e-60:
		tmp = -0.125 * (((D * M) / (d / D)) * (M * t_1))
	elif d <= 2.7e+126:
		tmp = t_0
	else:
		tmp = d * (math.pow(h, -0.5) * math.pow(l, -0.5))
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(sqrt(Float64(Float64(d * Float64(d / l)) / h)) * Float64(1.0 + Float64(-0.5 * Float64(Float64(0.25 / l) * Float64(Float64(D * Float64(D * Float64(M * M))) / Float64(d * Float64(d / h)))))))
	t_1 = sqrt(Float64(h / (l ^ 3.0)))
	tmp = 0.0
	if (d <= -2.8e+105)
		tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h)));
	elseif (d <= -2.1e-138)
		tmp = t_0;
	elseif (d <= -7.5e-306)
		tmp = Float64(d / Float64(Float64(1.0 + sqrt(Float64(h * l))) + -1.0));
	elseif (d <= 6.5e-238)
		tmp = Float64(-0.125 * Float64(Float64(t_1 * Float64(Float64(M * M) * Float64(D * D))) / d));
	elseif (d <= 4e-151)
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	elseif (d <= 5.4e-60)
		tmp = Float64(-0.125 * Float64(Float64(Float64(D * M) / Float64(d / D)) * Float64(M * t_1)));
	elseif (d <= 2.7e+126)
		tmp = t_0;
	else
		tmp = Float64(d * Float64((h ^ -0.5) * (l ^ -0.5)));
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	t_1 = sqrt((h / (l ^ 3.0)));
	tmp = 0.0;
	if (d <= -2.8e+105)
		tmp = sqrt((d / l)) * sqrt((d / h));
	elseif (d <= -2.1e-138)
		tmp = t_0;
	elseif (d <= -7.5e-306)
		tmp = d / ((1.0 + sqrt((h * l))) + -1.0);
	elseif (d <= 6.5e-238)
		tmp = -0.125 * ((t_1 * ((M * M) * (D * D))) / d);
	elseif (d <= 4e-151)
		tmp = d / (sqrt(h) * sqrt(l));
	elseif (d <= 5.4e-60)
		tmp = -0.125 * (((D * M) / (d / D)) * (M * t_1));
	elseif (d <= 2.7e+126)
		tmp = t_0;
	else
		tmp = d * ((h ^ -0.5) * (l ^ -0.5));
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Sqrt[N[(N[(d * N[(d / l), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(0.25 / l), $MachinePrecision] * N[(N[(D * N[(D * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * N[(d / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -2.8e+105], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.1e-138], t$95$0, If[LessEqual[d, -7.5e-306], N[(d / N[(N[(1.0 + N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.5e-238], N[(-0.125 * N[(N[(t$95$1 * N[(N[(M * M), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4e-151], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.4e-60], N[(-0.125 * N[(N[(N[(D * M), $MachinePrecision] / N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(M * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.7e+126], t$95$0, N[(d * N[(N[Power[h, -0.5], $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\
t_1 := \sqrt{\frac{h}{{\ell}^{3}}}\\
\mathbf{if}\;d \leq -2.8 \cdot 10^{+105}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\

\mathbf{elif}\;d \leq -2.1 \cdot 10^{-138}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq -7.5 \cdot 10^{-306}:\\
\;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\

\mathbf{elif}\;d \leq 6.5 \cdot 10^{-238}:\\
\;\;\;\;-0.125 \cdot \frac{t_1 \cdot \left(\left(M \cdot M\right) \cdot \left(D \cdot D\right)\right)}{d}\\

\mathbf{elif}\;d \leq 4 \cdot 10^{-151}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\

\mathbf{elif}\;d \leq 5.4 \cdot 10^{-60}:\\
\;\;\;\;-0.125 \cdot \left(\frac{D \cdot M}{\frac{d}{D}} \cdot \left(M \cdot t_1\right)\right)\\

\mathbf{elif}\;d \leq 2.7 \cdot 10^{+126}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 7 regimes
  2. if d < -2.8000000000000001e105

    1. Initial program 71.3%

      \[\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. Simplified69.0%

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

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{1}\right) \]

    if -2.8000000000000001e105 < d < -2.09999999999999986e-138 or 5.40000000000000001e-60 < d < 2.70000000000000002e126

    1. Initial program 76.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. Simplified76.0%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def32.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p61.7%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/64.0%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot \frac{d}{\ell}}{h}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      4. *-commutative64.0%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in h around 0 55.0%

      \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    7. Step-by-step derivation
      1. associate-*r/55.0%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{0.25 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}}\right) \]
      2. *-commutative55.0%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \frac{0.25 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{\color{blue}{\ell \cdot {d}^{2}}}\right) \]
      3. times-frac58.7%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(\frac{0.25}{\ell} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}\right)}\right) \]
      4. associate-*r*58.8%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2}}\right)\right) \]
      5. associate-/l*58.8%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}}\right)\right) \]
      6. unpow258.8%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}\right)\right) \]
      7. associate-*l*61.3%

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

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

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{\frac{\color{blue}{d \cdot d}}{h}}\right)\right) \]
      10. associate-*r/61.3%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{\color{blue}{d \cdot \frac{d}{h}}}\right)\right) \]
    8. Simplified61.3%

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

    if -2.09999999999999986e-138 < d < -7.5000000000000003e-306

    1. Initial program 42.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. Simplified39.2%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow130.0%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{1}} \]
      2. sqrt-div26.8%

        \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
      3. metadata-eval26.8%

        \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
    5. Applied egg-rr26.8%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow126.8%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/26.8%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity26.8%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified26.8%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u26.8%

        \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    9. Applied egg-rr26.8%

      \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    10. Step-by-step derivation
      1. expm1-udef49.1%

        \[\leadsto \frac{d}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)} - 1}} \]
      2. log1p-udef49.1%

        \[\leadsto \frac{d}{e^{\color{blue}{\log \left(1 + \sqrt{h \cdot \ell}\right)}} - 1} \]
      3. add-exp-log49.1%

        \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right)} - 1} \]
    11. Applied egg-rr49.1%

      \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right) - 1}} \]

    if -7.5000000000000003e-306 < d < 6.5000000000000006e-238

    1. Initial program 54.3%

      \[\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. Simplified50.1%

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

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    4. Step-by-step derivation
      1. associate-*l/70.0%

        \[\leadsto -0.125 \cdot \color{blue}{\frac{\left({D}^{2} \cdot {M}^{2}\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}}{d}} \]
      2. unpow270.0%

        \[\leadsto -0.125 \cdot \frac{\left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}}{d} \]
      3. unpow270.0%

        \[\leadsto -0.125 \cdot \frac{\left(\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}}{d} \]
    5. Simplified70.0%

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

    if 6.5000000000000006e-238 < d < 3.9999999999999998e-151

    1. Initial program 61.3%

      \[\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. Simplified59.5%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow141.4%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{1}} \]
      2. sqrt-div41.4%

        \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
      3. metadata-eval41.4%

        \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
    5. Applied egg-rr41.4%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow141.4%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/41.3%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity41.3%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified41.3%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. sqrt-prod49.1%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    9. Applied egg-rr49.1%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]

    if 3.9999999999999998e-151 < d < 5.40000000000000001e-60

    1. Initial program 61.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. Simplified61.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. add-cube-cbrt61.7%

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\sqrt[3]{\sqrt{\frac{d}{\ell}}}\right)}^{3}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Taylor expanded in d around 0 40.4%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    6. Step-by-step derivation
      1. unpow240.4%

        \[\leadsto -0.125 \cdot \left(\frac{{D}^{2} \cdot \color{blue}{\left(M \cdot M\right)}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \]
      2. associate-*l/40.4%

        \[\leadsto -0.125 \cdot \left(\color{blue}{\left(\frac{{D}^{2}}{d} \cdot \left(M \cdot M\right)\right)} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \]
      3. unpow240.4%

        \[\leadsto -0.125 \cdot \left(\left(\frac{\color{blue}{D \cdot D}}{d} \cdot \left(M \cdot M\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \]
      4. associate-*r*53.8%

        \[\leadsto -0.125 \cdot \left(\color{blue}{\left(\left(\frac{D \cdot D}{d} \cdot M\right) \cdot M\right)} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \]
      5. associate-*l*53.9%

        \[\leadsto -0.125 \cdot \color{blue}{\left(\left(\frac{D \cdot D}{d} \cdot M\right) \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
      6. associate-/l*53.9%

        \[\leadsto -0.125 \cdot \left(\left(\color{blue}{\frac{D}{\frac{d}{D}}} \cdot M\right) \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right) \]
      7. associate-*l/60.6%

        \[\leadsto -0.125 \cdot \left(\color{blue}{\frac{D \cdot M}{\frac{d}{D}}} \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right) \]
    7. Simplified60.6%

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

    if 2.70000000000000002e126 < d

    1. Initial program 55.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. Simplified55.7%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow1/275.1%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    5. Applied egg-rr75.1%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    6. Step-by-step derivation
      1. unpow1/275.1%

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
      2. unpow-175.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      3. sqr-pow75.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}} \]
      4. rem-sqrt-square75.1%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|} \]
      5. metadata-eval75.1%

        \[\leadsto d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right| \]
      6. sqr-pow74.7%

        \[\leadsto d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      7. fabs-sqr74.7%

        \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      8. sqr-pow75.1%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    7. Simplified75.1%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. unpow-prod-down81.0%

        \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
    9. Applied egg-rr81.0%

      \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
  3. Recombined 7 regimes into one program.
  4. Final simplification59.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.8 \cdot 10^{+105}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -2.1 \cdot 10^{-138}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{elif}\;d \leq -7.5 \cdot 10^{-306}:\\ \;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\ \mathbf{elif}\;d \leq 6.5 \cdot 10^{-238}:\\ \;\;\;\;-0.125 \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \left(D \cdot D\right)\right)}{d}\\ \mathbf{elif}\;d \leq 4 \cdot 10^{-151}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;d \leq 5.4 \cdot 10^{-60}:\\ \;\;\;\;-0.125 \cdot \left(\frac{D \cdot M}{\frac{d}{D}} \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{+126}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\ \end{array} \]

Alternative 13: 67.5% accurate, 1.5× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\\ t_1 := d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{if}\;h \leq -4.8 \cdot 10^{-235}:\\ \;\;\;\;t_1 \cdot \left(-1 - t_0\right)\\ \mathbf{elif}\;h \leq 4.8 \cdot 10^{-211}:\\ \;\;\;\;\left(1 + \frac{h}{\ell} \cdot \left(-0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + t_0\right) \cdot t_1\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (* -0.5 (* (/ h l) (pow (* (/ D d) (* M 0.5)) 2.0))))
        (t_1 (* d (pow (* h l) -0.5))))
   (if (<= h -4.8e-235)
     (* t_1 (- -1.0 t_0))
     (if (<= h 4.8e-211)
       (*
        (+ 1.0 (* (/ h l) (* -0.125 (pow (* D (/ M d)) 2.0))))
        (sqrt (* (/ d l) (/ d h))))
       (* (+ 1.0 t_0) t_1)))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = -0.5 * ((h / l) * pow(((D / d) * (M * 0.5)), 2.0));
	double t_1 = d * pow((h * l), -0.5);
	double tmp;
	if (h <= -4.8e-235) {
		tmp = t_1 * (-1.0 - t_0);
	} else if (h <= 4.8e-211) {
		tmp = (1.0 + ((h / l) * (-0.125 * pow((D * (M / d)), 2.0)))) * sqrt(((d / l) * (d / h)));
	} else {
		tmp = (1.0 + t_0) * t_1;
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (-0.5d0) * ((h / l) * (((d_1 / d) * (m * 0.5d0)) ** 2.0d0))
    t_1 = d * ((h * l) ** (-0.5d0))
    if (h <= (-4.8d-235)) then
        tmp = t_1 * ((-1.0d0) - t_0)
    else if (h <= 4.8d-211) then
        tmp = (1.0d0 + ((h / l) * ((-0.125d0) * ((d_1 * (m / d)) ** 2.0d0)))) * sqrt(((d / l) * (d / h)))
    else
        tmp = (1.0d0 + t_0) * t_1
    end if
    code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = -0.5 * ((h / l) * Math.pow(((D / d) * (M * 0.5)), 2.0));
	double t_1 = d * Math.pow((h * l), -0.5);
	double tmp;
	if (h <= -4.8e-235) {
		tmp = t_1 * (-1.0 - t_0);
	} else if (h <= 4.8e-211) {
		tmp = (1.0 + ((h / l) * (-0.125 * Math.pow((D * (M / d)), 2.0)))) * Math.sqrt(((d / l) * (d / h)));
	} else {
		tmp = (1.0 + t_0) * t_1;
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = -0.5 * ((h / l) * math.pow(((D / d) * (M * 0.5)), 2.0))
	t_1 = d * math.pow((h * l), -0.5)
	tmp = 0
	if h <= -4.8e-235:
		tmp = t_1 * (-1.0 - t_0)
	elif h <= 4.8e-211:
		tmp = (1.0 + ((h / l) * (-0.125 * math.pow((D * (M / d)), 2.0)))) * math.sqrt(((d / l) * (d / h)))
	else:
		tmp = (1.0 + t_0) * t_1
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M * 0.5)) ^ 2.0)))
	t_1 = Float64(d * (Float64(h * l) ^ -0.5))
	tmp = 0.0
	if (h <= -4.8e-235)
		tmp = Float64(t_1 * Float64(-1.0 - t_0));
	elseif (h <= 4.8e-211)
		tmp = Float64(Float64(1.0 + Float64(Float64(h / l) * Float64(-0.125 * (Float64(D * Float64(M / d)) ^ 2.0)))) * sqrt(Float64(Float64(d / l) * Float64(d / h))));
	else
		tmp = Float64(Float64(1.0 + t_0) * t_1);
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = -0.5 * ((h / l) * (((D / d) * (M * 0.5)) ^ 2.0));
	t_1 = d * ((h * l) ^ -0.5);
	tmp = 0.0;
	if (h <= -4.8e-235)
		tmp = t_1 * (-1.0 - t_0);
	elseif (h <= 4.8e-211)
		tmp = (1.0 + ((h / l) * (-0.125 * ((D * (M / d)) ^ 2.0)))) * sqrt(((d / l) * (d / h)));
	else
		tmp = (1.0 + t_0) * t_1;
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -4.8e-235], N[(t$95$1 * N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 4.8e-211], N[(N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.125 * N[Power[N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\\
t_1 := d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\
\mathbf{if}\;h \leq -4.8 \cdot 10^{-235}:\\
\;\;\;\;t_1 \cdot \left(-1 - t_0\right)\\

\mathbf{elif}\;h \leq 4.8 \cdot 10^{-211}:\\
\;\;\;\;\left(1 + \frac{h}{\ell} \cdot \left(-0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\

\mathbf{else}:\\
\;\;\;\;\left(1 + t_0\right) \cdot t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -4.80000000000000022e-235

    1. Initial program 63.8%

      \[\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. Simplified62.9%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def30.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p52.4%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/47.6%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot \frac{d}{\ell}}{h}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      4. *-commutative47.6%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in d around -inf 68.6%

      \[\leadsto \color{blue}{\left(-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    7. Step-by-step derivation
      1. mul-1-neg68.6%

        \[\leadsto \color{blue}{\left(-d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      2. distribute-rgt-neg-in68.6%

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

        \[\leadsto \left(d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      4. sqr-pow68.6%

        \[\leadsto \left(d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      5. rem-sqrt-square68.6%

        \[\leadsto \left(d \cdot \left(-\color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      6. metadata-eval68.6%

        \[\leadsto \left(d \cdot \left(-\left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right|\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      7. sqr-pow68.5%

        \[\leadsto \left(d \cdot \left(-\left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right|\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      8. fabs-sqr68.5%

        \[\leadsto \left(d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      9. sqr-pow68.6%

        \[\leadsto \left(d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{-0.5}}\right)\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    8. Simplified68.6%

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

    if -4.80000000000000022e-235 < h < 4.8000000000000004e-211

    1. Initial program 70.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. Simplified67.3%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def41.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p59.7%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{h}{\ell}, {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot -0.125, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}} \]
    6. Step-by-step derivation
      1. fma-udef61.3%

        \[\leadsto \color{blue}{\left(\frac{h}{\ell} \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot -0.125\right) + 1\right)} \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \]
    7. Applied egg-rr61.3%

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

    if 4.8000000000000004e-211 < h

    1. Initial program 63.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. Simplified61.5%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def22.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p44.3%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/39.1%

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in d around 0 72.3%

      \[\leadsto \color{blue}{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    7. Step-by-step derivation
      1. unpow-172.3%

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

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

        \[\leadsto \left(d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|}\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      4. metadata-eval72.3%

        \[\leadsto \left(d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right|\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      5. sqr-pow72.2%

        \[\leadsto \left(d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right|\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      6. fabs-sqr72.2%

        \[\leadsto \left(d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)}\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      7. sqr-pow72.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -4.8 \cdot 10^{-235}:\\ \;\;\;\;\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{elif}\;h \leq 4.8 \cdot 10^{-211}:\\ \;\;\;\;\left(1 + \frac{h}{\ell} \cdot \left(-0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)\\ \end{array} \]

Alternative 14: 61.4% accurate, 1.5× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;h \leq 1.45 \cdot 10^{-213}:\\ \;\;\;\;\left(1 + \frac{h}{\ell} \cdot \left(-0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (if (<= h 1.45e-213)
   (*
    (+ 1.0 (* (/ h l) (* -0.125 (pow (* D (/ M d)) 2.0))))
    (sqrt (* (/ d l) (/ d h))))
   (*
    (+ 1.0 (* -0.5 (* (/ h l) (pow (* (/ D d) (* M 0.5)) 2.0))))
    (* d (pow (* h l) -0.5)))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= 1.45e-213) {
		tmp = (1.0 + ((h / l) * (-0.125 * pow((D * (M / d)), 2.0)))) * sqrt(((d / l) * (d / h)));
	} else {
		tmp = (1.0 + (-0.5 * ((h / l) * pow(((D / d) * (M * 0.5)), 2.0)))) * (d * pow((h * l), -0.5));
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (h <= 1.45d-213) then
        tmp = (1.0d0 + ((h / l) * ((-0.125d0) * ((d_1 * (m / d)) ** 2.0d0)))) * sqrt(((d / l) * (d / h)))
    else
        tmp = (1.0d0 + ((-0.5d0) * ((h / l) * (((d_1 / d) * (m * 0.5d0)) ** 2.0d0)))) * (d * ((h * l) ** (-0.5d0)))
    end if
    code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= 1.45e-213) {
		tmp = (1.0 + ((h / l) * (-0.125 * Math.pow((D * (M / d)), 2.0)))) * Math.sqrt(((d / l) * (d / h)));
	} else {
		tmp = (1.0 + (-0.5 * ((h / l) * Math.pow(((D / d) * (M * 0.5)), 2.0)))) * (d * Math.pow((h * l), -0.5));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if h <= 1.45e-213:
		tmp = (1.0 + ((h / l) * (-0.125 * math.pow((D * (M / d)), 2.0)))) * math.sqrt(((d / l) * (d / h)))
	else:
		tmp = (1.0 + (-0.5 * ((h / l) * math.pow(((D / d) * (M * 0.5)), 2.0)))) * (d * math.pow((h * l), -0.5))
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (h <= 1.45e-213)
		tmp = Float64(Float64(1.0 + Float64(Float64(h / l) * Float64(-0.125 * (Float64(D * Float64(M / d)) ^ 2.0)))) * sqrt(Float64(Float64(d / l) * Float64(d / h))));
	else
		tmp = Float64(Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M * 0.5)) ^ 2.0)))) * Float64(d * (Float64(h * l) ^ -0.5)));
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (h <= 1.45e-213)
		tmp = (1.0 + ((h / l) * (-0.125 * ((D * (M / d)) ^ 2.0)))) * sqrt(((d / l) * (d / h)));
	else
		tmp = (1.0 + (-0.5 * ((h / l) * (((D / d) * (M * 0.5)) ^ 2.0)))) * (d * ((h * l) ^ -0.5));
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := If[LessEqual[h, 1.45e-213], N[(N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.125 * N[Power[N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq 1.45 \cdot 10^{-213}:\\
\;\;\;\;\left(1 + \frac{h}{\ell} \cdot \left(-0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if h < 1.45e-213

    1. Initial program 65.3%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def33.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p54.2%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{h}{\ell}, {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot -0.125, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}} \]
    6. Step-by-step derivation
      1. fma-udef54.6%

        \[\leadsto \color{blue}{\left(\frac{h}{\ell} \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot -0.125\right) + 1\right)} \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \]
    7. Applied egg-rr54.6%

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

    if 1.45e-213 < h

    1. Initial program 63.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. Simplified61.5%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def22.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p44.3%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/39.1%

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in d around 0 72.3%

      \[\leadsto \color{blue}{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
    7. Step-by-step derivation
      1. unpow-172.3%

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

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

        \[\leadsto \left(d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|}\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      4. metadata-eval72.3%

        \[\leadsto \left(d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right|\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      5. sqr-pow72.2%

        \[\leadsto \left(d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right|\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      6. fabs-sqr72.2%

        \[\leadsto \left(d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)}\right) \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \]
      7. sqr-pow72.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq 1.45 \cdot 10^{-213}:\\ \;\;\;\;\left(1 + \frac{h}{\ell} \cdot \left(-0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)\\ \end{array} \]

Alternative 15: 50.7% accurate, 1.5× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;h \leq 1.08 \cdot 10^{-247}:\\ \;\;\;\;\left(1 + \frac{h}{\ell} \cdot \left(-0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{elif}\;h \leq 2.2 \cdot 10^{-47}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{else}:\\ \;\;\;\;-0.125 \cdot \left(\frac{D \cdot M}{\frac{d}{D}} \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (if (<= h 1.08e-247)
   (*
    (+ 1.0 (* (/ h l) (* -0.125 (pow (* D (/ M d)) 2.0))))
    (sqrt (* (/ d l) (/ d h))))
   (if (<= h 2.2e-47)
     (/ d (* (sqrt h) (sqrt l)))
     (* -0.125 (* (/ (* D M) (/ d D)) (* M (sqrt (/ h (pow l 3.0)))))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= 1.08e-247) {
		tmp = (1.0 + ((h / l) * (-0.125 * pow((D * (M / d)), 2.0)))) * sqrt(((d / l) * (d / h)));
	} else if (h <= 2.2e-47) {
		tmp = d / (sqrt(h) * sqrt(l));
	} else {
		tmp = -0.125 * (((D * M) / (d / D)) * (M * sqrt((h / pow(l, 3.0)))));
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (h <= 1.08d-247) then
        tmp = (1.0d0 + ((h / l) * ((-0.125d0) * ((d_1 * (m / d)) ** 2.0d0)))) * sqrt(((d / l) * (d / h)))
    else if (h <= 2.2d-47) then
        tmp = d / (sqrt(h) * sqrt(l))
    else
        tmp = (-0.125d0) * (((d_1 * m) / (d / d_1)) * (m * sqrt((h / (l ** 3.0d0)))))
    end if
    code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= 1.08e-247) {
		tmp = (1.0 + ((h / l) * (-0.125 * Math.pow((D * (M / d)), 2.0)))) * Math.sqrt(((d / l) * (d / h)));
	} else if (h <= 2.2e-47) {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	} else {
		tmp = -0.125 * (((D * M) / (d / D)) * (M * Math.sqrt((h / Math.pow(l, 3.0)))));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if h <= 1.08e-247:
		tmp = (1.0 + ((h / l) * (-0.125 * math.pow((D * (M / d)), 2.0)))) * math.sqrt(((d / l) * (d / h)))
	elif h <= 2.2e-47:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	else:
		tmp = -0.125 * (((D * M) / (d / D)) * (M * math.sqrt((h / math.pow(l, 3.0)))))
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (h <= 1.08e-247)
		tmp = Float64(Float64(1.0 + Float64(Float64(h / l) * Float64(-0.125 * (Float64(D * Float64(M / d)) ^ 2.0)))) * sqrt(Float64(Float64(d / l) * Float64(d / h))));
	elseif (h <= 2.2e-47)
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	else
		tmp = Float64(-0.125 * Float64(Float64(Float64(D * M) / Float64(d / D)) * Float64(M * sqrt(Float64(h / (l ^ 3.0))))));
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (h <= 1.08e-247)
		tmp = (1.0 + ((h / l) * (-0.125 * ((D * (M / d)) ^ 2.0)))) * sqrt(((d / l) * (d / h)));
	elseif (h <= 2.2e-47)
		tmp = d / (sqrt(h) * sqrt(l));
	else
		tmp = -0.125 * (((D * M) / (d / D)) * (M * sqrt((h / (l ^ 3.0)))));
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := If[LessEqual[h, 1.08e-247], N[(N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.125 * N[Power[N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 2.2e-47], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.125 * N[(N[(N[(D * M), $MachinePrecision] / N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(M * N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq 1.08 \cdot 10^{-247}:\\
\;\;\;\;\left(1 + \frac{h}{\ell} \cdot \left(-0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\

\mathbf{elif}\;h \leq 2.2 \cdot 10^{-47}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\

\mathbf{else}:\\
\;\;\;\;-0.125 \cdot \left(\frac{D \cdot M}{\frac{d}{D}} \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < 1.08e-247

    1. Initial program 64.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. Simplified63.2%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def31.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p52.9%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{h}{\ell}, {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot -0.125, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}} \]
    6. Step-by-step derivation
      1. fma-udef53.4%

        \[\leadsto \color{blue}{\left(\frac{h}{\ell} \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot -0.125\right) + 1\right)} \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \]
    7. Applied egg-rr53.4%

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

    if 1.08e-247 < h < 2.20000000000000019e-47

    1. Initial program 66.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. Simplified66.6%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow170.1%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{1}} \]
      2. sqrt-div70.1%

        \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
      3. metadata-eval70.1%

        \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
    5. Applied egg-rr70.1%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow170.1%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/70.1%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity70.1%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified70.1%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. sqrt-prod72.6%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    9. Applied egg-rr72.6%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]

    if 2.20000000000000019e-47 < h

    1. Initial program 62.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. Simplified60.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. add-cube-cbrt60.3%

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\sqrt[3]{\sqrt{\frac{d}{\ell}}}\right)}^{3}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Taylor expanded in d around 0 47.3%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    6. Step-by-step derivation
      1. unpow247.3%

        \[\leadsto -0.125 \cdot \left(\frac{{D}^{2} \cdot \color{blue}{\left(M \cdot M\right)}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \]
      2. associate-*l/44.5%

        \[\leadsto -0.125 \cdot \left(\color{blue}{\left(\frac{{D}^{2}}{d} \cdot \left(M \cdot M\right)\right)} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \]
      3. unpow244.5%

        \[\leadsto -0.125 \cdot \left(\left(\frac{\color{blue}{D \cdot D}}{d} \cdot \left(M \cdot M\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \]
      4. associate-*r*47.3%

        \[\leadsto -0.125 \cdot \left(\color{blue}{\left(\left(\frac{D \cdot D}{d} \cdot M\right) \cdot M\right)} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \]
      5. associate-*l*47.4%

        \[\leadsto -0.125 \cdot \color{blue}{\left(\left(\frac{D \cdot D}{d} \cdot M\right) \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
      6. associate-/l*49.9%

        \[\leadsto -0.125 \cdot \left(\left(\color{blue}{\frac{D}{\frac{d}{D}}} \cdot M\right) \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right) \]
      7. associate-*l/54.0%

        \[\leadsto -0.125 \cdot \left(\color{blue}{\frac{D \cdot M}{\frac{d}{D}}} \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right) \]
    7. Simplified54.0%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{D \cdot M}{\frac{d}{D}} \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification56.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq 1.08 \cdot 10^{-247}:\\ \;\;\;\;\left(1 + \frac{h}{\ell} \cdot \left(-0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{elif}\;h \leq 2.2 \cdot 10^{-47}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{else}:\\ \;\;\;\;-0.125 \cdot \left(\frac{D \cdot M}{\frac{d}{D}} \cdot \left(M \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)\\ \end{array} \]

Alternative 16: 51.6% accurate, 1.5× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{if}\;d \leq -2.8 \cdot 10^{+105}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -3.3 \cdot 10^{-137}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.8 \cdot 10^{-305}:\\ \;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\ \mathbf{elif}\;d \leq 10^{-151}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;d \leq 3.4 \cdot 10^{+126}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0
         (*
          (sqrt (/ (* d (/ d l)) h))
          (+
           1.0
           (* -0.5 (* (/ 0.25 l) (/ (* D (* D (* M M))) (* d (/ d h)))))))))
   (if (<= d -2.8e+105)
     (* (sqrt (/ d l)) (sqrt (/ d h)))
     (if (<= d -3.3e-137)
       t_0
       (if (<= d 2.8e-305)
         (/ d (+ (+ 1.0 (sqrt (* h l))) -1.0))
         (if (<= d 1e-151)
           (/ d (* (sqrt h) (sqrt l)))
           (if (<= d 3.4e+126) t_0 (* d (* (pow h -0.5) (pow l -0.5))))))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	double tmp;
	if (d <= -2.8e+105) {
		tmp = sqrt((d / l)) * sqrt((d / h));
	} else if (d <= -3.3e-137) {
		tmp = t_0;
	} else if (d <= 2.8e-305) {
		tmp = d / ((1.0 + sqrt((h * l))) + -1.0);
	} else if (d <= 1e-151) {
		tmp = d / (sqrt(h) * sqrt(l));
	} else if (d <= 3.4e+126) {
		tmp = t_0;
	} else {
		tmp = d * (pow(h, -0.5) * pow(l, -0.5));
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt(((d * (d / l)) / h)) * (1.0d0 + ((-0.5d0) * ((0.25d0 / l) * ((d_1 * (d_1 * (m * m))) / (d * (d / h))))))
    if (d <= (-2.8d+105)) then
        tmp = sqrt((d / l)) * sqrt((d / h))
    else if (d <= (-3.3d-137)) then
        tmp = t_0
    else if (d <= 2.8d-305) then
        tmp = d / ((1.0d0 + sqrt((h * l))) + (-1.0d0))
    else if (d <= 1d-151) then
        tmp = d / (sqrt(h) * sqrt(l))
    else if (d <= 3.4d+126) then
        tmp = t_0
    else
        tmp = d * ((h ** (-0.5d0)) * (l ** (-0.5d0)))
    end if
    code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	double tmp;
	if (d <= -2.8e+105) {
		tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
	} else if (d <= -3.3e-137) {
		tmp = t_0;
	} else if (d <= 2.8e-305) {
		tmp = d / ((1.0 + Math.sqrt((h * l))) + -1.0);
	} else if (d <= 1e-151) {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	} else if (d <= 3.4e+126) {
		tmp = t_0;
	} else {
		tmp = d * (Math.pow(h, -0.5) * Math.pow(l, -0.5));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))))
	tmp = 0
	if d <= -2.8e+105:
		tmp = math.sqrt((d / l)) * math.sqrt((d / h))
	elif d <= -3.3e-137:
		tmp = t_0
	elif d <= 2.8e-305:
		tmp = d / ((1.0 + math.sqrt((h * l))) + -1.0)
	elif d <= 1e-151:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	elif d <= 3.4e+126:
		tmp = t_0
	else:
		tmp = d * (math.pow(h, -0.5) * math.pow(l, -0.5))
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(sqrt(Float64(Float64(d * Float64(d / l)) / h)) * Float64(1.0 + Float64(-0.5 * Float64(Float64(0.25 / l) * Float64(Float64(D * Float64(D * Float64(M * M))) / Float64(d * Float64(d / h)))))))
	tmp = 0.0
	if (d <= -2.8e+105)
		tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h)));
	elseif (d <= -3.3e-137)
		tmp = t_0;
	elseif (d <= 2.8e-305)
		tmp = Float64(d / Float64(Float64(1.0 + sqrt(Float64(h * l))) + -1.0));
	elseif (d <= 1e-151)
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	elseif (d <= 3.4e+126)
		tmp = t_0;
	else
		tmp = Float64(d * Float64((h ^ -0.5) * (l ^ -0.5)));
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	tmp = 0.0;
	if (d <= -2.8e+105)
		tmp = sqrt((d / l)) * sqrt((d / h));
	elseif (d <= -3.3e-137)
		tmp = t_0;
	elseif (d <= 2.8e-305)
		tmp = d / ((1.0 + sqrt((h * l))) + -1.0);
	elseif (d <= 1e-151)
		tmp = d / (sqrt(h) * sqrt(l));
	elseif (d <= 3.4e+126)
		tmp = t_0;
	else
		tmp = d * ((h ^ -0.5) * (l ^ -0.5));
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Sqrt[N[(N[(d * N[(d / l), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(0.25 / l), $MachinePrecision] * N[(N[(D * N[(D * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * N[(d / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.8e+105], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -3.3e-137], t$95$0, If[LessEqual[d, 2.8e-305], N[(d / N[(N[(1.0 + N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1e-151], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.4e+126], t$95$0, N[(d * N[(N[Power[h, -0.5], $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\
\mathbf{if}\;d \leq -2.8 \cdot 10^{+105}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\

\mathbf{elif}\;d \leq -3.3 \cdot 10^{-137}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq 2.8 \cdot 10^{-305}:\\
\;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\

\mathbf{elif}\;d \leq 10^{-151}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\

\mathbf{elif}\;d \leq 3.4 \cdot 10^{+126}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -2.8000000000000001e105

    1. Initial program 71.3%

      \[\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. Simplified69.0%

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

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{1}\right) \]

    if -2.8000000000000001e105 < d < -3.3000000000000002e-137 or 9.9999999999999994e-152 < d < 3.39999999999999989e126

    1. Initial program 74.1%

      \[\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. Simplified74.1%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def29.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p60.1%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/61.9%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot \frac{d}{\ell}}{h}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      4. *-commutative61.9%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in h around 0 48.4%

      \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    7. Step-by-step derivation
      1. associate-*r/48.4%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{0.25 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}}\right) \]
      2. *-commutative48.4%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \frac{0.25 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{\color{blue}{\ell \cdot {d}^{2}}}\right) \]
      3. times-frac54.4%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(\frac{0.25}{\ell} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}\right)}\right) \]
      4. associate-*r*54.5%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2}}\right)\right) \]
      5. associate-/l*54.5%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}}\right)\right) \]
      6. unpow254.5%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}\right)\right) \]
      7. associate-*l*57.6%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{D \cdot \left(D \cdot {M}^{2}\right)}}{\frac{{d}^{2}}{h}}\right)\right) \]
      8. unpow257.6%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \color{blue}{\left(M \cdot M\right)}\right)}{\frac{{d}^{2}}{h}}\right)\right) \]
      9. unpow257.6%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{\frac{\color{blue}{d \cdot d}}{h}}\right)\right) \]
      10. associate-*r/57.6%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{\color{blue}{d \cdot \frac{d}{h}}}\right)\right) \]
    8. Simplified57.6%

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

    if -3.3000000000000002e-137 < d < 2.80000000000000014e-305

    1. Initial program 39.8%

      \[\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. Simplified36.8%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow128.3%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{1}} \]
      2. sqrt-div25.3%

        \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
      3. metadata-eval25.3%

        \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
    5. Applied egg-rr25.3%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow125.3%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/25.3%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity25.3%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified25.3%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u25.3%

        \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    9. Applied egg-rr25.3%

      \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    10. Step-by-step derivation
      1. expm1-udef46.2%

        \[\leadsto \frac{d}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)} - 1}} \]
      2. log1p-udef46.2%

        \[\leadsto \frac{d}{e^{\color{blue}{\log \left(1 + \sqrt{h \cdot \ell}\right)}} - 1} \]
      3. add-exp-log46.2%

        \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right)} - 1} \]
    11. Applied egg-rr46.2%

      \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right) - 1}} \]

    if 2.80000000000000014e-305 < d < 9.9999999999999994e-152

    1. Initial program 59.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. Simplified56.4%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow130.2%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{1}} \]
      2. sqrt-div30.3%

        \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
      3. metadata-eval30.3%

        \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
    5. Applied egg-rr30.3%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow130.3%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/30.2%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity30.2%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified30.2%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. sqrt-prod34.6%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    9. Applied egg-rr34.6%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]

    if 3.39999999999999989e126 < d

    1. Initial program 55.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. Simplified55.7%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow1/275.1%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    5. Applied egg-rr75.1%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    6. Step-by-step derivation
      1. unpow1/275.1%

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
      2. unpow-175.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      3. sqr-pow75.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}} \]
      4. rem-sqrt-square75.1%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|} \]
      5. metadata-eval75.1%

        \[\leadsto d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right| \]
      6. sqr-pow74.7%

        \[\leadsto d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      7. fabs-sqr74.7%

        \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      8. sqr-pow75.1%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    7. Simplified75.1%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. unpow-prod-down81.0%

        \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
    9. Applied egg-rr81.0%

      \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification53.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.8 \cdot 10^{+105}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -3.3 \cdot 10^{-137}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{elif}\;d \leq 2.8 \cdot 10^{-305}:\\ \;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\ \mathbf{elif}\;d \leq 10^{-151}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;d \leq 3.4 \cdot 10^{+126}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\ \end{array} \]

Alternative 17: 49.6% accurate, 1.5× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{if}\;d \leq -4 \cdot 10^{-140}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\ \mathbf{elif}\;d \leq 2.6 \cdot 10^{-153}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;d \leq 3.1 \cdot 10^{+126}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0
         (*
          (sqrt (/ (* d (/ d l)) h))
          (+
           1.0
           (* -0.5 (* (/ 0.25 l) (/ (* D (* D (* M M))) (* d (/ d h)))))))))
   (if (<= d -4e-140)
     t_0
     (if (<= d -2e-310)
       (/ d (+ (+ 1.0 (sqrt (* h l))) -1.0))
       (if (<= d 2.6e-153)
         (/ d (* (sqrt h) (sqrt l)))
         (if (<= d 3.1e+126) t_0 (* d (* (pow h -0.5) (pow l -0.5)))))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	double tmp;
	if (d <= -4e-140) {
		tmp = t_0;
	} else if (d <= -2e-310) {
		tmp = d / ((1.0 + sqrt((h * l))) + -1.0);
	} else if (d <= 2.6e-153) {
		tmp = d / (sqrt(h) * sqrt(l));
	} else if (d <= 3.1e+126) {
		tmp = t_0;
	} else {
		tmp = d * (pow(h, -0.5) * pow(l, -0.5));
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt(((d * (d / l)) / h)) * (1.0d0 + ((-0.5d0) * ((0.25d0 / l) * ((d_1 * (d_1 * (m * m))) / (d * (d / h))))))
    if (d <= (-4d-140)) then
        tmp = t_0
    else if (d <= (-2d-310)) then
        tmp = d / ((1.0d0 + sqrt((h * l))) + (-1.0d0))
    else if (d <= 2.6d-153) then
        tmp = d / (sqrt(h) * sqrt(l))
    else if (d <= 3.1d+126) then
        tmp = t_0
    else
        tmp = d * ((h ** (-0.5d0)) * (l ** (-0.5d0)))
    end if
    code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	double tmp;
	if (d <= -4e-140) {
		tmp = t_0;
	} else if (d <= -2e-310) {
		tmp = d / ((1.0 + Math.sqrt((h * l))) + -1.0);
	} else if (d <= 2.6e-153) {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	} else if (d <= 3.1e+126) {
		tmp = t_0;
	} else {
		tmp = d * (Math.pow(h, -0.5) * Math.pow(l, -0.5));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))))
	tmp = 0
	if d <= -4e-140:
		tmp = t_0
	elif d <= -2e-310:
		tmp = d / ((1.0 + math.sqrt((h * l))) + -1.0)
	elif d <= 2.6e-153:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	elif d <= 3.1e+126:
		tmp = t_0
	else:
		tmp = d * (math.pow(h, -0.5) * math.pow(l, -0.5))
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(sqrt(Float64(Float64(d * Float64(d / l)) / h)) * Float64(1.0 + Float64(-0.5 * Float64(Float64(0.25 / l) * Float64(Float64(D * Float64(D * Float64(M * M))) / Float64(d * Float64(d / h)))))))
	tmp = 0.0
	if (d <= -4e-140)
		tmp = t_0;
	elseif (d <= -2e-310)
		tmp = Float64(d / Float64(Float64(1.0 + sqrt(Float64(h * l))) + -1.0));
	elseif (d <= 2.6e-153)
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	elseif (d <= 3.1e+126)
		tmp = t_0;
	else
		tmp = Float64(d * Float64((h ^ -0.5) * (l ^ -0.5)));
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	tmp = 0.0;
	if (d <= -4e-140)
		tmp = t_0;
	elseif (d <= -2e-310)
		tmp = d / ((1.0 + sqrt((h * l))) + -1.0);
	elseif (d <= 2.6e-153)
		tmp = d / (sqrt(h) * sqrt(l));
	elseif (d <= 3.1e+126)
		tmp = t_0;
	else
		tmp = d * ((h ^ -0.5) * (l ^ -0.5));
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Sqrt[N[(N[(d * N[(d / l), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(0.25 / l), $MachinePrecision] * N[(N[(D * N[(D * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * N[(d / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4e-140], t$95$0, If[LessEqual[d, -2e-310], N[(d / N[(N[(1.0 + N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.6e-153], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.1e+126], t$95$0, N[(d * N[(N[Power[h, -0.5], $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\
\mathbf{if}\;d \leq -4 \cdot 10^{-140}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\

\mathbf{elif}\;d \leq 2.6 \cdot 10^{-153}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\

\mathbf{elif}\;d \leq 3.1 \cdot 10^{+126}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -3.9999999999999999e-140 or 2.6000000000000001e-153 < d < 3.1e126

    1. Initial program 73.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. Simplified72.5%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def31.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p59.1%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/56.5%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot \frac{d}{\ell}}{h}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      4. *-commutative56.5%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in h around 0 40.1%

      \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    7. Step-by-step derivation
      1. associate-*r/40.1%

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

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

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(\frac{0.25}{\ell} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}\right)}\right) \]
      4. associate-*r*44.3%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2}}\right)\right) \]
      5. associate-/l*42.9%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}}\right)\right) \]
      6. unpow242.9%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}\right)\right) \]
      7. associate-*l*46.6%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{D \cdot \left(D \cdot {M}^{2}\right)}}{\frac{{d}^{2}}{h}}\right)\right) \]
      8. unpow246.6%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \color{blue}{\left(M \cdot M\right)}\right)}{\frac{{d}^{2}}{h}}\right)\right) \]
      9. unpow246.6%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{\frac{\color{blue}{d \cdot d}}{h}}\right)\right) \]
      10. associate-*r/47.3%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{\color{blue}{d \cdot \frac{d}{h}}}\right)\right) \]
    8. Simplified47.3%

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

    if -3.9999999999999999e-140 < d < -1.999999999999994e-310

    1. Initial program 41.1%

      \[\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. Simplified38.0%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow129.1%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{1}} \]
      2. sqrt-div26.1%

        \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
      3. metadata-eval26.1%

        \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
    5. Applied egg-rr26.1%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow126.1%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/26.1%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity26.1%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified26.1%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u26.1%

        \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    9. Applied egg-rr26.1%

      \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    10. Step-by-step derivation
      1. expm1-udef47.6%

        \[\leadsto \frac{d}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)} - 1}} \]
      2. log1p-udef47.6%

        \[\leadsto \frac{d}{e^{\color{blue}{\log \left(1 + \sqrt{h \cdot \ell}\right)}} - 1} \]
      3. add-exp-log47.6%

        \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right)} - 1} \]
    11. Applied egg-rr47.6%

      \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right) - 1}} \]

    if -1.999999999999994e-310 < d < 2.6000000000000001e-153

    1. Initial program 58.3%

      \[\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. Simplified55.2%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow129.6%

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

        \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
      3. metadata-eval29.6%

        \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
    5. Applied egg-rr29.6%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow129.6%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/29.6%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity29.6%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified29.6%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. sqrt-prod33.9%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    9. Applied egg-rr33.9%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]

    if 3.1e126 < d

    1. Initial program 55.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. Simplified55.7%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow1/275.1%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    5. Applied egg-rr75.1%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    6. Step-by-step derivation
      1. unpow1/275.1%

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
      2. unpow-175.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      3. sqr-pow75.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}} \]
      4. rem-sqrt-square75.1%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|} \]
      5. metadata-eval75.1%

        \[\leadsto d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right| \]
      6. sqr-pow74.7%

        \[\leadsto d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      7. fabs-sqr74.7%

        \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      8. sqr-pow75.1%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    7. Simplified75.1%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. unpow-prod-down81.0%

        \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
    9. Applied egg-rr81.0%

      \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification49.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4 \cdot 10^{-140}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\ \mathbf{elif}\;d \leq 2.6 \cdot 10^{-153}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;d \leq 3.1 \cdot 10^{+126}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)\\ \end{array} \]

Alternative 18: 49.6% accurate, 1.6× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{if}\;d \leq -2.8 \cdot 10^{-143}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\ \mathbf{elif}\;d \leq 1.48 \cdot 10^{-153} \lor \neg \left(d \leq 3.2 \cdot 10^{+126}\right):\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0
         (*
          (sqrt (/ (* d (/ d l)) h))
          (+
           1.0
           (* -0.5 (* (/ 0.25 l) (/ (* D (* D (* M M))) (* d (/ d h)))))))))
   (if (<= d -2.8e-143)
     t_0
     (if (<= d -2e-310)
       (/ d (+ (+ 1.0 (sqrt (* h l))) -1.0))
       (if (or (<= d 1.48e-153) (not (<= d 3.2e+126)))
         (/ d (* (sqrt h) (sqrt l)))
         t_0)))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	double tmp;
	if (d <= -2.8e-143) {
		tmp = t_0;
	} else if (d <= -2e-310) {
		tmp = d / ((1.0 + sqrt((h * l))) + -1.0);
	} else if ((d <= 1.48e-153) || !(d <= 3.2e+126)) {
		tmp = d / (sqrt(h) * sqrt(l));
	} else {
		tmp = t_0;
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt(((d * (d / l)) / h)) * (1.0d0 + ((-0.5d0) * ((0.25d0 / l) * ((d_1 * (d_1 * (m * m))) / (d * (d / h))))))
    if (d <= (-2.8d-143)) then
        tmp = t_0
    else if (d <= (-2d-310)) then
        tmp = d / ((1.0d0 + sqrt((h * l))) + (-1.0d0))
    else if ((d <= 1.48d-153) .or. (.not. (d <= 3.2d+126))) then
        tmp = d / (sqrt(h) * sqrt(l))
    else
        tmp = t_0
    end if
    code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	double tmp;
	if (d <= -2.8e-143) {
		tmp = t_0;
	} else if (d <= -2e-310) {
		tmp = d / ((1.0 + Math.sqrt((h * l))) + -1.0);
	} else if ((d <= 1.48e-153) || !(d <= 3.2e+126)) {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	} else {
		tmp = t_0;
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))))
	tmp = 0
	if d <= -2.8e-143:
		tmp = t_0
	elif d <= -2e-310:
		tmp = d / ((1.0 + math.sqrt((h * l))) + -1.0)
	elif (d <= 1.48e-153) or not (d <= 3.2e+126):
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	else:
		tmp = t_0
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(sqrt(Float64(Float64(d * Float64(d / l)) / h)) * Float64(1.0 + Float64(-0.5 * Float64(Float64(0.25 / l) * Float64(Float64(D * Float64(D * Float64(M * M))) / Float64(d * Float64(d / h)))))))
	tmp = 0.0
	if (d <= -2.8e-143)
		tmp = t_0;
	elseif (d <= -2e-310)
		tmp = Float64(d / Float64(Float64(1.0 + sqrt(Float64(h * l))) + -1.0));
	elseif ((d <= 1.48e-153) || !(d <= 3.2e+126))
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	else
		tmp = t_0;
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	tmp = 0.0;
	if (d <= -2.8e-143)
		tmp = t_0;
	elseif (d <= -2e-310)
		tmp = d / ((1.0 + sqrt((h * l))) + -1.0);
	elseif ((d <= 1.48e-153) || ~((d <= 3.2e+126)))
		tmp = d / (sqrt(h) * sqrt(l));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Sqrt[N[(N[(d * N[(d / l), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(0.25 / l), $MachinePrecision] * N[(N[(D * N[(D * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * N[(d / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.8e-143], t$95$0, If[LessEqual[d, -2e-310], N[(d / N[(N[(1.0 + N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d, 1.48e-153], N[Not[LessEqual[d, 3.2e+126]], $MachinePrecision]], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\
\mathbf{if}\;d \leq -2.8 \cdot 10^{-143}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\

\mathbf{elif}\;d \leq 1.48 \cdot 10^{-153} \lor \neg \left(d \leq 3.2 \cdot 10^{+126}\right):\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.7999999999999999e-143 or 1.47999999999999995e-153 < d < 3.1999999999999998e126

    1. Initial program 73.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. Simplified72.5%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def31.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p59.1%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/56.5%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot \frac{d}{\ell}}{h}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      4. *-commutative56.5%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in h around 0 40.1%

      \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    7. Step-by-step derivation
      1. associate-*r/40.1%

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

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

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(\frac{0.25}{\ell} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}\right)}\right) \]
      4. associate-*r*44.3%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2}}\right)\right) \]
      5. associate-/l*42.9%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}}\right)\right) \]
      6. unpow242.9%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}\right)\right) \]
      7. associate-*l*46.6%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{D \cdot \left(D \cdot {M}^{2}\right)}}{\frac{{d}^{2}}{h}}\right)\right) \]
      8. unpow246.6%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \color{blue}{\left(M \cdot M\right)}\right)}{\frac{{d}^{2}}{h}}\right)\right) \]
      9. unpow246.6%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{\frac{\color{blue}{d \cdot d}}{h}}\right)\right) \]
      10. associate-*r/47.3%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{\color{blue}{d \cdot \frac{d}{h}}}\right)\right) \]
    8. Simplified47.3%

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

    if -2.7999999999999999e-143 < d < -1.999999999999994e-310

    1. Initial program 41.1%

      \[\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. Simplified38.0%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow129.1%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{1}} \]
      2. sqrt-div26.1%

        \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
      3. metadata-eval26.1%

        \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
    5. Applied egg-rr26.1%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow126.1%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/26.1%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity26.1%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified26.1%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u26.1%

        \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    9. Applied egg-rr26.1%

      \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    10. Step-by-step derivation
      1. expm1-udef47.6%

        \[\leadsto \frac{d}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)} - 1}} \]
      2. log1p-udef47.6%

        \[\leadsto \frac{d}{e^{\color{blue}{\log \left(1 + \sqrt{h \cdot \ell}\right)}} - 1} \]
      3. add-exp-log47.6%

        \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right)} - 1} \]
    11. Applied egg-rr47.6%

      \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right) - 1}} \]

    if -1.999999999999994e-310 < d < 1.47999999999999995e-153 or 3.1999999999999998e126 < d

    1. Initial program 57.3%

      \[\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. Simplified55.4%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow148.3%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{1}} \]
      2. sqrt-div48.3%

        \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
      3. metadata-eval48.3%

        \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
    5. Applied egg-rr48.3%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow148.3%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/48.2%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity48.2%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified48.2%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. sqrt-prod53.1%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    9. Applied egg-rr53.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.8 \cdot 10^{-143}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\ \mathbf{elif}\;d \leq 1.48 \cdot 10^{-153} \lor \neg \left(d \leq 3.2 \cdot 10^{+126}\right):\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \end{array} \]

Alternative 19: 47.5% accurate, 2.4× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{h \cdot \ell}\\ t_1 := \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{if}\;d \leq -1.65 \cdot 10^{-143}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-276}:\\ \;\;\;\;\frac{d}{\left(1 + t_0\right) + -1}\\ \mathbf{elif}\;d \leq 2.2 \cdot 10^{-152}:\\ \;\;\;\;d \cdot \frac{1}{t_0}\\ \mathbf{elif}\;d \leq 3.2 \cdot 10^{+126}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (* h l)))
        (t_1
         (*
          (sqrt (/ (* d (/ d l)) h))
          (+
           1.0
           (* -0.5 (* (/ 0.25 l) (/ (* D (* D (* M M))) (* d (/ d h)))))))))
   (if (<= d -1.65e-143)
     t_1
     (if (<= d -2e-276)
       (/ d (+ (+ 1.0 t_0) -1.0))
       (if (<= d 2.2e-152)
         (* d (/ 1.0 t_0))
         (if (<= d 3.2e+126) t_1 (* d (pow (* h l) -0.5))))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((h * l));
	double t_1 = sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	double tmp;
	if (d <= -1.65e-143) {
		tmp = t_1;
	} else if (d <= -2e-276) {
		tmp = d / ((1.0 + t_0) + -1.0);
	} else if (d <= 2.2e-152) {
		tmp = d * (1.0 / t_0);
	} else if (d <= 3.2e+126) {
		tmp = t_1;
	} else {
		tmp = d * pow((h * l), -0.5);
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = sqrt((h * l))
    t_1 = sqrt(((d * (d / l)) / h)) * (1.0d0 + ((-0.5d0) * ((0.25d0 / l) * ((d_1 * (d_1 * (m * m))) / (d * (d / h))))))
    if (d <= (-1.65d-143)) then
        tmp = t_1
    else if (d <= (-2d-276)) then
        tmp = d / ((1.0d0 + t_0) + (-1.0d0))
    else if (d <= 2.2d-152) then
        tmp = d * (1.0d0 / t_0)
    else if (d <= 3.2d+126) then
        tmp = t_1
    else
        tmp = d * ((h * l) ** (-0.5d0))
    end if
    code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt((h * l));
	double t_1 = Math.sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	double tmp;
	if (d <= -1.65e-143) {
		tmp = t_1;
	} else if (d <= -2e-276) {
		tmp = d / ((1.0 + t_0) + -1.0);
	} else if (d <= 2.2e-152) {
		tmp = d * (1.0 / t_0);
	} else if (d <= 3.2e+126) {
		tmp = t_1;
	} else {
		tmp = d * Math.pow((h * l), -0.5);
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt((h * l))
	t_1 = math.sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))))
	tmp = 0
	if d <= -1.65e-143:
		tmp = t_1
	elif d <= -2e-276:
		tmp = d / ((1.0 + t_0) + -1.0)
	elif d <= 2.2e-152:
		tmp = d * (1.0 / t_0)
	elif d <= 3.2e+126:
		tmp = t_1
	else:
		tmp = d * math.pow((h * l), -0.5)
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(h * l))
	t_1 = Float64(sqrt(Float64(Float64(d * Float64(d / l)) / h)) * Float64(1.0 + Float64(-0.5 * Float64(Float64(0.25 / l) * Float64(Float64(D * Float64(D * Float64(M * M))) / Float64(d * Float64(d / h)))))))
	tmp = 0.0
	if (d <= -1.65e-143)
		tmp = t_1;
	elseif (d <= -2e-276)
		tmp = Float64(d / Float64(Float64(1.0 + t_0) + -1.0));
	elseif (d <= 2.2e-152)
		tmp = Float64(d * Float64(1.0 / t_0));
	elseif (d <= 3.2e+126)
		tmp = t_1;
	else
		tmp = Float64(d * (Float64(h * l) ^ -0.5));
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt((h * l));
	t_1 = sqrt(((d * (d / l)) / h)) * (1.0 + (-0.5 * ((0.25 / l) * ((D * (D * (M * M))) / (d * (d / h))))));
	tmp = 0.0;
	if (d <= -1.65e-143)
		tmp = t_1;
	elseif (d <= -2e-276)
		tmp = d / ((1.0 + t_0) + -1.0);
	elseif (d <= 2.2e-152)
		tmp = d * (1.0 / t_0);
	elseif (d <= 3.2e+126)
		tmp = t_1;
	else
		tmp = d * ((h * l) ^ -0.5);
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(N[(d * N[(d / l), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(0.25 / l), $MachinePrecision] * N[(N[(D * N[(D * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * N[(d / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.65e-143], t$95$1, If[LessEqual[d, -2e-276], N[(d / N[(N[(1.0 + t$95$0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.2e-152], N[(d * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.2e+126], t$95$1, N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{h \cdot \ell}\\
t_1 := \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\
\mathbf{if}\;d \leq -1.65 \cdot 10^{-143}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;d \leq -2 \cdot 10^{-276}:\\
\;\;\;\;\frac{d}{\left(1 + t_0\right) + -1}\\

\mathbf{elif}\;d \leq 2.2 \cdot 10^{-152}:\\
\;\;\;\;d \cdot \frac{1}{t_0}\\

\mathbf{elif}\;d \leq 3.2 \cdot 10^{+126}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.65e-143 or 2.19999999999999985e-152 < d < 3.1999999999999998e126

    1. Initial program 73.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. Simplified72.5%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def31.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p59.1%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. associate-*l/56.5%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot \frac{d}{\ell}}{h}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      4. *-commutative56.5%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    6. Taylor expanded in h around 0 40.1%

      \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    7. Step-by-step derivation
      1. associate-*r/40.1%

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

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

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(\frac{0.25}{\ell} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}\right)}\right) \]
      4. associate-*r*44.3%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2}}\right)\right) \]
      5. associate-/l*42.9%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}}\right)\right) \]
      6. unpow242.9%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}\right)\right) \]
      7. associate-*l*46.6%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{\color{blue}{D \cdot \left(D \cdot {M}^{2}\right)}}{\frac{{d}^{2}}{h}}\right)\right) \]
      8. unpow246.6%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \color{blue}{\left(M \cdot M\right)}\right)}{\frac{{d}^{2}}{h}}\right)\right) \]
      9. unpow246.6%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{\frac{\color{blue}{d \cdot d}}{h}}\right)\right) \]
      10. associate-*r/47.3%

        \[\leadsto \sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{\color{blue}{d \cdot \frac{d}{h}}}\right)\right) \]
    8. Simplified47.3%

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

    if -1.65e-143 < d < -2e-276

    1. Initial program 44.1%

      \[\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.8%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow123.8%

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

        \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
      3. metadata-eval19.6%

        \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
    5. Applied egg-rr19.6%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow119.6%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/19.6%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity19.6%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified19.6%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u19.6%

        \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    9. Applied egg-rr19.6%

      \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    10. Step-by-step derivation
      1. expm1-udef49.5%

        \[\leadsto \frac{d}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)} - 1}} \]
      2. log1p-udef49.5%

        \[\leadsto \frac{d}{e^{\color{blue}{\log \left(1 + \sqrt{h \cdot \ell}\right)}} - 1} \]
      3. add-exp-log49.5%

        \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right)} - 1} \]
    11. Applied egg-rr49.5%

      \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right) - 1}} \]

    if -2e-276 < d < 2.19999999999999985e-152

    1. Initial program 54.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. Simplified51.6%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-un-lft-identity31.7%

        \[\leadsto d \cdot \color{blue}{\left(1 \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. sqrt-div31.8%

        \[\leadsto d \cdot \left(1 \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right) \]
      3. metadata-eval31.8%

        \[\leadsto d \cdot \left(1 \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right) \]
    5. Applied egg-rr31.8%

      \[\leadsto d \cdot \color{blue}{\left(1 \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)} \]
    6. Step-by-step derivation
      1. *-lft-identity31.8%

        \[\leadsto d \cdot \color{blue}{\frac{1}{\sqrt{h \cdot \ell}}} \]
    7. Simplified31.8%

      \[\leadsto d \cdot \color{blue}{\frac{1}{\sqrt{h \cdot \ell}}} \]

    if 3.1999999999999998e126 < d

    1. Initial program 55.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. Simplified55.7%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow1/275.1%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    5. Applied egg-rr75.1%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    6. Step-by-step derivation
      1. unpow1/275.1%

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
      2. unpow-175.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      3. sqr-pow75.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}} \]
      4. rem-sqrt-square75.1%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|} \]
      5. metadata-eval75.1%

        \[\leadsto d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right| \]
      6. sqr-pow74.7%

        \[\leadsto d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      7. fabs-sqr74.7%

        \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      8. sqr-pow75.1%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    7. Simplified75.1%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification47.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.65 \cdot 10^{-143}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-276}:\\ \;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\ \mathbf{elif}\;d \leq 2.2 \cdot 10^{-152}:\\ \;\;\;\;d \cdot \frac{1}{\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;d \leq 3.2 \cdot 10^{+126}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{0.25}{\ell} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot \frac{d}{h}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \end{array} \]

Alternative 20: 32.0% accurate, 3.0× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;h \leq -3.8 \cdot 10^{-249}:\\ \;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (if (<= h -3.8e-249)
   (/ d (+ (+ 1.0 (sqrt (* h l))) -1.0))
   (* d (sqrt (/ 1.0 (* h l))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= -3.8e-249) {
		tmp = d / ((1.0 + sqrt((h * l))) + -1.0);
	} else {
		tmp = d * sqrt((1.0 / (h * l)));
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (h <= (-3.8d-249)) then
        tmp = d / ((1.0d0 + sqrt((h * l))) + (-1.0d0))
    else
        tmp = d * sqrt((1.0d0 / (h * l)))
    end if
    code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= -3.8e-249) {
		tmp = d / ((1.0 + Math.sqrt((h * l))) + -1.0);
	} else {
		tmp = d * Math.sqrt((1.0 / (h * l)));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if h <= -3.8e-249:
		tmp = d / ((1.0 + math.sqrt((h * l))) + -1.0)
	else:
		tmp = d * math.sqrt((1.0 / (h * l)))
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (h <= -3.8e-249)
		tmp = Float64(d / Float64(Float64(1.0 + sqrt(Float64(h * l))) + -1.0));
	else
		tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * l))));
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (h <= -3.8e-249)
		tmp = d / ((1.0 + sqrt((h * l))) + -1.0);
	else
		tmp = d * sqrt((1.0 / (h * l)));
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := If[LessEqual[h, -3.8e-249], N[(d / N[(N[(1.0 + N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -3.8 \cdot 10^{-249}:\\
\;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if h < -3.8000000000000001e-249

    1. Initial program 64.5%

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow114.4%

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

        \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
      3. metadata-eval13.6%

        \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
    5. Applied egg-rr13.6%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow113.6%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/13.6%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity13.6%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified13.6%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u13.6%

        \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    9. Applied egg-rr13.6%

      \[\leadsto \frac{d}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)\right)}} \]
    10. Step-by-step derivation
      1. expm1-udef24.6%

        \[\leadsto \frac{d}{\color{blue}{e^{\mathsf{log1p}\left(\sqrt{h \cdot \ell}\right)} - 1}} \]
      2. log1p-udef24.6%

        \[\leadsto \frac{d}{e^{\color{blue}{\log \left(1 + \sqrt{h \cdot \ell}\right)}} - 1} \]
      3. add-exp-log24.6%

        \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right)} - 1} \]
    11. Applied egg-rr24.6%

      \[\leadsto \frac{d}{\color{blue}{\left(1 + \sqrt{h \cdot \ell}\right) - 1}} \]

    if -3.8000000000000001e-249 < h

    1. Initial program 64.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. Simplified62.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -3.8 \cdot 10^{-249}:\\ \;\;\;\;\frac{d}{\left(1 + \sqrt{h \cdot \ell}\right) + -1}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \end{array} \]

Alternative 21: 27.2% accurate, 3.1× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ d \cdot \sqrt{\frac{1}{h \cdot \ell}} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D) :precision binary64 (* d (sqrt (/ 1.0 (* h l)))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d * sqrt((1.0 / (h * l)));
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    code = d * sqrt((1.0d0 / (h * l)))
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.sqrt((1.0 / (h * l)));
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * math.sqrt((1.0 / (h * l)))
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d * sqrt(Float64(1.0 / Float64(h * l))))
end
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt((1.0 / (h * l)));
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot \sqrt{\frac{1}{h \cdot \ell}}
\end{array}
Derivation
  1. Initial program 64.3%

    \[\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. Simplified63.0%

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

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  4. Final simplification27.5%

    \[\leadsto d \cdot \sqrt{\frac{1}{h \cdot \ell}} \]

Alternative 22: 27.1% accurate, 3.1× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ d \cdot {\left(h \cdot \ell\right)}^{-0.5} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D) :precision binary64 (* d (pow (* h l) -0.5)))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d * pow((h * l), -0.5);
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    code = d * ((h * l) ** (-0.5d0))
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.pow((h * l), -0.5);
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * math.pow((h * l), -0.5)
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d * (Float64(h * l) ^ -0.5))
end
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d * ((h * l) ^ -0.5);
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot {\left(h \cdot \ell\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 64.3%

    \[\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. Simplified63.0%

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

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  4. Step-by-step derivation
    1. pow1/227.5%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
  5. Applied egg-rr27.5%

    \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
  6. Step-by-step derivation
    1. unpow1/227.5%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    2. unpow-127.5%

      \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
    3. sqr-pow27.5%

      \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}} \]
    4. rem-sqrt-square27.1%

      \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right|} \]
    5. metadata-eval27.1%

      \[\leadsto d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right| \]
    6. sqr-pow27.0%

      \[\leadsto d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
    7. fabs-sqr27.0%

      \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
    8. sqr-pow27.1%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  7. Simplified27.1%

    \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  8. Final simplification27.1%

    \[\leadsto d \cdot {\left(h \cdot \ell\right)}^{-0.5} \]

Alternative 23: 27.1% accurate, 3.2× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \frac{d}{\sqrt{h \cdot \ell}} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D) :precision binary64 (/ d (sqrt (* h l))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d / sqrt((h * l));
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    code = d / sqrt((h * l))
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return d / Math.sqrt((h * l));
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d / math.sqrt((h * l))
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d / sqrt(Float64(h * l)))
end
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d / sqrt((h * l));
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\frac{d}{\sqrt{h \cdot \ell}}
\end{array}
Derivation
  1. Initial program 64.3%

    \[\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. Simplified63.0%

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

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  4. Step-by-step derivation
    1. pow127.5%

      \[\leadsto \color{blue}{{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{1}} \]
    2. sqrt-div27.1%

      \[\leadsto {\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)}^{1} \]
    3. metadata-eval27.1%

      \[\leadsto {\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)}^{1} \]
  5. Applied egg-rr27.1%

    \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
  6. Step-by-step derivation
    1. unpow127.1%

      \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
    2. associate-*r/27.1%

      \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
    3. *-rgt-identity27.1%

      \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
  7. Simplified27.1%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  8. Final simplification27.1%

    \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]

Reproduce

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