Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.9% → 75.9%
Time: 26.0s
Alternatives: 22
Speedup: 1.0×

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 22 alternatives:

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

Initial Program: 66.9% 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: 75.9% accurate, 0.6× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 8.3 \cdot 10^{-302}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{\frac{M \cdot D}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}\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 (<= l 8.3e-302)
   (*
    (* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
    (- 1.0 (/ (* h (* 0.5 (pow (* (* 0.5 M) (/ D d)) 2.0))) l)))
   (*
    (/ (sqrt d) (sqrt h))
    (*
     (/ (sqrt d) (sqrt l))
     (- 1.0 (* 0.5 (* (pow (/ (/ (* M D) 2.0) d) 2.0) (/ h l))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= 8.3e-302) {
		tmp = (pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h * (0.5 * pow(((0.5 * M) * (D / d)), 2.0))) / l));
	} else {
		tmp = (sqrt(d) / sqrt(h)) * ((sqrt(d) / sqrt(l)) * (1.0 - (0.5 * (pow((((M * D) / 2.0) / d), 2.0) * (h / 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 (l <= 8.3d-302) then
        tmp = (((d / h) ** 0.5d0) * ((d / l) ** 0.5d0)) * (1.0d0 - ((h * (0.5d0 * (((0.5d0 * m) * (d_1 / d)) ** 2.0d0))) / l))
    else
        tmp = (sqrt(d) / sqrt(h)) * ((sqrt(d) / sqrt(l)) * (1.0d0 - (0.5d0 * (((((m * d_1) / 2.0d0) / d) ** 2.0d0) * (h / 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 (l <= 8.3e-302) {
		tmp = (Math.pow((d / h), 0.5) * Math.pow((d / l), 0.5)) * (1.0 - ((h * (0.5 * Math.pow(((0.5 * M) * (D / d)), 2.0))) / l));
	} else {
		tmp = (Math.sqrt(d) / Math.sqrt(h)) * ((Math.sqrt(d) / Math.sqrt(l)) * (1.0 - (0.5 * (Math.pow((((M * D) / 2.0) / d), 2.0) * (h / l)))));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if l <= 8.3e-302:
		tmp = (math.pow((d / h), 0.5) * math.pow((d / l), 0.5)) * (1.0 - ((h * (0.5 * math.pow(((0.5 * M) * (D / d)), 2.0))) / l))
	else:
		tmp = (math.sqrt(d) / math.sqrt(h)) * ((math.sqrt(d) / math.sqrt(l)) * (1.0 - (0.5 * (math.pow((((M * D) / 2.0) / d), 2.0) * (h / l)))))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= 8.3e-302)
		tmp = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h * Float64(0.5 * (Float64(Float64(0.5 * M) * Float64(D / d)) ^ 2.0))) / l)));
	else
		tmp = Float64(Float64(sqrt(d) / sqrt(h)) * Float64(Float64(sqrt(d) / sqrt(l)) * Float64(1.0 - Float64(0.5 * Float64((Float64(Float64(Float64(M * D) / 2.0) / d) ^ 2.0) * Float64(h / 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 (l <= 8.3e-302)
		tmp = (((d / h) ^ 0.5) * ((d / l) ^ 0.5)) * (1.0 - ((h * (0.5 * (((0.5 * M) * (D / d)) ^ 2.0))) / l));
	else
		tmp = (sqrt(d) / sqrt(h)) * ((sqrt(d) / sqrt(l)) * (1.0 - (0.5 * (((((M * D) / 2.0) / d) ^ 2.0) * (h / 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[l, 8.3e-302], N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h * N[(0.5 * N[Power[N[(N[(0.5 * M), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[Power[N[(N[(N[(M * D), $MachinePrecision] / 2.0), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 8.3 \cdot 10^{-302}:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\right)\\

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


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

    1. Initial program 65.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. Step-by-step derivation
      1. associate-*r/67.2%

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

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

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

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

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

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

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

    if 8.29999999999999954e-302 < l

    1. Initial program 61.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. Step-by-step derivation
      1. associate-*l*61.4%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right)} \]
      2. metadata-eval61.4%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      3. unpow1/261.4%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      4. metadata-eval61.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 69.4% accurate, 0.8× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -1.55 \cdot 10^{-302}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\right)\\ \mathbf{elif}\;d \leq 1.32 \cdot 10^{-168}:\\ \;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \mathbf{elif}\;d \leq 10^{+177}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\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
 (if (<= d -1.55e-302)
   (*
    (* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
    (- 1.0 (/ (* h (* 0.5 (pow (* (* 0.5 M) (/ D d)) 2.0))) l)))
   (if (<= d 1.32e-168)
     (* -0.125 (* (* (* D D) (* M (/ M d))) (sqrt (/ h (pow l 3.0)))))
     (if (<= d 1e+177)
       (*
        (sqrt (/ d h))
        (*
         (/ (sqrt d) (sqrt l))
         (- 1.0 (* 0.5 (* (/ h l) (pow (* (/ M d) (/ D 2.0)) 2.0))))))
       (* d (/ (sqrt (/ 1.0 h)) (sqrt l)))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -1.55e-302) {
		tmp = (pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h * (0.5 * pow(((0.5 * M) * (D / d)), 2.0))) / l));
	} else if (d <= 1.32e-168) {
		tmp = -0.125 * (((D * D) * (M * (M / d))) * sqrt((h / pow(l, 3.0))));
	} else if (d <= 1e+177) {
		tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0 - (0.5 * ((h / l) * pow(((M / d) * (D / 2.0)), 2.0)))));
	} else {
		tmp = d * (sqrt((1.0 / 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) :: tmp
    if (d <= (-1.55d-302)) then
        tmp = (((d / h) ** 0.5d0) * ((d / l) ** 0.5d0)) * (1.0d0 - ((h * (0.5d0 * (((0.5d0 * m) * (d_1 / d)) ** 2.0d0))) / l))
    else if (d <= 1.32d-168) then
        tmp = (-0.125d0) * (((d_1 * d_1) * (m * (m / d))) * sqrt((h / (l ** 3.0d0))))
    else if (d <= 1d+177) then
        tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0d0 - (0.5d0 * ((h / l) * (((m / d) * (d_1 / 2.0d0)) ** 2.0d0)))))
    else
        tmp = d * (sqrt((1.0d0 / 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 tmp;
	if (d <= -1.55e-302) {
		tmp = (Math.pow((d / h), 0.5) * Math.pow((d / l), 0.5)) * (1.0 - ((h * (0.5 * Math.pow(((0.5 * M) * (D / d)), 2.0))) / l));
	} else if (d <= 1.32e-168) {
		tmp = -0.125 * (((D * D) * (M * (M / d))) * Math.sqrt((h / Math.pow(l, 3.0))));
	} else if (d <= 1e+177) {
		tmp = Math.sqrt((d / h)) * ((Math.sqrt(d) / Math.sqrt(l)) * (1.0 - (0.5 * ((h / l) * Math.pow(((M / d) * (D / 2.0)), 2.0)))));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if d <= -1.55e-302:
		tmp = (math.pow((d / h), 0.5) * math.pow((d / l), 0.5)) * (1.0 - ((h * (0.5 * math.pow(((0.5 * M) * (D / d)), 2.0))) / l))
	elif d <= 1.32e-168:
		tmp = -0.125 * (((D * D) * (M * (M / d))) * math.sqrt((h / math.pow(l, 3.0))))
	elif d <= 1e+177:
		tmp = math.sqrt((d / h)) * ((math.sqrt(d) / math.sqrt(l)) * (1.0 - (0.5 * ((h / l) * math.pow(((M / d) * (D / 2.0)), 2.0)))))
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= -1.55e-302)
		tmp = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h * Float64(0.5 * (Float64(Float64(0.5 * M) * Float64(D / d)) ^ 2.0))) / l)));
	elseif (d <= 1.32e-168)
		tmp = Float64(-0.125 * Float64(Float64(Float64(D * D) * Float64(M * Float64(M / d))) * sqrt(Float64(h / (l ^ 3.0)))));
	elseif (d <= 1e+177)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(sqrt(d) / sqrt(l)) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(M / d) * Float64(D / 2.0)) ^ 2.0))))));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / 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)
	tmp = 0.0;
	if (d <= -1.55e-302)
		tmp = (((d / h) ^ 0.5) * ((d / l) ^ 0.5)) * (1.0 - ((h * (0.5 * (((0.5 * M) * (D / d)) ^ 2.0))) / l));
	elseif (d <= 1.32e-168)
		tmp = -0.125 * (((D * D) * (M * (M / d))) * sqrt((h / (l ^ 3.0))));
	elseif (d <= 1e+177)
		tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0 - (0.5 * ((h / l) * (((M / d) * (D / 2.0)) ^ 2.0)))));
	else
		tmp = d * (sqrt((1.0 / 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_] := If[LessEqual[d, -1.55e-302], N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h * N[(0.5 * N[Power[N[(N[(0.5 * M), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.32e-168], N[(-0.125 * N[(N[(N[(D * D), $MachinePrecision] * N[(M * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1e+177], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M / d), $MachinePrecision] * N[(D / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.55 \cdot 10^{-302}:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\right)\\

\mathbf{elif}\;d \leq 1.32 \cdot 10^{-168}:\\
\;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\

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

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


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

    1. Initial program 66.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. Step-by-step derivation
      1. associate-*r/67.8%

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

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

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

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

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

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

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

    if -1.54999999999999992e-302 < d < 1.3200000000000001e-168

    1. Initial program 37.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. Taylor expanded in d around 0 54.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3200000000000001e-168 < d < 1e177

    1. Initial program 71.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. Step-by-step derivation
      1. associate-*l*71.8%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right)} \]
      2. metadata-eval71.8%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      3. unpow1/271.8%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      4. metadata-eval71.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e177 < d

    1. Initial program 62.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. Taylor expanded in d around inf 95.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.55 \cdot 10^{-302}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\right)\\ \mathbf{elif}\;d \leq 1.32 \cdot 10^{-168}:\\ \;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \mathbf{elif}\;d \leq 10^{+177}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 3: 70.5% accurate, 0.8× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -1.55 \cdot 10^{-302}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\right)\\ \mathbf{elif}\;d \leq 2 \cdot 10^{-176}:\\ \;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \mathbf{elif}\;d \leq 2.3 \cdot 10^{+178}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\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
 (if (<= d -1.55e-302)
   (*
    (* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
    (- 1.0 (/ (* h (* 0.5 (pow (* (* 0.5 M) (/ D d)) 2.0))) l)))
   (if (<= d 2e-176)
     (* -0.125 (* (* (* D D) (* M (/ M d))) (sqrt (/ h (pow l 3.0)))))
     (if (<= d 2.3e+178)
       (*
        (sqrt (/ d h))
        (*
         (/ (sqrt d) (sqrt l))
         (- 1.0 (* 0.5 (/ (* h (pow (/ (* M D) (* d 2.0)) 2.0)) l)))))
       (* d (/ (sqrt (/ 1.0 h)) (sqrt l)))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -1.55e-302) {
		tmp = (pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h * (0.5 * pow(((0.5 * M) * (D / d)), 2.0))) / l));
	} else if (d <= 2e-176) {
		tmp = -0.125 * (((D * D) * (M * (M / d))) * sqrt((h / pow(l, 3.0))));
	} else if (d <= 2.3e+178) {
		tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0 - (0.5 * ((h * pow(((M * D) / (d * 2.0)), 2.0)) / l))));
	} else {
		tmp = d * (sqrt((1.0 / 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) :: tmp
    if (d <= (-1.55d-302)) then
        tmp = (((d / h) ** 0.5d0) * ((d / l) ** 0.5d0)) * (1.0d0 - ((h * (0.5d0 * (((0.5d0 * m) * (d_1 / d)) ** 2.0d0))) / l))
    else if (d <= 2d-176) then
        tmp = (-0.125d0) * (((d_1 * d_1) * (m * (m / d))) * sqrt((h / (l ** 3.0d0))))
    else if (d <= 2.3d+178) then
        tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0d0 - (0.5d0 * ((h * (((m * d_1) / (d * 2.0d0)) ** 2.0d0)) / l))))
    else
        tmp = d * (sqrt((1.0d0 / 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 tmp;
	if (d <= -1.55e-302) {
		tmp = (Math.pow((d / h), 0.5) * Math.pow((d / l), 0.5)) * (1.0 - ((h * (0.5 * Math.pow(((0.5 * M) * (D / d)), 2.0))) / l));
	} else if (d <= 2e-176) {
		tmp = -0.125 * (((D * D) * (M * (M / d))) * Math.sqrt((h / Math.pow(l, 3.0))));
	} else if (d <= 2.3e+178) {
		tmp = Math.sqrt((d / h)) * ((Math.sqrt(d) / Math.sqrt(l)) * (1.0 - (0.5 * ((h * Math.pow(((M * D) / (d * 2.0)), 2.0)) / l))));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if d <= -1.55e-302:
		tmp = (math.pow((d / h), 0.5) * math.pow((d / l), 0.5)) * (1.0 - ((h * (0.5 * math.pow(((0.5 * M) * (D / d)), 2.0))) / l))
	elif d <= 2e-176:
		tmp = -0.125 * (((D * D) * (M * (M / d))) * math.sqrt((h / math.pow(l, 3.0))))
	elif d <= 2.3e+178:
		tmp = math.sqrt((d / h)) * ((math.sqrt(d) / math.sqrt(l)) * (1.0 - (0.5 * ((h * math.pow(((M * D) / (d * 2.0)), 2.0)) / l))))
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= -1.55e-302)
		tmp = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h * Float64(0.5 * (Float64(Float64(0.5 * M) * Float64(D / d)) ^ 2.0))) / l)));
	elseif (d <= 2e-176)
		tmp = Float64(-0.125 * Float64(Float64(Float64(D * D) * Float64(M * Float64(M / d))) * sqrt(Float64(h / (l ^ 3.0)))));
	elseif (d <= 2.3e+178)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(sqrt(d) / sqrt(l)) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0)) / l)))));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / 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)
	tmp = 0.0;
	if (d <= -1.55e-302)
		tmp = (((d / h) ^ 0.5) * ((d / l) ^ 0.5)) * (1.0 - ((h * (0.5 * (((0.5 * M) * (D / d)) ^ 2.0))) / l));
	elseif (d <= 2e-176)
		tmp = -0.125 * (((D * D) * (M * (M / d))) * sqrt((h / (l ^ 3.0))));
	elseif (d <= 2.3e+178)
		tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0 - (0.5 * ((h * (((M * D) / (d * 2.0)) ^ 2.0)) / l))));
	else
		tmp = d * (sqrt((1.0 / 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_] := If[LessEqual[d, -1.55e-302], N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h * N[(0.5 * N[Power[N[(N[(0.5 * M), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2e-176], N[(-0.125 * N[(N[(N[(D * D), $MachinePrecision] * N[(M * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.3e+178], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.55 \cdot 10^{-302}:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\right)\\

\mathbf{elif}\;d \leq 2 \cdot 10^{-176}:\\
\;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\

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

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


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

    1. Initial program 66.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. Step-by-step derivation
      1. associate-*r/67.8%

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

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

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

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

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

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

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

    if -1.54999999999999992e-302 < d < 2e-176

    1. Initial program 37.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. Taylor expanded in d around 0 54.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e-176 < d < 2.3000000000000001e178

    1. Initial program 71.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. Step-by-step derivation
      1. associate-*l*71.8%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right)} \]
      2. metadata-eval71.8%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      3. unpow1/271.8%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      4. metadata-eval71.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.3000000000000001e178 < d

    1. Initial program 62.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. Taylor expanded in d around inf 95.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.55 \cdot 10^{-302}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\right)\\ \mathbf{elif}\;d \leq 2 \cdot 10^{-176}:\\ \;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \mathbf{elif}\;d \leq 2.3 \cdot 10^{+178}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 4: 71.0% accurate, 0.8× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{\ell}}\\ t_1 := \sqrt{\frac{d}{h}}\\ t_2 := 1 - 0.5 \cdot \frac{h \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}}{\ell}\\ \mathbf{if}\;d \leq 2.1 \cdot 10^{-266}:\\ \;\;\;\;\left(t_0 \cdot t_2\right) \cdot t_1\\ \mathbf{elif}\;d \leq 1.65 \cdot 10^{-177}:\\ \;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(t_0 \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\right)\\ \mathbf{elif}\;d \leq 9.6 \cdot 10^{+178}:\\ \;\;\;\;t_1 \cdot \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot t_2\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\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 (sqrt (/ d l)))
        (t_1 (sqrt (/ d h)))
        (t_2 (- 1.0 (* 0.5 (/ (* h (pow (/ (* M D) (* d 2.0)) 2.0)) l)))))
   (if (<= d 2.1e-266)
     (* (* t_0 t_2) t_1)
     (if (<= d 1.65e-177)
       (*
        (/ (sqrt d) (sqrt h))
        (* t_0 (- 1.0 (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M 2.0)) 2.0))))))
       (if (<= d 9.6e+178)
         (* t_1 (* (/ (sqrt d) (sqrt l)) t_2))
         (* d (/ (sqrt (/ 1.0 h)) (sqrt l))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / l));
	double t_1 = sqrt((d / h));
	double t_2 = 1.0 - (0.5 * ((h * pow(((M * D) / (d * 2.0)), 2.0)) / l));
	double tmp;
	if (d <= 2.1e-266) {
		tmp = (t_0 * t_2) * t_1;
	} else if (d <= 1.65e-177) {
		tmp = (sqrt(d) / sqrt(h)) * (t_0 * (1.0 - (0.5 * ((h / l) * pow(((D / d) * (M / 2.0)), 2.0)))));
	} else if (d <= 9.6e+178) {
		tmp = t_1 * ((sqrt(d) / sqrt(l)) * t_2);
	} else {
		tmp = d * (sqrt((1.0 / 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) :: t_2
    real(8) :: tmp
    t_0 = sqrt((d / l))
    t_1 = sqrt((d / h))
    t_2 = 1.0d0 - (0.5d0 * ((h * (((m * d_1) / (d * 2.0d0)) ** 2.0d0)) / l))
    if (d <= 2.1d-266) then
        tmp = (t_0 * t_2) * t_1
    else if (d <= 1.65d-177) then
        tmp = (sqrt(d) / sqrt(h)) * (t_0 * (1.0d0 - (0.5d0 * ((h / l) * (((d_1 / d) * (m / 2.0d0)) ** 2.0d0)))))
    else if (d <= 9.6d+178) then
        tmp = t_1 * ((sqrt(d) / sqrt(l)) * t_2)
    else
        tmp = d * (sqrt((1.0d0 / 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 = Math.sqrt((d / l));
	double t_1 = Math.sqrt((d / h));
	double t_2 = 1.0 - (0.5 * ((h * Math.pow(((M * D) / (d * 2.0)), 2.0)) / l));
	double tmp;
	if (d <= 2.1e-266) {
		tmp = (t_0 * t_2) * t_1;
	} else if (d <= 1.65e-177) {
		tmp = (Math.sqrt(d) / Math.sqrt(h)) * (t_0 * (1.0 - (0.5 * ((h / l) * Math.pow(((D / d) * (M / 2.0)), 2.0)))));
	} else if (d <= 9.6e+178) {
		tmp = t_1 * ((Math.sqrt(d) / Math.sqrt(l)) * t_2);
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt((d / l))
	t_1 = math.sqrt((d / h))
	t_2 = 1.0 - (0.5 * ((h * math.pow(((M * D) / (d * 2.0)), 2.0)) / l))
	tmp = 0
	if d <= 2.1e-266:
		tmp = (t_0 * t_2) * t_1
	elif d <= 1.65e-177:
		tmp = (math.sqrt(d) / math.sqrt(h)) * (t_0 * (1.0 - (0.5 * ((h / l) * math.pow(((D / d) * (M / 2.0)), 2.0)))))
	elif d <= 9.6e+178:
		tmp = t_1 * ((math.sqrt(d) / math.sqrt(l)) * t_2)
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(d / l))
	t_1 = sqrt(Float64(d / h))
	t_2 = Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0)) / l)))
	tmp = 0.0
	if (d <= 2.1e-266)
		tmp = Float64(Float64(t_0 * t_2) * t_1);
	elseif (d <= 1.65e-177)
		tmp = Float64(Float64(sqrt(d) / sqrt(h)) * Float64(t_0 * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0))))));
	elseif (d <= 9.6e+178)
		tmp = Float64(t_1 * Float64(Float64(sqrt(d) / sqrt(l)) * t_2));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / 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 = sqrt((d / l));
	t_1 = sqrt((d / h));
	t_2 = 1.0 - (0.5 * ((h * (((M * D) / (d * 2.0)) ^ 2.0)) / l));
	tmp = 0.0;
	if (d <= 2.1e-266)
		tmp = (t_0 * t_2) * t_1;
	elseif (d <= 1.65e-177)
		tmp = (sqrt(d) / sqrt(h)) * (t_0 * (1.0 - (0.5 * ((h / l) * (((D / d) * (M / 2.0)) ^ 2.0)))));
	elseif (d <= 9.6e+178)
		tmp = t_1 * ((sqrt(d) / sqrt(l)) * t_2);
	else
		tmp = d * (sqrt((1.0 / 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[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, 2.1e-266], N[(N[(t$95$0 * t$95$2), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[d, 1.65e-177], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * 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]), $MachinePrecision], If[LessEqual[d, 9.6e+178], N[(t$95$1 * N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \sqrt{\frac{d}{h}}\\
t_2 := 1 - 0.5 \cdot \frac{h \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}}{\ell}\\
\mathbf{if}\;d \leq 2.1 \cdot 10^{-266}:\\
\;\;\;\;\left(t_0 \cdot t_2\right) \cdot t_1\\

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

\mathbf{elif}\;d \leq 9.6 \cdot 10^{+178}:\\
\;\;\;\;t_1 \cdot \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot t_2\right)\\

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


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

    1. Initial program 63.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. Step-by-step derivation
      1. associate-*l*63.9%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right)} \]
      2. metadata-eval63.9%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      3. unpow1/263.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      4. metadata-eval63.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.09999999999999997e-266 < d < 1.65e-177

    1. Initial program 39.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. Step-by-step derivation
      1. associate-*l*39.5%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right)} \]
      2. metadata-eval39.5%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      3. unpow1/239.5%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      4. metadata-eval39.5%

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

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

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

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

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

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

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

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

    if 1.65e-177 < d < 9.599999999999999e178

    1. Initial program 70.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. Step-by-step derivation
      1. associate-*l*70.9%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right)} \]
      2. metadata-eval70.9%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      3. unpow1/270.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      4. metadata-eval70.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.599999999999999e178 < d

    1. Initial program 62.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. Taylor expanded in d around inf 95.9%

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

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

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

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

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

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

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

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

Alternative 5: 74.3% accurate, 0.8× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1 \cdot 10^{-310}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\right)\\ \mathbf{elif}\;\ell \leq 1.4 \cdot 10^{+189}:\\ \;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\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
 (if (<= l -1e-310)
   (*
    (* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
    (- 1.0 (/ (* h (* 0.5 (pow (* (* 0.5 M) (/ D d)) 2.0))) l)))
   (if (<= l 1.4e+189)
     (*
      (/ (sqrt d) (sqrt h))
      (*
       (sqrt (/ d l))
       (- 1.0 (* 0.5 (/ (* h (pow (/ (* M D) (* d 2.0)) 2.0)) l)))))
     (* d (/ (sqrt (/ 1.0 h)) (sqrt l))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -1e-310) {
		tmp = (pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h * (0.5 * pow(((0.5 * M) * (D / d)), 2.0))) / l));
	} else if (l <= 1.4e+189) {
		tmp = (sqrt(d) / sqrt(h)) * (sqrt((d / l)) * (1.0 - (0.5 * ((h * pow(((M * D) / (d * 2.0)), 2.0)) / l))));
	} else {
		tmp = d * (sqrt((1.0 / 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) :: tmp
    if (l <= (-1d-310)) then
        tmp = (((d / h) ** 0.5d0) * ((d / l) ** 0.5d0)) * (1.0d0 - ((h * (0.5d0 * (((0.5d0 * m) * (d_1 / d)) ** 2.0d0))) / l))
    else if (l <= 1.4d+189) then
        tmp = (sqrt(d) / sqrt(h)) * (sqrt((d / l)) * (1.0d0 - (0.5d0 * ((h * (((m * d_1) / (d * 2.0d0)) ** 2.0d0)) / l))))
    else
        tmp = d * (sqrt((1.0d0 / 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 tmp;
	if (l <= -1e-310) {
		tmp = (Math.pow((d / h), 0.5) * Math.pow((d / l), 0.5)) * (1.0 - ((h * (0.5 * Math.pow(((0.5 * M) * (D / d)), 2.0))) / l));
	} else if (l <= 1.4e+189) {
		tmp = (Math.sqrt(d) / Math.sqrt(h)) * (Math.sqrt((d / l)) * (1.0 - (0.5 * ((h * Math.pow(((M * D) / (d * 2.0)), 2.0)) / l))));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if l <= -1e-310:
		tmp = (math.pow((d / h), 0.5) * math.pow((d / l), 0.5)) * (1.0 - ((h * (0.5 * math.pow(((0.5 * M) * (D / d)), 2.0))) / l))
	elif l <= 1.4e+189:
		tmp = (math.sqrt(d) / math.sqrt(h)) * (math.sqrt((d / l)) * (1.0 - (0.5 * ((h * math.pow(((M * D) / (d * 2.0)), 2.0)) / l))))
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -1e-310)
		tmp = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h * Float64(0.5 * (Float64(Float64(0.5 * M) * Float64(D / d)) ^ 2.0))) / l)));
	elseif (l <= 1.4e+189)
		tmp = Float64(Float64(sqrt(d) / sqrt(h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0)) / l)))));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / 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)
	tmp = 0.0;
	if (l <= -1e-310)
		tmp = (((d / h) ^ 0.5) * ((d / l) ^ 0.5)) * (1.0 - ((h * (0.5 * (((0.5 * M) * (D / d)) ^ 2.0))) / l));
	elseif (l <= 1.4e+189)
		tmp = (sqrt(d) / sqrt(h)) * (sqrt((d / l)) * (1.0 - (0.5 * ((h * (((M * D) / (d * 2.0)) ^ 2.0)) / l))));
	else
		tmp = d * (sqrt((1.0 / 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_] := If[LessEqual[l, -1e-310], N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h * N[(0.5 * N[Power[N[(N[(0.5 * M), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.4e+189], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\right)\\

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

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


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

    1. Initial program 65.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. Step-by-step derivation
      1. associate-*r/67.2%

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

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

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

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

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

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

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

    if -9.999999999999969e-311 < l < 1.40000000000000003e189

    1. Initial program 66.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. associate-*l*66.2%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right)} \]
      2. metadata-eval66.2%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      3. unpow1/266.2%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      4. metadata-eval66.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.40000000000000003e189 < l

    1. Initial program 45.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. Taylor expanded in d around inf 59.3%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    4. Simplified59.3%

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

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

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

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

Alternative 6: 65.8% accurate, 1.0× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := {\left(\frac{d}{h}\right)}^{0.5}\\ t_1 := \sqrt{\frac{d}{\ell}}\\ t_2 := \sqrt{\frac{d}{h}} \cdot \left(t_1 \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\right)\\ \mathbf{if}\;d \leq -1700:\\ \;\;\;\;\left(t_0 \cdot t_1\right) \cdot \left(1 - \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{h \cdot M}{\ell}\right)\right) \cdot 0.125\right)\\ \mathbf{elif}\;d \leq -8.5 \cdot 10^{-107}:\\ \;\;\;\;\left(t_0 \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - 0.125 \cdot \frac{D \cdot \left(\frac{h}{d} \cdot \frac{M}{\frac{d}{M}}\right)}{\frac{\ell}{D}}\right)\\ \mathbf{elif}\;d \leq -1.55 \cdot 10^{-302}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;d \leq 1.46 \cdot 10^{-168}:\\ \;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \mathbf{elif}\;d \leq 2 \cdot 10^{+170}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\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 (pow (/ d h) 0.5))
        (t_1 (sqrt (/ d l)))
        (t_2
         (*
          (sqrt (/ d h))
          (*
           t_1
           (- 1.0 (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M 2.0)) 2.0))))))))
   (if (<= d -1700.0)
     (*
      (* t_0 t_1)
      (- 1.0 (* (* (* (/ D d) (/ D d)) (* M (/ (* h M) l))) 0.125)))
     (if (<= d -8.5e-107)
       (*
        (* t_0 (pow (/ d l) 0.5))
        (- 1.0 (* 0.125 (/ (* D (* (/ h d) (/ M (/ d M)))) (/ l D)))))
       (if (<= d -1.55e-302)
         t_2
         (if (<= d 1.46e-168)
           (* -0.125 (* (* (* D D) (* M (/ M d))) (sqrt (/ h (pow l 3.0)))))
           (if (<= d 2e+170) t_2 (* d (/ (sqrt (/ 1.0 h)) (sqrt l))))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = pow((d / h), 0.5);
	double t_1 = sqrt((d / l));
	double t_2 = sqrt((d / h)) * (t_1 * (1.0 - (0.5 * ((h / l) * pow(((D / d) * (M / 2.0)), 2.0)))));
	double tmp;
	if (d <= -1700.0) {
		tmp = (t_0 * t_1) * (1.0 - ((((D / d) * (D / d)) * (M * ((h * M) / l))) * 0.125));
	} else if (d <= -8.5e-107) {
		tmp = (t_0 * pow((d / l), 0.5)) * (1.0 - (0.125 * ((D * ((h / d) * (M / (d / M)))) / (l / D))));
	} else if (d <= -1.55e-302) {
		tmp = t_2;
	} else if (d <= 1.46e-168) {
		tmp = -0.125 * (((D * D) * (M * (M / d))) * sqrt((h / pow(l, 3.0))));
	} else if (d <= 2e+170) {
		tmp = t_2;
	} else {
		tmp = d * (sqrt((1.0 / 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) :: t_2
    real(8) :: tmp
    t_0 = (d / h) ** 0.5d0
    t_1 = sqrt((d / l))
    t_2 = sqrt((d / h)) * (t_1 * (1.0d0 - (0.5d0 * ((h / l) * (((d_1 / d) * (m / 2.0d0)) ** 2.0d0)))))
    if (d <= (-1700.0d0)) then
        tmp = (t_0 * t_1) * (1.0d0 - ((((d_1 / d) * (d_1 / d)) * (m * ((h * m) / l))) * 0.125d0))
    else if (d <= (-8.5d-107)) then
        tmp = (t_0 * ((d / l) ** 0.5d0)) * (1.0d0 - (0.125d0 * ((d_1 * ((h / d) * (m / (d / m)))) / (l / d_1))))
    else if (d <= (-1.55d-302)) then
        tmp = t_2
    else if (d <= 1.46d-168) then
        tmp = (-0.125d0) * (((d_1 * d_1) * (m * (m / d))) * sqrt((h / (l ** 3.0d0))))
    else if (d <= 2d+170) then
        tmp = t_2
    else
        tmp = d * (sqrt((1.0d0 / 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 = Math.pow((d / h), 0.5);
	double t_1 = Math.sqrt((d / l));
	double t_2 = Math.sqrt((d / h)) * (t_1 * (1.0 - (0.5 * ((h / l) * Math.pow(((D / d) * (M / 2.0)), 2.0)))));
	double tmp;
	if (d <= -1700.0) {
		tmp = (t_0 * t_1) * (1.0 - ((((D / d) * (D / d)) * (M * ((h * M) / l))) * 0.125));
	} else if (d <= -8.5e-107) {
		tmp = (t_0 * Math.pow((d / l), 0.5)) * (1.0 - (0.125 * ((D * ((h / d) * (M / (d / M)))) / (l / D))));
	} else if (d <= -1.55e-302) {
		tmp = t_2;
	} else if (d <= 1.46e-168) {
		tmp = -0.125 * (((D * D) * (M * (M / d))) * Math.sqrt((h / Math.pow(l, 3.0))));
	} else if (d <= 2e+170) {
		tmp = t_2;
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.pow((d / h), 0.5)
	t_1 = math.sqrt((d / l))
	t_2 = math.sqrt((d / h)) * (t_1 * (1.0 - (0.5 * ((h / l) * math.pow(((D / d) * (M / 2.0)), 2.0)))))
	tmp = 0
	if d <= -1700.0:
		tmp = (t_0 * t_1) * (1.0 - ((((D / d) * (D / d)) * (M * ((h * M) / l))) * 0.125))
	elif d <= -8.5e-107:
		tmp = (t_0 * math.pow((d / l), 0.5)) * (1.0 - (0.125 * ((D * ((h / d) * (M / (d / M)))) / (l / D))))
	elif d <= -1.55e-302:
		tmp = t_2
	elif d <= 1.46e-168:
		tmp = -0.125 * (((D * D) * (M * (M / d))) * math.sqrt((h / math.pow(l, 3.0))))
	elif d <= 2e+170:
		tmp = t_2
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(d / h) ^ 0.5
	t_1 = sqrt(Float64(d / l))
	t_2 = Float64(sqrt(Float64(d / h)) * Float64(t_1 * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0))))))
	tmp = 0.0
	if (d <= -1700.0)
		tmp = Float64(Float64(t_0 * t_1) * Float64(1.0 - Float64(Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(M * Float64(Float64(h * M) / l))) * 0.125)));
	elseif (d <= -8.5e-107)
		tmp = Float64(Float64(t_0 * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(0.125 * Float64(Float64(D * Float64(Float64(h / d) * Float64(M / Float64(d / M)))) / Float64(l / D)))));
	elseif (d <= -1.55e-302)
		tmp = t_2;
	elseif (d <= 1.46e-168)
		tmp = Float64(-0.125 * Float64(Float64(Float64(D * D) * Float64(M * Float64(M / d))) * sqrt(Float64(h / (l ^ 3.0)))));
	elseif (d <= 2e+170)
		tmp = t_2;
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / 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 = (d / h) ^ 0.5;
	t_1 = sqrt((d / l));
	t_2 = sqrt((d / h)) * (t_1 * (1.0 - (0.5 * ((h / l) * (((D / d) * (M / 2.0)) ^ 2.0)))));
	tmp = 0.0;
	if (d <= -1700.0)
		tmp = (t_0 * t_1) * (1.0 - ((((D / d) * (D / d)) * (M * ((h * M) / l))) * 0.125));
	elseif (d <= -8.5e-107)
		tmp = (t_0 * ((d / l) ^ 0.5)) * (1.0 - (0.125 * ((D * ((h / d) * (M / (d / M)))) / (l / D))));
	elseif (d <= -1.55e-302)
		tmp = t_2;
	elseif (d <= 1.46e-168)
		tmp = -0.125 * (((D * D) * (M * (M / d))) * sqrt((h / (l ^ 3.0))));
	elseif (d <= 2e+170)
		tmp = t_2;
	else
		tmp = d * (sqrt((1.0 / 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[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(t$95$1 * 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]), $MachinePrecision]}, If[LessEqual[d, -1700.0], N[(N[(t$95$0 * t$95$1), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(M * N[(N[(h * M), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -8.5e-107], N[(N[(t$95$0 * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.125 * N[(N[(D * N[(N[(h / d), $MachinePrecision] * N[(M / N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.55e-302], t$95$2, If[LessEqual[d, 1.46e-168], N[(-0.125 * N[(N[(N[(D * D), $MachinePrecision] * N[(M * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2e+170], t$95$2, N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{d}{h}\right)}^{0.5}\\
t_1 := \sqrt{\frac{d}{\ell}}\\
t_2 := \sqrt{\frac{d}{h}} \cdot \left(t_1 \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\right)\\
\mathbf{if}\;d \leq -1700:\\
\;\;\;\;\left(t_0 \cdot t_1\right) \cdot \left(1 - \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{h \cdot M}{\ell}\right)\right) \cdot 0.125\right)\\

\mathbf{elif}\;d \leq -8.5 \cdot 10^{-107}:\\
\;\;\;\;\left(t_0 \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - 0.125 \cdot \frac{D \cdot \left(\frac{h}{d} \cdot \frac{M}{\frac{d}{M}}\right)}{\frac{\ell}{D}}\right)\\

\mathbf{elif}\;d \leq -1.55 \cdot 10^{-302}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;d \leq 1.46 \cdot 10^{-168}:\\
\;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\

\mathbf{elif}\;d \leq 2 \cdot 10^{+170}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -1700

    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. Taylor expanded in M around 0 50.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1700 < d < -8.49999999999999956e-107

    1. Initial program 74.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. Taylor expanded in M around 0 60.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.49999999999999956e-107 < d < -1.54999999999999992e-302 or 1.46e-168 < d < 2.00000000000000007e170

    1. Initial program 64.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. Step-by-step derivation
      1. associate-*l*64.9%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right)} \]
      2. metadata-eval64.9%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      3. unpow1/264.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      4. metadata-eval64.9%

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

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

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

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

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

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

    if -1.54999999999999992e-302 < d < 1.46e-168

    1. Initial program 37.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. Taylor expanded in d around 0 54.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000007e170 < d

    1. Initial program 62.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. Taylor expanded in d around inf 95.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1700:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{h \cdot M}{\ell}\right)\right) \cdot 0.125\right)\\ \mathbf{elif}\;d \leq -8.5 \cdot 10^{-107}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - 0.125 \cdot \frac{D \cdot \left(\frac{h}{d} \cdot \frac{M}{\frac{d}{M}}\right)}{\frac{\ell}{D}}\right)\\ \mathbf{elif}\;d \leq -1.55 \cdot 10^{-302}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\right)\\ \mathbf{elif}\;d \leq 1.46 \cdot 10^{-168}:\\ \;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \mathbf{elif}\;d \leq 2 \cdot 10^{+170}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 7: 68.8% accurate, 1.0× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -2.4 \cdot 10^{-302}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\right)\\ \mathbf{elif}\;d \leq 1.85 \cdot 10^{-177}:\\ \;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \mathbf{elif}\;d \leq 1.45 \cdot 10^{+171}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}}{\ell}\right)\right) \cdot \sqrt{\frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\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
 (if (<= d -2.4e-302)
   (*
    (* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
    (- 1.0 (/ (* h (* 0.5 (pow (* (* 0.5 M) (/ D d)) 2.0))) l)))
   (if (<= d 1.85e-177)
     (* -0.125 (* (* (* D D) (* M (/ M d))) (sqrt (/ h (pow l 3.0)))))
     (if (<= d 1.45e+171)
       (*
        (*
         (sqrt (/ d l))
         (- 1.0 (* 0.5 (/ (* h (pow (/ (* M D) (* d 2.0)) 2.0)) l))))
        (sqrt (/ d h)))
       (* d (/ (sqrt (/ 1.0 h)) (sqrt l)))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -2.4e-302) {
		tmp = (pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h * (0.5 * pow(((0.5 * M) * (D / d)), 2.0))) / l));
	} else if (d <= 1.85e-177) {
		tmp = -0.125 * (((D * D) * (M * (M / d))) * sqrt((h / pow(l, 3.0))));
	} else if (d <= 1.45e+171) {
		tmp = (sqrt((d / l)) * (1.0 - (0.5 * ((h * pow(((M * D) / (d * 2.0)), 2.0)) / l)))) * sqrt((d / h));
	} else {
		tmp = d * (sqrt((1.0 / 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) :: tmp
    if (d <= (-2.4d-302)) then
        tmp = (((d / h) ** 0.5d0) * ((d / l) ** 0.5d0)) * (1.0d0 - ((h * (0.5d0 * (((0.5d0 * m) * (d_1 / d)) ** 2.0d0))) / l))
    else if (d <= 1.85d-177) then
        tmp = (-0.125d0) * (((d_1 * d_1) * (m * (m / d))) * sqrt((h / (l ** 3.0d0))))
    else if (d <= 1.45d+171) then
        tmp = (sqrt((d / l)) * (1.0d0 - (0.5d0 * ((h * (((m * d_1) / (d * 2.0d0)) ** 2.0d0)) / l)))) * sqrt((d / h))
    else
        tmp = d * (sqrt((1.0d0 / 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 tmp;
	if (d <= -2.4e-302) {
		tmp = (Math.pow((d / h), 0.5) * Math.pow((d / l), 0.5)) * (1.0 - ((h * (0.5 * Math.pow(((0.5 * M) * (D / d)), 2.0))) / l));
	} else if (d <= 1.85e-177) {
		tmp = -0.125 * (((D * D) * (M * (M / d))) * Math.sqrt((h / Math.pow(l, 3.0))));
	} else if (d <= 1.45e+171) {
		tmp = (Math.sqrt((d / l)) * (1.0 - (0.5 * ((h * Math.pow(((M * D) / (d * 2.0)), 2.0)) / l)))) * Math.sqrt((d / h));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if d <= -2.4e-302:
		tmp = (math.pow((d / h), 0.5) * math.pow((d / l), 0.5)) * (1.0 - ((h * (0.5 * math.pow(((0.5 * M) * (D / d)), 2.0))) / l))
	elif d <= 1.85e-177:
		tmp = -0.125 * (((D * D) * (M * (M / d))) * math.sqrt((h / math.pow(l, 3.0))))
	elif d <= 1.45e+171:
		tmp = (math.sqrt((d / l)) * (1.0 - (0.5 * ((h * math.pow(((M * D) / (d * 2.0)), 2.0)) / l)))) * math.sqrt((d / h))
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= -2.4e-302)
		tmp = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h * Float64(0.5 * (Float64(Float64(0.5 * M) * Float64(D / d)) ^ 2.0))) / l)));
	elseif (d <= 1.85e-177)
		tmp = Float64(-0.125 * Float64(Float64(Float64(D * D) * Float64(M * Float64(M / d))) * sqrt(Float64(h / (l ^ 3.0)))));
	elseif (d <= 1.45e+171)
		tmp = Float64(Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0)) / l)))) * sqrt(Float64(d / h)));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / 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)
	tmp = 0.0;
	if (d <= -2.4e-302)
		tmp = (((d / h) ^ 0.5) * ((d / l) ^ 0.5)) * (1.0 - ((h * (0.5 * (((0.5 * M) * (D / d)) ^ 2.0))) / l));
	elseif (d <= 1.85e-177)
		tmp = -0.125 * (((D * D) * (M * (M / d))) * sqrt((h / (l ^ 3.0))));
	elseif (d <= 1.45e+171)
		tmp = (sqrt((d / l)) * (1.0 - (0.5 * ((h * (((M * D) / (d * 2.0)) ^ 2.0)) / l)))) * sqrt((d / h));
	else
		tmp = d * (sqrt((1.0 / 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_] := If[LessEqual[d, -2.4e-302], N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h * N[(0.5 * N[Power[N[(N[(0.5 * M), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.85e-177], N[(-0.125 * N[(N[(N[(D * D), $MachinePrecision] * N[(M * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.45e+171], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.4 \cdot 10^{-302}:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\right)\\

\mathbf{elif}\;d \leq 1.85 \cdot 10^{-177}:\\
\;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\

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

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


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

    1. Initial program 66.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. Step-by-step derivation
      1. associate-*r/67.8%

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

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

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

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

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

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

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

    if -2.40000000000000022e-302 < d < 1.84999999999999997e-177

    1. Initial program 37.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. Taylor expanded in d around 0 54.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.84999999999999997e-177 < d < 1.44999999999999992e171

    1. Initial program 71.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. Step-by-step derivation
      1. associate-*l*71.8%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right)} \]
      2. metadata-eval71.8%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      3. unpow1/271.8%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      4. metadata-eval71.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.44999999999999992e171 < d

    1. Initial program 62.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. Taylor expanded in d around inf 95.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.4 \cdot 10^{-302}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\right)\\ \mathbf{elif}\;d \leq 1.85 \cdot 10^{-177}:\\ \;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \mathbf{elif}\;d \leq 1.45 \cdot 10^{+171}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}}{\ell}\right)\right) \cdot \sqrt{\frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 8: 68.5% accurate, 1.0× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.7 \cdot 10^{+136}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\left(1 - 0.5 \cdot \left({\left(\frac{\frac{M \cdot D}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \sqrt{\frac{d}{\ell}}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\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
 (if (<= l 1.7e+136)
   (*
    (sqrt (/ d h))
    (*
     (- 1.0 (* 0.5 (* (pow (/ (/ (* M D) 2.0) d) 2.0) (/ h l))))
     (sqrt (/ d l))))
   (* d (/ (sqrt (/ 1.0 h)) (sqrt l)))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= 1.7e+136) {
		tmp = sqrt((d / h)) * ((1.0 - (0.5 * (pow((((M * D) / 2.0) / d), 2.0) * (h / l)))) * sqrt((d / l)));
	} else {
		tmp = d * (sqrt((1.0 / 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) :: tmp
    if (l <= 1.7d+136) then
        tmp = sqrt((d / h)) * ((1.0d0 - (0.5d0 * (((((m * d_1) / 2.0d0) / d) ** 2.0d0) * (h / l)))) * sqrt((d / l)))
    else
        tmp = d * (sqrt((1.0d0 / 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 tmp;
	if (l <= 1.7e+136) {
		tmp = Math.sqrt((d / h)) * ((1.0 - (0.5 * (Math.pow((((M * D) / 2.0) / d), 2.0) * (h / l)))) * Math.sqrt((d / l)));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if l <= 1.7e+136:
		tmp = math.sqrt((d / h)) * ((1.0 - (0.5 * (math.pow((((M * D) / 2.0) / d), 2.0) * (h / l)))) * math.sqrt((d / l)))
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= 1.7e+136)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(1.0 - Float64(0.5 * Float64((Float64(Float64(Float64(M * D) / 2.0) / d) ^ 2.0) * Float64(h / l)))) * sqrt(Float64(d / l))));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / 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)
	tmp = 0.0;
	if (l <= 1.7e+136)
		tmp = sqrt((d / h)) * ((1.0 - (0.5 * (((((M * D) / 2.0) / d) ^ 2.0) * (h / l)))) * sqrt((d / l)));
	else
		tmp = d * (sqrt((1.0 / 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_] := If[LessEqual[l, 1.7e+136], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 - N[(0.5 * N[(N[Power[N[(N[(N[(M * D), $MachinePrecision] / 2.0), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.7 \cdot 10^{+136}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\left(1 - 0.5 \cdot \left({\left(\frac{\frac{M \cdot D}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \sqrt{\frac{d}{\ell}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 1.69999999999999998e136

    1. Initial program 66.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. associate-*l*66.2%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right)} \]
      2. metadata-eval66.2%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      3. unpow1/266.2%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      4. metadata-eval66.2%

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

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

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

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

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

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

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

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

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

    if 1.69999999999999998e136 < l

    1. Initial program 48.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. Taylor expanded in d around inf 58.7%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    4. Simplified58.6%

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

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

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

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

Alternative 9: 69.6% accurate, 1.0× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 3.3 \cdot 10^{+136}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\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
 (if (<= l 3.3e+136)
   (*
    (sqrt (/ d h))
    (*
     (sqrt (/ d l))
     (- 1.0 (* 0.5 (/ (* h (pow (* (* 0.5 M) (/ D d)) 2.0)) l)))))
   (* d (/ (sqrt (/ 1.0 h)) (sqrt l)))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= 3.3e+136) {
		tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - (0.5 * ((h * pow(((0.5 * M) * (D / d)), 2.0)) / l))));
	} else {
		tmp = d * (sqrt((1.0 / 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) :: tmp
    if (l <= 3.3d+136) then
        tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0d0 - (0.5d0 * ((h * (((0.5d0 * m) * (d_1 / d)) ** 2.0d0)) / l))))
    else
        tmp = d * (sqrt((1.0d0 / 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 tmp;
	if (l <= 3.3e+136) {
		tmp = Math.sqrt((d / h)) * (Math.sqrt((d / l)) * (1.0 - (0.5 * ((h * Math.pow(((0.5 * M) * (D / d)), 2.0)) / l))));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if l <= 3.3e+136:
		tmp = math.sqrt((d / h)) * (math.sqrt((d / l)) * (1.0 - (0.5 * ((h * math.pow(((0.5 * M) * (D / d)), 2.0)) / l))))
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= 3.3e+136)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(0.5 * M) * Float64(D / d)) ^ 2.0)) / l)))));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / 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)
	tmp = 0.0;
	if (l <= 3.3e+136)
		tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - (0.5 * ((h * (((0.5 * M) * (D / d)) ^ 2.0)) / l))));
	else
		tmp = d * (sqrt((1.0 / 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_] := If[LessEqual[l, 3.3e+136], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(0.5 * M), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 3.3 \cdot 10^{+136}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 3.29999999999999992e136

    1. Initial program 66.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. associate-*l*66.2%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right)} \]
      2. metadata-eval66.2%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      3. unpow1/266.2%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      4. metadata-eval66.2%

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

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

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

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

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

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

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

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

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

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

    if 3.29999999999999992e136 < l

    1. Initial program 48.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. Taylor expanded in d around inf 58.7%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    4. Simplified58.6%

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

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

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

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

Alternative 10: 70.0% accurate, 1.0× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 5.8 \cdot 10^{+138}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}}{\ell}\right)\right) \cdot \sqrt{\frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\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
 (if (<= l 5.8e+138)
   (*
    (*
     (sqrt (/ d l))
     (- 1.0 (* 0.5 (/ (* h (pow (/ (* M D) (* d 2.0)) 2.0)) l))))
    (sqrt (/ d h)))
   (* d (/ (sqrt (/ 1.0 h)) (sqrt l)))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= 5.8e+138) {
		tmp = (sqrt((d / l)) * (1.0 - (0.5 * ((h * pow(((M * D) / (d * 2.0)), 2.0)) / l)))) * sqrt((d / h));
	} else {
		tmp = d * (sqrt((1.0 / 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) :: tmp
    if (l <= 5.8d+138) then
        tmp = (sqrt((d / l)) * (1.0d0 - (0.5d0 * ((h * (((m * d_1) / (d * 2.0d0)) ** 2.0d0)) / l)))) * sqrt((d / h))
    else
        tmp = d * (sqrt((1.0d0 / 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 tmp;
	if (l <= 5.8e+138) {
		tmp = (Math.sqrt((d / l)) * (1.0 - (0.5 * ((h * Math.pow(((M * D) / (d * 2.0)), 2.0)) / l)))) * Math.sqrt((d / h));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if l <= 5.8e+138:
		tmp = (math.sqrt((d / l)) * (1.0 - (0.5 * ((h * math.pow(((M * D) / (d * 2.0)), 2.0)) / l)))) * math.sqrt((d / h))
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= 5.8e+138)
		tmp = Float64(Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0)) / l)))) * sqrt(Float64(d / h)));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / 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)
	tmp = 0.0;
	if (l <= 5.8e+138)
		tmp = (sqrt((d / l)) * (1.0 - (0.5 * ((h * (((M * D) / (d * 2.0)) ^ 2.0)) / l)))) * sqrt((d / h));
	else
		tmp = d * (sqrt((1.0 / 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_] := If[LessEqual[l, 5.8e+138], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 5.8 \cdot 10^{+138}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}}{\ell}\right)\right) \cdot \sqrt{\frac{d}{h}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 5.80000000000000019e138

    1. Initial program 66.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. associate-*l*66.2%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right)} \]
      2. metadata-eval66.2%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      3. unpow1/266.2%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      4. metadata-eval66.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.80000000000000019e138 < l

    1. Initial program 48.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. Taylor expanded in d around inf 58.7%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    4. Simplified58.6%

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

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

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

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

Alternative 11: 60.9% accurate, 1.4× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{\ell}}\\ t_1 := \left({\left(\frac{d}{h}\right)}^{0.5} \cdot t_0\right) \cdot \left(1 - \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{h \cdot M}{\ell}\right)\right) \cdot 0.125\right)\\ \mathbf{if}\;d \leq -4.3 \cdot 10^{-131}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -8.5 \cdot 10^{-215}:\\ \;\;\;\;\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}} \cdot \left(1 + \frac{-0.5}{\frac{\frac{\ell}{h}}{{\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right)}^{2}}}\right)\\ \mathbf{elif}\;d \leq -1.55 \cdot 10^{-302}:\\ \;\;\;\;t_0 \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 1.55 \cdot 10^{-169}:\\ \;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \mathbf{elif}\;d \leq 2.35 \cdot 10^{+174}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\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 (sqrt (/ d l)))
        (t_1
         (*
          (* (pow (/ d h) 0.5) t_0)
          (- 1.0 (* (* (* (/ D d) (/ D d)) (* M (/ (* h M) l))) 0.125)))))
   (if (<= d -4.3e-131)
     t_1
     (if (<= d -8.5e-215)
       (*
        (sqrt (/ (/ d h) (/ l d)))
        (+ 1.0 (/ -0.5 (/ (/ l h) (pow (* 0.5 (/ M (/ d D))) 2.0)))))
       (if (<= d -1.55e-302)
         (* t_0 (sqrt (/ d h)))
         (if (<= d 1.55e-169)
           (* -0.125 (* (* (* D D) (* M (/ M d))) (sqrt (/ h (pow l 3.0)))))
           (if (<= d 2.35e+174) t_1 (* d (/ (sqrt (/ 1.0 h)) (sqrt l))))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / l));
	double t_1 = (pow((d / h), 0.5) * t_0) * (1.0 - ((((D / d) * (D / d)) * (M * ((h * M) / l))) * 0.125));
	double tmp;
	if (d <= -4.3e-131) {
		tmp = t_1;
	} else if (d <= -8.5e-215) {
		tmp = sqrt(((d / h) / (l / d))) * (1.0 + (-0.5 / ((l / h) / pow((0.5 * (M / (d / D))), 2.0))));
	} else if (d <= -1.55e-302) {
		tmp = t_0 * sqrt((d / h));
	} else if (d <= 1.55e-169) {
		tmp = -0.125 * (((D * D) * (M * (M / d))) * sqrt((h / pow(l, 3.0))));
	} else if (d <= 2.35e+174) {
		tmp = t_1;
	} else {
		tmp = d * (sqrt((1.0 / 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 = sqrt((d / l))
    t_1 = (((d / h) ** 0.5d0) * t_0) * (1.0d0 - ((((d_1 / d) * (d_1 / d)) * (m * ((h * m) / l))) * 0.125d0))
    if (d <= (-4.3d-131)) then
        tmp = t_1
    else if (d <= (-8.5d-215)) then
        tmp = sqrt(((d / h) / (l / d))) * (1.0d0 + ((-0.5d0) / ((l / h) / ((0.5d0 * (m / (d / d_1))) ** 2.0d0))))
    else if (d <= (-1.55d-302)) then
        tmp = t_0 * sqrt((d / h))
    else if (d <= 1.55d-169) then
        tmp = (-0.125d0) * (((d_1 * d_1) * (m * (m / d))) * sqrt((h / (l ** 3.0d0))))
    else if (d <= 2.35d+174) then
        tmp = t_1
    else
        tmp = d * (sqrt((1.0d0 / 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 = Math.sqrt((d / l));
	double t_1 = (Math.pow((d / h), 0.5) * t_0) * (1.0 - ((((D / d) * (D / d)) * (M * ((h * M) / l))) * 0.125));
	double tmp;
	if (d <= -4.3e-131) {
		tmp = t_1;
	} else if (d <= -8.5e-215) {
		tmp = Math.sqrt(((d / h) / (l / d))) * (1.0 + (-0.5 / ((l / h) / Math.pow((0.5 * (M / (d / D))), 2.0))));
	} else if (d <= -1.55e-302) {
		tmp = t_0 * Math.sqrt((d / h));
	} else if (d <= 1.55e-169) {
		tmp = -0.125 * (((D * D) * (M * (M / d))) * Math.sqrt((h / Math.pow(l, 3.0))));
	} else if (d <= 2.35e+174) {
		tmp = t_1;
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt((d / l))
	t_1 = (math.pow((d / h), 0.5) * t_0) * (1.0 - ((((D / d) * (D / d)) * (M * ((h * M) / l))) * 0.125))
	tmp = 0
	if d <= -4.3e-131:
		tmp = t_1
	elif d <= -8.5e-215:
		tmp = math.sqrt(((d / h) / (l / d))) * (1.0 + (-0.5 / ((l / h) / math.pow((0.5 * (M / (d / D))), 2.0))))
	elif d <= -1.55e-302:
		tmp = t_0 * math.sqrt((d / h))
	elif d <= 1.55e-169:
		tmp = -0.125 * (((D * D) * (M * (M / d))) * math.sqrt((h / math.pow(l, 3.0))))
	elif d <= 2.35e+174:
		tmp = t_1
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(d / l))
	t_1 = Float64(Float64((Float64(d / h) ^ 0.5) * t_0) * Float64(1.0 - Float64(Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(M * Float64(Float64(h * M) / l))) * 0.125)))
	tmp = 0.0
	if (d <= -4.3e-131)
		tmp = t_1;
	elseif (d <= -8.5e-215)
		tmp = Float64(sqrt(Float64(Float64(d / h) / Float64(l / d))) * Float64(1.0 + Float64(-0.5 / Float64(Float64(l / h) / (Float64(0.5 * Float64(M / Float64(d / D))) ^ 2.0)))));
	elseif (d <= -1.55e-302)
		tmp = Float64(t_0 * sqrt(Float64(d / h)));
	elseif (d <= 1.55e-169)
		tmp = Float64(-0.125 * Float64(Float64(Float64(D * D) * Float64(M * Float64(M / d))) * sqrt(Float64(h / (l ^ 3.0)))));
	elseif (d <= 2.35e+174)
		tmp = t_1;
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / 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 = sqrt((d / l));
	t_1 = (((d / h) ^ 0.5) * t_0) * (1.0 - ((((D / d) * (D / d)) * (M * ((h * M) / l))) * 0.125));
	tmp = 0.0;
	if (d <= -4.3e-131)
		tmp = t_1;
	elseif (d <= -8.5e-215)
		tmp = sqrt(((d / h) / (l / d))) * (1.0 + (-0.5 / ((l / h) / ((0.5 * (M / (d / D))) ^ 2.0))));
	elseif (d <= -1.55e-302)
		tmp = t_0 * sqrt((d / h));
	elseif (d <= 1.55e-169)
		tmp = -0.125 * (((D * D) * (M * (M / d))) * sqrt((h / (l ^ 3.0))));
	elseif (d <= 2.35e+174)
		tmp = t_1;
	else
		tmp = d * (sqrt((1.0 / 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[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * t$95$0), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(M * N[(N[(h * M), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.3e-131], t$95$1, If[LessEqual[d, -8.5e-215], N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] / N[(l / d), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 / N[(N[(l / h), $MachinePrecision] / N[Power[N[(0.5 * N[(M / N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.55e-302], N[(t$95$0 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.55e-169], N[(-0.125 * N[(N[(N[(D * D), $MachinePrecision] * N[(M * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.35e+174], t$95$1, N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \left({\left(\frac{d}{h}\right)}^{0.5} \cdot t_0\right) \cdot \left(1 - \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{h \cdot M}{\ell}\right)\right) \cdot 0.125\right)\\
\mathbf{if}\;d \leq -4.3 \cdot 10^{-131}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;d \leq -1.55 \cdot 10^{-302}:\\
\;\;\;\;t_0 \cdot \sqrt{\frac{d}{h}}\\

\mathbf{elif}\;d \leq 1.55 \cdot 10^{-169}:\\
\;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\

\mathbf{elif}\;d \leq 2.35 \cdot 10^{+174}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -4.30000000000000019e-131 or 1.5500000000000001e-169 < d < 2.3499999999999998e174

    1. Initial program 73.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. Taylor expanded in M around 0 51.7%

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

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

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

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}}\right) \]
      4. *-commutative51.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.30000000000000019e-131 < d < -8.4999999999999998e-215

    1. Initial program 73.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. Step-by-step derivation
      1. associate-*r/73.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.4999999999999998e-215 < d < -1.54999999999999992e-302

    1. Initial program 25.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. Step-by-step derivation
      1. associate-*l*25.7%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right)} \]
      2. metadata-eval25.7%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      3. unpow1/225.7%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      4. metadata-eval25.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.54999999999999992e-302 < d < 1.5500000000000001e-169

    1. Initial program 37.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. Taylor expanded in d around 0 54.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.3499999999999998e174 < d

    1. Initial program 62.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. Taylor expanded in d around inf 95.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.3 \cdot 10^{-131}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{h \cdot M}{\ell}\right)\right) \cdot 0.125\right)\\ \mathbf{elif}\;d \leq -8.5 \cdot 10^{-215}:\\ \;\;\;\;\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}} \cdot \left(1 + \frac{-0.5}{\frac{\frac{\ell}{h}}{{\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right)}^{2}}}\right)\\ \mathbf{elif}\;d \leq -1.55 \cdot 10^{-302}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 1.55 \cdot 10^{-169}:\\ \;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \mathbf{elif}\;d \leq 2.35 \cdot 10^{+174}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{h \cdot M}{\ell}\right)\right) \cdot 0.125\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 12: 61.7% accurate, 1.4× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := {\left(\frac{d}{h}\right)}^{0.5}\\ t_1 := \left(t_0 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{h \cdot M}{\ell}\right)\right) \cdot 0.125\right)\\ \mathbf{if}\;d \leq -1.2 \cdot 10^{-22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 2.45 \cdot 10^{-266}:\\ \;\;\;\;\left(t_0 \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - 0.125 \cdot \left(\frac{D}{\frac{\ell}{D}} \cdot \left(\left(M \cdot \frac{M}{d}\right) \cdot \frac{h}{d}\right)\right)\right)\\ \mathbf{elif}\;d \leq 9.6 \cdot 10^{-167}:\\ \;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{-0.125 \cdot \left(D \cdot D\right)}{\frac{\frac{d}{M}}{M}}\\ \mathbf{elif}\;d \leq 1.4 \cdot 10^{+178}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\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 (pow (/ d h) 0.5))
        (t_1
         (*
          (* t_0 (sqrt (/ d l)))
          (- 1.0 (* (* (* (/ D d) (/ D d)) (* M (/ (* h M) l))) 0.125)))))
   (if (<= d -1.2e-22)
     t_1
     (if (<= d 2.45e-266)
       (*
        (* t_0 (pow (/ d l) 0.5))
        (- 1.0 (* 0.125 (* (/ D (/ l D)) (* (* M (/ M d)) (/ h d))))))
       (if (<= d 9.6e-167)
         (* (sqrt (/ h (pow l 3.0))) (/ (* -0.125 (* D D)) (/ (/ d M) M)))
         (if (<= d 1.4e+178) t_1 (* d (/ (sqrt (/ 1.0 h)) (sqrt l)))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = pow((d / h), 0.5);
	double t_1 = (t_0 * sqrt((d / l))) * (1.0 - ((((D / d) * (D / d)) * (M * ((h * M) / l))) * 0.125));
	double tmp;
	if (d <= -1.2e-22) {
		tmp = t_1;
	} else if (d <= 2.45e-266) {
		tmp = (t_0 * pow((d / l), 0.5)) * (1.0 - (0.125 * ((D / (l / D)) * ((M * (M / d)) * (h / d)))));
	} else if (d <= 9.6e-167) {
		tmp = sqrt((h / pow(l, 3.0))) * ((-0.125 * (D * D)) / ((d / M) / M));
	} else if (d <= 1.4e+178) {
		tmp = t_1;
	} else {
		tmp = d * (sqrt((1.0 / 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 = (d / h) ** 0.5d0
    t_1 = (t_0 * sqrt((d / l))) * (1.0d0 - ((((d_1 / d) * (d_1 / d)) * (m * ((h * m) / l))) * 0.125d0))
    if (d <= (-1.2d-22)) then
        tmp = t_1
    else if (d <= 2.45d-266) then
        tmp = (t_0 * ((d / l) ** 0.5d0)) * (1.0d0 - (0.125d0 * ((d_1 / (l / d_1)) * ((m * (m / d)) * (h / d)))))
    else if (d <= 9.6d-167) then
        tmp = sqrt((h / (l ** 3.0d0))) * (((-0.125d0) * (d_1 * d_1)) / ((d / m) / m))
    else if (d <= 1.4d+178) then
        tmp = t_1
    else
        tmp = d * (sqrt((1.0d0 / 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 = Math.pow((d / h), 0.5);
	double t_1 = (t_0 * Math.sqrt((d / l))) * (1.0 - ((((D / d) * (D / d)) * (M * ((h * M) / l))) * 0.125));
	double tmp;
	if (d <= -1.2e-22) {
		tmp = t_1;
	} else if (d <= 2.45e-266) {
		tmp = (t_0 * Math.pow((d / l), 0.5)) * (1.0 - (0.125 * ((D / (l / D)) * ((M * (M / d)) * (h / d)))));
	} else if (d <= 9.6e-167) {
		tmp = Math.sqrt((h / Math.pow(l, 3.0))) * ((-0.125 * (D * D)) / ((d / M) / M));
	} else if (d <= 1.4e+178) {
		tmp = t_1;
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.pow((d / h), 0.5)
	t_1 = (t_0 * math.sqrt((d / l))) * (1.0 - ((((D / d) * (D / d)) * (M * ((h * M) / l))) * 0.125))
	tmp = 0
	if d <= -1.2e-22:
		tmp = t_1
	elif d <= 2.45e-266:
		tmp = (t_0 * math.pow((d / l), 0.5)) * (1.0 - (0.125 * ((D / (l / D)) * ((M * (M / d)) * (h / d)))))
	elif d <= 9.6e-167:
		tmp = math.sqrt((h / math.pow(l, 3.0))) * ((-0.125 * (D * D)) / ((d / M) / M))
	elif d <= 1.4e+178:
		tmp = t_1
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(d / h) ^ 0.5
	t_1 = Float64(Float64(t_0 * sqrt(Float64(d / l))) * Float64(1.0 - Float64(Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(M * Float64(Float64(h * M) / l))) * 0.125)))
	tmp = 0.0
	if (d <= -1.2e-22)
		tmp = t_1;
	elseif (d <= 2.45e-266)
		tmp = Float64(Float64(t_0 * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(0.125 * Float64(Float64(D / Float64(l / D)) * Float64(Float64(M * Float64(M / d)) * Float64(h / d))))));
	elseif (d <= 9.6e-167)
		tmp = Float64(sqrt(Float64(h / (l ^ 3.0))) * Float64(Float64(-0.125 * Float64(D * D)) / Float64(Float64(d / M) / M)));
	elseif (d <= 1.4e+178)
		tmp = t_1;
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / 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 = (d / h) ^ 0.5;
	t_1 = (t_0 * sqrt((d / l))) * (1.0 - ((((D / d) * (D / d)) * (M * ((h * M) / l))) * 0.125));
	tmp = 0.0;
	if (d <= -1.2e-22)
		tmp = t_1;
	elseif (d <= 2.45e-266)
		tmp = (t_0 * ((d / l) ^ 0.5)) * (1.0 - (0.125 * ((D / (l / D)) * ((M * (M / d)) * (h / d)))));
	elseif (d <= 9.6e-167)
		tmp = sqrt((h / (l ^ 3.0))) * ((-0.125 * (D * D)) / ((d / M) / M));
	elseif (d <= 1.4e+178)
		tmp = t_1;
	else
		tmp = d * (sqrt((1.0 / 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[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(M * N[(N[(h * M), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.2e-22], t$95$1, If[LessEqual[d, 2.45e-266], N[(N[(t$95$0 * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.125 * N[(N[(D / N[(l / D), $MachinePrecision]), $MachinePrecision] * N[(N[(M * N[(M / d), $MachinePrecision]), $MachinePrecision] * N[(h / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9.6e-167], N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(-0.125 * N[(D * D), $MachinePrecision]), $MachinePrecision] / N[(N[(d / M), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.4e+178], t$95$1, N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{d}{h}\right)}^{0.5}\\
t_1 := \left(t_0 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{h \cdot M}{\ell}\right)\right) \cdot 0.125\right)\\
\mathbf{if}\;d \leq -1.2 \cdot 10^{-22}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;d \leq 2.45 \cdot 10^{-266}:\\
\;\;\;\;\left(t_0 \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - 0.125 \cdot \left(\frac{D}{\frac{\ell}{D}} \cdot \left(\left(M \cdot \frac{M}{d}\right) \cdot \frac{h}{d}\right)\right)\right)\\

\mathbf{elif}\;d \leq 9.6 \cdot 10^{-167}:\\
\;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{-0.125 \cdot \left(D \cdot D\right)}{\frac{\frac{d}{M}}{M}}\\

\mathbf{elif}\;d \leq 1.4 \cdot 10^{+178}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.20000000000000001e-22 or 9.59999999999999972e-167 < d < 1.39999999999999997e178

    1. Initial program 73.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. Taylor expanded in M around 0 50.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.20000000000000001e-22 < d < 2.4500000000000001e-266

    1. Initial program 54.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. Taylor expanded in M around 0 28.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.4500000000000001e-266 < d < 9.59999999999999972e-167

    1. Initial program 38.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. Taylor expanded in d around 0 69.1%

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

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

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

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

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

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

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

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

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

    if 1.39999999999999997e178 < d

    1. Initial program 62.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. Taylor expanded in d around inf 95.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.2 \cdot 10^{-22}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{h \cdot M}{\ell}\right)\right) \cdot 0.125\right)\\ \mathbf{elif}\;d \leq 2.45 \cdot 10^{-266}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - 0.125 \cdot \left(\frac{D}{\frac{\ell}{D}} \cdot \left(\left(M \cdot \frac{M}{d}\right) \cdot \frac{h}{d}\right)\right)\right)\\ \mathbf{elif}\;d \leq 9.6 \cdot 10^{-167}:\\ \;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{-0.125 \cdot \left(D \cdot D\right)}{\frac{\frac{d}{M}}{M}}\\ \mathbf{elif}\;d \leq 1.4 \cdot 10^{+178}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{h \cdot M}{\ell}\right)\right) \cdot 0.125\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 13: 62.4% accurate, 1.4× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := {\left(\frac{d}{h}\right)}^{0.5}\\ t_1 := \left(t_0 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{h \cdot M}{\ell}\right)\right) \cdot 0.125\right)\\ \mathbf{if}\;d \leq -40000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 9 \cdot 10^{-266}:\\ \;\;\;\;\left(t_0 \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - 0.125 \cdot \frac{D \cdot \left(\frac{h}{d} \cdot \frac{M}{\frac{d}{M}}\right)}{\frac{\ell}{D}}\right)\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{-172}:\\ \;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{-0.125 \cdot \left(D \cdot D\right)}{\frac{\frac{d}{M}}{M}}\\ \mathbf{elif}\;d \leq 5.1 \cdot 10^{+169}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\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 (pow (/ d h) 0.5))
        (t_1
         (*
          (* t_0 (sqrt (/ d l)))
          (- 1.0 (* (* (* (/ D d) (/ D d)) (* M (/ (* h M) l))) 0.125)))))
   (if (<= d -40000.0)
     t_1
     (if (<= d 9e-266)
       (*
        (* t_0 (pow (/ d l) 0.5))
        (- 1.0 (* 0.125 (/ (* D (* (/ h d) (/ M (/ d M)))) (/ l D)))))
       (if (<= d 3.3e-172)
         (* (sqrt (/ h (pow l 3.0))) (/ (* -0.125 (* D D)) (/ (/ d M) M)))
         (if (<= d 5.1e+169) t_1 (* d (/ (sqrt (/ 1.0 h)) (sqrt l)))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = pow((d / h), 0.5);
	double t_1 = (t_0 * sqrt((d / l))) * (1.0 - ((((D / d) * (D / d)) * (M * ((h * M) / l))) * 0.125));
	double tmp;
	if (d <= -40000.0) {
		tmp = t_1;
	} else if (d <= 9e-266) {
		tmp = (t_0 * pow((d / l), 0.5)) * (1.0 - (0.125 * ((D * ((h / d) * (M / (d / M)))) / (l / D))));
	} else if (d <= 3.3e-172) {
		tmp = sqrt((h / pow(l, 3.0))) * ((-0.125 * (D * D)) / ((d / M) / M));
	} else if (d <= 5.1e+169) {
		tmp = t_1;
	} else {
		tmp = d * (sqrt((1.0 / 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 = (d / h) ** 0.5d0
    t_1 = (t_0 * sqrt((d / l))) * (1.0d0 - ((((d_1 / d) * (d_1 / d)) * (m * ((h * m) / l))) * 0.125d0))
    if (d <= (-40000.0d0)) then
        tmp = t_1
    else if (d <= 9d-266) then
        tmp = (t_0 * ((d / l) ** 0.5d0)) * (1.0d0 - (0.125d0 * ((d_1 * ((h / d) * (m / (d / m)))) / (l / d_1))))
    else if (d <= 3.3d-172) then
        tmp = sqrt((h / (l ** 3.0d0))) * (((-0.125d0) * (d_1 * d_1)) / ((d / m) / m))
    else if (d <= 5.1d+169) then
        tmp = t_1
    else
        tmp = d * (sqrt((1.0d0 / 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 = Math.pow((d / h), 0.5);
	double t_1 = (t_0 * Math.sqrt((d / l))) * (1.0 - ((((D / d) * (D / d)) * (M * ((h * M) / l))) * 0.125));
	double tmp;
	if (d <= -40000.0) {
		tmp = t_1;
	} else if (d <= 9e-266) {
		tmp = (t_0 * Math.pow((d / l), 0.5)) * (1.0 - (0.125 * ((D * ((h / d) * (M / (d / M)))) / (l / D))));
	} else if (d <= 3.3e-172) {
		tmp = Math.sqrt((h / Math.pow(l, 3.0))) * ((-0.125 * (D * D)) / ((d / M) / M));
	} else if (d <= 5.1e+169) {
		tmp = t_1;
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.pow((d / h), 0.5)
	t_1 = (t_0 * math.sqrt((d / l))) * (1.0 - ((((D / d) * (D / d)) * (M * ((h * M) / l))) * 0.125))
	tmp = 0
	if d <= -40000.0:
		tmp = t_1
	elif d <= 9e-266:
		tmp = (t_0 * math.pow((d / l), 0.5)) * (1.0 - (0.125 * ((D * ((h / d) * (M / (d / M)))) / (l / D))))
	elif d <= 3.3e-172:
		tmp = math.sqrt((h / math.pow(l, 3.0))) * ((-0.125 * (D * D)) / ((d / M) / M))
	elif d <= 5.1e+169:
		tmp = t_1
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(d / h) ^ 0.5
	t_1 = Float64(Float64(t_0 * sqrt(Float64(d / l))) * Float64(1.0 - Float64(Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(M * Float64(Float64(h * M) / l))) * 0.125)))
	tmp = 0.0
	if (d <= -40000.0)
		tmp = t_1;
	elseif (d <= 9e-266)
		tmp = Float64(Float64(t_0 * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(0.125 * Float64(Float64(D * Float64(Float64(h / d) * Float64(M / Float64(d / M)))) / Float64(l / D)))));
	elseif (d <= 3.3e-172)
		tmp = Float64(sqrt(Float64(h / (l ^ 3.0))) * Float64(Float64(-0.125 * Float64(D * D)) / Float64(Float64(d / M) / M)));
	elseif (d <= 5.1e+169)
		tmp = t_1;
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / 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 = (d / h) ^ 0.5;
	t_1 = (t_0 * sqrt((d / l))) * (1.0 - ((((D / d) * (D / d)) * (M * ((h * M) / l))) * 0.125));
	tmp = 0.0;
	if (d <= -40000.0)
		tmp = t_1;
	elseif (d <= 9e-266)
		tmp = (t_0 * ((d / l) ^ 0.5)) * (1.0 - (0.125 * ((D * ((h / d) * (M / (d / M)))) / (l / D))));
	elseif (d <= 3.3e-172)
		tmp = sqrt((h / (l ^ 3.0))) * ((-0.125 * (D * D)) / ((d / M) / M));
	elseif (d <= 5.1e+169)
		tmp = t_1;
	else
		tmp = d * (sqrt((1.0 / 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[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(M * N[(N[(h * M), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -40000.0], t$95$1, If[LessEqual[d, 9e-266], N[(N[(t$95$0 * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.125 * N[(N[(D * N[(N[(h / d), $MachinePrecision] * N[(M / N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.3e-172], N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(-0.125 * N[(D * D), $MachinePrecision]), $MachinePrecision] / N[(N[(d / M), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.1e+169], t$95$1, N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{d}{h}\right)}^{0.5}\\
t_1 := \left(t_0 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{h \cdot M}{\ell}\right)\right) \cdot 0.125\right)\\
\mathbf{if}\;d \leq -40000:\\
\;\;\;\;t_1\\

\mathbf{elif}\;d \leq 9 \cdot 10^{-266}:\\
\;\;\;\;\left(t_0 \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - 0.125 \cdot \frac{D \cdot \left(\frac{h}{d} \cdot \frac{M}{\frac{d}{M}}\right)}{\frac{\ell}{D}}\right)\\

\mathbf{elif}\;d \leq 3.3 \cdot 10^{-172}:\\
\;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{-0.125 \cdot \left(D \cdot D\right)}{\frac{\frac{d}{M}}{M}}\\

\mathbf{elif}\;d \leq 5.1 \cdot 10^{+169}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -4e4 or 3.3e-172 < d < 5.10000000000000008e169

    1. Initial program 72.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. Taylor expanded in M around 0 50.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4e4 < d < 9.0000000000000006e-266

    1. Initial program 56.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. Taylor expanded in M around 0 31.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.0000000000000006e-266 < d < 3.3e-172

    1. Initial program 39.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. Taylor expanded in d around 0 71.7%

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

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

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

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

        \[\leadsto \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\frac{-0.125 \cdot {D}^{2}}{\frac{d}{{M}^{2}}}} \]
      5. unpow271.7%

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

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

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

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

    if 5.10000000000000008e169 < d

    1. Initial program 62.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. Taylor expanded in d around inf 95.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -40000:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{h \cdot M}{\ell}\right)\right) \cdot 0.125\right)\\ \mathbf{elif}\;d \leq 9 \cdot 10^{-266}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - 0.125 \cdot \frac{D \cdot \left(\frac{h}{d} \cdot \frac{M}{\frac{d}{M}}\right)}{\frac{\ell}{D}}\right)\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{-172}:\\ \;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{-0.125 \cdot \left(D \cdot D\right)}{\frac{\frac{d}{M}}{M}}\\ \mathbf{elif}\;d \leq 5.1 \cdot 10^{+169}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{h \cdot M}{\ell}\right)\right) \cdot 0.125\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 14: 59.9% accurate, 1.4× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - h \cdot \frac{0.5 \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\\ \mathbf{if}\;d \leq -2.5 \cdot 10^{-257}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 6.2 \cdot 10^{-169}:\\ \;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{-0.125 \cdot \left(D \cdot D\right)}{\frac{\frac{d}{M}}{M}}\\ \mathbf{elif}\;d \leq 9.5 \cdot 10^{+164}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\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
         (*
          (sqrt (* (/ d h) (/ d l)))
          (- 1.0 (* h (/ (* 0.5 (pow (* (* 0.5 M) (/ D d)) 2.0)) l))))))
   (if (<= d -2.5e-257)
     t_0
     (if (<= d 6.2e-169)
       (* (sqrt (/ h (pow l 3.0))) (/ (* -0.125 (* D D)) (/ (/ d M) M)))
       (if (<= d 9.5e+164) t_0 (* d (/ (sqrt (/ 1.0 h)) (sqrt l))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt(((d / h) * (d / l))) * (1.0 - (h * ((0.5 * pow(((0.5 * M) * (D / d)), 2.0)) / l)));
	double tmp;
	if (d <= -2.5e-257) {
		tmp = t_0;
	} else if (d <= 6.2e-169) {
		tmp = sqrt((h / pow(l, 3.0))) * ((-0.125 * (D * D)) / ((d / M) / M));
	} else if (d <= 9.5e+164) {
		tmp = t_0;
	} else {
		tmp = d * (sqrt((1.0 / 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) :: tmp
    t_0 = sqrt(((d / h) * (d / l))) * (1.0d0 - (h * ((0.5d0 * (((0.5d0 * m) * (d_1 / d)) ** 2.0d0)) / l)))
    if (d <= (-2.5d-257)) then
        tmp = t_0
    else if (d <= 6.2d-169) then
        tmp = sqrt((h / (l ** 3.0d0))) * (((-0.125d0) * (d_1 * d_1)) / ((d / m) / m))
    else if (d <= 9.5d+164) then
        tmp = t_0
    else
        tmp = d * (sqrt((1.0d0 / 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 = Math.sqrt(((d / h) * (d / l))) * (1.0 - (h * ((0.5 * Math.pow(((0.5 * M) * (D / d)), 2.0)) / l)));
	double tmp;
	if (d <= -2.5e-257) {
		tmp = t_0;
	} else if (d <= 6.2e-169) {
		tmp = Math.sqrt((h / Math.pow(l, 3.0))) * ((-0.125 * (D * D)) / ((d / M) / M));
	} else if (d <= 9.5e+164) {
		tmp = t_0;
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt(((d / h) * (d / l))) * (1.0 - (h * ((0.5 * math.pow(((0.5 * M) * (D / d)), 2.0)) / l)))
	tmp = 0
	if d <= -2.5e-257:
		tmp = t_0
	elif d <= 6.2e-169:
		tmp = math.sqrt((h / math.pow(l, 3.0))) * ((-0.125 * (D * D)) / ((d / M) / M))
	elif d <= 9.5e+164:
		tmp = t_0
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 - Float64(h * Float64(Float64(0.5 * (Float64(Float64(0.5 * M) * Float64(D / d)) ^ 2.0)) / l))))
	tmp = 0.0
	if (d <= -2.5e-257)
		tmp = t_0;
	elseif (d <= 6.2e-169)
		tmp = Float64(sqrt(Float64(h / (l ^ 3.0))) * Float64(Float64(-0.125 * Float64(D * D)) / Float64(Float64(d / M) / M)));
	elseif (d <= 9.5e+164)
		tmp = t_0;
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / 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 = sqrt(((d / h) * (d / l))) * (1.0 - (h * ((0.5 * (((0.5 * M) * (D / d)) ^ 2.0)) / l)));
	tmp = 0.0;
	if (d <= -2.5e-257)
		tmp = t_0;
	elseif (d <= 6.2e-169)
		tmp = sqrt((h / (l ^ 3.0))) * ((-0.125 * (D * D)) / ((d / M) / M));
	elseif (d <= 9.5e+164)
		tmp = t_0;
	else
		tmp = d * (sqrt((1.0 / 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[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(h * N[(N[(0.5 * N[Power[N[(N[(0.5 * M), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.5e-257], t$95$0, If[LessEqual[d, 6.2e-169], N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(-0.125 * N[(D * D), $MachinePrecision]), $MachinePrecision] / N[(N[(d / M), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9.5e+164], t$95$0, N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - h \cdot \frac{0.5 \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\\
\mathbf{if}\;d \leq -2.5 \cdot 10^{-257}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq 6.2 \cdot 10^{-169}:\\
\;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{-0.125 \cdot \left(D \cdot D\right)}{\frac{\frac{d}{M}}{M}}\\

\mathbf{elif}\;d \leq 9.5 \cdot 10^{+164}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.49999999999999994e-257 or 6.2000000000000004e-169 < d < 9.49999999999999976e164

    1. Initial program 70.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. associate-*r/72.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.49999999999999994e-257 < d < 6.2000000000000004e-169

    1. Initial program 34.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. Taylor expanded in d around 0 44.0%

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

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

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

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

        \[\leadsto \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\frac{-0.125 \cdot {D}^{2}}{\frac{d}{{M}^{2}}}} \]
      5. unpow243.8%

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

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

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

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

    if 9.49999999999999976e164 < d

    1. Initial program 65.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Taylor expanded in d around inf 96.1%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    4. Simplified95.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.5 \cdot 10^{-257}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - h \cdot \frac{0.5 \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\\ \mathbf{elif}\;d \leq 6.2 \cdot 10^{-169}:\\ \;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{-0.125 \cdot \left(D \cdot D\right)}{\frac{\frac{d}{M}}{M}}\\ \mathbf{elif}\;d \leq 9.5 \cdot 10^{+164}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - h \cdot \frac{0.5 \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 15: 47.1% accurate, 1.5× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{if}\;d \leq -5 \cdot 10^{-157}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -1.7 \cdot 10^{-225}:\\ \;\;\;\;d \cdot {\left({\left(\ell \cdot h\right)}^{-3}\right)}^{0.16666666666666666}\\ \mathbf{elif}\;d \leq -1.55 \cdot 10^{-302}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 1.15 \cdot 10^{-169}:\\ \;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\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 (* (sqrt (/ d l)) (sqrt (/ d h)))))
   (if (<= d -5e-157)
     t_0
     (if (<= d -1.7e-225)
       (* d (pow (pow (* l h) -3.0) 0.16666666666666666))
       (if (<= d -1.55e-302)
         t_0
         (if (<= d 1.15e-169)
           (* -0.125 (* (* (* D D) (* M (/ M d))) (sqrt (/ h (pow l 3.0)))))
           (* d (/ (sqrt (/ 1.0 h)) (sqrt l)))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / l)) * sqrt((d / h));
	double tmp;
	if (d <= -5e-157) {
		tmp = t_0;
	} else if (d <= -1.7e-225) {
		tmp = d * pow(pow((l * h), -3.0), 0.16666666666666666);
	} else if (d <= -1.55e-302) {
		tmp = t_0;
	} else if (d <= 1.15e-169) {
		tmp = -0.125 * (((D * D) * (M * (M / d))) * sqrt((h / pow(l, 3.0))));
	} else {
		tmp = d * (sqrt((1.0 / 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) :: tmp
    t_0 = sqrt((d / l)) * sqrt((d / h))
    if (d <= (-5d-157)) then
        tmp = t_0
    else if (d <= (-1.7d-225)) then
        tmp = d * (((l * h) ** (-3.0d0)) ** 0.16666666666666666d0)
    else if (d <= (-1.55d-302)) then
        tmp = t_0
    else if (d <= 1.15d-169) then
        tmp = (-0.125d0) * (((d_1 * d_1) * (m * (m / d))) * sqrt((h / (l ** 3.0d0))))
    else
        tmp = d * (sqrt((1.0d0 / 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 = Math.sqrt((d / l)) * Math.sqrt((d / h));
	double tmp;
	if (d <= -5e-157) {
		tmp = t_0;
	} else if (d <= -1.7e-225) {
		tmp = d * Math.pow(Math.pow((l * h), -3.0), 0.16666666666666666);
	} else if (d <= -1.55e-302) {
		tmp = t_0;
	} else if (d <= 1.15e-169) {
		tmp = -0.125 * (((D * D) * (M * (M / d))) * Math.sqrt((h / Math.pow(l, 3.0))));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt((d / l)) * math.sqrt((d / h))
	tmp = 0
	if d <= -5e-157:
		tmp = t_0
	elif d <= -1.7e-225:
		tmp = d * math.pow(math.pow((l * h), -3.0), 0.16666666666666666)
	elif d <= -1.55e-302:
		tmp = t_0
	elif d <= 1.15e-169:
		tmp = -0.125 * (((D * D) * (M * (M / d))) * math.sqrt((h / math.pow(l, 3.0))))
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h)))
	tmp = 0.0
	if (d <= -5e-157)
		tmp = t_0;
	elseif (d <= -1.7e-225)
		tmp = Float64(d * ((Float64(l * h) ^ -3.0) ^ 0.16666666666666666));
	elseif (d <= -1.55e-302)
		tmp = t_0;
	elseif (d <= 1.15e-169)
		tmp = Float64(-0.125 * Float64(Float64(Float64(D * D) * Float64(M * Float64(M / d))) * sqrt(Float64(h / (l ^ 3.0)))));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / 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 = sqrt((d / l)) * sqrt((d / h));
	tmp = 0.0;
	if (d <= -5e-157)
		tmp = t_0;
	elseif (d <= -1.7e-225)
		tmp = d * (((l * h) ^ -3.0) ^ 0.16666666666666666);
	elseif (d <= -1.55e-302)
		tmp = t_0;
	elseif (d <= 1.15e-169)
		tmp = -0.125 * (((D * D) * (M * (M / d))) * sqrt((h / (l ^ 3.0))));
	else
		tmp = d * (sqrt((1.0 / 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[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5e-157], t$95$0, If[LessEqual[d, -1.7e-225], N[(d * N[Power[N[Power[N[(l * h), $MachinePrecision], -3.0], $MachinePrecision], 0.16666666666666666], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.55e-302], t$95$0, If[LessEqual[d, 1.15e-169], N[(-0.125 * N[(N[(N[(D * D), $MachinePrecision] * N[(M * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{if}\;d \leq -5 \cdot 10^{-157}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq -1.7 \cdot 10^{-225}:\\
\;\;\;\;d \cdot {\left({\left(\ell \cdot h\right)}^{-3}\right)}^{0.16666666666666666}\\

\mathbf{elif}\;d \leq -1.55 \cdot 10^{-302}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq 1.15 \cdot 10^{-169}:\\
\;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -5.0000000000000002e-157 or -1.7e-225 < d < -1.54999999999999992e-302

    1. Initial program 67.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. Step-by-step derivation
      1. associate-*l*67.3%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right)} \]
      2. metadata-eval67.3%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      3. unpow1/267.3%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      4. metadata-eval67.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.0000000000000002e-157 < d < -1.7e-225

    1. Initial program 58.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. Taylor expanded in d around inf 23.6%

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

        \[\leadsto \color{blue}{{\left(\frac{1}{\ell \cdot h}\right)}^{0.5}} \cdot d \]
      2. add-cbrt-cube33.9%

        \[\leadsto {\color{blue}{\left(\sqrt[3]{\left(\frac{1}{\ell \cdot h} \cdot \frac{1}{\ell \cdot h}\right) \cdot \frac{1}{\ell \cdot h}}\right)}}^{0.5} \cdot d \]
      3. pow1/333.9%

        \[\leadsto {\color{blue}{\left({\left(\left(\frac{1}{\ell \cdot h} \cdot \frac{1}{\ell \cdot h}\right) \cdot \frac{1}{\ell \cdot h}\right)}^{0.3333333333333333}\right)}}^{0.5} \cdot d \]
      4. pow-pow33.9%

        \[\leadsto \color{blue}{{\left(\left(\frac{1}{\ell \cdot h} \cdot \frac{1}{\ell \cdot h}\right) \cdot \frac{1}{\ell \cdot h}\right)}^{\left(0.3333333333333333 \cdot 0.5\right)}} \cdot d \]
      5. pow333.9%

        \[\leadsto {\color{blue}{\left({\left(\frac{1}{\ell \cdot h}\right)}^{3}\right)}}^{\left(0.3333333333333333 \cdot 0.5\right)} \cdot d \]
      6. inv-pow33.9%

        \[\leadsto {\left({\color{blue}{\left({\left(\ell \cdot h\right)}^{-1}\right)}}^{3}\right)}^{\left(0.3333333333333333 \cdot 0.5\right)} \cdot d \]
      7. pow-pow33.9%

        \[\leadsto {\color{blue}{\left({\left(\ell \cdot h\right)}^{\left(-1 \cdot 3\right)}\right)}}^{\left(0.3333333333333333 \cdot 0.5\right)} \cdot d \]
      8. *-commutative33.9%

        \[\leadsto {\left({\color{blue}{\left(h \cdot \ell\right)}}^{\left(-1 \cdot 3\right)}\right)}^{\left(0.3333333333333333 \cdot 0.5\right)} \cdot d \]
      9. metadata-eval33.9%

        \[\leadsto {\left({\left(h \cdot \ell\right)}^{\color{blue}{-3}}\right)}^{\left(0.3333333333333333 \cdot 0.5\right)} \cdot d \]
      10. metadata-eval33.9%

        \[\leadsto {\left({\left(h \cdot \ell\right)}^{-3}\right)}^{\color{blue}{0.16666666666666666}} \cdot d \]
    4. Applied egg-rr33.9%

      \[\leadsto \color{blue}{{\left({\left(h \cdot \ell\right)}^{-3}\right)}^{0.16666666666666666}} \cdot d \]

    if -1.54999999999999992e-302 < d < 1.15e-169

    1. Initial program 37.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. Taylor expanded in d around 0 54.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.15e-169 < d

    1. Initial program 69.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. Taylor expanded in d around inf 55.9%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    4. Simplified55.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5 \cdot 10^{-157}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -1.7 \cdot 10^{-225}:\\ \;\;\;\;d \cdot {\left({\left(\ell \cdot h\right)}^{-3}\right)}^{0.16666666666666666}\\ \mathbf{elif}\;d \leq -1.55 \cdot 10^{-302}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 1.15 \cdot 10^{-169}:\\ \;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 16: 47.1% accurate, 1.5× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{if}\;d \leq -9.2 \cdot 10^{-157}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -1.25 \cdot 10^{-226}:\\ \;\;\;\;d \cdot \sqrt{\sqrt[3]{\frac{1}{\left(\ell \cdot \ell\right) \cdot \left(h \cdot h\right)} \cdot \frac{1}{\ell \cdot h}}}\\ \mathbf{elif}\;d \leq -1.55 \cdot 10^{-302}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.45 \cdot 10^{-167}:\\ \;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\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 (* (sqrt (/ d l)) (sqrt (/ d h)))))
   (if (<= d -9.2e-157)
     t_0
     (if (<= d -1.25e-226)
       (* d (sqrt (cbrt (* (/ 1.0 (* (* l l) (* h h))) (/ 1.0 (* l h))))))
       (if (<= d -1.55e-302)
         t_0
         (if (<= d 2.45e-167)
           (* -0.125 (* (* (* D D) (* M (/ M d))) (sqrt (/ h (pow l 3.0)))))
           (* d (/ (sqrt (/ 1.0 h)) (sqrt l)))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / l)) * sqrt((d / h));
	double tmp;
	if (d <= -9.2e-157) {
		tmp = t_0;
	} else if (d <= -1.25e-226) {
		tmp = d * sqrt(cbrt(((1.0 / ((l * l) * (h * h))) * (1.0 / (l * h)))));
	} else if (d <= -1.55e-302) {
		tmp = t_0;
	} else if (d <= 2.45e-167) {
		tmp = -0.125 * (((D * D) * (M * (M / d))) * sqrt((h / pow(l, 3.0))));
	} else {
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	}
	return tmp;
}
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt((d / l)) * Math.sqrt((d / h));
	double tmp;
	if (d <= -9.2e-157) {
		tmp = t_0;
	} else if (d <= -1.25e-226) {
		tmp = d * Math.sqrt(Math.cbrt(((1.0 / ((l * l) * (h * h))) * (1.0 / (l * h)))));
	} else if (d <= -1.55e-302) {
		tmp = t_0;
	} else if (d <= 2.45e-167) {
		tmp = -0.125 * (((D * D) * (M * (M / d))) * Math.sqrt((h / Math.pow(l, 3.0))));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h)))
	tmp = 0.0
	if (d <= -9.2e-157)
		tmp = t_0;
	elseif (d <= -1.25e-226)
		tmp = Float64(d * sqrt(cbrt(Float64(Float64(1.0 / Float64(Float64(l * l) * Float64(h * h))) * Float64(1.0 / Float64(l * h))))));
	elseif (d <= -1.55e-302)
		tmp = t_0;
	elseif (d <= 2.45e-167)
		tmp = Float64(-0.125 * Float64(Float64(Float64(D * D) * Float64(M * Float64(M / d))) * sqrt(Float64(h / (l ^ 3.0)))));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / h)) / sqrt(l)));
	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[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -9.2e-157], t$95$0, If[LessEqual[d, -1.25e-226], N[(d * N[Sqrt[N[Power[N[(N[(1.0 / N[(N[(l * l), $MachinePrecision] * N[(h * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.55e-302], t$95$0, If[LessEqual[d, 2.45e-167], N[(-0.125 * N[(N[(N[(D * D), $MachinePrecision] * N[(M * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{if}\;d \leq -9.2 \cdot 10^{-157}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq -1.25 \cdot 10^{-226}:\\
\;\;\;\;d \cdot \sqrt{\sqrt[3]{\frac{1}{\left(\ell \cdot \ell\right) \cdot \left(h \cdot h\right)} \cdot \frac{1}{\ell \cdot h}}}\\

\mathbf{elif}\;d \leq -1.55 \cdot 10^{-302}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq 2.45 \cdot 10^{-167}:\\
\;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -9.19999999999999954e-157 or -1.2499999999999999e-226 < d < -1.54999999999999992e-302

    1. Initial program 67.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. Step-by-step derivation
      1. associate-*l*67.3%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right)} \]
      2. metadata-eval67.3%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      3. unpow1/267.3%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      4. metadata-eval67.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.19999999999999954e-157 < d < -1.2499999999999999e-226

    1. Initial program 58.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. Taylor expanded in d around inf 23.6%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    4. Simplified23.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    5. Step-by-step derivation
      1. add-cbrt-cube33.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\sqrt[3]{\left(\frac{\frac{1}{h}}{\ell} \cdot \frac{\frac{1}{h}}{\ell}\right) \cdot \frac{\frac{1}{h}}{\ell}}}} \]
      2. associate-/l/33.9%

        \[\leadsto d \cdot \sqrt{\sqrt[3]{\left(\color{blue}{\frac{1}{\ell \cdot h}} \cdot \frac{\frac{1}{h}}{\ell}\right) \cdot \frac{\frac{1}{h}}{\ell}}} \]
      3. associate-/l/33.9%

        \[\leadsto d \cdot \sqrt{\sqrt[3]{\left(\frac{1}{\ell \cdot h} \cdot \color{blue}{\frac{1}{\ell \cdot h}}\right) \cdot \frac{\frac{1}{h}}{\ell}}} \]
      4. associate-/l/33.9%

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

      \[\leadsto d \cdot \sqrt{\color{blue}{\sqrt[3]{\left(\frac{1}{\ell \cdot h} \cdot \frac{1}{\ell \cdot h}\right) \cdot \frac{1}{\ell \cdot h}}}} \]
    7. Taylor expanded in l around 0 38.8%

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

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

        \[\leadsto d \cdot \sqrt{\sqrt[3]{\frac{1}{\left(\ell \cdot \ell\right) \cdot \color{blue}{\left(h \cdot h\right)}} \cdot \frac{1}{\ell \cdot h}}} \]
    9. Simplified38.8%

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

    if -1.54999999999999992e-302 < d < 2.45000000000000002e-167

    1. Initial program 37.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. Taylor expanded in d around 0 54.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.45000000000000002e-167 < d

    1. Initial program 69.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. Taylor expanded in d around inf 55.9%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    4. Simplified55.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9.2 \cdot 10^{-157}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -1.25 \cdot 10^{-226}:\\ \;\;\;\;d \cdot \sqrt{\sqrt[3]{\frac{1}{\left(\ell \cdot \ell\right) \cdot \left(h \cdot h\right)} \cdot \frac{1}{\ell \cdot h}}}\\ \mathbf{elif}\;d \leq -1.55 \cdot 10^{-302}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 2.45 \cdot 10^{-167}:\\ \;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 17: 29.5% accurate, 1.6× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.05 \cdot 10^{-236}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\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
 (if (<= l 1.05e-236)
   (* d (sqrt (/ (/ 1.0 h) l)))
   (* d (/ (sqrt (/ 1.0 h)) (sqrt l)))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= 1.05e-236) {
		tmp = d * sqrt(((1.0 / h) / l));
	} else {
		tmp = d * (sqrt((1.0 / 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) :: tmp
    if (l <= 1.05d-236) then
        tmp = d * sqrt(((1.0d0 / h) / l))
    else
        tmp = d * (sqrt((1.0d0 / 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 tmp;
	if (l <= 1.05e-236) {
		tmp = d * Math.sqrt(((1.0 / h) / l));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if l <= 1.05e-236:
		tmp = d * math.sqrt(((1.0 / h) / l))
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= 1.05e-236)
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / h) / l)));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / 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)
	tmp = 0.0;
	if (l <= 1.05e-236)
		tmp = d * sqrt(((1.0 / h) / l));
	else
		tmp = d * (sqrt((1.0 / 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_] := If[LessEqual[l, 1.05e-236], N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.05 \cdot 10^{-236}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

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


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

    1. Initial program 63.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. Taylor expanded in d around inf 11.3%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    4. Simplified11.3%

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

    if 1.04999999999999989e-236 < l

    1. Initial program 62.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. Taylor expanded in d around inf 46.9%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    4. Simplified46.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 1.05 \cdot 10^{-236}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 18: 44.3% accurate, 1.6× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.85 \cdot 10^{-243}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\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
 (if (<= l 1.85e-243)
   (* (sqrt (/ d l)) (sqrt (/ d h)))
   (* d (/ (sqrt (/ 1.0 h)) (sqrt l)))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= 1.85e-243) {
		tmp = sqrt((d / l)) * sqrt((d / h));
	} else {
		tmp = d * (sqrt((1.0 / 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) :: tmp
    if (l <= 1.85d-243) then
        tmp = sqrt((d / l)) * sqrt((d / h))
    else
        tmp = d * (sqrt((1.0d0 / 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 tmp;
	if (l <= 1.85e-243) {
		tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if l <= 1.85e-243:
		tmp = math.sqrt((d / l)) * math.sqrt((d / h))
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= 1.85e-243)
		tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h)));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / 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)
	tmp = 0.0;
	if (l <= 1.85e-243)
		tmp = sqrt((d / l)) * sqrt((d / h));
	else
		tmp = d * (sqrt((1.0 / 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_] := If[LessEqual[l, 1.85e-243], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.85 \cdot 10^{-243}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\

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


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

    1. Initial program 64.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. associate-*l*64.3%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right)} \]
      2. metadata-eval64.3%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      3. unpow1/264.3%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\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)\right) \]
      4. metadata-eval64.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.85e-243 < l

    1. Initial program 62.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. Taylor expanded in d around inf 47.3%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    4. Simplified47.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 1.85 \cdot 10^{-243}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 19: 26.2% accurate, 3.1× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}} \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 (/ (/ 1.0 h) l))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d * sqrt(((1.0 / h) / l));
}
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(((1.0d0 / h) / l))
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(((1.0 / h) / l));
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * math.sqrt(((1.0 / h) / l))
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d * sqrt(Float64(Float64(1.0 / h) / l)))
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt(((1.0 / h) / l));
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[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}
\end{array}
Derivation
  1. Initial program 63.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. Taylor expanded in d around inf 28.5%

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

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

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

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
  4. Simplified28.5%

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

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

Alternative 20: 26.2% accurate, 3.1× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ d \cdot \sqrt{\frac{\frac{1}{\ell}}{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 (/ (/ 1.0 l) h))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d * sqrt(((1.0 / 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(((1.0d0 / 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(((1.0 / l) / h));
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * math.sqrt(((1.0 / l) / h))
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d * sqrt(Float64(Float64(1.0 / l) / h)))
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt(((1.0 / 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[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}
\end{array}
Derivation
  1. Initial program 63.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. Taylor expanded in d around inf 28.5%

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

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

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

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
  4. Simplified28.5%

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

      \[\leadsto d \cdot \sqrt{\color{blue}{\sqrt[3]{\left(\frac{\frac{1}{h}}{\ell} \cdot \frac{\frac{1}{h}}{\ell}\right) \cdot \frac{\frac{1}{h}}{\ell}}}} \]
    2. associate-/l/17.7%

      \[\leadsto d \cdot \sqrt{\sqrt[3]{\left(\color{blue}{\frac{1}{\ell \cdot h}} \cdot \frac{\frac{1}{h}}{\ell}\right) \cdot \frac{\frac{1}{h}}{\ell}}} \]
    3. associate-/l/17.7%

      \[\leadsto d \cdot \sqrt{\sqrt[3]{\left(\frac{1}{\ell \cdot h} \cdot \color{blue}{\frac{1}{\ell \cdot h}}\right) \cdot \frac{\frac{1}{h}}{\ell}}} \]
    4. associate-/l/17.7%

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

    \[\leadsto d \cdot \sqrt{\color{blue}{\sqrt[3]{\left(\frac{1}{\ell \cdot h} \cdot \frac{1}{\ell \cdot h}\right) \cdot \frac{1}{\ell \cdot h}}}} \]
  7. Taylor expanded in l around 0 28.5%

    \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{\ell \cdot h}}} \]
  8. Step-by-step derivation
    1. associate-/r*28.5%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
  9. Simplified28.5%

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

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

Alternative 21: 26.0% accurate, 3.1× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ d \cdot \sqrt{\frac{1}{\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 (/ 1.0 (* l h)))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d * sqrt((1.0 / (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((1.0d0 / (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((1.0 / (l * h)));
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * math.sqrt((1.0 / (l * h)))
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d * sqrt(Float64(1.0 / Float64(l * h))))
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt((1.0 / (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[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot \sqrt{\frac{1}{\ell \cdot h}}
\end{array}
Derivation
  1. Initial program 63.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. Taylor expanded in d around inf 28.5%

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

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

Alternative 22: 26.0% 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 63.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. Taylor expanded in d around inf 28.5%

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

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

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

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

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

      \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\ell \cdot h\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \cdot d \]
    6. *-commutative17.3%

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

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

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

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

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

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

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

Reproduce

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