Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.5% → 81.3%
Time: 27.7s
Alternatives: 17
Speedup: 1.4×

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 17 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.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (*
  (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
  (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
	return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
	return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D):
	return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D)
	return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l))))
end
function tmp = code(d, h, l, M, D)
	tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l)));
end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}

Alternative 1: 81.3% accurate, 0.6× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < l

    1. Initial program 63.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.1%

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

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

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

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

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

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

Alternative 2: 80.5% accurate, 0.8× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \frac{D\_m}{d} \cdot \left(0.5 \cdot M\_m\right)\\ \mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D\_m}{d} \cdot \frac{M\_m}{2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (* (/ D_m d) (* 0.5 M_m))))
   (if (<= l -2e-310)
     (*
      (* (/ (sqrt (- d)) (sqrt (- h))) (sqrt (/ d l)))
      (- 1.0 (* 0.5 (* h (* t_0 (/ t_0 l))))))
     (*
      d
      (/
       (fma (* (/ h l) -0.5) (pow (* (/ D_m d) (/ M_m 2.0)) 2.0) 1.0)
       (* (sqrt l) (sqrt h)))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = (D_m / d) * (0.5 * M_m);
	double tmp;
	if (l <= -2e-310) {
		tmp = ((sqrt(-d) / sqrt(-h)) * sqrt((d / l))) * (1.0 - (0.5 * (h * (t_0 * (t_0 / l)))));
	} else {
		tmp = d * (fma(((h / l) * -0.5), pow(((D_m / d) * (M_m / 2.0)), 2.0), 1.0) / (sqrt(l) * sqrt(h)));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(Float64(D_m / d) * Float64(0.5 * M_m))
	tmp = 0.0
	if (l <= -2e-310)
		tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * Float64(h * Float64(t_0 * Float64(t_0 / l))))));
	else
		tmp = Float64(d * Float64(fma(Float64(Float64(h / l) * -0.5), (Float64(Float64(D_m / d) * Float64(M_m / 2.0)) ^ 2.0), 1.0) / Float64(sqrt(l) * sqrt(h))));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2e-310], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(h * N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{D\_m}{d} \cdot \left(0.5 \cdot M\_m\right)\\
\mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)\right)\right)\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < l

    1. Initial program 63.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 79.6% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.00000000000023e-311 < h < 2.6000000000000001e74

    1. Initial program 66.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. Simplified67.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.6000000000000001e74 < h

    1. Initial program 57.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. Simplified57.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(h \cdot \left(\left(\frac{D}{d} \cdot \left(0.5 \cdot M\right)\right) \cdot \frac{\frac{D}{d} \cdot \left(0.5 \cdot M\right)}{\ell}\right)\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\right)\\ \mathbf{elif}\;h \leq 2.6 \cdot 10^{+74}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(h \cdot \left(\left(\frac{D}{d} \cdot \left(0.5 \cdot M\right)\right) \cdot \frac{\frac{D}{d} \cdot \left(0.5 \cdot M\right)}{\ell}\right)\right)\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 80.9% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{\ell}}\\ t_1 := \frac{D\_m}{d} \cdot \left(0.5 \cdot M\_m\right)\\ t_2 := 1 - 0.5 \cdot \left(h \cdot \left(t\_1 \cdot \frac{t\_1}{\ell}\right)\right)\\ \mathbf{if}\;h \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t\_0\right) \cdot t\_2\\ \mathbf{elif}\;h \leq 4 \cdot 10^{+72}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D\_m \cdot \frac{\frac{M\_m}{d}}{2}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;t\_2 \cdot \left(t\_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (/ d l)))
        (t_1 (* (/ D_m d) (* 0.5 M_m)))
        (t_2 (- 1.0 (* 0.5 (* h (* t_1 (/ t_1 l)))))))
   (if (<= h -5e-311)
     (* (* (/ (sqrt (- d)) (sqrt (- h))) t_0) t_2)
     (if (<= h 4e+72)
       (*
        (/ d (* (sqrt l) (sqrt h)))
        (+ 1.0 (* (* (/ h l) -0.5) (pow (* D_m (/ (/ M_m d) 2.0)) 2.0))))
       (* t_2 (* t_0 (/ (sqrt d) (sqrt h))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt((d / l));
	double t_1 = (D_m / d) * (0.5 * M_m);
	double t_2 = 1.0 - (0.5 * (h * (t_1 * (t_1 / l))));
	double tmp;
	if (h <= -5e-311) {
		tmp = ((sqrt(-d) / sqrt(-h)) * t_0) * t_2;
	} else if (h <= 4e+72) {
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (((h / l) * -0.5) * pow((D_m * ((M_m / d) / 2.0)), 2.0)));
	} else {
		tmp = t_2 * (t_0 * (sqrt(d) / sqrt(h)));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = sqrt((d / l))
    t_1 = (d_m / d) * (0.5d0 * m_m)
    t_2 = 1.0d0 - (0.5d0 * (h * (t_1 * (t_1 / l))))
    if (h <= (-5d-311)) then
        tmp = ((sqrt(-d) / sqrt(-h)) * t_0) * t_2
    else if (h <= 4d+72) then
        tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + (((h / l) * (-0.5d0)) * ((d_m * ((m_m / d) / 2.0d0)) ** 2.0d0)))
    else
        tmp = t_2 * (t_0 * (sqrt(d) / sqrt(h)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = Math.sqrt((d / l));
	double t_1 = (D_m / d) * (0.5 * M_m);
	double t_2 = 1.0 - (0.5 * (h * (t_1 * (t_1 / l))));
	double tmp;
	if (h <= -5e-311) {
		tmp = ((Math.sqrt(-d) / Math.sqrt(-h)) * t_0) * t_2;
	} else if (h <= 4e+72) {
		tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + (((h / l) * -0.5) * Math.pow((D_m * ((M_m / d) / 2.0)), 2.0)));
	} else {
		tmp = t_2 * (t_0 * (Math.sqrt(d) / Math.sqrt(h)));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = math.sqrt((d / l))
	t_1 = (D_m / d) * (0.5 * M_m)
	t_2 = 1.0 - (0.5 * (h * (t_1 * (t_1 / l))))
	tmp = 0
	if h <= -5e-311:
		tmp = ((math.sqrt(-d) / math.sqrt(-h)) * t_0) * t_2
	elif h <= 4e+72:
		tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + (((h / l) * -0.5) * math.pow((D_m * ((M_m / d) / 2.0)), 2.0)))
	else:
		tmp = t_2 * (t_0 * (math.sqrt(d) / math.sqrt(h)))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = sqrt(Float64(d / l))
	t_1 = Float64(Float64(D_m / d) * Float64(0.5 * M_m))
	t_2 = Float64(1.0 - Float64(0.5 * Float64(h * Float64(t_1 * Float64(t_1 / l)))))
	tmp = 0.0
	if (h <= -5e-311)
		tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_0) * t_2);
	elseif (h <= 4e+72)
		tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(D_m * Float64(Float64(M_m / d) / 2.0)) ^ 2.0))));
	else
		tmp = Float64(t_2 * Float64(t_0 * Float64(sqrt(d) / sqrt(h))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = sqrt((d / l));
	t_1 = (D_m / d) * (0.5 * M_m);
	t_2 = 1.0 - (0.5 * (h * (t_1 * (t_1 / l))));
	tmp = 0.0;
	if (h <= -5e-311)
		tmp = ((sqrt(-d) / sqrt(-h)) * t_0) * t_2;
	elseif (h <= 4e+72)
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (((h / l) * -0.5) * ((D_m * ((M_m / d) / 2.0)) ^ 2.0)));
	else
		tmp = t_2 * (t_0 * (sqrt(d) / sqrt(h)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(D$95$m / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[(0.5 * N[(h * N[(t$95$1 * N[(t$95$1 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -5e-311], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[h, 4e+72], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(D$95$m * N[(N[(M$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$2 * N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \frac{D\_m}{d} \cdot \left(0.5 \cdot M\_m\right)\\
t_2 := 1 - 0.5 \cdot \left(h \cdot \left(t\_1 \cdot \frac{t\_1}{\ell}\right)\right)\\
\mathbf{if}\;h \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t\_0\right) \cdot t\_2\\

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

\mathbf{else}:\\
\;\;\;\;t\_2 \cdot \left(t\_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.00000000000023e-311 < h < 3.99999999999999978e72

    1. Initial program 66.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. Simplified67.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.99999999999999978e72 < h

    1. Initial program 57.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. Simplified57.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\left(\frac{D}{d} \cdot \left(0.5 \cdot M\right)\right) \cdot \frac{\frac{D}{d} \cdot \left(0.5 \cdot M\right)}{\ell}\right)\right)\right)\\ \mathbf{elif}\;h \leq 4 \cdot 10^{+72}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(h \cdot \left(\left(\frac{D}{d} \cdot \left(0.5 \cdot M\right)\right) \cdot \frac{\frac{D}{d} \cdot \left(0.5 \cdot M\right)}{\ell}\right)\right)\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 73.8% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \frac{D\_m}{d} \cdot \left(0.5 \cdot M\_m\right)\\ \mathbf{if}\;\ell \leq 2.5 \cdot 10^{-90}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(h \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D\_m \cdot \frac{\frac{M\_m}{d}}{2}\right)}^{2}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (* (/ D_m d) (* 0.5 M_m))))
   (if (<= l 2.5e-90)
     (*
      (- 1.0 (* 0.5 (* h (* t_0 (/ t_0 l)))))
      (* (sqrt (/ d h)) (/ 1.0 (sqrt (/ l d)))))
     (*
      (/ d (* (sqrt l) (sqrt h)))
      (+ 1.0 (* (* (/ h l) -0.5) (pow (* D_m (/ (/ M_m d) 2.0)) 2.0)))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = (D_m / d) * (0.5 * M_m);
	double tmp;
	if (l <= 2.5e-90) {
		tmp = (1.0 - (0.5 * (h * (t_0 * (t_0 / l))))) * (sqrt((d / h)) * (1.0 / sqrt((l / d))));
	} else {
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (((h / l) * -0.5) * pow((D_m * ((M_m / d) / 2.0)), 2.0)));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (d_m / d) * (0.5d0 * m_m)
    if (l <= 2.5d-90) then
        tmp = (1.0d0 - (0.5d0 * (h * (t_0 * (t_0 / l))))) * (sqrt((d / h)) * (1.0d0 / sqrt((l / d))))
    else
        tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + (((h / l) * (-0.5d0)) * ((d_m * ((m_m / d) / 2.0d0)) ** 2.0d0)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = (D_m / d) * (0.5 * M_m);
	double tmp;
	if (l <= 2.5e-90) {
		tmp = (1.0 - (0.5 * (h * (t_0 * (t_0 / l))))) * (Math.sqrt((d / h)) * (1.0 / Math.sqrt((l / d))));
	} else {
		tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + (((h / l) * -0.5) * Math.pow((D_m * ((M_m / d) / 2.0)), 2.0)));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = (D_m / d) * (0.5 * M_m)
	tmp = 0
	if l <= 2.5e-90:
		tmp = (1.0 - (0.5 * (h * (t_0 * (t_0 / l))))) * (math.sqrt((d / h)) * (1.0 / math.sqrt((l / d))))
	else:
		tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + (((h / l) * -0.5) * math.pow((D_m * ((M_m / d) / 2.0)), 2.0)))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(Float64(D_m / d) * Float64(0.5 * M_m))
	tmp = 0.0
	if (l <= 2.5e-90)
		tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(h * Float64(t_0 * Float64(t_0 / l))))) * Float64(sqrt(Float64(d / h)) * Float64(1.0 / sqrt(Float64(l / d)))));
	else
		tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(D_m * Float64(Float64(M_m / d) / 2.0)) ^ 2.0))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = (D_m / d) * (0.5 * M_m);
	tmp = 0.0;
	if (l <= 2.5e-90)
		tmp = (1.0 - (0.5 * (h * (t_0 * (t_0 / l))))) * (sqrt((d / h)) * (1.0 / sqrt((l / d))));
	else
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (((h / l) * -0.5) * ((D_m * ((M_m / d) / 2.0)) ^ 2.0)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, 2.5e-90], N[(N[(1.0 - N[(0.5 * N[(h * N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Sqrt[N[(l / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(D$95$m * N[(N[(M$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{D\_m}{d} \cdot \left(0.5 \cdot M\_m\right)\\
\mathbf{if}\;\ell \leq 2.5 \cdot 10^{-90}:\\
\;\;\;\;\left(1 - 0.5 \cdot \left(h \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\right)\\

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


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

    1. Initial program 68.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. Simplified66.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.5000000000000001e-90 < l

    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. Simplified55.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 66.9% accurate, 1.4× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;\ell \leq -5.2 \cdot 10^{+138}:\\ \;\;\;\;\frac{d}{-t\_0}\\ \mathbf{elif}\;\ell \leq 1.65 \cdot 10^{-307}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\left(\frac{D\_m}{d} \cdot \left(0.5 \cdot M\_m\right)\right) \cdot \left(D\_m \cdot \left(0.5 \cdot \frac{M\_m}{\ell \cdot d}\right)\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D\_m \cdot \frac{\frac{M\_m}{d}}{2}\right)}^{2}\right) \cdot \frac{d}{t\_0}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (* l h))))
   (if (<= l -5.2e+138)
     (/ d (- t_0))
     (if (<= l 1.65e-307)
       (*
        (* (sqrt (/ d l)) (sqrt (/ d h)))
        (-
         1.0
         (*
          0.5
          (*
           h
           (* (* (/ D_m d) (* 0.5 M_m)) (* D_m (* 0.5 (/ M_m (* l d)))))))))
       (*
        (+ 1.0 (* (* (/ h l) -0.5) (pow (* D_m (/ (/ M_m d) 2.0)) 2.0)))
        (/ d t_0))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt((l * h));
	double tmp;
	if (l <= -5.2e+138) {
		tmp = d / -t_0;
	} else if (l <= 1.65e-307) {
		tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * (h * (((D_m / d) * (0.5 * M_m)) * (D_m * (0.5 * (M_m / (l * d))))))));
	} else {
		tmp = (1.0 + (((h / l) * -0.5) * pow((D_m * ((M_m / d) / 2.0)), 2.0))) * (d / t_0);
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((l * h))
    if (l <= (-5.2d+138)) then
        tmp = d / -t_0
    else if (l <= 1.65d-307) then
        tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - (0.5d0 * (h * (((d_m / d) * (0.5d0 * m_m)) * (d_m * (0.5d0 * (m_m / (l * d))))))))
    else
        tmp = (1.0d0 + (((h / l) * (-0.5d0)) * ((d_m * ((m_m / d) / 2.0d0)) ** 2.0d0))) * (d / t_0)
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = Math.sqrt((l * h));
	double tmp;
	if (l <= -5.2e+138) {
		tmp = d / -t_0;
	} else if (l <= 1.65e-307) {
		tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - (0.5 * (h * (((D_m / d) * (0.5 * M_m)) * (D_m * (0.5 * (M_m / (l * d))))))));
	} else {
		tmp = (1.0 + (((h / l) * -0.5) * Math.pow((D_m * ((M_m / d) / 2.0)), 2.0))) * (d / t_0);
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = math.sqrt((l * h))
	tmp = 0
	if l <= -5.2e+138:
		tmp = d / -t_0
	elif l <= 1.65e-307:
		tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - (0.5 * (h * (((D_m / d) * (0.5 * M_m)) * (D_m * (0.5 * (M_m / (l * d))))))))
	else:
		tmp = (1.0 + (((h / l) * -0.5) * math.pow((D_m * ((M_m / d) / 2.0)), 2.0))) * (d / t_0)
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = sqrt(Float64(l * h))
	tmp = 0.0
	if (l <= -5.2e+138)
		tmp = Float64(d / Float64(-t_0));
	elseif (l <= 1.65e-307)
		tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(0.5 * Float64(h * Float64(Float64(Float64(D_m / d) * Float64(0.5 * M_m)) * Float64(D_m * Float64(0.5 * Float64(M_m / Float64(l * d)))))))));
	else
		tmp = Float64(Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(D_m * Float64(Float64(M_m / d) / 2.0)) ^ 2.0))) * Float64(d / t_0));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = sqrt((l * h));
	tmp = 0.0;
	if (l <= -5.2e+138)
		tmp = d / -t_0;
	elseif (l <= 1.65e-307)
		tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * (h * (((D_m / d) * (0.5 * M_m)) * (D_m * (0.5 * (M_m / (l * d))))))));
	else
		tmp = (1.0 + (((h / l) * -0.5) * ((D_m * ((M_m / d) / 2.0)) ^ 2.0))) * (d / t_0);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -5.2e+138], N[(d / (-t$95$0)), $MachinePrecision], If[LessEqual[l, 1.65e-307], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(h * N[(N[(N[(D$95$m / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * N[(0.5 * N[(M$95$m / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(D$95$m * N[(N[(M$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;\ell \leq -5.2 \cdot 10^{+138}:\\
\;\;\;\;\frac{d}{-t\_0}\\

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

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


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

    1. Initial program 44.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. Simplified44.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    11. Step-by-step derivation
      1. *-commutative0.0%

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

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt59.0%

        \[\leadsto \left(\color{blue}{-1} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. mul-1-neg59.0%

        \[\leadsto \color{blue}{\left(-d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      5. distribute-lft-neg-in59.0%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. rem-exp-log56.3%

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

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

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

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      10. distribute-lft-neg-out56.3%

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

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      12. exp-to-pow59.0%

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

        \[\leadsto -d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      14. associate-/l*59.1%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      15. associate-*l/59.1%

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

        \[\leadsto -\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      17. distribute-neg-frac259.1%

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

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

    if -5.2000000000000002e138 < l < 1.65e-307

    1. Initial program 69.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. Simplified66.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.65e-307 < l

    1. Initial program 63.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 62.2% accurate, 1.4× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;\ell \leq -3.7 \cdot 10^{+80}:\\ \;\;\;\;\frac{d}{-t\_0}\\ \mathbf{elif}\;\ell \leq 1.2 \cdot 10^{-69}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{D\_m}{d} \cdot \left(0.5 \cdot M\_m\right)\right)}^{2}}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D\_m \cdot \frac{\frac{M\_m}{d}}{2}\right)}^{2}\right) \cdot \frac{d}{t\_0}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (* l h))))
   (if (<= l -3.7e+80)
     (/ d (- t_0))
     (if (<= l 1.2e-69)
       (*
        (sqrt (* (/ d l) (/ d h)))
        (- 1.0 (* 0.5 (* h (/ (pow (* (/ D_m d) (* 0.5 M_m)) 2.0) l)))))
       (*
        (+ 1.0 (* (* (/ h l) -0.5) (pow (* D_m (/ (/ M_m d) 2.0)) 2.0)))
        (/ d t_0))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt((l * h));
	double tmp;
	if (l <= -3.7e+80) {
		tmp = d / -t_0;
	} else if (l <= 1.2e-69) {
		tmp = sqrt(((d / l) * (d / h))) * (1.0 - (0.5 * (h * (pow(((D_m / d) * (0.5 * M_m)), 2.0) / l))));
	} else {
		tmp = (1.0 + (((h / l) * -0.5) * pow((D_m * ((M_m / d) / 2.0)), 2.0))) * (d / t_0);
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((l * h))
    if (l <= (-3.7d+80)) then
        tmp = d / -t_0
    else if (l <= 1.2d-69) then
        tmp = sqrt(((d / l) * (d / h))) * (1.0d0 - (0.5d0 * (h * ((((d_m / d) * (0.5d0 * m_m)) ** 2.0d0) / l))))
    else
        tmp = (1.0d0 + (((h / l) * (-0.5d0)) * ((d_m * ((m_m / d) / 2.0d0)) ** 2.0d0))) * (d / t_0)
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = Math.sqrt((l * h));
	double tmp;
	if (l <= -3.7e+80) {
		tmp = d / -t_0;
	} else if (l <= 1.2e-69) {
		tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 - (0.5 * (h * (Math.pow(((D_m / d) * (0.5 * M_m)), 2.0) / l))));
	} else {
		tmp = (1.0 + (((h / l) * -0.5) * Math.pow((D_m * ((M_m / d) / 2.0)), 2.0))) * (d / t_0);
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = math.sqrt((l * h))
	tmp = 0
	if l <= -3.7e+80:
		tmp = d / -t_0
	elif l <= 1.2e-69:
		tmp = math.sqrt(((d / l) * (d / h))) * (1.0 - (0.5 * (h * (math.pow(((D_m / d) * (0.5 * M_m)), 2.0) / l))))
	else:
		tmp = (1.0 + (((h / l) * -0.5) * math.pow((D_m * ((M_m / d) / 2.0)), 2.0))) * (d / t_0)
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = sqrt(Float64(l * h))
	tmp = 0.0
	if (l <= -3.7e+80)
		tmp = Float64(d / Float64(-t_0));
	elseif (l <= 1.2e-69)
		tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 - Float64(0.5 * Float64(h * Float64((Float64(Float64(D_m / d) * Float64(0.5 * M_m)) ^ 2.0) / l)))));
	else
		tmp = Float64(Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(D_m * Float64(Float64(M_m / d) / 2.0)) ^ 2.0))) * Float64(d / t_0));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = sqrt((l * h));
	tmp = 0.0;
	if (l <= -3.7e+80)
		tmp = d / -t_0;
	elseif (l <= 1.2e-69)
		tmp = sqrt(((d / l) * (d / h))) * (1.0 - (0.5 * (h * ((((D_m / d) * (0.5 * M_m)) ^ 2.0) / l))));
	else
		tmp = (1.0 + (((h / l) * -0.5) * ((D_m * ((M_m / d) / 2.0)) ^ 2.0))) * (d / t_0);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -3.7e+80], N[(d / (-t$95$0)), $MachinePrecision], If[LessEqual[l, 1.2e-69], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(0.5 * N[(h * N[(N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(D$95$m * N[(N[(M$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;\ell \leq -3.7 \cdot 10^{+80}:\\
\;\;\;\;\frac{d}{-t\_0}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -3.69999999999999996e80

    1. Initial program 48.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. Simplified48.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    11. Step-by-step derivation
      1. *-commutative0.0%

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

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt58.5%

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

        \[\leadsto \color{blue}{\left(-d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      5. distribute-lft-neg-in58.5%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. rem-exp-log55.3%

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

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

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

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      10. distribute-lft-neg-out55.3%

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

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      12. exp-to-pow58.4%

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

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

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

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

        \[\leadsto -\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      17. distribute-neg-frac258.6%

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

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

    if -3.69999999999999996e80 < l < 1.2000000000000001e-69

    1. Initial program 75.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. Simplified73.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.2000000000000001e-69 < l

    1. Initial program 52.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. Simplified53.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.7 \cdot 10^{+80}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;\ell \leq 1.2 \cdot 10^{-69}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{D}{d} \cdot \left(0.5 \cdot M\right)\right)}^{2}}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 55.3% accurate, 1.4× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;d \leq -2.4 \cdot 10^{-158}:\\ \;\;\;\;\frac{d}{-t\_0}\\ \mathbf{elif}\;d \leq 9.2 \cdot 10^{-272}:\\ \;\;\;\;d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D\_m \cdot \frac{\frac{M\_m}{d}}{2}\right)}^{2}\right) \cdot \frac{d}{t\_0}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (* l h))))
   (if (<= d -2.4e-158)
     (/ d (- t_0))
     (if (<= d 9.2e-272)
       (* d (pow (pow (* l h) 2.0) -0.25))
       (*
        (+ 1.0 (* (* (/ h l) -0.5) (pow (* D_m (/ (/ M_m d) 2.0)) 2.0)))
        (/ d t_0))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt((l * h));
	double tmp;
	if (d <= -2.4e-158) {
		tmp = d / -t_0;
	} else if (d <= 9.2e-272) {
		tmp = d * pow(pow((l * h), 2.0), -0.25);
	} else {
		tmp = (1.0 + (((h / l) * -0.5) * pow((D_m * ((M_m / d) / 2.0)), 2.0))) * (d / t_0);
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((l * h))
    if (d <= (-2.4d-158)) then
        tmp = d / -t_0
    else if (d <= 9.2d-272) then
        tmp = d * (((l * h) ** 2.0d0) ** (-0.25d0))
    else
        tmp = (1.0d0 + (((h / l) * (-0.5d0)) * ((d_m * ((m_m / d) / 2.0d0)) ** 2.0d0))) * (d / t_0)
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = Math.sqrt((l * h));
	double tmp;
	if (d <= -2.4e-158) {
		tmp = d / -t_0;
	} else if (d <= 9.2e-272) {
		tmp = d * Math.pow(Math.pow((l * h), 2.0), -0.25);
	} else {
		tmp = (1.0 + (((h / l) * -0.5) * Math.pow((D_m * ((M_m / d) / 2.0)), 2.0))) * (d / t_0);
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = math.sqrt((l * h))
	tmp = 0
	if d <= -2.4e-158:
		tmp = d / -t_0
	elif d <= 9.2e-272:
		tmp = d * math.pow(math.pow((l * h), 2.0), -0.25)
	else:
		tmp = (1.0 + (((h / l) * -0.5) * math.pow((D_m * ((M_m / d) / 2.0)), 2.0))) * (d / t_0)
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = sqrt(Float64(l * h))
	tmp = 0.0
	if (d <= -2.4e-158)
		tmp = Float64(d / Float64(-t_0));
	elseif (d <= 9.2e-272)
		tmp = Float64(d * ((Float64(l * h) ^ 2.0) ^ -0.25));
	else
		tmp = Float64(Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(D_m * Float64(Float64(M_m / d) / 2.0)) ^ 2.0))) * Float64(d / t_0));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = sqrt((l * h));
	tmp = 0.0;
	if (d <= -2.4e-158)
		tmp = d / -t_0;
	elseif (d <= 9.2e-272)
		tmp = d * (((l * h) ^ 2.0) ^ -0.25);
	else
		tmp = (1.0 + (((h / l) * -0.5) * ((D_m * ((M_m / d) / 2.0)) ^ 2.0))) * (d / t_0);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -2.4e-158], N[(d / (-t$95$0)), $MachinePrecision], If[LessEqual[d, 9.2e-272], N[(d * N[Power[N[Power[N[(l * h), $MachinePrecision], 2.0], $MachinePrecision], -0.25], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(D$95$m * N[(N[(M$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;d \leq -2.4 \cdot 10^{-158}:\\
\;\;\;\;\frac{d}{-t\_0}\\

\mathbf{elif}\;d \leq 9.2 \cdot 10^{-272}:\\
\;\;\;\;d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.40000000000000007e-158

    1. Initial program 74.6%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified71.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    11. Step-by-step derivation
      1. *-commutative0.0%

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

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt50.5%

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

        \[\leadsto \color{blue}{\left(-d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      5. distribute-lft-neg-in50.5%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. rem-exp-log47.9%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}} \]
      7. exp-neg47.9%

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

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

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      10. distribute-lft-neg-out47.9%

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

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      12. exp-to-pow50.4%

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

        \[\leadsto -d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      14. associate-/l*50.6%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      15. associate-*l/50.6%

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

        \[\leadsto -\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      17. distribute-neg-frac250.6%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]
    12. Simplified50.6%

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

    if -2.40000000000000007e-158 < d < 9.19999999999999955e-272

    1. Initial program 36.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. Simplified36.1%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. add-cbrt-cube22.3%

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

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

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

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

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

        \[\leadsto d \cdot {\color{blue}{\left({\left(\frac{1}{h \cdot \ell}\right)}^{\left(1 + 0.5\right)}\right)}}^{0.3333333333333333} \]
      7. associate-/r*22.3%

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

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    6. Applied egg-rr22.3%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    7. Step-by-step derivation
      1. pow-pow15.9%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}} \]
      2. div-inv15.9%

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

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

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

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

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

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \color{blue}{\sqrt{\frac{1}{\ell}}}\right) \]
    10. Simplified2.5%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{\frac{1}{h}} \cdot \sqrt{\frac{1}{\ell}}\right)} \]
    11. Step-by-step derivation
      1. pow1/22.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      11. pow-prod-down24.5%

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

        \[\leadsto d \cdot {\color{blue}{\left({\left(h \cdot \ell\right)}^{2}\right)}}^{\left(\frac{-0.5}{2}\right)} \]
      13. *-commutative24.5%

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

        \[\leadsto d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{\color{blue}{-0.25}} \]
    12. Applied egg-rr24.5%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}} \]

    if 9.19999999999999955e-272 < d

    1. Initial program 65.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. Simplified66.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.4 \cdot 10^{-158}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 9.2 \cdot 10^{-272}:\\ \;\;\;\;d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 69.5% accurate, 1.4× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \frac{D\_m}{d} \cdot \left(0.5 \cdot M\_m\right)\\ \left(1 - 0.5 \cdot \left(h \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)\right)\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (* (/ D_m d) (* 0.5 M_m))))
   (*
    (- 1.0 (* 0.5 (* h (* t_0 (/ t_0 l)))))
    (* (sqrt (/ d l)) (sqrt (/ d h))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = (D_m / d) * (0.5 * M_m);
	return (1.0 - (0.5 * (h * (t_0 * (t_0 / l))))) * (sqrt((d / l)) * sqrt((d / h)));
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    t_0 = (d_m / d) * (0.5d0 * m_m)
    code = (1.0d0 - (0.5d0 * (h * (t_0 * (t_0 / l))))) * (sqrt((d / l)) * sqrt((d / h)))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = (D_m / d) * (0.5 * M_m);
	return (1.0 - (0.5 * (h * (t_0 * (t_0 / l))))) * (Math.sqrt((d / l)) * Math.sqrt((d / h)));
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = (D_m / d) * (0.5 * M_m)
	return (1.0 - (0.5 * (h * (t_0 * (t_0 / l))))) * (math.sqrt((d / l)) * math.sqrt((d / h)))
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(Float64(D_m / d) * Float64(0.5 * M_m))
	return Float64(Float64(1.0 - Float64(0.5 * Float64(h * Float64(t_0 * Float64(t_0 / l))))) * Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	t_0 = (D_m / d) * (0.5 * M_m);
	tmp = (1.0 - (0.5 * (h * (t_0 * (t_0 / l))))) * (sqrt((d / l)) * sqrt((d / h)));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 - N[(0.5 * N[(h * N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{D\_m}{d} \cdot \left(0.5 \cdot M\_m\right)\\
\left(1 - 0.5 \cdot \left(h \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)\right)\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 63.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. Simplified62.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(1 - 0.5 \cdot \left(h \cdot \left(\left(\frac{D}{d} \cdot \left(0.5 \cdot M\right)\right) \cdot \frac{\frac{D}{d} \cdot \left(0.5 \cdot M\right)}{\ell}\right)\right)\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \]
  11. Add Preprocessing

Alternative 10: 46.8% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -2 \cdot 10^{-158}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left(\sqrt{\frac{1}{h}} \cdot \sqrt{\frac{1}{\ell}}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= d -2e-158)
   (/ d (- (sqrt (* l h))))
   (if (<= d -5e-310)
     (* d (pow (pow (* l h) 2.0) -0.25))
     (* d (* (sqrt (/ 1.0 h)) (sqrt (/ 1.0 l)))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -2e-158) {
		tmp = d / -sqrt((l * h));
	} else if (d <= -5e-310) {
		tmp = d * pow(pow((l * h), 2.0), -0.25);
	} else {
		tmp = d * (sqrt((1.0 / h)) * sqrt((1.0 / l)));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (d <= (-2d-158)) then
        tmp = d / -sqrt((l * h))
    else if (d <= (-5d-310)) then
        tmp = d * (((l * h) ** 2.0d0) ** (-0.25d0))
    else
        tmp = d * (sqrt((1.0d0 / h)) * sqrt((1.0d0 / l)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -2e-158) {
		tmp = d / -Math.sqrt((l * h));
	} else if (d <= -5e-310) {
		tmp = d * Math.pow(Math.pow((l * h), 2.0), -0.25);
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) * Math.sqrt((1.0 / l)));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if d <= -2e-158:
		tmp = d / -math.sqrt((l * h))
	elif d <= -5e-310:
		tmp = d * math.pow(math.pow((l * h), 2.0), -0.25)
	else:
		tmp = d * (math.sqrt((1.0 / h)) * math.sqrt((1.0 / l)))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (d <= -2e-158)
		tmp = Float64(d / Float64(-sqrt(Float64(l * h))));
	elseif (d <= -5e-310)
		tmp = Float64(d * ((Float64(l * h) ^ 2.0) ^ -0.25));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / h)) * sqrt(Float64(1.0 / l))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (d <= -2e-158)
		tmp = d / -sqrt((l * h));
	elseif (d <= -5e-310)
		tmp = d * (((l * h) ^ 2.0) ^ -0.25);
	else
		tmp = d * (sqrt((1.0 / h)) * sqrt((1.0 / l)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, -2e-158], N[(d / (-N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[d, -5e-310], N[(d * N[Power[N[Power[N[(l * h), $MachinePrecision], 2.0], $MachinePrecision], -0.25], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2 \cdot 10^{-158}:\\
\;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\

\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.00000000000000013e-158

    1. Initial program 74.6%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified71.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    11. Step-by-step derivation
      1. *-commutative0.0%

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

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt50.5%

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

        \[\leadsto \color{blue}{\left(-d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      5. distribute-lft-neg-in50.5%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. rem-exp-log47.9%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}} \]
      7. exp-neg47.9%

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

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

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      10. distribute-lft-neg-out47.9%

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

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      12. exp-to-pow50.4%

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

        \[\leadsto -d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      14. associate-/l*50.6%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      15. associate-*l/50.6%

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

        \[\leadsto -\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      17. distribute-neg-frac250.6%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]
    12. Simplified50.6%

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

    if -2.00000000000000013e-158 < d < -4.999999999999985e-310

    1. Initial program 40.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. Simplified40.0%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. add-cbrt-cube26.0%

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

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

        \[\leadsto d \cdot {\left(\color{blue}{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{0.3333333333333333} \]
      4. pow126.0%

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

        \[\leadsto d \cdot {\left({\left(\frac{1}{h \cdot \ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)}^{0.3333333333333333} \]
      6. pow-prod-up26.0%

        \[\leadsto d \cdot {\color{blue}{\left({\left(\frac{1}{h \cdot \ell}\right)}^{\left(1 + 0.5\right)}\right)}}^{0.3333333333333333} \]
      7. associate-/r*26.0%

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

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

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    7. Step-by-step derivation
      1. pow-pow18.3%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}} \]
      2. div-inv18.3%

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

        \[\leadsto d \cdot {\left(\frac{1}{h} \cdot \frac{1}{\ell}\right)}^{\color{blue}{0.5}} \]
      4. unpow-prod-down0.0%

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

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

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

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \color{blue}{\sqrt{\frac{1}{\ell}}}\right) \]
    10. Simplified0.0%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{\frac{1}{h}} \cdot \sqrt{\frac{1}{\ell}}\right)} \]
    11. Step-by-step derivation
      1. pow1/20.0%

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      10. sqr-pow18.3%

        \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      11. pow-prod-down28.6%

        \[\leadsto d \cdot \color{blue}{{\left(\left(h \cdot \ell\right) \cdot \left(h \cdot \ell\right)\right)}^{\left(\frac{-0.5}{2}\right)}} \]
      12. pow228.6%

        \[\leadsto d \cdot {\color{blue}{\left({\left(h \cdot \ell\right)}^{2}\right)}}^{\left(\frac{-0.5}{2}\right)} \]
      13. *-commutative28.6%

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

        \[\leadsto d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{\color{blue}{-0.25}} \]
    12. Applied egg-rr28.6%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}} \]

    if -4.999999999999985e-310 < d

    1. Initial program 63.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.8%

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

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

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

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

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

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

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

        \[\leadsto d \cdot {\color{blue}{\left({\left(\frac{1}{h \cdot \ell}\right)}^{\left(1 + 0.5\right)}\right)}}^{0.3333333333333333} \]
      7. associate-/r*29.9%

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

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    6. Applied egg-rr29.9%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    7. Step-by-step derivation
      1. pow-pow37.2%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}} \]
      2. div-inv37.2%

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

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

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

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

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

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \color{blue}{\sqrt{\frac{1}{\ell}}}\right) \]
    10. Simplified44.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2 \cdot 10^{-158}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left(\sqrt{\frac{1}{h}} \cdot \sqrt{\frac{1}{\ell}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 46.8% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -7.6 \cdot 10^{-153}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= d -7.6e-153)
   (/ d (- (sqrt (* l h))))
   (if (<= d -5e-310)
     (* d (pow (pow (* l h) 2.0) -0.25))
     (* d (* (pow l -0.5) (pow h -0.5))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -7.6e-153) {
		tmp = d / -sqrt((l * h));
	} else if (d <= -5e-310) {
		tmp = d * pow(pow((l * h), 2.0), -0.25);
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (d <= (-7.6d-153)) then
        tmp = d / -sqrt((l * h))
    else if (d <= (-5d-310)) then
        tmp = d * (((l * h) ** 2.0d0) ** (-0.25d0))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -7.6e-153) {
		tmp = d / -Math.sqrt((l * h));
	} else if (d <= -5e-310) {
		tmp = d * Math.pow(Math.pow((l * h), 2.0), -0.25);
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if d <= -7.6e-153:
		tmp = d / -math.sqrt((l * h))
	elif d <= -5e-310:
		tmp = d * math.pow(math.pow((l * h), 2.0), -0.25)
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (d <= -7.6e-153)
		tmp = Float64(d / Float64(-sqrt(Float64(l * h))));
	elseif (d <= -5e-310)
		tmp = Float64(d * ((Float64(l * h) ^ 2.0) ^ -0.25));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (d <= -7.6e-153)
		tmp = d / -sqrt((l * h));
	elseif (d <= -5e-310)
		tmp = d * (((l * h) ^ 2.0) ^ -0.25);
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, -7.6e-153], N[(d / (-N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[d, -5e-310], N[(d * N[Power[N[Power[N[(l * h), $MachinePrecision], 2.0], $MachinePrecision], -0.25], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.6 \cdot 10^{-153}:\\
\;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\

\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -7.60000000000000046e-153

    1. Initial program 74.6%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified71.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    11. Step-by-step derivation
      1. *-commutative0.0%

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

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt50.5%

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

        \[\leadsto \color{blue}{\left(-d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      5. distribute-lft-neg-in50.5%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. rem-exp-log47.9%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}} \]
      7. exp-neg47.9%

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

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

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      10. distribute-lft-neg-out47.9%

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

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      12. exp-to-pow50.4%

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

        \[\leadsto -d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      14. associate-/l*50.6%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      15. associate-*l/50.6%

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

        \[\leadsto -\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      17. distribute-neg-frac250.6%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]
    12. Simplified50.6%

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

    if -7.60000000000000046e-153 < d < -4.999999999999985e-310

    1. Initial program 40.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. Simplified40.0%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. add-cbrt-cube26.0%

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

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

        \[\leadsto d \cdot {\left(\color{blue}{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{0.3333333333333333} \]
      4. pow126.0%

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

        \[\leadsto d \cdot {\left({\left(\frac{1}{h \cdot \ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)}^{0.3333333333333333} \]
      6. pow-prod-up26.0%

        \[\leadsto d \cdot {\color{blue}{\left({\left(\frac{1}{h \cdot \ell}\right)}^{\left(1 + 0.5\right)}\right)}}^{0.3333333333333333} \]
      7. associate-/r*26.0%

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

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

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    7. Step-by-step derivation
      1. pow-pow18.3%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}} \]
      2. div-inv18.3%

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

        \[\leadsto d \cdot {\left(\frac{1}{h} \cdot \frac{1}{\ell}\right)}^{\color{blue}{0.5}} \]
      4. unpow-prod-down0.0%

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

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

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

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \color{blue}{\sqrt{\frac{1}{\ell}}}\right) \]
    10. Simplified0.0%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{\frac{1}{h}} \cdot \sqrt{\frac{1}{\ell}}\right)} \]
    11. Step-by-step derivation
      1. pow1/20.0%

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      10. sqr-pow18.3%

        \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      11. pow-prod-down28.6%

        \[\leadsto d \cdot \color{blue}{{\left(\left(h \cdot \ell\right) \cdot \left(h \cdot \ell\right)\right)}^{\left(\frac{-0.5}{2}\right)}} \]
      12. pow228.6%

        \[\leadsto d \cdot {\color{blue}{\left({\left(h \cdot \ell\right)}^{2}\right)}}^{\left(\frac{-0.5}{2}\right)} \]
      13. *-commutative28.6%

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

        \[\leadsto d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{\color{blue}{-0.25}} \]
    12. Applied egg-rr28.6%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}} \]

    if -4.999999999999985e-310 < d

    1. Initial program 63.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.8%

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square36.3%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt36.2%

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

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt36.3%

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. *-commutative36.3%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down44.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.6 \cdot 10^{-153}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 46.5% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;h \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= h -5e-311)
   (/ d (- (sqrt (* l h))))
   (* d (* (pow l -0.5) (pow h -0.5)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (h <= -5e-311) {
		tmp = d / -sqrt((l * h));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (h <= (-5d-311)) then
        tmp = d / -sqrt((l * h))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (h <= -5e-311) {
		tmp = d / -Math.sqrt((l * h));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if h <= -5e-311:
		tmp = d / -math.sqrt((l * h))
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (h <= -5e-311)
		tmp = Float64(d / Float64(-sqrt(Float64(l * h))));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (h <= -5e-311)
		tmp = d / -sqrt((l * h));
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[h, -5e-311], N[(d / (-N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    11. Step-by-step derivation
      1. *-commutative0.0%

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

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt40.5%

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

        \[\leadsto \color{blue}{\left(-d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      5. distribute-lft-neg-in40.5%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. rem-exp-log38.5%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}} \]
      7. exp-neg38.5%

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

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

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      10. distribute-lft-neg-out38.5%

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

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      12. exp-to-pow40.4%

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

        \[\leadsto -d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      14. associate-/l*40.5%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      15. associate-*l/40.5%

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

        \[\leadsto -\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      17. distribute-neg-frac240.5%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]
    12. Simplified40.5%

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

    if -5.00000000000023e-311 < h

    1. Initial program 63.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.8%

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square36.3%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt36.2%

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

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt36.3%

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. *-commutative36.3%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down44.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 46.5% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;h \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= h -5e-311) (/ d (- (sqrt (* l h)))) (/ d (* (sqrt l) (sqrt h)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (h <= -5e-311) {
		tmp = d / -sqrt((l * h));
	} else {
		tmp = d / (sqrt(l) * sqrt(h));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (h <= (-5d-311)) then
        tmp = d / -sqrt((l * h))
    else
        tmp = d / (sqrt(l) * sqrt(h))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (h <= -5e-311) {
		tmp = d / -Math.sqrt((l * h));
	} else {
		tmp = d / (Math.sqrt(l) * Math.sqrt(h));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if h <= -5e-311:
		tmp = d / -math.sqrt((l * h))
	else:
		tmp = d / (math.sqrt(l) * math.sqrt(h))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (h <= -5e-311)
		tmp = Float64(d / Float64(-sqrt(Float64(l * h))));
	else
		tmp = Float64(d / Float64(sqrt(l) * sqrt(h)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (h <= -5e-311)
		tmp = d / -sqrt((l * h));
	else
		tmp = d / (sqrt(l) * sqrt(h));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[h, -5e-311], N[(d / (-N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\

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


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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}}^{2}}{\ell}\right)\right) \]
    7. Simplified63.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}\right)}\right) \]
    8. Step-by-step derivation
      1. add-sqr-sqrt22.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \color{blue}{\left(\sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)}\right)\right) \]
      2. sqrt-div0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\color{blue}{\frac{\sqrt{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}}{\sqrt{\ell}}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      3. sqrt-pow10.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{\left(\frac{2}{2}\right)}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      4. metadata-eval0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{\color{blue}{1}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      5. pow10.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{\frac{D}{d} \cdot \frac{M}{2}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      6. *-commutative0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      7. frac-times0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      8. *-commutative0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\frac{M \cdot D}{\color{blue}{d \cdot 2}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      9. associate-*r/0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{M \cdot \frac{D}{d \cdot 2}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      10. sqrt-div0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}}{\sqrt{\ell}}}\right)\right)\right) \]
      11. sqrt-pow10.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{\left(\frac{2}{2}\right)}}}{\sqrt{\ell}}\right)\right)\right) \]
      12. metadata-eval0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{\color{blue}{1}}}{\sqrt{\ell}}\right)\right)\right) \]
      13. pow10.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{\frac{D}{d} \cdot \frac{M}{2}}}{\sqrt{\ell}}\right)\right)\right) \]
      14. *-commutative0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\sqrt{\ell}}\right)\right)\right) \]
      15. frac-times0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\sqrt{\ell}}\right)\right)\right) \]
      16. *-commutative0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\frac{M \cdot D}{\color{blue}{d \cdot 2}}}{\sqrt{\ell}}\right)\right)\right) \]
      17. associate-*r/0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{M \cdot \frac{D}{d \cdot 2}}}{\sqrt{\ell}}\right)\right)\right) \]
    9. Applied egg-rr65.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \color{blue}{\left(\frac{\frac{D}{d} \cdot \left(M \cdot 0.5\right)}{1} \cdot \frac{\frac{D}{d} \cdot \left(M \cdot 0.5\right)}{\ell}\right)}\right)\right) \]
    10. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    11. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. unpow20.0%

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt40.5%

        \[\leadsto \left(\color{blue}{-1} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. mul-1-neg40.5%

        \[\leadsto \color{blue}{\left(-d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      5. distribute-lft-neg-in40.5%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. rem-exp-log38.5%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}} \]
      7. exp-neg38.5%

        \[\leadsto -d \cdot \sqrt{\color{blue}{e^{-\log \left(h \cdot \ell\right)}}} \]
      8. unpow1/238.5%

        \[\leadsto -d \cdot \color{blue}{{\left(e^{-\log \left(h \cdot \ell\right)}\right)}^{0.5}} \]
      9. exp-prod38.5%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      10. distribute-lft-neg-out38.5%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      11. exp-neg38.5%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      12. exp-to-pow40.4%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      13. unpow1/240.4%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      14. associate-/l*40.5%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      15. associate-*l/40.5%

        \[\leadsto -\color{blue}{\frac{d}{\sqrt{h \cdot \ell}} \cdot 1} \]
      16. *-rgt-identity40.5%

        \[\leadsto -\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      17. distribute-neg-frac240.5%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]
    12. Simplified40.5%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if -5.00000000000023e-311 < h

    1. Initial program 63.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.8%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 35.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div36.3%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval36.3%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. sqrt-unprod44.5%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      4. div-inv44.6%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      5. sqrt-unprod36.4%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \]
    6. Applied egg-rr36.4%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. sqrt-prod44.6%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      2. *-commutative44.6%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    8. Applied egg-rr44.6%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification42.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 42.3% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 2.25 \cdot 10^{-204}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l 2.25e-204) (/ d (- (sqrt (* l h)))) (* d (sqrt (/ (/ 1.0 h) l)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 2.25e-204) {
		tmp = d / -sqrt((l * h));
	} else {
		tmp = d * sqrt(((1.0 / h) / l));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= 2.25d-204) then
        tmp = d / -sqrt((l * h))
    else
        tmp = d * sqrt(((1.0d0 / h) / l))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 2.25e-204) {
		tmp = d / -Math.sqrt((l * h));
	} else {
		tmp = d * Math.sqrt(((1.0 / h) / l));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= 2.25e-204:
		tmp = d / -math.sqrt((l * h))
	else:
		tmp = d * math.sqrt(((1.0 / h) / l))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= 2.25e-204)
		tmp = Float64(d / Float64(-sqrt(Float64(l * h))));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / h) / l)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= 2.25e-204)
		tmp = d / -sqrt((l * h));
	else
		tmp = d * sqrt(((1.0 / h) / l));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, 2.25e-204], N[(d / (-N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2.25 \cdot 10^{-204}:\\
\;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 2.24999999999999987e-204

    1. Initial program 67.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified65.2%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-*r/66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}}\right) \]
      2. frac-times67.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot h}{\ell}\right) \]
      3. associate-/l*66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{2} \cdot h}{\ell}\right) \]
      4. *-commutative66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right)}^{2} \cdot h}{\ell}\right) \]
    5. Applied egg-rr66.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2} \cdot h}{\ell}}\right) \]
    6. Step-by-step derivation
      1. *-commutative66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{h \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}}{\ell}\right) \]
      2. associate-/l*66.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
      3. associate-*r/68.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}}{\ell}\right)\right) \]
      4. *-commutative68.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}}{\ell}\right)\right) \]
      5. times-frac66.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}}^{2}}{\ell}\right)\right) \]
    7. Simplified66.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}\right)}\right) \]
    8. Step-by-step derivation
      1. add-sqr-sqrt32.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \color{blue}{\left(\sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)}\right)\right) \]
      2. sqrt-div13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\color{blue}{\frac{\sqrt{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}}{\sqrt{\ell}}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      3. sqrt-pow18.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{\left(\frac{2}{2}\right)}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      4. metadata-eval8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{\color{blue}{1}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      5. pow18.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{\frac{D}{d} \cdot \frac{M}{2}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      6. *-commutative8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      7. frac-times8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      8. *-commutative8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\frac{M \cdot D}{\color{blue}{d \cdot 2}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      9. associate-*r/8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{M \cdot \frac{D}{d \cdot 2}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      10. sqrt-div8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}}{\sqrt{\ell}}}\right)\right)\right) \]
      11. sqrt-pow113.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{\left(\frac{2}{2}\right)}}}{\sqrt{\ell}}\right)\right)\right) \]
      12. metadata-eval13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{\color{blue}{1}}}{\sqrt{\ell}}\right)\right)\right) \]
      13. pow113.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{\frac{D}{d} \cdot \frac{M}{2}}}{\sqrt{\ell}}\right)\right)\right) \]
      14. *-commutative13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\sqrt{\ell}}\right)\right)\right) \]
      15. frac-times13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\sqrt{\ell}}\right)\right)\right) \]
      16. *-commutative13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\frac{M \cdot D}{\color{blue}{d \cdot 2}}}{\sqrt{\ell}}\right)\right)\right) \]
      17. associate-*r/13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{M \cdot \frac{D}{d \cdot 2}}}{\sqrt{\ell}}\right)\right)\right) \]
    9. Applied egg-rr68.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \color{blue}{\left(\frac{\frac{D}{d} \cdot \left(M \cdot 0.5\right)}{1} \cdot \frac{\frac{D}{d} \cdot \left(M \cdot 0.5\right)}{\ell}\right)}\right)\right) \]
    10. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    11. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. unpow20.0%

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt41.1%

        \[\leadsto \left(\color{blue}{-1} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. mul-1-neg41.1%

        \[\leadsto \color{blue}{\left(-d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      5. distribute-lft-neg-in41.1%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. rem-exp-log39.4%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}} \]
      7. exp-neg39.4%

        \[\leadsto -d \cdot \sqrt{\color{blue}{e^{-\log \left(h \cdot \ell\right)}}} \]
      8. unpow1/239.4%

        \[\leadsto -d \cdot \color{blue}{{\left(e^{-\log \left(h \cdot \ell\right)}\right)}^{0.5}} \]
      9. exp-prod39.4%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      10. distribute-lft-neg-out39.4%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      11. exp-neg39.4%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      12. exp-to-pow41.0%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      13. unpow1/241.0%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      14. associate-/l*41.1%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      15. associate-*l/41.1%

        \[\leadsto -\color{blue}{\frac{d}{\sqrt{h \cdot \ell}} \cdot 1} \]
      16. *-rgt-identity41.1%

        \[\leadsto -\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      17. distribute-neg-frac241.1%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]
    12. Simplified41.1%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if 2.24999999999999987e-204 < l

    1. Initial program 58.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified59.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 38.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*40.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified40.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification40.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 2.25 \cdot 10^{-204}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 42.2% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 3.1 \cdot 10^{-203}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l 3.1e-203) (/ d (- (sqrt (* l h)))) (* d (sqrt (/ (/ 1.0 l) h)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 3.1e-203) {
		tmp = d / -sqrt((l * h));
	} else {
		tmp = d * sqrt(((1.0 / l) / h));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= 3.1d-203) then
        tmp = d / -sqrt((l * h))
    else
        tmp = d * sqrt(((1.0d0 / l) / h))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 3.1e-203) {
		tmp = d / -Math.sqrt((l * h));
	} else {
		tmp = d * Math.sqrt(((1.0 / l) / h));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= 3.1e-203:
		tmp = d / -math.sqrt((l * h))
	else:
		tmp = d * math.sqrt(((1.0 / l) / h))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= 3.1e-203)
		tmp = Float64(d / Float64(-sqrt(Float64(l * h))));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / l) / h)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= 3.1e-203)
		tmp = d / -sqrt((l * h));
	else
		tmp = d * sqrt(((1.0 / l) / h));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, 3.1e-203], N[(d / (-N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 3.1 \cdot 10^{-203}:\\
\;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 3.09999999999999977e-203

    1. Initial program 67.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified65.2%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-*r/66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}}\right) \]
      2. frac-times67.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot h}{\ell}\right) \]
      3. associate-/l*66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{2} \cdot h}{\ell}\right) \]
      4. *-commutative66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right)}^{2} \cdot h}{\ell}\right) \]
    5. Applied egg-rr66.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2} \cdot h}{\ell}}\right) \]
    6. Step-by-step derivation
      1. *-commutative66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{h \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}}{\ell}\right) \]
      2. associate-/l*66.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
      3. associate-*r/68.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}}{\ell}\right)\right) \]
      4. *-commutative68.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}}{\ell}\right)\right) \]
      5. times-frac66.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}}^{2}}{\ell}\right)\right) \]
    7. Simplified66.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}\right)}\right) \]
    8. Step-by-step derivation
      1. add-sqr-sqrt32.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \color{blue}{\left(\sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)}\right)\right) \]
      2. sqrt-div13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\color{blue}{\frac{\sqrt{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}}{\sqrt{\ell}}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      3. sqrt-pow18.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{\left(\frac{2}{2}\right)}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      4. metadata-eval8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{\color{blue}{1}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      5. pow18.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{\frac{D}{d} \cdot \frac{M}{2}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      6. *-commutative8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      7. frac-times8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      8. *-commutative8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\frac{M \cdot D}{\color{blue}{d \cdot 2}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      9. associate-*r/8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{M \cdot \frac{D}{d \cdot 2}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      10. sqrt-div8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}}{\sqrt{\ell}}}\right)\right)\right) \]
      11. sqrt-pow113.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{\left(\frac{2}{2}\right)}}}{\sqrt{\ell}}\right)\right)\right) \]
      12. metadata-eval13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{\color{blue}{1}}}{\sqrt{\ell}}\right)\right)\right) \]
      13. pow113.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{\frac{D}{d} \cdot \frac{M}{2}}}{\sqrt{\ell}}\right)\right)\right) \]
      14. *-commutative13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\sqrt{\ell}}\right)\right)\right) \]
      15. frac-times13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\sqrt{\ell}}\right)\right)\right) \]
      16. *-commutative13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\frac{M \cdot D}{\color{blue}{d \cdot 2}}}{\sqrt{\ell}}\right)\right)\right) \]
      17. associate-*r/13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{M \cdot \frac{D}{d \cdot 2}}}{\sqrt{\ell}}\right)\right)\right) \]
    9. Applied egg-rr68.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \color{blue}{\left(\frac{\frac{D}{d} \cdot \left(M \cdot 0.5\right)}{1} \cdot \frac{\frac{D}{d} \cdot \left(M \cdot 0.5\right)}{\ell}\right)}\right)\right) \]
    10. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    11. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. unpow20.0%

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt41.1%

        \[\leadsto \left(\color{blue}{-1} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. mul-1-neg41.1%

        \[\leadsto \color{blue}{\left(-d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      5. distribute-lft-neg-in41.1%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. rem-exp-log39.4%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}} \]
      7. exp-neg39.4%

        \[\leadsto -d \cdot \sqrt{\color{blue}{e^{-\log \left(h \cdot \ell\right)}}} \]
      8. unpow1/239.4%

        \[\leadsto -d \cdot \color{blue}{{\left(e^{-\log \left(h \cdot \ell\right)}\right)}^{0.5}} \]
      9. exp-prod39.4%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      10. distribute-lft-neg-out39.4%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      11. exp-neg39.4%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      12. exp-to-pow41.0%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      13. unpow1/241.0%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      14. associate-/l*41.1%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      15. associate-*l/41.1%

        \[\leadsto -\color{blue}{\frac{d}{\sqrt{h \cdot \ell}} \cdot 1} \]
      16. *-rgt-identity41.1%

        \[\leadsto -\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      17. distribute-neg-frac241.1%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]
    12. Simplified41.1%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if 3.09999999999999977e-203 < l

    1. Initial program 58.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified59.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 38.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-un-lft-identity38.8%

        \[\leadsto d \cdot \sqrt{\color{blue}{1 \cdot \frac{1}{h \cdot \ell}}} \]
      2. associate-/r*40.4%

        \[\leadsto d \cdot \sqrt{1 \cdot \color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Applied egg-rr40.4%

      \[\leadsto d \cdot \sqrt{\color{blue}{1 \cdot \frac{\frac{1}{h}}{\ell}}} \]
    7. Step-by-step derivation
      1. *-lft-identity40.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. associate-/l/38.8%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{\ell \cdot h}}} \]
      3. associate-/r*40.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    8. Simplified40.4%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification40.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 3.1 \cdot 10^{-203}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 42.2% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;\ell \leq 1.15 \cdot 10^{-204}:\\ \;\;\;\;\frac{d}{-t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{t\_0}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (* l h)))) (if (<= l 1.15e-204) (/ d (- t_0)) (/ d t_0))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt((l * h));
	double tmp;
	if (l <= 1.15e-204) {
		tmp = d / -t_0;
	} else {
		tmp = d / t_0;
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((l * h))
    if (l <= 1.15d-204) then
        tmp = d / -t_0
    else
        tmp = d / t_0
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = Math.sqrt((l * h));
	double tmp;
	if (l <= 1.15e-204) {
		tmp = d / -t_0;
	} else {
		tmp = d / t_0;
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = math.sqrt((l * h))
	tmp = 0
	if l <= 1.15e-204:
		tmp = d / -t_0
	else:
		tmp = d / t_0
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = sqrt(Float64(l * h))
	tmp = 0.0
	if (l <= 1.15e-204)
		tmp = Float64(d / Float64(-t_0));
	else
		tmp = Float64(d / t_0);
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = sqrt((l * h));
	tmp = 0.0;
	if (l <= 1.15e-204)
		tmp = d / -t_0;
	else
		tmp = d / t_0;
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, 1.15e-204], N[(d / (-t$95$0)), $MachinePrecision], N[(d / t$95$0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;\ell \leq 1.15 \cdot 10^{-204}:\\
\;\;\;\;\frac{d}{-t\_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 1.15e-204

    1. Initial program 67.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified65.2%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-*r/66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}}\right) \]
      2. frac-times67.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot h}{\ell}\right) \]
      3. associate-/l*66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{2} \cdot h}{\ell}\right) \]
      4. *-commutative66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right)}^{2} \cdot h}{\ell}\right) \]
    5. Applied egg-rr66.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2} \cdot h}{\ell}}\right) \]
    6. Step-by-step derivation
      1. *-commutative66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{h \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}}{\ell}\right) \]
      2. associate-/l*66.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
      3. associate-*r/68.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}}{\ell}\right)\right) \]
      4. *-commutative68.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}}{\ell}\right)\right) \]
      5. times-frac66.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}}^{2}}{\ell}\right)\right) \]
    7. Simplified66.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}\right)}\right) \]
    8. Step-by-step derivation
      1. add-sqr-sqrt32.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \color{blue}{\left(\sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)}\right)\right) \]
      2. sqrt-div13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\color{blue}{\frac{\sqrt{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}}{\sqrt{\ell}}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      3. sqrt-pow18.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{\left(\frac{2}{2}\right)}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      4. metadata-eval8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{\color{blue}{1}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      5. pow18.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{\frac{D}{d} \cdot \frac{M}{2}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      6. *-commutative8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      7. frac-times8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      8. *-commutative8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\frac{M \cdot D}{\color{blue}{d \cdot 2}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      9. associate-*r/8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{\color{blue}{M \cdot \frac{D}{d \cdot 2}}}{\sqrt{\ell}} \cdot \sqrt{\frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}}\right)\right)\right) \]
      10. sqrt-div8.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}}{\sqrt{\ell}}}\right)\right)\right) \]
      11. sqrt-pow113.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{\left(\frac{2}{2}\right)}}}{\sqrt{\ell}}\right)\right)\right) \]
      12. metadata-eval13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{\color{blue}{1}}}{\sqrt{\ell}}\right)\right)\right) \]
      13. pow113.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{\frac{D}{d} \cdot \frac{M}{2}}}{\sqrt{\ell}}\right)\right)\right) \]
      14. *-commutative13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\sqrt{\ell}}\right)\right)\right) \]
      15. frac-times13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\sqrt{\ell}}\right)\right)\right) \]
      16. *-commutative13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\frac{M \cdot D}{\color{blue}{d \cdot 2}}}{\sqrt{\ell}}\right)\right)\right) \]
      17. associate-*r/13.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \left(\frac{M \cdot \frac{D}{d \cdot 2}}{\sqrt{\ell}} \cdot \frac{\color{blue}{M \cdot \frac{D}{d \cdot 2}}}{\sqrt{\ell}}\right)\right)\right) \]
    9. Applied egg-rr68.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \color{blue}{\left(\frac{\frac{D}{d} \cdot \left(M \cdot 0.5\right)}{1} \cdot \frac{\frac{D}{d} \cdot \left(M \cdot 0.5\right)}{\ell}\right)}\right)\right) \]
    10. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    11. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. unpow20.0%

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt41.1%

        \[\leadsto \left(\color{blue}{-1} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. mul-1-neg41.1%

        \[\leadsto \color{blue}{\left(-d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      5. distribute-lft-neg-in41.1%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. rem-exp-log39.4%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}} \]
      7. exp-neg39.4%

        \[\leadsto -d \cdot \sqrt{\color{blue}{e^{-\log \left(h \cdot \ell\right)}}} \]
      8. unpow1/239.4%

        \[\leadsto -d \cdot \color{blue}{{\left(e^{-\log \left(h \cdot \ell\right)}\right)}^{0.5}} \]
      9. exp-prod39.4%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      10. distribute-lft-neg-out39.4%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      11. exp-neg39.4%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      12. exp-to-pow41.0%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      13. unpow1/241.0%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      14. associate-/l*41.1%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      15. associate-*l/41.1%

        \[\leadsto -\color{blue}{\frac{d}{\sqrt{h \cdot \ell}} \cdot 1} \]
      16. *-rgt-identity41.1%

        \[\leadsto -\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      17. distribute-neg-frac241.1%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]
    12. Simplified41.1%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if 1.15e-204 < l

    1. Initial program 58.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified59.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 38.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div39.3%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval39.3%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. sqrt-unprod47.6%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      4. div-inv47.6%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      5. sqrt-unprod39.4%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \]
    6. Applied egg-rr39.4%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification40.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 1.15 \cdot 10^{-204}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 26.0% accurate, 3.2× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \frac{d}{\sqrt{\ell \cdot h}} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (/ d (sqrt (* l h))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d / sqrt((l * h));
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d / sqrt((l * h))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d / Math.sqrt((l * h));
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d / math.sqrt((l * h))
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d / sqrt(Float64(l * h)))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d / sqrt((l * h));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Derivation
  1. Initial program 63.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. Simplified62.9%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in d around inf 23.6%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  5. Step-by-step derivation
    1. sqrt-div23.8%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
    2. metadata-eval23.8%

      \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
    3. sqrt-unprod22.4%

      \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    4. div-inv22.5%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    5. sqrt-unprod23.8%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \]
  6. Applied egg-rr23.8%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  7. Final simplification23.8%

    \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
  8. Add Preprocessing

Reproduce

?
herbie shell --seed 2024076 
(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)))))