Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.6% → 81.7%
Time: 28.1s
Alternatives: 21
Speedup: 1.1×

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

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

Initial Program: 66.6% accurate, 1.0× speedup?

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

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

Alternative 1: 81.7% accurate, 0.6× speedup?

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

\mathbf{elif}\;\ell \leq 7.8 \cdot 10^{+138}:\\
\;\;\;\;t\_2 \cdot \left(t\_0 \cdot t\_1\right)\\

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


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

    1. Initial program 70.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. Simplified70.8%

      \[\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. *-commutative70.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l < 7.7999999999999996e138

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.7999999999999996e138 < l

    1. Initial program 59.4%

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

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

        \[\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) \]
      2. clear-num70.7%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{\ell}}{\sqrt{d}}}} \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-rr70.7%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{\ell}}{\sqrt{d}}}} \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-div66.8%

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{\sqrt{\ell}}{\sqrt{d}}} \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 3 regimes into one program.
  4. Final simplification84.0%

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

Alternative 2: 78.7% accurate, 0.2× speedup?

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

\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;t\_4\\

\mathbf{elif}\;t\_0 \leq 10^{+250}:\\
\;\;\;\;t\_1 \cdot \left(\left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{M\_m}{d}\right)}^{2}\right)\right) \cdot t\_2\right)\\

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;t\_4\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -5e-239

    1. Initial program 84.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified85.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. *-commutative85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5e-239 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0 or 9.9999999999999992e249 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0

    1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}}} \]
      2. rem-sqrt-square57.4%

        \[\leadsto \color{blue}{\left|\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right|} \]
      3. frac-times57.4%

        \[\leadsto \left|\sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}}\right| \]
      4. sqrt-div63.2%

        \[\leadsto \left|\color{blue}{\frac{\sqrt{d \cdot d}}{\sqrt{h \cdot \ell}}}\right| \]
      5. sqrt-unprod48.1%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right| \]
      6. add-sqr-sqrt90.2%

        \[\leadsto \left|\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right| \]
    10. Applied egg-rr90.2%

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

    if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 9.9999999999999992e249

    1. Initial program 97.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. Simplified97.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l))))

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 74.2% accurate, 0.8× speedup?

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

\mathbf{elif}\;d \leq -7.2 \cdot 10^{-304}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(t\_1 \cdot \left(-0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{M\_m}{d}\right)}^{2}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(\left(1 + \frac{t\_0 \cdot \left(h \cdot -0.5\right)}{\ell}\right) \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\


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

    1. Initial program 77.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified78.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. *-commutative78.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.50000000000000026e-160 < d < -7.2000000000000003e-304

    1. Initial program 43.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. Simplified43.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\left(\left(\frac{M}{d} \cdot D\right) \cdot \color{blue}{\left(\frac{M}{d} \cdot D\right)}\right) \cdot \frac{h}{\ell}\right)\right)\right) \]
      14. associate-/r/35.9%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\left(\color{blue}{\frac{M}{\frac{d}{D}}} \cdot \left(\frac{M}{d} \cdot D\right)\right) \cdot \frac{h}{\ell}\right)\right)\right) \]
      15. associate-/r/35.9%

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

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

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

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

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

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

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

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

    if -7.2000000000000003e-304 < d

    1. Initial program 63.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 79.4% accurate, 0.8× speedup?

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

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


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

    1. Initial program 70.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. Simplified70.8%

      \[\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. *-commutative70.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 64.4%

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

      \[\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. *-commutative65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 78.2% accurate, 0.8× speedup?

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

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


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

    1. Initial program 70.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. Simplified70.8%

      \[\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. *-commutative70.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 64.4%

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

      \[\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. *-commutative65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 68.7% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -9.4999999999999994e-21

    1. Initial program 67.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. Simplified69.0%

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

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

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

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

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

    if -9.4999999999999994e-21 < l < 3.000000000000001e-309

    1. Initial program 73.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified73.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. *-commutative73.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.000000000000001e-309 < l < 4.79999999999999977e210

    1. Initial program 67.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. 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. *-commutative66.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.79999999999999977e210 < l

    1. Initial program 53.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. Simplified56.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \]
      5. frac-times60.4%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-sqr-sqrt60.3%

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    11. Step-by-step derivation
      1. associate-/l/60.5%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
    12. Simplified60.5%

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

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

Alternative 7: 71.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 70.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.4e-278 < l < 1.2499999999999999e211

    1. Initial program 66.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. 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. *-commutative65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.2499999999999999e211 < l

    1. Initial program 53.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. Simplified56.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \]
      5. frac-times60.4%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-sqr-sqrt60.3%

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    11. Step-by-step derivation
      1. associate-/l/60.5%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
    12. Simplified60.5%

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

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

Alternative 8: 71.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 70.7%

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

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

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

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

    if 3.79999999999999976e-281 < l < 2.8999999999999998e212

    1. Initial program 66.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. 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. *-commutative65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.8999999999999998e212 < l

    1. Initial program 53.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. Simplified56.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \]
      5. frac-times60.4%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-sqr-sqrt60.3%

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    11. Step-by-step derivation
      1. associate-/l/60.5%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
    12. Simplified60.5%

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

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

Alternative 9: 72.6% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 70.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6e-278 < l < 8.0000000000000006e209

    1. Initial program 66.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. 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. *-commutative65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.0000000000000006e209 < l

    1. Initial program 53.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. Simplified56.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \]
      5. frac-times60.4%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-sqr-sqrt60.3%

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    11. Step-by-step derivation
      1. associate-/l/60.5%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
    12. Simplified60.5%

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

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

Alternative 10: 68.1% accurate, 1.1× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -1.12000000000000002e-20

    1. Initial program 67.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. Simplified69.0%

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

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

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

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

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

    if -1.12000000000000002e-20 < l < -4.999999999999985e-310

    1. Initial program 73.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified73.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. *-commutative73.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l < 2.01999999999999999e214

    1. Initial program 67.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. 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. *-commutative66.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.01999999999999999e214 < l

    1. Initial program 53.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. Simplified56.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \]
      5. frac-times60.4%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-sqr-sqrt60.3%

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    11. Step-by-step derivation
      1. associate-/l/60.5%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
    12. Simplified60.5%

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

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

Alternative 11: 66.2% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -2.3000000000000001e144 or -1.6e-18 < l < -4.999999999999985e-310

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.3000000000000001e144 < l < -1.6e-18

    1. Initial program 67.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. Simplified70.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. clear-num70.3%

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

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval71.0%

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

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

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

    if -4.999999999999985e-310 < l < 1.56000000000000009e212

    1. Initial program 67.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. 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. *-commutative66.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.56000000000000009e212 < l

    1. Initial program 53.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. Simplified56.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \]
      5. frac-times60.4%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-sqr-sqrt60.3%

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    11. Step-by-step derivation
      1. associate-/l/60.5%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
    12. Simplified60.5%

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

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

Alternative 12: 59.4% accurate, 1.4× speedup?

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

\mathbf{elif}\;h \leq 2.2 \cdot 10^{-304}:\\
\;\;\;\;\left|t\_0\right|\\

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


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

    1. Initial program 60.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9e55 < h < 2.2e-304

    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. Simplified75.7%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt38.7%

        \[\leadsto \sqrt{\color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}}} \]
      2. rem-sqrt-square38.7%

        \[\leadsto \color{blue}{\left|\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right|} \]
      3. frac-times34.5%

        \[\leadsto \left|\sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}}\right| \]
      4. sqrt-div37.5%

        \[\leadsto \left|\color{blue}{\frac{\sqrt{d \cdot d}}{\sqrt{h \cdot \ell}}}\right| \]
      5. sqrt-unprod2.2%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right| \]
      6. add-sqr-sqrt51.1%

        \[\leadsto \left|\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right| \]
    10. Applied egg-rr51.1%

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

    if 2.2e-304 < h

    1. Initial program 64.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. Simplified64.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. *-commutative64.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 46.3% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 55.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}^{1}} \]
    7. Step-by-step derivation
      1. unpow136.5%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    8. Simplified36.5%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    9. Step-by-step derivation
      1. sqrt-prod45.0%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} \]
      2. *-commutative45.0%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}} \]
    10. Applied egg-rr45.0%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}} \]

    if -2.02e149 < h < 6.000000000000001e-309

    1. Initial program 75.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified76.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. clear-num76.4%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. sqrt-div76.7%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval76.7%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr76.7%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Taylor expanded in d around -inf 49.6%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]

    if 6.000000000000001e-309 < h

    1. Initial program 64.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified64.4%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 38.9%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. pow138.9%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right)\right)}^{1}} \]
      2. *-rgt-identity38.9%

        \[\leadsto {\left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}}\right)}^{1} \]
      3. sqrt-unprod29.2%

        \[\leadsto {\color{blue}{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}}^{1} \]
    6. Applied egg-rr29.2%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}^{1}} \]
    7. Step-by-step derivation
      1. unpow129.2%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    8. Simplified29.2%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    9. Step-by-step derivation
      1. sqrt-prod38.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} \]
      2. *-commutative38.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}} \]
      3. sqrt-div43.4%

        \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}} \]
      4. sqrt-div47.1%

        \[\leadsto \frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \]
      5. frac-times47.2%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-sqr-sqrt47.2%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} \]
    10. Applied egg-rr47.2%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    11. Step-by-step derivation
      1. associate-/l/47.2%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
    12. Simplified47.2%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification47.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -2.02 \cdot 10^{+149}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;h \leq 6 \cdot 10^{-309}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 42.5% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} \mathbf{if}\;h \leq -1.25 \cdot 10^{+166}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (if (<= h -1.25e+166) (sqrt (* (/ d l) (/ d h))) (fabs (/ d (sqrt (* l h))))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (h <= -1.25e+166) {
		tmp = sqrt(((d / l) * (d / h)));
	} else {
		tmp = fabs((d / sqrt((l * h))));
	}
	return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    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_1
    real(8) :: tmp
    if (h <= (-1.25d+166)) then
        tmp = sqrt(((d / l) * (d / h)))
    else
        tmp = abs((d / sqrt((l * h))))
    end if
    code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (h <= -1.25e+166) {
		tmp = Math.sqrt(((d / l) * (d / h)));
	} else {
		tmp = Math.abs((d / Math.sqrt((l * h))));
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	tmp = 0
	if h <= -1.25e+166:
		tmp = math.sqrt(((d / l) * (d / h)))
	else:
		tmp = math.fabs((d / math.sqrt((l * h))))
	return tmp
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	tmp = 0.0
	if (h <= -1.25e+166)
		tmp = sqrt(Float64(Float64(d / l) * Float64(d / h)));
	else
		tmp = abs(Float64(d / sqrt(Float64(l * h))));
	end
	return tmp
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
	tmp = 0.0;
	if (h <= -1.25e+166)
		tmp = sqrt(((d / l) * (d / h)));
	else
		tmp = abs((d / sqrt((l * h))));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[h, -1.25e+166], N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -1.25 \cdot 10^{+166}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if h < -1.25e166

    1. Initial program 55.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified55.5%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 44.6%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. pow144.6%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right)\right)}^{1}} \]
      2. *-rgt-identity44.6%

        \[\leadsto {\left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}}\right)}^{1} \]
      3. sqrt-unprod38.5%

        \[\leadsto {\color{blue}{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}}^{1} \]
    6. Applied egg-rr38.5%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}^{1}} \]
    7. Step-by-step derivation
      1. unpow138.5%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    8. Simplified38.5%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]

    if -1.25e166 < h

    1. Initial program 69.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. Simplified69.5%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 41.5%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. pow141.5%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right)\right)}^{1}} \]
      2. *-rgt-identity41.5%

        \[\leadsto {\left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}}\right)}^{1} \]
      3. sqrt-unprod32.8%

        \[\leadsto {\color{blue}{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}}^{1} \]
    6. Applied egg-rr32.8%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}^{1}} \]
    7. Step-by-step derivation
      1. unpow132.8%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    8. Simplified32.8%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt32.8%

        \[\leadsto \sqrt{\color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}}} \]
      2. rem-sqrt-square32.8%

        \[\leadsto \color{blue}{\left|\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right|} \]
      3. frac-times26.3%

        \[\leadsto \left|\sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}}\right| \]
      4. sqrt-div29.6%

        \[\leadsto \left|\color{blue}{\frac{\sqrt{d \cdot d}}{\sqrt{h \cdot \ell}}}\right| \]
      5. sqrt-unprod21.1%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right| \]
      6. add-sqr-sqrt43.2%

        \[\leadsto \left|\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right| \]
    10. Applied egg-rr43.2%

      \[\leadsto \color{blue}{\left|\frac{d}{\sqrt{h \cdot \ell}}\right|} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification42.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -1.25 \cdot 10^{+166}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 45.9% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq 3.9 \cdot 10^{-274}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (if (<= d 3.9e-274)
   (* (- d) (sqrt (/ 1.0 (* l h))))
   (/ d (* (sqrt h) (sqrt l)))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (d <= 3.9e-274) {
		tmp = -d * sqrt((1.0 / (l * h)));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    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_1
    real(8) :: tmp
    if (d <= 3.9d-274) then
        tmp = -d * sqrt((1.0d0 / (l * h)))
    else
        tmp = d / (sqrt(h) * sqrt(l))
    end if
    code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (d <= 3.9e-274) {
		tmp = -d * Math.sqrt((1.0 / (l * h)));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	tmp = 0
	if d <= 3.9e-274:
		tmp = -d * math.sqrt((1.0 / (l * h)))
	else:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	return tmp
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	tmp = 0.0
	if (d <= 3.9e-274)
		tmp = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h))));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
	tmp = 0.0;
	if (d <= 3.9e-274)
		tmp = -d * sqrt((1.0 / (l * h)));
	else
		tmp = d / (sqrt(h) * sqrt(l));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[d, 3.9e-274], N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 3.9 \cdot 10^{-274}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 3.89999999999999985e-274

    1. Initial program 66.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. Simplified66.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. Step-by-step derivation
      1. clear-num66.0%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. sqrt-div66.2%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval66.2%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr66.2%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Taylor expanded in d around -inf 41.6%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]

    if 3.89999999999999985e-274 < d

    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. Simplified68.8%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 42.5%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. pow142.5%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right)\right)}^{1}} \]
      2. *-rgt-identity42.5%

        \[\leadsto {\left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}}\right)}^{1} \]
      3. sqrt-unprod31.9%

        \[\leadsto {\color{blue}{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}}^{1} \]
    6. Applied egg-rr31.9%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}^{1}} \]
    7. Step-by-step derivation
      1. unpow131.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    8. Simplified31.9%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    9. Step-by-step derivation
      1. sqrt-prod42.5%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} \]
      2. *-commutative42.5%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}} \]
      3. sqrt-div46.6%

        \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}} \]
      4. sqrt-div50.7%

        \[\leadsto \frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \]
      5. frac-times50.7%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-sqr-sqrt50.7%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} \]
    10. Applied egg-rr50.7%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification45.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 3.9 \cdot 10^{-274}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 45.2% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq 1.42 \cdot 10^{-276}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (if (<= d 1.42e-276)
   (* (- d) (sqrt (/ 1.0 (* l h))))
   (/ (/ d (sqrt h)) (sqrt l))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (d <= 1.42e-276) {
		tmp = -d * sqrt((1.0 / (l * h)));
	} else {
		tmp = (d / sqrt(h)) / sqrt(l);
	}
	return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    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_1
    real(8) :: tmp
    if (d <= 1.42d-276) then
        tmp = -d * sqrt((1.0d0 / (l * h)))
    else
        tmp = (d / sqrt(h)) / sqrt(l)
    end if
    code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (d <= 1.42e-276) {
		tmp = -d * Math.sqrt((1.0 / (l * h)));
	} else {
		tmp = (d / Math.sqrt(h)) / Math.sqrt(l);
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	tmp = 0
	if d <= 1.42e-276:
		tmp = -d * math.sqrt((1.0 / (l * h)))
	else:
		tmp = (d / math.sqrt(h)) / math.sqrt(l)
	return tmp
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	tmp = 0.0
	if (d <= 1.42e-276)
		tmp = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h))));
	else
		tmp = Float64(Float64(d / sqrt(h)) / sqrt(l));
	end
	return tmp
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
	tmp = 0.0;
	if (d <= 1.42e-276)
		tmp = -d * sqrt((1.0 / (l * h)));
	else
		tmp = (d / sqrt(h)) / sqrt(l);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[d, 1.42e-276], N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 1.42 \cdot 10^{-276}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 1.41999999999999993e-276

    1. Initial program 66.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. Simplified66.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. Step-by-step derivation
      1. clear-num66.0%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. sqrt-div66.2%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval66.2%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr66.2%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Taylor expanded in d around -inf 41.6%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]

    if 1.41999999999999993e-276 < d

    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. Simplified68.8%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 42.5%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. pow142.5%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right)\right)}^{1}} \]
      2. *-rgt-identity42.5%

        \[\leadsto {\left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}}\right)}^{1} \]
      3. sqrt-unprod31.9%

        \[\leadsto {\color{blue}{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}}^{1} \]
    6. Applied egg-rr31.9%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}^{1}} \]
    7. Step-by-step derivation
      1. unpow131.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    8. Simplified31.9%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    9. Step-by-step derivation
      1. sqrt-prod42.5%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} \]
      2. *-commutative42.5%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}} \]
      3. sqrt-div46.6%

        \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}} \]
      4. sqrt-div50.7%

        \[\leadsto \frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \]
      5. frac-times50.7%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-sqr-sqrt50.7%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} \]
    10. Applied egg-rr50.7%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    11. Step-by-step derivation
      1. associate-/l/50.8%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
    12. Simplified50.8%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification45.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 1.42 \cdot 10^{-276}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 42.2% accurate, 2.9× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 6 \cdot 10^{-296}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (if (<= l 6e-296) (* (- d) (sqrt (/ (/ 1.0 h) l))) (* d (pow (* l h) -0.5))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (l <= 6e-296) {
		tmp = -d * sqrt(((1.0 / h) / l));
	} else {
		tmp = d * pow((l * h), -0.5);
	}
	return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    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_1
    real(8) :: tmp
    if (l <= 6d-296) then
        tmp = -d * sqrt(((1.0d0 / h) / l))
    else
        tmp = d * ((l * h) ** (-0.5d0))
    end if
    code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (l <= 6e-296) {
		tmp = -d * Math.sqrt(((1.0 / h) / l));
	} else {
		tmp = d * Math.pow((l * h), -0.5);
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	tmp = 0
	if l <= 6e-296:
		tmp = -d * math.sqrt(((1.0 / h) / l))
	else:
		tmp = d * math.pow((l * h), -0.5)
	return tmp
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	tmp = 0.0
	if (l <= 6e-296)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l)));
	else
		tmp = Float64(d * (Float64(l * h) ^ -0.5));
	end
	return tmp
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
	tmp = 0.0;
	if (l <= 6e-296)
		tmp = -d * sqrt(((1.0 / h) / l));
	else
		tmp = d * ((l * h) ^ -0.5);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, 6e-296], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 6 \cdot 10^{-296}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 5.9999999999999995e-296

    1. Initial program 70.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified71.0%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 43.5%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. pow143.5%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right)\right)}^{1}} \]
      2. *-rgt-identity43.5%

        \[\leadsto {\left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}}\right)}^{1} \]
      3. sqrt-unprod36.6%

        \[\leadsto {\color{blue}{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}}^{1} \]
    6. Applied egg-rr36.6%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}^{1}} \]
    7. Step-by-step derivation
      1. unpow136.6%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    8. Simplified36.6%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    9. Taylor expanded in d around -inf 43.6%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    10. Step-by-step derivation
      1. associate-*r*43.6%

        \[\leadsto \color{blue}{\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. neg-mul-143.6%

        \[\leadsto \color{blue}{\left(-d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. associate-/r*43.5%

        \[\leadsto \left(-d\right) \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    11. Simplified43.5%

      \[\leadsto \color{blue}{\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]

    if 5.9999999999999995e-296 < l

    1. Initial program 64.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. Simplified64.0%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 40.2%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. pow140.2%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right)\right)}^{1}} \]
      2. *-rgt-identity40.2%

        \[\leadsto {\left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}}\right)}^{1} \]
      3. sqrt-unprod30.1%

        \[\leadsto {\color{blue}{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}}^{1} \]
    6. Applied egg-rr30.1%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}^{1}} \]
    7. Step-by-step derivation
      1. unpow130.1%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    8. Simplified30.1%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    9. Step-by-step derivation
      1. sqrt-prod40.2%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} \]
      2. clear-num40.1%

        \[\leadsto \sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}} \]
      3. sqrt-div40.8%

        \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}} \]
      4. metadata-eval40.8%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}} \]
      5. *-rgt-identity40.8%

        \[\leadsto \frac{1}{\sqrt{\frac{h}{d}}} \cdot \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot 1\right)} \]
      6. associate-*r*40.8%

        \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1} \]
      7. metadata-eval40.8%

        \[\leadsto \left(\frac{\color{blue}{\sqrt{1}}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1 \]
      8. sqrt-div40.1%

        \[\leadsto \left(\color{blue}{\sqrt{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1 \]
      9. clear-num40.2%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{d}{h}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1 \]
      10. sqrt-prod30.1%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot 1 \]
      11. frac-times21.9%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}} \cdot 1 \]
      12. sqrt-div25.0%

        \[\leadsto \color{blue}{\frac{\sqrt{d \cdot d}}{\sqrt{h \cdot \ell}}} \cdot 1 \]
      13. sqrt-unprod39.2%

        \[\leadsto \frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}} \cdot 1 \]
      14. add-sqr-sqrt39.3%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \cdot 1 \]
    10. Applied egg-rr39.3%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}} \cdot 1} \]
    11. Step-by-step derivation
      1. *-rgt-identity39.3%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    12. Simplified39.3%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    13. Step-by-step derivation
      1. clear-num39.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h \cdot \ell}}{d}}} \]
      2. associate-/r/39.3%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{h \cdot \ell}} \cdot d} \]
      3. pow1/239.3%

        \[\leadsto \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \cdot d \]
      4. pow-flip39.3%

        \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.5\right)}} \cdot d \]
      5. metadata-eval39.3%

        \[\leadsto {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \cdot d \]
    14. Applied egg-rr39.3%

      \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot d} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification41.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 6 \cdot 10^{-296}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 42.0% accurate, 2.9× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 2.2 \cdot 10^{-292}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (if (<= l 2.2e-292)
   (* (- d) (sqrt (/ 1.0 (* l h))))
   (* d (pow (* l h) -0.5))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (l <= 2.2e-292) {
		tmp = -d * sqrt((1.0 / (l * h)));
	} else {
		tmp = d * pow((l * h), -0.5);
	}
	return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    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_1
    real(8) :: tmp
    if (l <= 2.2d-292) then
        tmp = -d * sqrt((1.0d0 / (l * h)))
    else
        tmp = d * ((l * h) ** (-0.5d0))
    end if
    code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (l <= 2.2e-292) {
		tmp = -d * Math.sqrt((1.0 / (l * h)));
	} else {
		tmp = d * Math.pow((l * h), -0.5);
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	tmp = 0
	if l <= 2.2e-292:
		tmp = -d * math.sqrt((1.0 / (l * h)))
	else:
		tmp = d * math.pow((l * h), -0.5)
	return tmp
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	tmp = 0.0
	if (l <= 2.2e-292)
		tmp = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h))));
	else
		tmp = Float64(d * (Float64(l * h) ^ -0.5));
	end
	return tmp
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
	tmp = 0.0;
	if (l <= 2.2e-292)
		tmp = -d * sqrt((1.0 / (l * h)));
	else
		tmp = d * ((l * h) ^ -0.5);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, 2.2e-292], N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2.2 \cdot 10^{-292}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 2.20000000000000011e-292

    1. Initial program 70.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified71.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. clear-num70.1%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. sqrt-div70.3%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval70.3%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr70.3%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Taylor expanded in d around -inf 43.6%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]

    if 2.20000000000000011e-292 < l

    1. Initial program 64.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. Simplified64.0%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 40.2%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. pow140.2%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right)\right)}^{1}} \]
      2. *-rgt-identity40.2%

        \[\leadsto {\left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}}\right)}^{1} \]
      3. sqrt-unprod30.1%

        \[\leadsto {\color{blue}{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}}^{1} \]
    6. Applied egg-rr30.1%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}^{1}} \]
    7. Step-by-step derivation
      1. unpow130.1%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    8. Simplified30.1%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    9. Step-by-step derivation
      1. sqrt-prod40.2%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} \]
      2. clear-num40.1%

        \[\leadsto \sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}} \]
      3. sqrt-div40.8%

        \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}} \]
      4. metadata-eval40.8%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}} \]
      5. *-rgt-identity40.8%

        \[\leadsto \frac{1}{\sqrt{\frac{h}{d}}} \cdot \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot 1\right)} \]
      6. associate-*r*40.8%

        \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1} \]
      7. metadata-eval40.8%

        \[\leadsto \left(\frac{\color{blue}{\sqrt{1}}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1 \]
      8. sqrt-div40.1%

        \[\leadsto \left(\color{blue}{\sqrt{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1 \]
      9. clear-num40.2%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{d}{h}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1 \]
      10. sqrt-prod30.1%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot 1 \]
      11. frac-times21.9%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}} \cdot 1 \]
      12. sqrt-div25.0%

        \[\leadsto \color{blue}{\frac{\sqrt{d \cdot d}}{\sqrt{h \cdot \ell}}} \cdot 1 \]
      13. sqrt-unprod39.2%

        \[\leadsto \frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}} \cdot 1 \]
      14. add-sqr-sqrt39.3%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \cdot 1 \]
    10. Applied egg-rr39.3%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}} \cdot 1} \]
    11. Step-by-step derivation
      1. *-rgt-identity39.3%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    12. Simplified39.3%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    13. Step-by-step derivation
      1. clear-num39.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h \cdot \ell}}{d}}} \]
      2. associate-/r/39.3%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{h \cdot \ell}} \cdot d} \]
      3. pow1/239.3%

        \[\leadsto \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \cdot d \]
      4. pow-flip39.3%

        \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.5\right)}} \cdot d \]
      5. metadata-eval39.3%

        \[\leadsto {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \cdot d \]
    14. Applied egg-rr39.3%

      \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot d} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification41.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 2.2 \cdot 10^{-292}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 37.2% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -2.9 \cdot 10^{-136}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (if (<= d -2.9e-136) (sqrt (* (/ d l) (/ d h))) (* d (pow (* l h) -0.5))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (d <= -2.9e-136) {
		tmp = sqrt(((d / l) * (d / h)));
	} else {
		tmp = d * pow((l * h), -0.5);
	}
	return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    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_1
    real(8) :: tmp
    if (d <= (-2.9d-136)) then
        tmp = sqrt(((d / l) * (d / h)))
    else
        tmp = d * ((l * h) ** (-0.5d0))
    end if
    code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (d <= -2.9e-136) {
		tmp = Math.sqrt(((d / l) * (d / h)));
	} else {
		tmp = d * Math.pow((l * h), -0.5);
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	tmp = 0
	if d <= -2.9e-136:
		tmp = math.sqrt(((d / l) * (d / h)))
	else:
		tmp = d * math.pow((l * h), -0.5)
	return tmp
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	tmp = 0.0
	if (d <= -2.9e-136)
		tmp = sqrt(Float64(Float64(d / l) * Float64(d / h)));
	else
		tmp = Float64(d * (Float64(l * h) ^ -0.5));
	end
	return tmp
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
	tmp = 0.0;
	if (d <= -2.9e-136)
		tmp = sqrt(((d / l) * (d / h)));
	else
		tmp = d * ((l * h) ^ -0.5);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[d, -2.9e-136], N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.9 \cdot 10^{-136}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.89999999999999995e-136

    1. Initial program 78.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. Simplified79.5%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 55.0%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. pow155.0%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right)\right)}^{1}} \]
      2. *-rgt-identity55.0%

        \[\leadsto {\left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}}\right)}^{1} \]
      3. sqrt-unprod46.4%

        \[\leadsto {\color{blue}{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}}^{1} \]
    6. Applied egg-rr46.4%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}^{1}} \]
    7. Step-by-step derivation
      1. unpow146.4%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    8. Simplified46.4%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]

    if -2.89999999999999995e-136 < d

    1. Initial program 60.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. Simplified60.5%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 33.9%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. pow133.9%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right)\right)}^{1}} \]
      2. *-rgt-identity33.9%

        \[\leadsto {\left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}}\right)}^{1} \]
      3. sqrt-unprod25.8%

        \[\leadsto {\color{blue}{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}}^{1} \]
    6. Applied egg-rr25.8%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}^{1}} \]
    7. Step-by-step derivation
      1. unpow125.8%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    8. Simplified25.8%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    9. Step-by-step derivation
      1. sqrt-prod33.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} \]
      2. clear-num33.9%

        \[\leadsto \sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}} \]
      3. sqrt-div34.4%

        \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}} \]
      4. metadata-eval34.4%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}} \]
      5. *-rgt-identity34.4%

        \[\leadsto \frac{1}{\sqrt{\frac{h}{d}}} \cdot \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot 1\right)} \]
      6. associate-*r*34.4%

        \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1} \]
      7. metadata-eval34.4%

        \[\leadsto \left(\frac{\color{blue}{\sqrt{1}}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1 \]
      8. sqrt-div33.9%

        \[\leadsto \left(\color{blue}{\sqrt{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1 \]
      9. clear-num33.9%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{d}{h}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1 \]
      10. sqrt-prod25.8%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot 1 \]
      11. frac-times18.4%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}} \cdot 1 \]
      12. sqrt-div21.1%

        \[\leadsto \color{blue}{\frac{\sqrt{d \cdot d}}{\sqrt{h \cdot \ell}}} \cdot 1 \]
      13. sqrt-unprod29.7%

        \[\leadsto \frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}} \cdot 1 \]
      14. add-sqr-sqrt33.5%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \cdot 1 \]
    10. Applied egg-rr33.5%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}} \cdot 1} \]
    11. Step-by-step derivation
      1. *-rgt-identity33.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    12. Simplified33.5%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    13. Step-by-step derivation
      1. clear-num33.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h \cdot \ell}}{d}}} \]
      2. associate-/r/33.5%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{h \cdot \ell}} \cdot d} \]
      3. pow1/233.5%

        \[\leadsto \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \cdot d \]
      4. pow-flip33.5%

        \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.5\right)}} \cdot d \]
      5. metadata-eval33.5%

        \[\leadsto {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \cdot d \]
    14. Applied egg-rr33.5%

      \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot d} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification38.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.9 \cdot 10^{-136}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 25.4% accurate, 3.1× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ d \cdot {\left(\ell \cdot h\right)}^{-0.5} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D) :precision binary64 (* d (pow (* l h) -0.5)))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	return d * pow((l * h), -0.5);
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    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_1
    code = d * ((l * h) ** (-0.5d0))
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	return d * Math.pow((l * h), -0.5);
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	return d * math.pow((l * h), -0.5)
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	return Float64(d * (Float64(l * h) ^ -0.5))
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
	tmp = d * ((l * h) ^ -0.5);
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
d \cdot {\left(\ell \cdot h\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 67.3%

    \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  2. Simplified67.7%

    \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in M around 0 41.9%

    \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
  5. Step-by-step derivation
    1. pow141.9%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right)\right)}^{1}} \]
    2. *-rgt-identity41.9%

      \[\leadsto {\left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}}\right)}^{1} \]
    3. sqrt-unprod33.6%

      \[\leadsto {\color{blue}{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}}^{1} \]
  6. Applied egg-rr33.6%

    \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}^{1}} \]
  7. Step-by-step derivation
    1. unpow133.6%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
  8. Simplified33.6%

    \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
  9. Step-by-step derivation
    1. sqrt-prod41.9%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} \]
    2. clear-num41.8%

      \[\leadsto \sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}} \]
    3. sqrt-div42.3%

      \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}} \]
    4. metadata-eval42.3%

      \[\leadsto \frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}} \]
    5. *-rgt-identity42.3%

      \[\leadsto \frac{1}{\sqrt{\frac{h}{d}}} \cdot \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot 1\right)} \]
    6. associate-*r*42.3%

      \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1} \]
    7. metadata-eval42.3%

      \[\leadsto \left(\frac{\color{blue}{\sqrt{1}}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1 \]
    8. sqrt-div41.8%

      \[\leadsto \left(\color{blue}{\sqrt{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1 \]
    9. clear-num41.9%

      \[\leadsto \left(\sqrt{\color{blue}{\frac{d}{h}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1 \]
    10. sqrt-prod33.6%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot 1 \]
    11. frac-times24.0%

      \[\leadsto \sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}} \cdot 1 \]
    12. sqrt-div27.3%

      \[\leadsto \color{blue}{\frac{\sqrt{d \cdot d}}{\sqrt{h \cdot \ell}}} \cdot 1 \]
    13. sqrt-unprod18.4%

      \[\leadsto \frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}} \cdot 1 \]
    14. add-sqr-sqrt23.6%

      \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \cdot 1 \]
  10. Applied egg-rr23.6%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}} \cdot 1} \]
  11. Step-by-step derivation
    1. *-rgt-identity23.6%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  12. Simplified23.6%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  13. Step-by-step derivation
    1. clear-num23.6%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h \cdot \ell}}{d}}} \]
    2. associate-/r/23.6%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{h \cdot \ell}} \cdot d} \]
    3. pow1/223.6%

      \[\leadsto \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \cdot d \]
    4. pow-flip23.6%

      \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.5\right)}} \cdot d \]
    5. metadata-eval23.6%

      \[\leadsto {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \cdot d \]
  14. Applied egg-rr23.6%

    \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot d} \]
  15. Final simplification23.6%

    \[\leadsto d \cdot {\left(\ell \cdot h\right)}^{-0.5} \]
  16. Add Preprocessing

Alternative 21: 25.4% accurate, 3.2× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \frac{d}{\sqrt{\ell \cdot h}} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D) :precision binary64 (/ d (sqrt (* l h))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	return d / sqrt((l * h));
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    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_1
    code = d / sqrt((l * h))
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	return d / Math.sqrt((l * h));
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	return d / math.sqrt((l * h))
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	return Float64(d / sqrt(Float64(l * h)))
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
	tmp = d / sqrt((l * h));
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Derivation
  1. Initial program 67.3%

    \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  2. Simplified67.7%

    \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in M around 0 41.9%

    \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
  5. Step-by-step derivation
    1. pow141.9%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right)\right)}^{1}} \]
    2. *-rgt-identity41.9%

      \[\leadsto {\left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}}\right)}^{1} \]
    3. sqrt-unprod33.6%

      \[\leadsto {\color{blue}{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}}^{1} \]
  6. Applied egg-rr33.6%

    \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)}^{1}} \]
  7. Step-by-step derivation
    1. unpow133.6%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
  8. Simplified33.6%

    \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
  9. Step-by-step derivation
    1. sqrt-prod41.9%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} \]
    2. clear-num41.8%

      \[\leadsto \sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}} \]
    3. sqrt-div42.3%

      \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}} \]
    4. metadata-eval42.3%

      \[\leadsto \frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}} \]
    5. *-rgt-identity42.3%

      \[\leadsto \frac{1}{\sqrt{\frac{h}{d}}} \cdot \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot 1\right)} \]
    6. associate-*r*42.3%

      \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1} \]
    7. metadata-eval42.3%

      \[\leadsto \left(\frac{\color{blue}{\sqrt{1}}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1 \]
    8. sqrt-div41.8%

      \[\leadsto \left(\color{blue}{\sqrt{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1 \]
    9. clear-num41.9%

      \[\leadsto \left(\sqrt{\color{blue}{\frac{d}{h}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot 1 \]
    10. sqrt-prod33.6%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot 1 \]
    11. frac-times24.0%

      \[\leadsto \sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}} \cdot 1 \]
    12. sqrt-div27.3%

      \[\leadsto \color{blue}{\frac{\sqrt{d \cdot d}}{\sqrt{h \cdot \ell}}} \cdot 1 \]
    13. sqrt-unprod18.4%

      \[\leadsto \frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}} \cdot 1 \]
    14. add-sqr-sqrt23.6%

      \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \cdot 1 \]
  10. Applied egg-rr23.6%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}} \cdot 1} \]
  11. Step-by-step derivation
    1. *-rgt-identity23.6%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  12. Simplified23.6%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  13. Final simplification23.6%

    \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
  14. Add Preprocessing

Reproduce

?
herbie shell --seed 2024115 
(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)))))