Henrywood and Agarwal, Equation (12)

Percentage Accurate: 65.5% → 74.1%
Time: 39.2s
Alternatives: 12
Speedup: 2.6×

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 12 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: 65.5% 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: 74.1% accurate, 0.5× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h}}\\ t_1 := \sqrt{\frac{d}{\ell}}\\ \mathbf{if}\;d \leq -5.2 \cdot 10^{-303}:\\ \;\;\;\;{\left({\left(-d\right)}^{0.25} \cdot {\left(\frac{-1}{\ell}\right)}^{0.25}\right)}^{2} \cdot \left(t_0 \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot -0.125, 1\right)\right)\\ \mathbf{elif}\;d \leq 8 \cdot 10^{-148}:\\ \;\;\;\;d \cdot \left(\mathsf{fma}\left(-0.125, \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right), 1\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\ \mathbf{elif}\;d \leq 1.65 \cdot 10^{+88}:\\ \;\;\;\;\left(t_0 \cdot t_1\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \left(\frac{D}{\frac{d}{\frac{M}{\ell}}} \cdot \left(h \cdot \frac{D}{\frac{d}{M}}\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t_1 \cdot \frac{\sqrt{d}}{\sqrt{h}}\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 should be positive before calling this function
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 h))) (t_1 (sqrt (/ d l))))
   (if (<= d -5.2e-303)
     (*
      (pow (* (pow (- d) 0.25) (pow (/ -1.0 l) 0.25)) 2.0)
      (* t_0 (fma (/ h l) (* (pow (* D (/ M d)) 2.0) -0.125) 1.0)))
     (if (<= d 8e-148)
       (*
        d
        (*
         (fma -0.125 (* (* h M) (* (/ D d) (* M (/ (/ D d) l)))) 1.0)
         (sqrt (/ 1.0 (* l h)))))
       (if (<= d 1.65e+88)
         (*
          (* t_0 t_1)
          (- 1.0 (* 0.5 (* 0.25 (* (/ D (/ d (/ M l))) (* h (/ D (/ d M))))))))
         (*
          (* t_1 (/ (sqrt d) (sqrt h)))
          (- 1.0 (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M 2.0)) 2.0))))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / h));
	double t_1 = sqrt((d / l));
	double tmp;
	if (d <= -5.2e-303) {
		tmp = pow((pow(-d, 0.25) * pow((-1.0 / l), 0.25)), 2.0) * (t_0 * fma((h / l), (pow((D * (M / d)), 2.0) * -0.125), 1.0));
	} else if (d <= 8e-148) {
		tmp = d * (fma(-0.125, ((h * M) * ((D / d) * (M * ((D / d) / l)))), 1.0) * sqrt((1.0 / (l * h))));
	} else if (d <= 1.65e+88) {
		tmp = (t_0 * t_1) * (1.0 - (0.5 * (0.25 * ((D / (d / (M / l))) * (h * (D / (d / M)))))));
	} else {
		tmp = (t_1 * (sqrt(d) / sqrt(h))) * (1.0 - (0.5 * ((h / l) * pow(((D / d) * (M / 2.0)), 2.0))));
	}
	return tmp;
}
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(d / h))
	t_1 = sqrt(Float64(d / l))
	tmp = 0.0
	if (d <= -5.2e-303)
		tmp = Float64((Float64((Float64(-d) ^ 0.25) * (Float64(-1.0 / l) ^ 0.25)) ^ 2.0) * Float64(t_0 * fma(Float64(h / l), Float64((Float64(D * Float64(M / d)) ^ 2.0) * -0.125), 1.0)));
	elseif (d <= 8e-148)
		tmp = Float64(d * Float64(fma(-0.125, Float64(Float64(h * M) * Float64(Float64(D / d) * Float64(M * Float64(Float64(D / d) / l)))), 1.0) * sqrt(Float64(1.0 / Float64(l * h)))));
	elseif (d <= 1.65e+88)
		tmp = Float64(Float64(t_0 * t_1) * Float64(1.0 - Float64(0.5 * Float64(0.25 * Float64(Float64(D / Float64(d / Float64(M / l))) * Float64(h * Float64(D / Float64(d / M))))))));
	else
		tmp = Float64(Float64(t_1 * Float64(sqrt(d) / sqrt(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 should be positive before calling this function
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 / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -5.2e-303], N[(N[Power[N[(N[Power[(-d), 0.25], $MachinePrecision] * N[Power[N[(-1.0 / l), $MachinePrecision], 0.25], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(t$95$0 * N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.125), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 8e-148], N[(d * N[(N[(-0.125 * N[(N[(h * M), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(M * N[(N[(D / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.65e+88], N[(N[(t$95$0 * t$95$1), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(0.25 * N[(N[(D / N[(d / N[(M / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h * N[(D / N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $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 = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}}\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;d \leq -5.2 \cdot 10^{-303}:\\
\;\;\;\;{\left({\left(-d\right)}^{0.25} \cdot {\left(\frac{-1}{\ell}\right)}^{0.25}\right)}^{2} \cdot \left(t_0 \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot -0.125, 1\right)\right)\\

\mathbf{elif}\;d \leq 8 \cdot 10^{-148}:\\
\;\;\;\;d \cdot \left(\mathsf{fma}\left(-0.125, \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right), 1\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\

\mathbf{elif}\;d \leq 1.65 \cdot 10^{+88}:\\
\;\;\;\;\left(t_0 \cdot t_1\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \left(\frac{D}{\frac{d}{\frac{M}{\ell}}} \cdot \left(h \cdot \frac{D}{\frac{d}{M}}\right)\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(t_1 \cdot \frac{\sqrt{d}}{\sqrt{h}}\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 4 regimes
  2. if d < -5.20000000000000009e-303

    1. Initial program 69.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. Simplified69.4%

      \[\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. fma-udef69.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(e^{0.25 \cdot \color{blue}{\left(\log \left(-1 \cdot d\right) + \log \left(\frac{-1}{\ell}\right)\right)}}\right)}^{2} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot -0.125, 1\right)\right) \]
      2. distribute-lft-in75.1%

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

        \[\leadsto {\left(e^{0.25 \cdot \log \left(-1 \cdot d\right) + \color{blue}{\log \left(\frac{-1}{\ell}\right) \cdot 0.25}}\right)}^{2} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot -0.125, 1\right)\right) \]
      4. exp-sum75.3%

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

        \[\leadsto {\left(e^{\color{blue}{\log \left(-1 \cdot d\right) \cdot 0.25}} \cdot e^{\log \left(\frac{-1}{\ell}\right) \cdot 0.25}\right)}^{2} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot -0.125, 1\right)\right) \]
      6. exp-to-pow75.8%

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

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

        \[\leadsto {\left({\left(-d\right)}^{0.25} \cdot e^{\log \left(\frac{\color{blue}{-1}}{\ell}\right) \cdot 0.25}\right)}^{2} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot -0.125, 1\right)\right) \]
      9. distribute-neg-frac75.8%

        \[\leadsto {\left({\left(-d\right)}^{0.25} \cdot e^{\log \color{blue}{\left(-\frac{1}{\ell}\right)} \cdot 0.25}\right)}^{2} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot -0.125, 1\right)\right) \]
      10. exp-to-pow78.3%

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

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

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

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

    if -5.20000000000000009e-303 < d < 7.99999999999999949e-148

    1. Initial program 47.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. Simplified44.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. Step-by-step derivation
      1. add-log-exp31.8%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative31.8%

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

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

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

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

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

    if 7.99999999999999949e-148 < d < 1.6500000000000002e88

    1. Initial program 85.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. Simplified85.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 M around 0 64.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(\frac{D}{\frac{d}{\frac{M}{\ell}}} \cdot \color{blue}{\frac{D \cdot \left(h \cdot M\right)}{d}}\right) \cdot 0.25\right)\right) \]
    11. Step-by-step derivation
      1. associate-*l/87.3%

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

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

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

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

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

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

    if 1.6500000000000002e88 < d

    1. Initial program 73.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. Simplified73.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. Step-by-step derivation
      1. sqrt-div92.1%

        \[\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) \]
    4. Applied egg-rr92.1%

      \[\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 4 regimes into one program.
  4. Final simplification81.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5.2 \cdot 10^{-303}:\\ \;\;\;\;{\left({\left(-d\right)}^{0.25} \cdot {\left(\frac{-1}{\ell}\right)}^{0.25}\right)}^{2} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot -0.125, 1\right)\right)\\ \mathbf{elif}\;d \leq 8 \cdot 10^{-148}:\\ \;\;\;\;d \cdot \left(\mathsf{fma}\left(-0.125, \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right), 1\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\ \mathbf{elif}\;d \leq 1.65 \cdot 10^{+88}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \left(\frac{D}{\frac{d}{\frac{M}{\ell}}} \cdot \left(h \cdot \frac{D}{\frac{d}{M}}\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{d}}{\sqrt{h}}\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 2: 73.9% accurate, 0.8× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right)\\ t_1 := \sqrt{\frac{d}{\ell}}\\ t_2 := \sqrt{\frac{d}{h}} \cdot t_1\\ \mathbf{if}\;d \leq -1.44 \cdot 10^{-55}:\\ \;\;\;\;t_2 \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot t_0\right)\right)\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{-303}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{-146}:\\ \;\;\;\;d \cdot \left(\mathsf{fma}\left(-0.125, t_0, 1\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\ \mathbf{elif}\;d \leq 3.1 \cdot 10^{+91}:\\ \;\;\;\;t_2 \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \left(\frac{D}{\frac{d}{\frac{M}{\ell}}} \cdot \left(h \cdot \frac{D}{\frac{d}{M}}\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t_1 \cdot \frac{\sqrt{d}}{\sqrt{h}}\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 should be positive before calling this function
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 (* (* h M) (* (/ D d) (* M (/ (/ D d) l)))))
        (t_1 (sqrt (/ d l)))
        (t_2 (* (sqrt (/ d h)) t_1)))
   (if (<= d -1.44e-55)
     (* t_2 (- 1.0 (* 0.5 (* 0.25 t_0))))
     (if (<= d -5.2e-303)
       (*
        (/ d (sqrt (* l h)))
        (- -1.0 (* -0.5 (* (/ h l) (pow (* M (* (/ D d) 0.5)) 2.0)))))
       (if (<= d 1.35e-146)
         (* d (* (fma -0.125 t_0 1.0) (sqrt (/ 1.0 (* l h)))))
         (if (<= d 3.1e+91)
           (*
            t_2
            (-
             1.0
             (* 0.5 (* 0.25 (* (/ D (/ d (/ M l))) (* h (/ D (/ d M))))))))
           (*
            (* t_1 (/ (sqrt d) (sqrt h)))
            (- 1.0 (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M 2.0)) 2.0)))))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = (h * M) * ((D / d) * (M * ((D / d) / l)));
	double t_1 = sqrt((d / l));
	double t_2 = sqrt((d / h)) * t_1;
	double tmp;
	if (d <= -1.44e-55) {
		tmp = t_2 * (1.0 - (0.5 * (0.25 * t_0)));
	} else if (d <= -5.2e-303) {
		tmp = (d / sqrt((l * h))) * (-1.0 - (-0.5 * ((h / l) * pow((M * ((D / d) * 0.5)), 2.0))));
	} else if (d <= 1.35e-146) {
		tmp = d * (fma(-0.125, t_0, 1.0) * sqrt((1.0 / (l * h))));
	} else if (d <= 3.1e+91) {
		tmp = t_2 * (1.0 - (0.5 * (0.25 * ((D / (d / (M / l))) * (h * (D / (d / M)))))));
	} else {
		tmp = (t_1 * (sqrt(d) / sqrt(h))) * (1.0 - (0.5 * ((h / l) * pow(((D / d) * (M / 2.0)), 2.0))));
	}
	return tmp;
}
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(Float64(h * M) * Float64(Float64(D / d) * Float64(M * Float64(Float64(D / d) / l))))
	t_1 = sqrt(Float64(d / l))
	t_2 = Float64(sqrt(Float64(d / h)) * t_1)
	tmp = 0.0
	if (d <= -1.44e-55)
		tmp = Float64(t_2 * Float64(1.0 - Float64(0.5 * Float64(0.25 * t_0))));
	elseif (d <= -5.2e-303)
		tmp = Float64(Float64(d / sqrt(Float64(l * h))) * Float64(-1.0 - Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(Float64(D / d) * 0.5)) ^ 2.0)))));
	elseif (d <= 1.35e-146)
		tmp = Float64(d * Float64(fma(-0.125, t_0, 1.0) * sqrt(Float64(1.0 / Float64(l * h)))));
	elseif (d <= 3.1e+91)
		tmp = Float64(t_2 * Float64(1.0 - Float64(0.5 * Float64(0.25 * Float64(Float64(D / Float64(d / Float64(M / l))) * Float64(h * Float64(D / Float64(d / M))))))));
	else
		tmp = Float64(Float64(t_1 * Float64(sqrt(d) / sqrt(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 should be positive before calling this function
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[(h * M), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(M * N[(N[(D / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[d, -1.44e-55], N[(t$95$2 * N[(1.0 - N[(0.5 * N[(0.25 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5.2e-303], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-1.0 - N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(N[(D / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.35e-146], N[(d * N[(N[(-0.125 * t$95$0 + 1.0), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.1e+91], N[(t$95$2 * N[(1.0 - N[(0.5 * N[(0.25 * N[(N[(D / N[(d / N[(M / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h * N[(D / N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $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 = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right)\\
t_1 := \sqrt{\frac{d}{\ell}}\\
t_2 := \sqrt{\frac{d}{h}} \cdot t_1\\
\mathbf{if}\;d \leq -1.44 \cdot 10^{-55}:\\
\;\;\;\;t_2 \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot t_0\right)\right)\\

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

\mathbf{elif}\;d \leq 1.35 \cdot 10^{-146}:\\
\;\;\;\;d \cdot \left(\mathsf{fma}\left(-0.125, t_0, 1\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\

\mathbf{elif}\;d \leq 3.1 \cdot 10^{+91}:\\
\;\;\;\;t_2 \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \left(\frac{D}{\frac{d}{\frac{M}{\ell}}} \cdot \left(h \cdot \frac{D}{\frac{d}{M}}\right)\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(t_1 \cdot \frac{\sqrt{d}}{\sqrt{h}}\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 5 regimes
  2. if d < -1.43999999999999991e-55

    1. Initial program 81.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. Simplified81.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 M around 0 45.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\color{blue}{\left(\left(\frac{D \cdot D}{d \cdot \left(d \cdot \ell\right)} \cdot M\right) \cdot \left(M \cdot h\right)\right)} \cdot 0.25\right)\right) \]
      9. *-commutative56.6%

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

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

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

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

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

    if -1.43999999999999991e-55 < d < -5.20000000000000009e-303

    1. Initial program 57.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.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. add-log-exp33.6%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative33.6%

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

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

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

        \[\leadsto \log \color{blue}{\left(e^{\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}}}\right)} \]
      2. add-log-exp41.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}}} \]
      3. associate-*l*41.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right) \cdot \left(-d \cdot e^{-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}}\right) \]
      9. unpow1/273.7%

        \[\leadsto \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right) \cdot \left(-d \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}}\right) \]
      10. rec-exp73.7%

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

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

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

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

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

    if -5.20000000000000009e-303 < d < 1.34999999999999997e-146

    1. Initial program 47.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. Simplified44.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. Step-by-step derivation
      1. add-log-exp31.8%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative31.8%

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

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

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

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

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

    if 1.34999999999999997e-146 < d < 3.09999999999999998e91

    1. Initial program 85.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. Simplified85.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 M around 0 64.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(\frac{D}{\frac{d}{\frac{M}{\ell}}} \cdot \color{blue}{\frac{D \cdot \left(h \cdot M\right)}{d}}\right) \cdot 0.25\right)\right) \]
    11. Step-by-step derivation
      1. associate-*l/87.3%

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

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

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

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

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

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

    if 3.09999999999999998e91 < d

    1. Initial program 73.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. Simplified73.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. Step-by-step derivation
      1. sqrt-div92.1%

        \[\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) \]
    4. Applied egg-rr92.1%

      \[\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 5 regimes into one program.
  4. Final simplification81.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.44 \cdot 10^{-55}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \left(\left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right)\right)\right)\right)\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{-303}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{-146}:\\ \;\;\;\;d \cdot \left(\mathsf{fma}\left(-0.125, \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right), 1\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\ \mathbf{elif}\;d \leq 3.1 \cdot 10^{+91}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \left(\frac{D}{\frac{d}{\frac{M}{\ell}}} \cdot \left(h \cdot \frac{D}{\frac{d}{M}}\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{d}}{\sqrt{h}}\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 3: 72.9% accurate, 1.4× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right)\\ t_1 := \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot t_0\right)\right)\\ \mathbf{if}\;d \leq -6.5 \cdot 10^{-57}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{-303}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{elif}\;d \leq 3.7 \cdot 10^{-137} \lor \neg \left(d \leq 1.15 \cdot 10^{+113}\right):\\ \;\;\;\;d \cdot \left(\mathsf{fma}\left(-0.125, t_0, 1\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
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 (* (* h M) (* (/ D d) (* M (/ (/ D d) l)))))
        (t_1
         (* (* (sqrt (/ d h)) (sqrt (/ d l))) (- 1.0 (* 0.5 (* 0.25 t_0))))))
   (if (<= d -6.5e-57)
     t_1
     (if (<= d -5.2e-303)
       (*
        (/ d (sqrt (* l h)))
        (- -1.0 (* -0.5 (* (/ h l) (pow (* M (* (/ D d) 0.5)) 2.0)))))
       (if (or (<= d 3.7e-137) (not (<= d 1.15e+113)))
         (* d (* (fma -0.125 t_0 1.0) (sqrt (/ 1.0 (* l h)))))
         t_1)))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = (h * M) * ((D / d) * (M * ((D / d) / l)));
	double t_1 = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * (0.25 * t_0)));
	double tmp;
	if (d <= -6.5e-57) {
		tmp = t_1;
	} else if (d <= -5.2e-303) {
		tmp = (d / sqrt((l * h))) * (-1.0 - (-0.5 * ((h / l) * pow((M * ((D / d) * 0.5)), 2.0))));
	} else if ((d <= 3.7e-137) || !(d <= 1.15e+113)) {
		tmp = d * (fma(-0.125, t_0, 1.0) * sqrt((1.0 / (l * h))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(Float64(h * M) * Float64(Float64(D / d) * Float64(M * Float64(Float64(D / d) / l))))
	t_1 = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * Float64(0.25 * t_0))))
	tmp = 0.0
	if (d <= -6.5e-57)
		tmp = t_1;
	elseif (d <= -5.2e-303)
		tmp = Float64(Float64(d / sqrt(Float64(l * h))) * Float64(-1.0 - Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(Float64(D / d) * 0.5)) ^ 2.0)))));
	elseif ((d <= 3.7e-137) || !(d <= 1.15e+113))
		tmp = Float64(d * Float64(fma(-0.125, t_0, 1.0) * sqrt(Float64(1.0 / Float64(l * h)))));
	else
		tmp = t_1;
	end
	return tmp
end
NOTE: M should be positive before calling this function
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[(h * M), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(M * N[(N[(D / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(0.25 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -6.5e-57], t$95$1, If[LessEqual[d, -5.2e-303], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-1.0 - N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(N[(D / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d, 3.7e-137], N[Not[LessEqual[d, 1.15e+113]], $MachinePrecision]], N[(d * N[(N[(-0.125 * t$95$0 + 1.0), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right)\\
t_1 := \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot t_0\right)\right)\\
\mathbf{if}\;d \leq -6.5 \cdot 10^{-57}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;d \leq 3.7 \cdot 10^{-137} \lor \neg \left(d \leq 1.15 \cdot 10^{+113}\right):\\
\;\;\;\;d \cdot \left(\mathsf{fma}\left(-0.125, t_0, 1\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -6.49999999999999992e-57 or 3.7e-137 < d < 1.14999999999999998e113

    1. Initial program 84.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. Simplified84.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 M around 0 55.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\color{blue}{\left(\left(\frac{D \cdot D}{d \cdot \left(d \cdot \ell\right)} \cdot M\right) \cdot \left(M \cdot h\right)\right)} \cdot 0.25\right)\right) \]
      9. *-commutative62.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\color{blue}{\left(\left(M \cdot h\right) \cdot \left(\frac{D \cdot D}{d \cdot \left(d \cdot \ell\right)} \cdot M\right)\right)} \cdot 0.25\right)\right) \]
      10. times-frac75.6%

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

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

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

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

    if -6.49999999999999992e-57 < d < -5.20000000000000009e-303

    1. Initial program 57.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.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. add-log-exp33.6%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative33.6%

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

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

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

        \[\leadsto \log \color{blue}{\left(e^{\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}}}\right)} \]
      2. add-log-exp41.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}}} \]
      3. associate-*l*41.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right) \cdot \left(-d \cdot e^{-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}}\right) \]
      9. unpow1/273.7%

        \[\leadsto \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right) \cdot \left(-d \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}}\right) \]
      10. rec-exp73.7%

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

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

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

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

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

    if -5.20000000000000009e-303 < d < 3.7e-137 or 1.14999999999999998e113 < d

    1. Initial program 60.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. Simplified58.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. Step-by-step derivation
      1. add-log-exp32.7%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative32.7%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.5 \cdot 10^{-57}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \left(\left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right)\right)\right)\right)\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{-303}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{elif}\;d \leq 3.7 \cdot 10^{-137} \lor \neg \left(d \leq 1.15 \cdot 10^{+113}\right):\\ \;\;\;\;d \cdot \left(\mathsf{fma}\left(-0.125, \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right), 1\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \left(\left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right)\right)\right)\right)\\ \end{array} \]

Alternative 4: 73.5% accurate, 1.4× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right)\\ t_1 := \sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{if}\;d \leq -1.55 \cdot 10^{-56}:\\ \;\;\;\;t_1 \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot t_0\right)\right)\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{-303}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{elif}\;d \leq 4.2 \cdot 10^{-146} \lor \neg \left(d \leq 9.2 \cdot 10^{+111}\right):\\ \;\;\;\;d \cdot \left(\mathsf{fma}\left(-0.125, t_0, 1\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \left(\frac{D}{\frac{d}{\frac{M}{\ell}}} \cdot \left(h \cdot \frac{D}{\frac{d}{M}}\right)\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
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 (* (* h M) (* (/ D d) (* M (/ (/ D d) l)))))
        (t_1 (* (sqrt (/ d h)) (sqrt (/ d l)))))
   (if (<= d -1.55e-56)
     (* t_1 (- 1.0 (* 0.5 (* 0.25 t_0))))
     (if (<= d -5.2e-303)
       (*
        (/ d (sqrt (* l h)))
        (- -1.0 (* -0.5 (* (/ h l) (pow (* M (* (/ D d) 0.5)) 2.0)))))
       (if (or (<= d 4.2e-146) (not (<= d 9.2e+111)))
         (* d (* (fma -0.125 t_0 1.0) (sqrt (/ 1.0 (* l h)))))
         (*
          t_1
          (-
           1.0
           (* 0.5 (* 0.25 (* (/ D (/ d (/ M l))) (* h (/ D (/ d M)))))))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = (h * M) * ((D / d) * (M * ((D / d) / l)));
	double t_1 = sqrt((d / h)) * sqrt((d / l));
	double tmp;
	if (d <= -1.55e-56) {
		tmp = t_1 * (1.0 - (0.5 * (0.25 * t_0)));
	} else if (d <= -5.2e-303) {
		tmp = (d / sqrt((l * h))) * (-1.0 - (-0.5 * ((h / l) * pow((M * ((D / d) * 0.5)), 2.0))));
	} else if ((d <= 4.2e-146) || !(d <= 9.2e+111)) {
		tmp = d * (fma(-0.125, t_0, 1.0) * sqrt((1.0 / (l * h))));
	} else {
		tmp = t_1 * (1.0 - (0.5 * (0.25 * ((D / (d / (M / l))) * (h * (D / (d / M)))))));
	}
	return tmp;
}
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(Float64(h * M) * Float64(Float64(D / d) * Float64(M * Float64(Float64(D / d) / l))))
	t_1 = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)))
	tmp = 0.0
	if (d <= -1.55e-56)
		tmp = Float64(t_1 * Float64(1.0 - Float64(0.5 * Float64(0.25 * t_0))));
	elseif (d <= -5.2e-303)
		tmp = Float64(Float64(d / sqrt(Float64(l * h))) * Float64(-1.0 - Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(Float64(D / d) * 0.5)) ^ 2.0)))));
	elseif ((d <= 4.2e-146) || !(d <= 9.2e+111))
		tmp = Float64(d * Float64(fma(-0.125, t_0, 1.0) * sqrt(Float64(1.0 / Float64(l * h)))));
	else
		tmp = Float64(t_1 * Float64(1.0 - Float64(0.5 * Float64(0.25 * Float64(Float64(D / Float64(d / Float64(M / l))) * Float64(h * Float64(D / Float64(d / M))))))));
	end
	return tmp
end
NOTE: M should be positive before calling this function
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[(h * M), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(M * N[(N[(D / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.55e-56], N[(t$95$1 * N[(1.0 - N[(0.5 * N[(0.25 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5.2e-303], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-1.0 - N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(N[(D / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d, 4.2e-146], N[Not[LessEqual[d, 9.2e+111]], $MachinePrecision]], N[(d * N[(N[(-0.125 * t$95$0 + 1.0), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 - N[(0.5 * N[(0.25 * N[(N[(D / N[(d / N[(M / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h * N[(D / N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right)\\
t_1 := \sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;d \leq -1.55 \cdot 10^{-56}:\\
\;\;\;\;t_1 \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot t_0\right)\right)\\

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

\mathbf{elif}\;d \leq 4.2 \cdot 10^{-146} \lor \neg \left(d \leq 9.2 \cdot 10^{+111}\right):\\
\;\;\;\;d \cdot \left(\mathsf{fma}\left(-0.125, t_0, 1\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.54999999999999994e-56

    1. Initial program 81.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. Simplified81.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 M around 0 45.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\color{blue}{\left(\left(\frac{D \cdot D}{d \cdot \left(d \cdot \ell\right)} \cdot M\right) \cdot \left(M \cdot h\right)\right)} \cdot 0.25\right)\right) \]
      9. *-commutative56.6%

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

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

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

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

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

    if -1.54999999999999994e-56 < d < -5.20000000000000009e-303

    1. Initial program 57.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.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. add-log-exp33.6%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative33.6%

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

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

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

        \[\leadsto \log \color{blue}{\left(e^{\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}}}\right)} \]
      2. add-log-exp41.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}}} \]
      3. associate-*l*41.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right) \cdot \left(-d \cdot e^{-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}}\right) \]
      9. unpow1/273.7%

        \[\leadsto \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right) \cdot \left(-d \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}}\right) \]
      10. rec-exp73.7%

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

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

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

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

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

    if -5.20000000000000009e-303 < d < 4.1999999999999998e-146 or 9.20000000000000008e111 < d

    1. Initial program 60.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.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. add-log-exp33.5%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative33.5%

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

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

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

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

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

    if 4.1999999999999998e-146 < d < 9.20000000000000008e111

    1. Initial program 85.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. Simplified85.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 M around 0 63.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{D \cdot D}{\color{blue}{\frac{d \cdot \ell}{M} \cdot \frac{d}{M \cdot h}}} \cdot 0.25\right)\right) \]
    8. Step-by-step derivation
      1. times-frac85.8%

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

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(\frac{D}{\frac{d}{\frac{M}{\ell}}} \cdot \color{blue}{\frac{D \cdot \left(h \cdot M\right)}{d}}\right) \cdot 0.25\right)\right) \]
    11. Step-by-step derivation
      1. associate-*l/85.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.55 \cdot 10^{-56}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \left(\left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right)\right)\right)\right)\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{-303}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{elif}\;d \leq 4.2 \cdot 10^{-146} \lor \neg \left(d \leq 9.2 \cdot 10^{+111}\right):\\ \;\;\;\;d \cdot \left(\mathsf{fma}\left(-0.125, \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right), 1\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \left(\frac{D}{\frac{d}{\frac{M}{\ell}}} \cdot \left(h \cdot \frac{D}{\frac{d}{M}}\right)\right)\right)\right)\\ \end{array} \]

Alternative 5: 75.1% accurate, 1.5× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \mathsf{fma}\left(-0.125, \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right), 1\right)\\ t_1 := \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{if}\;\ell \leq -1 \cdot 10^{-310}:\\ \;\;\;\;t_1 \cdot \left(d \cdot \left(-t_0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left(t_0 \cdot t_1\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
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 (fma -0.125 (* (* h M) (* (/ D d) (* M (/ (/ D d) l)))) 1.0))
        (t_1 (sqrt (/ 1.0 (* l h)))))
   (if (<= l -1e-310) (* t_1 (* d (- t_0))) (* d (* t_0 t_1)))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = fma(-0.125, ((h * M) * ((D / d) * (M * ((D / d) / l)))), 1.0);
	double t_1 = sqrt((1.0 / (l * h)));
	double tmp;
	if (l <= -1e-310) {
		tmp = t_1 * (d * -t_0);
	} else {
		tmp = d * (t_0 * t_1);
	}
	return tmp;
}
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = fma(-0.125, Float64(Float64(h * M) * Float64(Float64(D / d) * Float64(M * Float64(Float64(D / d) / l)))), 1.0)
	t_1 = sqrt(Float64(1.0 / Float64(l * h)))
	tmp = 0.0
	if (l <= -1e-310)
		tmp = Float64(t_1 * Float64(d * Float64(-t_0)));
	else
		tmp = Float64(d * Float64(t_0 * t_1));
	end
	return tmp
end
NOTE: M should be positive before calling this function
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[(h * M), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(M * N[(N[(D / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -1e-310], N[(t$95$1 * N[(d * (-t$95$0)), $MachinePrecision]), $MachinePrecision], N[(d * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-0.125, \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right), 1\right)\\
t_1 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;t_1 \cdot \left(d \cdot \left(-t_0\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -9.999999999999969e-311

    1. Initial program 68.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. Simplified68.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. add-log-exp40.3%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative40.3%

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

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

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

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

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

    if -9.999999999999969e-311 < l

    1. Initial program 72.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. Simplified71.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. Step-by-step derivation
      1. add-log-exp32.1%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative32.1%

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

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

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

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

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

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

Alternative 6: 72.1% accurate, 1.5× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 8.00000000000000022e-306

    1. Initial program 69.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. Simplified68.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. Step-by-step derivation
      1. add-log-exp40.0%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative40.0%

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

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

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

        \[\leadsto \log \color{blue}{\left(e^{\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}}}\right)} \]
      2. add-log-exp55.4%

        \[\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}}} \]
      3. associate-*l*55.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right) \cdot \left(-d \cdot e^{-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}}\right) \]
      9. unpow1/269.8%

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

        \[\leadsto \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right) \cdot \left(-d \cdot \color{blue}{\frac{1}{e^{\log \left(\sqrt{h \cdot \ell}\right)}}}\right) \]
      11. rem-exp-log72.0%

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

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

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

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

    if 8.00000000000000022e-306 < l

    1. Initial program 72.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. Simplified71.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-log-exp32.3%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative32.3%

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

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

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

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

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

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

Alternative 7: 69.7% accurate, 1.5× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := -0.125 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right)\right)\\ t_1 := \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{if}\;h \leq -4.5 \cdot 10^{+155}:\\ \;\;\;\;d \cdot \left(t_1 \cdot \left(-1 - t_0\right)\right)\\ \mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left(t_1 \cdot \left(1 + t_0\right)\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
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 (* (* M (* h M)) (* (/ D d) (/ D (* d l))))))
        (t_1 (sqrt (/ 1.0 (* l h)))))
   (if (<= h -4.5e+155)
     (* d (* t_1 (- -1.0 t_0)))
     (if (<= h -5e-310)
       (*
        (/ d (sqrt (* l h)))
        (- -1.0 (* -0.5 (* (/ h l) (pow (* M (* (/ D d) 0.5)) 2.0)))))
       (* d (* t_1 (+ 1.0 t_0)))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
	double t_1 = sqrt((1.0 / (l * h)));
	double tmp;
	if (h <= -4.5e+155) {
		tmp = d * (t_1 * (-1.0 - t_0));
	} else if (h <= -5e-310) {
		tmp = (d / sqrt((l * h))) * (-1.0 - (-0.5 * ((h / l) * pow((M * ((D / d) * 0.5)), 2.0))));
	} else {
		tmp = d * (t_1 * (1.0 + t_0));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
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) * ((m * (h * m)) * ((d_1 / d) * (d_1 / (d * l))))
    t_1 = sqrt((1.0d0 / (l * h)))
    if (h <= (-4.5d+155)) then
        tmp = d * (t_1 * ((-1.0d0) - t_0))
    else if (h <= (-5d-310)) then
        tmp = (d / sqrt((l * h))) * ((-1.0d0) - ((-0.5d0) * ((h / l) * ((m * ((d_1 / d) * 0.5d0)) ** 2.0d0))))
    else
        tmp = d * (t_1 * (1.0d0 + t_0))
    end if
    code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
	double t_1 = Math.sqrt((1.0 / (l * h)));
	double tmp;
	if (h <= -4.5e+155) {
		tmp = d * (t_1 * (-1.0 - t_0));
	} else if (h <= -5e-310) {
		tmp = (d / Math.sqrt((l * h))) * (-1.0 - (-0.5 * ((h / l) * Math.pow((M * ((D / d) * 0.5)), 2.0))));
	} else {
		tmp = d * (t_1 * (1.0 + t_0));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))))
	t_1 = math.sqrt((1.0 / (l * h)))
	tmp = 0
	if h <= -4.5e+155:
		tmp = d * (t_1 * (-1.0 - t_0))
	elif h <= -5e-310:
		tmp = (d / math.sqrt((l * h))) * (-1.0 - (-0.5 * ((h / l) * math.pow((M * ((D / d) * 0.5)), 2.0))))
	else:
		tmp = d * (t_1 * (1.0 + t_0))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(-0.125 * Float64(Float64(M * Float64(h * M)) * Float64(Float64(D / d) * Float64(D / Float64(d * l)))))
	t_1 = sqrt(Float64(1.0 / Float64(l * h)))
	tmp = 0.0
	if (h <= -4.5e+155)
		tmp = Float64(d * Float64(t_1 * Float64(-1.0 - t_0)));
	elseif (h <= -5e-310)
		tmp = Float64(Float64(d / sqrt(Float64(l * h))) * Float64(-1.0 - Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(Float64(D / d) * 0.5)) ^ 2.0)))));
	else
		tmp = Float64(d * Float64(t_1 * Float64(1.0 + t_0)));
	end
	return tmp
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
	t_1 = sqrt((1.0 / (l * h)));
	tmp = 0.0;
	if (h <= -4.5e+155)
		tmp = d * (t_1 * (-1.0 - t_0));
	elseif (h <= -5e-310)
		tmp = (d / sqrt((l * h))) * (-1.0 - (-0.5 * ((h / l) * ((M * ((D / d) * 0.5)) ^ 2.0))));
	else
		tmp = d * (t_1 * (1.0 + t_0));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
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[(M * N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -4.5e+155], N[(d * N[(t$95$1 * N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -5e-310], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-1.0 - N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(N[(D / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(t$95$1 * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := -0.125 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right)\right)\\
t_1 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;h \leq -4.5 \cdot 10^{+155}:\\
\;\;\;\;d \cdot \left(t_1 \cdot \left(-1 - t_0\right)\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -4.49999999999999973e155

    1. Initial program 41.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. Simplified41.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. add-log-exp22.1%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative22.1%

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

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

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

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

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

    if -4.49999999999999973e155 < h < -4.999999999999985e-310

    1. Initial program 75.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. Simplified75.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-log-exp44.8%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative44.8%

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

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

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

        \[\leadsto \log \color{blue}{\left(e^{\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}}}\right)} \]
      2. add-log-exp59.5%

        \[\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}}} \]
      3. associate-*l*59.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right) \cdot \left(-d \cdot e^{-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}}\right) \]
      9. unpow1/276.7%

        \[\leadsto \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right) \cdot \left(-d \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}}\right) \]
      10. rec-exp76.7%

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 72.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. Simplified71.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. Step-by-step derivation
      1. add-log-exp32.1%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative32.1%

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

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

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

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

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

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

Alternative 8: 68.9% accurate, 1.6× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := -0.125 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right)\right)\\ t_1 := \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{if}\;\ell \leq -1 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \left(t_1 \cdot \left(-1 - t_0\right)\right)\\ \mathbf{elif}\;\ell \leq 5.2 \cdot 10^{+133}:\\ \;\;\;\;d \cdot \left(t_1 \cdot \left(1 + t_0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
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 (* (* M (* h M)) (* (/ D d) (/ D (* d l))))))
        (t_1 (sqrt (/ 1.0 (* l h)))))
   (if (<= l -1e-310)
     (* d (* t_1 (- -1.0 t_0)))
     (if (<= l 5.2e+133)
       (* d (* t_1 (+ 1.0 t_0)))
       (/ d (* (sqrt h) (sqrt l)))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
	double t_1 = sqrt((1.0 / (l * h)));
	double tmp;
	if (l <= -1e-310) {
		tmp = d * (t_1 * (-1.0 - t_0));
	} else if (l <= 5.2e+133) {
		tmp = d * (t_1 * (1.0 + t_0));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
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) * ((m * (h * m)) * ((d_1 / d) * (d_1 / (d * l))))
    t_1 = sqrt((1.0d0 / (l * h)))
    if (l <= (-1d-310)) then
        tmp = d * (t_1 * ((-1.0d0) - t_0))
    else if (l <= 5.2d+133) then
        tmp = d * (t_1 * (1.0d0 + t_0))
    else
        tmp = d / (sqrt(h) * sqrt(l))
    end if
    code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
	double t_1 = Math.sqrt((1.0 / (l * h)));
	double tmp;
	if (l <= -1e-310) {
		tmp = d * (t_1 * (-1.0 - t_0));
	} else if (l <= 5.2e+133) {
		tmp = d * (t_1 * (1.0 + t_0));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))))
	t_1 = math.sqrt((1.0 / (l * h)))
	tmp = 0
	if l <= -1e-310:
		tmp = d * (t_1 * (-1.0 - t_0))
	elif l <= 5.2e+133:
		tmp = d * (t_1 * (1.0 + t_0))
	else:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(-0.125 * Float64(Float64(M * Float64(h * M)) * Float64(Float64(D / d) * Float64(D / Float64(d * l)))))
	t_1 = sqrt(Float64(1.0 / Float64(l * h)))
	tmp = 0.0
	if (l <= -1e-310)
		tmp = Float64(d * Float64(t_1 * Float64(-1.0 - t_0)));
	elseif (l <= 5.2e+133)
		tmp = Float64(d * Float64(t_1 * Float64(1.0 + t_0)));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
	t_1 = sqrt((1.0 / (l * h)));
	tmp = 0.0;
	if (l <= -1e-310)
		tmp = d * (t_1 * (-1.0 - t_0));
	elseif (l <= 5.2e+133)
		tmp = d * (t_1 * (1.0 + t_0));
	else
		tmp = d / (sqrt(h) * sqrt(l));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
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[(M * N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -1e-310], N[(d * N[(t$95$1 * N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.2e+133], N[(d * N[(t$95$1 * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := -0.125 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right)\right)\\
t_1 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \left(t_1 \cdot \left(-1 - t_0\right)\right)\\

\mathbf{elif}\;\ell \leq 5.2 \cdot 10^{+133}:\\
\;\;\;\;d \cdot \left(t_1 \cdot \left(1 + t_0\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -9.999999999999969e-311

    1. Initial program 68.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. Simplified68.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. add-log-exp40.3%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative40.3%

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

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

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

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

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

    if -9.999999999999969e-311 < l < 5.1999999999999995e133

    1. Initial program 76.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. Simplified75.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-log-exp38.0%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative38.0%

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

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

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

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

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

    if 5.1999999999999995e133 < l

    1. Initial program 60.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. Simplified60.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. Taylor expanded in d around inf 48.3%

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\sqrt{h \cdot \ell}}} \cdot d \]
    6. Taylor expanded in d around 0 48.3%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    7. Step-by-step derivation
      1. *-commutative48.3%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
      3. unpow1/248.3%

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

        \[\leadsto d \cdot \color{blue}{\left({\left(\frac{\frac{1}{\ell}}{h}\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\frac{\frac{1}{\ell}}{h}\right)}^{\left(\frac{0.5}{2}\right)}\right)} \]
      5. rem-exp-log45.2%

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

        \[\leadsto e^{\log d} \cdot \color{blue}{{\left(\frac{\frac{1}{\ell}}{h}\right)}^{0.5}} \]
      7. unpow1/245.2%

        \[\leadsto e^{\log d} \cdot \color{blue}{\sqrt{\frac{\frac{1}{\ell}}{h}}} \]
      8. associate-/r*45.2%

        \[\leadsto e^{\log d} \cdot \sqrt{\color{blue}{\frac{1}{\ell \cdot h}}} \]
      9. unpow-145.2%

        \[\leadsto e^{\log d} \cdot \sqrt{\color{blue}{{\left(\ell \cdot h\right)}^{-1}}} \]
      10. metadata-eval45.2%

        \[\leadsto e^{\log d} \cdot \sqrt{{\left(\ell \cdot h\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      11. pow-sqr45.2%

        \[\leadsto e^{\log d} \cdot \sqrt{\color{blue}{{\left(\ell \cdot h\right)}^{-0.5} \cdot {\left(\ell \cdot h\right)}^{-0.5}}} \]
      12. rem-sqrt-square45.2%

        \[\leadsto e^{\log d} \cdot \color{blue}{\left|{\left(\ell \cdot h\right)}^{-0.5}\right|} \]
      13. sqr-pow45.2%

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

        \[\leadsto e^{\log d} \cdot \color{blue}{\left({\left(\ell \cdot h\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(\ell \cdot h\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      15. sqr-pow45.2%

        \[\leadsto e^{\log d} \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
      16. rem-exp-log45.4%

        \[\leadsto e^{\log d} \cdot \color{blue}{e^{\log \left({\left(\ell \cdot h\right)}^{-0.5}\right)}} \]
      17. exp-sum45.2%

        \[\leadsto \color{blue}{e^{\log d + \log \left({\left(\ell \cdot h\right)}^{-0.5}\right)}} \]
      18. log-pow45.4%

        \[\leadsto e^{\log d + \color{blue}{-0.5 \cdot \log \left(\ell \cdot h\right)}} \]
      19. metadata-eval45.4%

        \[\leadsto e^{\log d + \color{blue}{\left(-0.5\right)} \cdot \log \left(\ell \cdot h\right)} \]
      20. distribute-lft-neg-in45.4%

        \[\leadsto e^{\log d + \color{blue}{\left(-0.5 \cdot \log \left(\ell \cdot h\right)\right)}} \]
      21. log-pow45.4%

        \[\leadsto e^{\log d + \left(-\color{blue}{\log \left({\left(\ell \cdot h\right)}^{0.5}\right)}\right)} \]
      22. unpow1/245.4%

        \[\leadsto e^{\log d + \left(-\log \color{blue}{\left(\sqrt{\ell \cdot h}\right)}\right)} \]
    8. Simplified48.4%

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

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    10. Applied egg-rr67.8%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification69.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-1 - -0.125 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right)\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 5.2 \cdot 10^{+133}:\\ \;\;\;\;d \cdot \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(1 + -0.125 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 9: 38.1% accurate, 2.6× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;h \leq 6.5 \cdot 10^{-296}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(1 + -0.125 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right)\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (if (<= h 6.5e-296)
   (/ d (sqrt (* l h)))
   (*
    d
    (*
     (sqrt (/ 1.0 (* l h)))
     (+ 1.0 (* -0.125 (* (* M (* h M)) (* (/ D d) (/ D (* d l))))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= 6.5e-296) {
		tmp = d / sqrt((l * h));
	} else {
		tmp = d * (sqrt((1.0 / (l * h))) * (1.0 + (-0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l)))))));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
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 <= 6.5d-296) then
        tmp = d / sqrt((l * h))
    else
        tmp = d * (sqrt((1.0d0 / (l * h))) * (1.0d0 + ((-0.125d0) * ((m * (h * m)) * ((d_1 / d) * (d_1 / (d * l)))))))
    end if
    code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= 6.5e-296) {
		tmp = d / Math.sqrt((l * h));
	} else {
		tmp = d * (Math.sqrt((1.0 / (l * h))) * (1.0 + (-0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l)))))));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if h <= 6.5e-296:
		tmp = d / math.sqrt((l * h))
	else:
		tmp = d * (math.sqrt((1.0 / (l * h))) * (1.0 + (-0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l)))))))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (h <= 6.5e-296)
		tmp = Float64(d / sqrt(Float64(l * h)));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / Float64(l * h))) * Float64(1.0 + Float64(-0.125 * Float64(Float64(M * Float64(h * M)) * Float64(Float64(D / d) * Float64(D / Float64(d * l))))))));
	end
	return tmp
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (h <= 6.5e-296)
		tmp = d / sqrt((l * h));
	else
		tmp = d * (sqrt((1.0 / (l * h))) * (1.0 + (-0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l)))))));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := If[LessEqual[h, 6.5e-296], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq 6.5 \cdot 10^{-296}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if h < 6.49999999999999963e-296

    1. Initial program 68.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. Simplified68.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 10.5%

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

        \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{\ell \cdot h}}} \cdot d \]
      2. metadata-eval10.5%

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

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

      \[\leadsto \color{blue}{\frac{1}{\sqrt{h \cdot \ell}}} \cdot d \]
    6. Taylor expanded in d around 0 10.5%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    7. Step-by-step derivation
      1. *-commutative10.5%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
      3. unpow1/210.5%

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

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

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

        \[\leadsto e^{\log d} \cdot \color{blue}{{\left(\frac{\frac{1}{\ell}}{h}\right)}^{0.5}} \]
      7. unpow1/20.8%

        \[\leadsto e^{\log d} \cdot \color{blue}{\sqrt{\frac{\frac{1}{\ell}}{h}}} \]
      8. associate-/r*0.8%

        \[\leadsto e^{\log d} \cdot \sqrt{\color{blue}{\frac{1}{\ell \cdot h}}} \]
      9. unpow-10.8%

        \[\leadsto e^{\log d} \cdot \sqrt{\color{blue}{{\left(\ell \cdot h\right)}^{-1}}} \]
      10. metadata-eval0.8%

        \[\leadsto e^{\log d} \cdot \sqrt{{\left(\ell \cdot h\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      11. pow-sqr0.8%

        \[\leadsto e^{\log d} \cdot \sqrt{\color{blue}{{\left(\ell \cdot h\right)}^{-0.5} \cdot {\left(\ell \cdot h\right)}^{-0.5}}} \]
      12. rem-sqrt-square0.8%

        \[\leadsto e^{\log d} \cdot \color{blue}{\left|{\left(\ell \cdot h\right)}^{-0.5}\right|} \]
      13. sqr-pow0.8%

        \[\leadsto e^{\log d} \cdot \left|\color{blue}{{\left(\ell \cdot h\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(\ell \cdot h\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      14. fabs-sqr0.8%

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

        \[\leadsto e^{\log d} \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
      16. rem-exp-log0.8%

        \[\leadsto e^{\log d} \cdot \color{blue}{e^{\log \left({\left(\ell \cdot h\right)}^{-0.5}\right)}} \]
      17. exp-sum0.8%

        \[\leadsto \color{blue}{e^{\log d + \log \left({\left(\ell \cdot h\right)}^{-0.5}\right)}} \]
      18. log-pow0.8%

        \[\leadsto e^{\log d + \color{blue}{-0.5 \cdot \log \left(\ell \cdot h\right)}} \]
      19. metadata-eval0.8%

        \[\leadsto e^{\log d + \color{blue}{\left(-0.5\right)} \cdot \log \left(\ell \cdot h\right)} \]
      20. distribute-lft-neg-in0.8%

        \[\leadsto e^{\log d + \color{blue}{\left(-0.5 \cdot \log \left(\ell \cdot h\right)\right)}} \]
      21. log-pow0.8%

        \[\leadsto e^{\log d + \left(-\color{blue}{\log \left({\left(\ell \cdot h\right)}^{0.5}\right)}\right)} \]
      22. unpow1/20.8%

        \[\leadsto e^{\log d + \left(-\log \color{blue}{\left(\sqrt{\ell \cdot h}\right)}\right)} \]
    8. Simplified10.5%

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

    if 6.49999999999999963e-296 < h

    1. Initial program 72.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. Simplified71.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. add-log-exp32.6%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative32.6%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq 6.5 \cdot 10^{-296}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(1 + -0.125 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right)\right)\right)\right)\\ \end{array} \]

Alternative 10: 67.4% accurate, 2.6× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := -0.125 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right)\right)\\ t_1 := \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{if}\;d \leq -6.8 \cdot 10^{-306}:\\ \;\;\;\;d \cdot \left(t_1 \cdot \left(-1 - t_0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left(t_1 \cdot \left(1 + t_0\right)\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
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 (* (* M (* h M)) (* (/ D d) (/ D (* d l))))))
        (t_1 (sqrt (/ 1.0 (* l h)))))
   (if (<= d -6.8e-306) (* d (* t_1 (- -1.0 t_0))) (* d (* t_1 (+ 1.0 t_0))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
	double t_1 = sqrt((1.0 / (l * h)));
	double tmp;
	if (d <= -6.8e-306) {
		tmp = d * (t_1 * (-1.0 - t_0));
	} else {
		tmp = d * (t_1 * (1.0 + t_0));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
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) * ((m * (h * m)) * ((d_1 / d) * (d_1 / (d * l))))
    t_1 = sqrt((1.0d0 / (l * h)))
    if (d <= (-6.8d-306)) then
        tmp = d * (t_1 * ((-1.0d0) - t_0))
    else
        tmp = d * (t_1 * (1.0d0 + t_0))
    end if
    code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
	double t_1 = Math.sqrt((1.0 / (l * h)));
	double tmp;
	if (d <= -6.8e-306) {
		tmp = d * (t_1 * (-1.0 - t_0));
	} else {
		tmp = d * (t_1 * (1.0 + t_0));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))))
	t_1 = math.sqrt((1.0 / (l * h)))
	tmp = 0
	if d <= -6.8e-306:
		tmp = d * (t_1 * (-1.0 - t_0))
	else:
		tmp = d * (t_1 * (1.0 + t_0))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(-0.125 * Float64(Float64(M * Float64(h * M)) * Float64(Float64(D / d) * Float64(D / Float64(d * l)))))
	t_1 = sqrt(Float64(1.0 / Float64(l * h)))
	tmp = 0.0
	if (d <= -6.8e-306)
		tmp = Float64(d * Float64(t_1 * Float64(-1.0 - t_0)));
	else
		tmp = Float64(d * Float64(t_1 * Float64(1.0 + t_0)));
	end
	return tmp
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
	t_1 = sqrt((1.0 / (l * h)));
	tmp = 0.0;
	if (d <= -6.8e-306)
		tmp = d * (t_1 * (-1.0 - t_0));
	else
		tmp = d * (t_1 * (1.0 + t_0));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
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[(M * N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -6.8e-306], N[(d * N[(t$95$1 * N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(t$95$1 * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := -0.125 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right)\right)\\
t_1 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;d \leq -6.8 \cdot 10^{-306}:\\
\;\;\;\;d \cdot \left(t_1 \cdot \left(-1 - t_0\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -6.7999999999999996e-306

    1. Initial program 69.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. Simplified68.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. add-log-exp40.6%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative40.6%

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

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

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

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

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

    if -6.7999999999999996e-306 < d

    1. Initial program 72.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. Simplified71.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. add-log-exp31.9%

        \[\leadsto \color{blue}{\log \left(e^{\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)}\right)} \]
      2. *-commutative31.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.8 \cdot 10^{-306}:\\ \;\;\;\;d \cdot \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-1 - -0.125 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(1 + -0.125 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right)\right)\right)\right)\\ \end{array} \]

Alternative 11: 26.6% accurate, 3.1× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ d \cdot {\left(\ell \cdot h\right)}^{-0.5} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D) :precision binary64 (* d (pow (* l h) -0.5)))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d * pow((l * h), -0.5);
}
NOTE: M should be positive before calling this function
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 * ((l * h) ** (-0.5d0))
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.pow((l * h), -0.5);
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * math.pow((l * h), -0.5)
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d * (Float64(l * h) ^ -0.5))
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d * ((l * h) ^ -0.5);
end
NOTE: M should be positive before calling this function
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[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot {\left(\ell \cdot h\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 70.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. Simplified70.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 inf 28.7%

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

      \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{\ell \cdot h}}} \cdot d \]
    2. metadata-eval28.9%

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

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

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

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

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

      \[\leadsto \left(e^{\mathsf{log1p}\left(\frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}}\right)} - 1\right) \cdot d \]
    4. metadata-eval20.5%

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

      \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-\sqrt{0.25}\right)}}\right)} - 1\right) \cdot d \]
    6. *-commutative20.5%

      \[\leadsto \left(e^{\mathsf{log1p}\left({\color{blue}{\left(\ell \cdot h\right)}}^{\left(-\sqrt{0.25}\right)}\right)} - 1\right) \cdot d \]
    7. metadata-eval20.5%

      \[\leadsto \left(e^{\mathsf{log1p}\left({\left(\ell \cdot h\right)}^{\left(-\color{blue}{0.5}\right)}\right)} - 1\right) \cdot d \]
    8. metadata-eval20.5%

      \[\leadsto \left(e^{\mathsf{log1p}\left({\left(\ell \cdot h\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \cdot d \]
  7. Applied egg-rr20.5%

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

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\ell \cdot h\right)}^{-0.5}\right)\right)} \cdot d \]
    2. expm1-log1p28.9%

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

    \[\leadsto \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \cdot d \]
  10. Final simplification28.9%

    \[\leadsto d \cdot {\left(\ell \cdot h\right)}^{-0.5} \]

Alternative 12: 26.6% accurate, 3.2× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \frac{d}{\sqrt{\ell \cdot h}} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D) :precision binary64 (/ d (sqrt (* l h))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d / sqrt((l * h));
}
NOTE: M should be positive before calling this function
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((l * h))
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return d / Math.sqrt((l * h));
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d / math.sqrt((l * h))
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d / sqrt(Float64(l * h)))
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d / sqrt((l * h));
end
NOTE: M should be positive before calling this function
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[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Derivation
  1. Initial program 70.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. Simplified70.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 inf 28.7%

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

      \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{\ell \cdot h}}} \cdot d \]
    2. metadata-eval28.9%

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

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

    \[\leadsto \color{blue}{\frac{1}{\sqrt{h \cdot \ell}}} \cdot d \]
  6. Taylor expanded in d around 0 28.7%

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

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

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    3. unpow1/228.7%

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

      \[\leadsto d \cdot \color{blue}{\left({\left(\frac{\frac{1}{\ell}}{h}\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\frac{\frac{1}{\ell}}{h}\right)}^{\left(\frac{0.5}{2}\right)}\right)} \]
    5. rem-exp-log22.3%

      \[\leadsto \color{blue}{e^{\log d}} \cdot \left({\left(\frac{\frac{1}{\ell}}{h}\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\frac{\frac{1}{\ell}}{h}\right)}^{\left(\frac{0.5}{2}\right)}\right) \]
    6. sqr-pow22.3%

      \[\leadsto e^{\log d} \cdot \color{blue}{{\left(\frac{\frac{1}{\ell}}{h}\right)}^{0.5}} \]
    7. unpow1/222.3%

      \[\leadsto e^{\log d} \cdot \color{blue}{\sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    8. associate-/r*22.3%

      \[\leadsto e^{\log d} \cdot \sqrt{\color{blue}{\frac{1}{\ell \cdot h}}} \]
    9. unpow-122.3%

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

      \[\leadsto e^{\log d} \cdot \sqrt{{\left(\ell \cdot h\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
    11. pow-sqr22.3%

      \[\leadsto e^{\log d} \cdot \sqrt{\color{blue}{{\left(\ell \cdot h\right)}^{-0.5} \cdot {\left(\ell \cdot h\right)}^{-0.5}}} \]
    12. rem-sqrt-square22.5%

      \[\leadsto e^{\log d} \cdot \color{blue}{\left|{\left(\ell \cdot h\right)}^{-0.5}\right|} \]
    13. sqr-pow22.5%

      \[\leadsto e^{\log d} \cdot \left|\color{blue}{{\left(\ell \cdot h\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(\ell \cdot h\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
    14. fabs-sqr22.5%

      \[\leadsto e^{\log d} \cdot \color{blue}{\left({\left(\ell \cdot h\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(\ell \cdot h\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
    15. sqr-pow22.5%

      \[\leadsto e^{\log d} \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
    16. rem-exp-log22.4%

      \[\leadsto e^{\log d} \cdot \color{blue}{e^{\log \left({\left(\ell \cdot h\right)}^{-0.5}\right)}} \]
    17. exp-sum22.4%

      \[\leadsto \color{blue}{e^{\log d + \log \left({\left(\ell \cdot h\right)}^{-0.5}\right)}} \]
    18. log-pow22.4%

      \[\leadsto e^{\log d + \color{blue}{-0.5 \cdot \log \left(\ell \cdot h\right)}} \]
    19. metadata-eval22.4%

      \[\leadsto e^{\log d + \color{blue}{\left(-0.5\right)} \cdot \log \left(\ell \cdot h\right)} \]
    20. distribute-lft-neg-in22.4%

      \[\leadsto e^{\log d + \color{blue}{\left(-0.5 \cdot \log \left(\ell \cdot h\right)\right)}} \]
    21. log-pow22.4%

      \[\leadsto e^{\log d + \left(-\color{blue}{\log \left({\left(\ell \cdot h\right)}^{0.5}\right)}\right)} \]
    22. unpow1/222.4%

      \[\leadsto e^{\log d + \left(-\log \color{blue}{\left(\sqrt{\ell \cdot h}\right)}\right)} \]
  8. Simplified28.9%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell \cdot h}}} \]
  9. Final simplification28.9%

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

Reproduce

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