Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.2% → 84.5%
Time: 22.1s
Alternatives: 23
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 23 alternatives:

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

Initial Program: 66.2% 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: 84.5% accurate, 0.8× speedup?

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

\mathbf{elif}\;\ell \leq 2.35 \cdot 10^{+42}:\\
\;\;\;\;\left(1 - t\_0\right) \cdot t\_1\\

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


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

    1. Initial program 66.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l < 2.34999999999999993e42

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.34999999999999993e42 < l

    1. Initial program 62.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 85.1% accurate, 0.8× speedup?

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

\mathbf{elif}\;\ell \leq 7.2 \cdot 10^{-84}:\\
\;\;\;\;\left(1 - t\_0\right) \cdot \frac{d}{t\_1}\\

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


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

    1. Initial program 66.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l < 7.20000000000000007e-84

    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. associate-*r/83.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.20000000000000007e-84 < l

    1. Initial program 64.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. Simplified63.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. Step-by-step derivation
      1. pow163.5%

        \[\leadsto \color{blue}{{\left(\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)\right)}^{1}} \]
    5. Applied egg-rr81.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 77.2% accurate, 1.0× speedup?

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

\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right) \cdot \left(-1 + t\_1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -3.79999999999999995e201

    1. Initial program 89.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. Simplified93.3%

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

        \[\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) \]
      2. metadata-eval93.3%

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

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

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

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

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

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

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

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

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

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

    if -3.79999999999999995e201 < d < -4.999999999999985e-310

    1. Initial program 60.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < d

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 74.5% accurate, 1.0× speedup?

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

\mathbf{elif}\;\ell \leq 1.25 \cdot 10^{-159}:\\
\;\;\;\;\left(1 - t\_0\right) \cdot \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\

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


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

    1. Initial program 62.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.7999999999999996e-238 < l < 1.25000000000000008e-159

    1. Initial program 81.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. Simplified81.4%

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

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

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

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

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

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

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

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

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

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

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

    if 1.25000000000000008e-159 < l

    1. Initial program 64.1%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \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 M around 0 46.7%

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{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) \]
      4. unpow248.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{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) \]
      5. unpow248.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{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) \]
      6. unpow248.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{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) \]
      7. times-frac69.6%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{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) \]
      8. swap-sqr82.6%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{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) \]
      9. associate-/l*81.5%

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

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

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

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

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

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

Alternative 5: 75.3% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 66.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l < 3.6000000000000002e192

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.6000000000000002e192 < l

    1. Initial program 62.9%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr90.2%

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

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

Alternative 6: 83.5% accurate, 1.0× speedup?

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

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


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

    1. Initial program 66.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 75.1% accurate, 1.0× speedup?

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

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


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

    1. Initial program 66.7%

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

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

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

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

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

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

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

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

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

    if 7.8e-292 < l

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 75.7% accurate, 1.0× speedup?

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

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


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

    1. Initial program 67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left({\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2} \cdot \frac{h}{\ell}\right)}\right) \]
      2. *-commutative67.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{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)}\right) \]
      3. associate-*l/70.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 \left(M \cdot 0.5\right)\right)}^{2}}{\ell}}\right) \]
      4. associate-/l*69.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.7000000000000001e-300 < h

    1. Initial program 67.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 77.8% accurate, 1.0× speedup?

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

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


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

    1. Initial program 67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.7000000000000001e-300 < h

    1. Initial program 67.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 67.0% accurate, 1.4× speedup?

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

\mathbf{elif}\;\ell \leq 7.8 \cdot 10^{-292}:\\
\;\;\;\;t\_0 \cdot \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\

\mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+192}:\\
\;\;\;\;t\_0 \cdot \left(d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right)\\

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


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

    1. Initial program 42.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. Simplified44.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 d around inf 2.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/r*4.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}} \]
      9. div-inv4.7%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      10. sqrt-div0.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      11. inv-pow0.0%

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

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

        \[\leadsto d \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}} \]
    11. Applied egg-rr0.0%

      \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
    12. Taylor expanded in h around -inf 0.0%

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. associate-/r*53.4%

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

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

    if -2.3999999999999998e103 < l < 7.8e-292

    1. Initial program 80.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. Simplified80.5%

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

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

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

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

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

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

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

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

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

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

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

    if 7.8e-292 < l < 2.3999999999999998e192

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.3999999999999998e192 < l

    1. Initial program 62.9%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr90.2%

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

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

Alternative 11: 66.0% accurate, 1.4× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -7.19999999999999955e95

    1. Initial program 42.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. Simplified44.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 d around inf 2.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/r*4.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}} \]
      9. div-inv4.7%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      10. sqrt-div0.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      11. inv-pow0.0%

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

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

        \[\leadsto d \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}} \]
    11. Applied egg-rr0.0%

      \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
    12. Taylor expanded in h around -inf 0.0%

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. associate-/r*53.4%

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

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

    if -7.19999999999999955e95 < l < -4.999999999999985e-310

    1. Initial program 81.6%

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

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

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

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

    if -4.999999999999985e-310 < l < 2.3999999999999998e192

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.3999999999999998e192 < l

    1. Initial program 62.9%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr90.2%

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

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

Alternative 12: 62.5% accurate, 1.4× speedup?

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

\mathbf{elif}\;\ell \leq -4.8 \cdot 10^{-307}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{0}}\\

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

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


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

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

      \[\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 d around inf 1.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/r*4.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}} \]
      9. div-inv4.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      10. sqrt-div0.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      11. inv-pow0.0%

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

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

        \[\leadsto d \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}} \]
    11. Applied egg-rr0.0%

      \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
    12. Taylor expanded in h around -inf 0.0%

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. associate-/r*50.5%

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

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

    if -1.55e-92 < l < -4.80000000000000036e-307

    1. Initial program 78.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. Simplified78.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 d around inf 18.3%

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

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

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

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

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\log \left({\left(e^{\ell}\right)}^{h}\right)}}} \]
    7. Taylor expanded in l around 0 57.1%

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

    if -4.80000000000000036e-307 < l < 1.06000000000000001e195

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.06000000000000001e195 < l

    1. Initial program 62.9%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr90.2%

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

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

Alternative 13: 60.7% accurate, 1.4× speedup?

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

\mathbf{elif}\;\ell \leq 2.7 \cdot 10^{-304}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{0}}\\

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

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


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

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

      \[\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 d around inf 1.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/r*4.9%

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

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

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{h \cdot \ell}\right)}}^{0.5} \]
      4. rem-exp-log4.8%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      5. exp-neg4.8%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      6. exp-prod4.8%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      7. distribute-lft-neg-out4.8%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in4.8%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval4.8%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      10. exp-to-pow4.8%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Simplified4.8%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Step-by-step derivation
      1. unpow-prod-down0.0%

        \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
      2. metadata-eval0.0%

        \[\leadsto d \cdot \left({h}^{\color{blue}{\left(\frac{-1}{2}\right)}} \cdot {\ell}^{-0.5}\right) \]
      3. sqrt-pow10.0%

        \[\leadsto d \cdot \left(\color{blue}{\sqrt{{h}^{-1}}} \cdot {\ell}^{-0.5}\right) \]
      4. inv-pow0.0%

        \[\leadsto d \cdot \left(\sqrt{\color{blue}{\frac{1}{h}}} \cdot {\ell}^{-0.5}\right) \]
      5. metadata-eval0.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot {\ell}^{\color{blue}{\left(\frac{-1}{2}\right)}}\right) \]
      6. sqrt-pow10.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \color{blue}{\sqrt{{\ell}^{-1}}}\right) \]
      7. inv-pow0.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\ell}}}\right) \]
      8. sqrt-prod4.9%

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}} \]
      9. div-inv4.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      10. sqrt-div0.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      11. inv-pow0.0%

        \[\leadsto d \cdot \frac{\sqrt{\color{blue}{{h}^{-1}}}}{\sqrt{\ell}} \]
      12. sqrt-pow10.0%

        \[\leadsto d \cdot \frac{\color{blue}{{h}^{\left(\frac{-1}{2}\right)}}}{\sqrt{\ell}} \]
      13. metadata-eval0.0%

        \[\leadsto d \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}} \]
    11. Applied egg-rr0.0%

      \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
    12. Taylor expanded in h around -inf 0.0%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
    13. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto d \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt49.4%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. mul-1-neg49.4%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. associate-/r*50.5%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
    14. Simplified50.5%

      \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)} \]

    if -5.1999999999999997e-93 < l < 2.7000000000000001e-304

    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. Simplified77.3%

      \[\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 d around inf 21.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. add-log-exp42.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\log \left(e^{h \cdot \ell}\right)}}} \]
      2. *-commutative42.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\log \left(e^{\color{blue}{\ell \cdot h}}\right)}} \]
      3. exp-prod57.7%

        \[\leadsto d \cdot \sqrt{\frac{1}{\log \color{blue}{\left({\left(e^{\ell}\right)}^{h}\right)}}} \]
    6. Applied egg-rr57.7%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\log \left({\left(e^{\ell}\right)}^{h}\right)}}} \]
    7. Taylor expanded in l around 0 57.7%

      \[\leadsto d \cdot \sqrt{\frac{1}{\log \color{blue}{1}}} \]

    if 2.7000000000000001e-304 < l < 3.39999999999999996e192

    1. Initial program 68.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified68.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative74.5%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      2. sqrt-div81.6%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      3. sqrt-div87.2%

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      4. frac-times87.1%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      5. add-sqr-sqrt87.4%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    5. Applied egg-rr79.8%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. associate-*l/82.6%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      2. cancel-sign-sub-inv82.6%

        \[\leadsto \frac{d \cdot \color{blue}{\left(1 + \left(-0.5\right) \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. metadata-eval82.6%

        \[\leadsto \frac{d \cdot \left(1 + \color{blue}{-0.5} \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      4. *-commutative82.6%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \left({\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      5. div-inv82.6%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \left({\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      6. metadata-eval82.6%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \left({\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      7. sqrt-unprod73.2%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \left({\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}{\color{blue}{\sqrt{\ell \cdot h}}} \]
      8. *-commutative73.2%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \left({\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    7. Applied egg-rr73.2%

      \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left({\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}{\sqrt{h \cdot \ell}}} \]

    if 3.39999999999999996e192 < l

    1. Initial program 62.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified58.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 d around inf 58.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div58.3%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval58.3%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative58.3%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod89.9%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv89.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. associate-/r*90.2%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr90.2%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification64.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5.2 \cdot 10^{-93}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\ \mathbf{elif}\;\ell \leq 2.7 \cdot 10^{-304}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{0}}\\ \mathbf{elif}\;\ell \leq 3.4 \cdot 10^{+192}:\\ \;\;\;\;\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(0.5 \cdot M\right)\right)}^{2}\right)\right)}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 60.2% accurate, 1.4× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1.35 \cdot 10^{-92}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\ \mathbf{elif}\;\ell \leq 2.7 \cdot 10^{-304}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{0}}\\ \mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+192}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D\_m}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l -1.35e-92)
   (* d (- (sqrt (/ (/ 1.0 h) l))))
   (if (<= l 2.7e-304)
     (* d (sqrt (/ 1.0 0.0)))
     (if (<= l 2.4e+192)
       (*
        (- 1.0 (* 0.5 (* (/ h l) (pow (* (/ D_m d) (/ M_m 2.0)) 2.0))))
        (/ d (sqrt (* l h))))
       (/ (/ d (sqrt l)) (sqrt h))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -1.35e-92) {
		tmp = d * -sqrt(((1.0 / h) / l));
	} else if (l <= 2.7e-304) {
		tmp = d * sqrt((1.0 / 0.0));
	} else if (l <= 2.4e+192) {
		tmp = (1.0 - (0.5 * ((h / l) * pow(((D_m / d) * (M_m / 2.0)), 2.0)))) * (d / sqrt((l * h)));
	} else {
		tmp = (d / sqrt(l)) / sqrt(h);
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= (-1.35d-92)) then
        tmp = d * -sqrt(((1.0d0 / h) / l))
    else if (l <= 2.7d-304) then
        tmp = d * sqrt((1.0d0 / 0.0d0))
    else if (l <= 2.4d+192) then
        tmp = (1.0d0 - (0.5d0 * ((h / l) * (((d_m / d) * (m_m / 2.0d0)) ** 2.0d0)))) * (d / sqrt((l * h)))
    else
        tmp = (d / sqrt(l)) / sqrt(h)
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -1.35e-92) {
		tmp = d * -Math.sqrt(((1.0 / h) / l));
	} else if (l <= 2.7e-304) {
		tmp = d * Math.sqrt((1.0 / 0.0));
	} else if (l <= 2.4e+192) {
		tmp = (1.0 - (0.5 * ((h / l) * Math.pow(((D_m / d) * (M_m / 2.0)), 2.0)))) * (d / Math.sqrt((l * h)));
	} else {
		tmp = (d / Math.sqrt(l)) / Math.sqrt(h);
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= -1.35e-92:
		tmp = d * -math.sqrt(((1.0 / h) / l))
	elif l <= 2.7e-304:
		tmp = d * math.sqrt((1.0 / 0.0))
	elif l <= 2.4e+192:
		tmp = (1.0 - (0.5 * ((h / l) * math.pow(((D_m / d) * (M_m / 2.0)), 2.0)))) * (d / math.sqrt((l * h)))
	else:
		tmp = (d / math.sqrt(l)) / math.sqrt(h)
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -1.35e-92)
		tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / h) / l))));
	elseif (l <= 2.7e-304)
		tmp = Float64(d * sqrt(Float64(1.0 / 0.0)));
	elseif (l <= 2.4e+192)
		tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D_m / d) * Float64(M_m / 2.0)) ^ 2.0)))) * Float64(d / sqrt(Float64(l * h))));
	else
		tmp = Float64(Float64(d / sqrt(l)) / sqrt(h));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= -1.35e-92)
		tmp = d * -sqrt(((1.0 / h) / l));
	elseif (l <= 2.7e-304)
		tmp = d * sqrt((1.0 / 0.0));
	elseif (l <= 2.4e+192)
		tmp = (1.0 - (0.5 * ((h / l) * (((D_m / d) * (M_m / 2.0)) ^ 2.0)))) * (d / sqrt((l * h)));
	else
		tmp = (d / sqrt(l)) / sqrt(h);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -1.35e-92], N[(d * (-N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[l, 2.7e-304], N[(d * N[Sqrt[N[(1.0 / 0.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.4e+192], N[(N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.35 \cdot 10^{-92}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\

\mathbf{elif}\;\ell \leq 2.7 \cdot 10^{-304}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{0}}\\

\mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+192}:\\
\;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D\_m}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -1.34999999999999998e-92

    1. Initial program 60.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. Simplified61.3%

      \[\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 d around inf 1.9%

      \[\leadsto \color{blue}{d \cdot \left(\sqrt{\frac{1}{h \cdot \ell}} + -0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative1.9%

        \[\leadsto d \cdot \color{blue}{\left(-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) + \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. fma-define1.9%

        \[\leadsto d \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. *-commutative1.9%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \color{blue}{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. *-commutative1.9%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      5. associate-/l*1.9%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      6. unpow21.9%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      7. unpow21.9%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{\color{blue}{D \cdot D}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      8. unpow21.9%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\color{blue}{d \cdot d}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      9. times-frac2.1%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      10. swap-sqr2.3%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      11. unpow22.3%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      12. associate-*r/2.2%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      13. *-commutative2.2%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      14. associate-/l*2.3%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    6. Simplified2.3%

      \[\leadsto \color{blue}{d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    7. Taylor expanded in h around 0 4.8%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/r*4.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. unpow1/24.9%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
      3. associate-/r*4.8%

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{h \cdot \ell}\right)}}^{0.5} \]
      4. rem-exp-log4.8%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      5. exp-neg4.8%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      6. exp-prod4.8%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      7. distribute-lft-neg-out4.8%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in4.8%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval4.8%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      10. exp-to-pow4.8%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Simplified4.8%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Step-by-step derivation
      1. unpow-prod-down0.0%

        \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
      2. metadata-eval0.0%

        \[\leadsto d \cdot \left({h}^{\color{blue}{\left(\frac{-1}{2}\right)}} \cdot {\ell}^{-0.5}\right) \]
      3. sqrt-pow10.0%

        \[\leadsto d \cdot \left(\color{blue}{\sqrt{{h}^{-1}}} \cdot {\ell}^{-0.5}\right) \]
      4. inv-pow0.0%

        \[\leadsto d \cdot \left(\sqrt{\color{blue}{\frac{1}{h}}} \cdot {\ell}^{-0.5}\right) \]
      5. metadata-eval0.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot {\ell}^{\color{blue}{\left(\frac{-1}{2}\right)}}\right) \]
      6. sqrt-pow10.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \color{blue}{\sqrt{{\ell}^{-1}}}\right) \]
      7. inv-pow0.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\ell}}}\right) \]
      8. sqrt-prod4.9%

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}} \]
      9. div-inv4.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      10. sqrt-div0.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      11. inv-pow0.0%

        \[\leadsto d \cdot \frac{\sqrt{\color{blue}{{h}^{-1}}}}{\sqrt{\ell}} \]
      12. sqrt-pow10.0%

        \[\leadsto d \cdot \frac{\color{blue}{{h}^{\left(\frac{-1}{2}\right)}}}{\sqrt{\ell}} \]
      13. metadata-eval0.0%

        \[\leadsto d \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}} \]
    11. Applied egg-rr0.0%

      \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
    12. Taylor expanded in h around -inf 0.0%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
    13. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto d \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt49.4%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. mul-1-neg49.4%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. associate-/r*50.5%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
    14. Simplified50.5%

      \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)} \]

    if -1.34999999999999998e-92 < l < 2.7000000000000001e-304

    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. Simplified77.3%

      \[\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 d around inf 21.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. add-log-exp42.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\log \left(e^{h \cdot \ell}\right)}}} \]
      2. *-commutative42.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\log \left(e^{\color{blue}{\ell \cdot h}}\right)}} \]
      3. exp-prod57.7%

        \[\leadsto d \cdot \sqrt{\frac{1}{\log \color{blue}{\left({\left(e^{\ell}\right)}^{h}\right)}}} \]
    6. Applied egg-rr57.7%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\log \left({\left(e^{\ell}\right)}^{h}\right)}}} \]
    7. Taylor expanded in l around 0 57.7%

      \[\leadsto d \cdot \sqrt{\frac{1}{\log \color{blue}{1}}} \]

    if 2.7000000000000001e-304 < l < 2.3999999999999998e192

    1. Initial program 68.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified68.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative74.5%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      2. sqrt-div81.6%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      3. sqrt-div87.2%

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      4. frac-times87.1%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      5. add-sqr-sqrt87.4%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    5. Applied egg-rr79.8%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \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 0 71.6%

      \[\leadsto \color{blue}{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. Step-by-step derivation
      1. *-commutative71.6%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot d\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. associate-/r*71.6%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot d\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. unpow1/271.6%

        \[\leadsto \left(\color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \cdot d\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. associate-/r*71.6%

        \[\leadsto \left({\color{blue}{\left(\frac{1}{h \cdot \ell}\right)}}^{0.5} \cdot d\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. rem-exp-log69.8%

        \[\leadsto \left({\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \cdot d\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. exp-neg69.8%

        \[\leadsto \left({\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot d\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      7. exp-prod70.4%

        \[\leadsto \left(\color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \cdot d\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      8. distribute-lft-neg-out70.4%

        \[\leadsto \left(e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot d\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      9. exp-neg70.4%

        \[\leadsto \left(\color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \cdot d\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      10. exp-to-pow72.2%

        \[\leadsto \left(\frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \cdot d\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      11. unpow1/272.2%

        \[\leadsto \left(\frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot d\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      12. unpow-172.2%

        \[\leadsto \left(\color{blue}{{\left(\sqrt{h \cdot \ell}\right)}^{-1}} \cdot d\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      13. unpow-172.2%

        \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{h \cdot \ell}}} \cdot d\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      14. associate-*l/72.2%

        \[\leadsto \color{blue}{\frac{1 \cdot d}{\sqrt{h \cdot \ell}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      15. *-lft-identity72.2%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    8. Simplified72.2%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]

    if 2.3999999999999998e192 < l

    1. Initial program 62.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified58.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 d around inf 58.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div58.3%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval58.3%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative58.3%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod89.9%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv89.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. associate-/r*90.2%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr90.2%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification63.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.35 \cdot 10^{-92}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\ \mathbf{elif}\;\ell \leq 2.7 \cdot 10^{-304}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{0}}\\ \mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+192}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 74.6% accurate, 1.4× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := 0.5 \cdot \frac{h \cdot {\left(M\_m \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\ell}\\ t_1 := d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;t\_1 \cdot \left(-1 + t\_0\right)\\ \mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+194}:\\ \;\;\;\;\left(1 - t\_0\right) \cdot t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (* 0.5 (/ (* h (pow (* M_m (* 0.5 (/ D_m d))) 2.0)) l)))
        (t_1 (* d (pow (* l h) -0.5))))
   (if (<= l -5e-310)
     (* t_1 (+ -1.0 t_0))
     (if (<= l 1.3e+194) (* (- 1.0 t_0) t_1) (/ (/ d (sqrt l)) (sqrt h))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = 0.5 * ((h * pow((M_m * (0.5 * (D_m / d))), 2.0)) / l);
	double t_1 = d * pow((l * h), -0.5);
	double tmp;
	if (l <= -5e-310) {
		tmp = t_1 * (-1.0 + t_0);
	} else if (l <= 1.3e+194) {
		tmp = (1.0 - t_0) * t_1;
	} else {
		tmp = (d / sqrt(l)) / sqrt(h);
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 0.5d0 * ((h * ((m_m * (0.5d0 * (d_m / d))) ** 2.0d0)) / l)
    t_1 = d * ((l * h) ** (-0.5d0))
    if (l <= (-5d-310)) then
        tmp = t_1 * ((-1.0d0) + t_0)
    else if (l <= 1.3d+194) then
        tmp = (1.0d0 - t_0) * t_1
    else
        tmp = (d / sqrt(l)) / sqrt(h)
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = 0.5 * ((h * Math.pow((M_m * (0.5 * (D_m / d))), 2.0)) / l);
	double t_1 = d * Math.pow((l * h), -0.5);
	double tmp;
	if (l <= -5e-310) {
		tmp = t_1 * (-1.0 + t_0);
	} else if (l <= 1.3e+194) {
		tmp = (1.0 - t_0) * t_1;
	} else {
		tmp = (d / Math.sqrt(l)) / Math.sqrt(h);
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = 0.5 * ((h * math.pow((M_m * (0.5 * (D_m / d))), 2.0)) / l)
	t_1 = d * math.pow((l * h), -0.5)
	tmp = 0
	if l <= -5e-310:
		tmp = t_1 * (-1.0 + t_0)
	elif l <= 1.3e+194:
		tmp = (1.0 - t_0) * t_1
	else:
		tmp = (d / math.sqrt(l)) / math.sqrt(h)
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(0.5 * Float64(Float64(h * (Float64(M_m * Float64(0.5 * Float64(D_m / d))) ^ 2.0)) / l))
	t_1 = Float64(d * (Float64(l * h) ^ -0.5))
	tmp = 0.0
	if (l <= -5e-310)
		tmp = Float64(t_1 * Float64(-1.0 + t_0));
	elseif (l <= 1.3e+194)
		tmp = Float64(Float64(1.0 - t_0) * t_1);
	else
		tmp = Float64(Float64(d / sqrt(l)) / sqrt(h));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = 0.5 * ((h * ((M_m * (0.5 * (D_m / d))) ^ 2.0)) / l);
	t_1 = d * ((l * h) ^ -0.5);
	tmp = 0.0;
	if (l <= -5e-310)
		tmp = t_1 * (-1.0 + t_0);
	elseif (l <= 1.3e+194)
		tmp = (1.0 - t_0) * t_1;
	else
		tmp = (d / sqrt(l)) / sqrt(h);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(0.5 * N[(N[(h * N[Power[N[(M$95$m * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5e-310], N[(t$95$1 * N[(-1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.3e+194], N[(N[(1.0 - t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{h \cdot {\left(M\_m \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\ell}\\
t_1 := d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;t\_1 \cdot \left(-1 + t\_0\right)\\

\mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+194}:\\
\;\;\;\;\left(1 - t\_0\right) \cdot t\_1\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -4.999999999999985e-310

    1. Initial program 66.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified67.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-*r/70.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}}\right) \]
      2. frac-times70.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot h}{\ell}\right) \]
      3. associate-/l*70.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{2} \cdot h}{\ell}\right) \]
      4. *-un-lft-identity70.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \frac{\color{blue}{1 \cdot D}}{2 \cdot d}\right)}^{2} \cdot h}{\ell}\right) \]
      5. times-frac70.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \color{blue}{\left(\frac{1}{2} \cdot \frac{D}{d}\right)}\right)}^{2} \cdot h}{\ell}\right) \]
      6. metadata-eval70.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(\color{blue}{0.5} \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    5. Applied egg-rr70.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}}\right) \]
    6. Step-by-step derivation
      1. clear-num70.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      2. sqrt-div70.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      3. metadata-eval70.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    7. Applied egg-rr70.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    8. Taylor expanded in d around -inf 67.1%

      \[\leadsto \color{blue}{\left(-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    9. Step-by-step derivation
      1. mul-1-neg67.1%

        \[\leadsto \color{blue}{\left(-d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      2. unpow-167.1%

        \[\leadsto \left(-d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      3. metadata-eval67.1%

        \[\leadsto \left(-d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      4. pow-sqr67.1%

        \[\leadsto \left(-d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      5. rem-sqrt-square67.6%

        \[\leadsto \left(-d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      6. metadata-eval67.6%

        \[\leadsto \left(-d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right|\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      7. pow-sqr67.4%

        \[\leadsto \left(-d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right|\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      8. fabs-sqr67.4%

        \[\leadsto \left(-d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      9. pow-sqr67.6%

        \[\leadsto \left(-d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(2 \cdot -0.25\right)}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      10. metadata-eval67.6%

        \[\leadsto \left(-d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      11. distribute-rgt-neg-in67.6%

        \[\leadsto \color{blue}{\left(d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    10. Simplified67.6%

      \[\leadsto \color{blue}{\left(d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]

    if -4.999999999999985e-310 < l < 1.2999999999999999e194

    1. Initial program 68.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. Simplified68.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-*r/75.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}}\right) \]
      2. frac-times75.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot h}{\ell}\right) \]
      3. associate-/l*75.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{2} \cdot h}{\ell}\right) \]
      4. *-un-lft-identity75.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \frac{\color{blue}{1 \cdot D}}{2 \cdot d}\right)}^{2} \cdot h}{\ell}\right) \]
      5. times-frac75.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \color{blue}{\left(\frac{1}{2} \cdot \frac{D}{d}\right)}\right)}^{2} \cdot h}{\ell}\right) \]
      6. metadata-eval75.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(\color{blue}{0.5} \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    5. Applied egg-rr75.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}}\right) \]
    6. Step-by-step derivation
      1. clear-num75.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      2. sqrt-div75.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      3. metadata-eval75.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    7. Applied egg-rr75.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    8. Taylor expanded in d around 0 79.6%

      \[\leadsto \color{blue}{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    9. Step-by-step derivation
      1. unpow-179.6%

        \[\leadsto \left(d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      2. metadata-eval79.6%

        \[\leadsto \left(d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      3. pow-sqr79.6%

        \[\leadsto \left(d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      4. rem-sqrt-square80.2%

        \[\leadsto \left(d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      5. metadata-eval80.2%

        \[\leadsto \left(d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right|\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      6. pow-sqr80.1%

        \[\leadsto \left(d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right|\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      7. fabs-sqr80.1%

        \[\leadsto \left(d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      8. pow-sqr80.2%

        \[\leadsto \left(d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(2 \cdot -0.25\right)}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      9. metadata-eval80.2%

        \[\leadsto \left(d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    10. Simplified80.2%

      \[\leadsto \color{blue}{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]

    if 1.2999999999999999e194 < l

    1. Initial program 62.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified58.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 d around inf 58.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div58.3%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval58.3%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative58.3%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod89.9%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv89.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. associate-/r*90.2%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr90.2%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification74.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left(d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right) \cdot \left(-1 + 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\ell}\right)\\ \mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+194}:\\ \;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\ell}\right) \cdot \left(d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 75.2% accurate, 1.4× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;t\_0 \cdot \left(-1 + 0.5 \cdot \left(h \cdot \frac{0.25 \cdot {\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+194}:\\ \;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot {\left(M\_m \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\ell}\right) \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (* d (pow (* l h) -0.5))))
   (if (<= l -5e-310)
     (* t_0 (+ -1.0 (* 0.5 (* h (/ (* 0.25 (pow (* D_m (/ M_m d)) 2.0)) l)))))
     (if (<= l 1.55e+194)
       (* (- 1.0 (* 0.5 (/ (* h (pow (* M_m (* 0.5 (/ D_m d))) 2.0)) l))) t_0)
       (/ (/ d (sqrt l)) (sqrt h))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = d * pow((l * h), -0.5);
	double tmp;
	if (l <= -5e-310) {
		tmp = t_0 * (-1.0 + (0.5 * (h * ((0.25 * pow((D_m * (M_m / d)), 2.0)) / l))));
	} else if (l <= 1.55e+194) {
		tmp = (1.0 - (0.5 * ((h * pow((M_m * (0.5 * (D_m / d))), 2.0)) / l))) * t_0;
	} else {
		tmp = (d / sqrt(l)) / sqrt(h);
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = d * ((l * h) ** (-0.5d0))
    if (l <= (-5d-310)) then
        tmp = t_0 * ((-1.0d0) + (0.5d0 * (h * ((0.25d0 * ((d_m * (m_m / d)) ** 2.0d0)) / l))))
    else if (l <= 1.55d+194) then
        tmp = (1.0d0 - (0.5d0 * ((h * ((m_m * (0.5d0 * (d_m / d))) ** 2.0d0)) / l))) * t_0
    else
        tmp = (d / sqrt(l)) / sqrt(h)
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = d * Math.pow((l * h), -0.5);
	double tmp;
	if (l <= -5e-310) {
		tmp = t_0 * (-1.0 + (0.5 * (h * ((0.25 * Math.pow((D_m * (M_m / d)), 2.0)) / l))));
	} else if (l <= 1.55e+194) {
		tmp = (1.0 - (0.5 * ((h * Math.pow((M_m * (0.5 * (D_m / d))), 2.0)) / l))) * t_0;
	} else {
		tmp = (d / Math.sqrt(l)) / Math.sqrt(h);
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = d * math.pow((l * h), -0.5)
	tmp = 0
	if l <= -5e-310:
		tmp = t_0 * (-1.0 + (0.5 * (h * ((0.25 * math.pow((D_m * (M_m / d)), 2.0)) / l))))
	elif l <= 1.55e+194:
		tmp = (1.0 - (0.5 * ((h * math.pow((M_m * (0.5 * (D_m / d))), 2.0)) / l))) * t_0
	else:
		tmp = (d / math.sqrt(l)) / math.sqrt(h)
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(d * (Float64(l * h) ^ -0.5))
	tmp = 0.0
	if (l <= -5e-310)
		tmp = Float64(t_0 * Float64(-1.0 + Float64(0.5 * Float64(h * Float64(Float64(0.25 * (Float64(D_m * Float64(M_m / d)) ^ 2.0)) / l)))));
	elseif (l <= 1.55e+194)
		tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(M_m * Float64(0.5 * Float64(D_m / d))) ^ 2.0)) / l))) * t_0);
	else
		tmp = Float64(Float64(d / sqrt(l)) / sqrt(h));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = d * ((l * h) ^ -0.5);
	tmp = 0.0;
	if (l <= -5e-310)
		tmp = t_0 * (-1.0 + (0.5 * (h * ((0.25 * ((D_m * (M_m / d)) ^ 2.0)) / l))));
	elseif (l <= 1.55e+194)
		tmp = (1.0 - (0.5 * ((h * ((M_m * (0.5 * (D_m / d))) ^ 2.0)) / l))) * t_0;
	else
		tmp = (d / sqrt(l)) / sqrt(h);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5e-310], N[(t$95$0 * N[(-1.0 + N[(0.5 * N[(h * N[(N[(0.25 * N[Power[N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.55e+194], N[(N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(M$95$m * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;t\_0 \cdot \left(-1 + 0.5 \cdot \left(h \cdot \frac{0.25 \cdot {\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}}{\ell}\right)\right)\\

\mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+194}:\\
\;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot {\left(M\_m \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\ell}\right) \cdot t\_0\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -4.999999999999985e-310

    1. Initial program 66.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified67.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-*r/70.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}}\right) \]
      2. frac-times70.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot h}{\ell}\right) \]
      3. associate-/l*70.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{2} \cdot h}{\ell}\right) \]
      4. *-un-lft-identity70.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \frac{\color{blue}{1 \cdot D}}{2 \cdot d}\right)}^{2} \cdot h}{\ell}\right) \]
      5. times-frac70.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \color{blue}{\left(\frac{1}{2} \cdot \frac{D}{d}\right)}\right)}^{2} \cdot h}{\ell}\right) \]
      6. metadata-eval70.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(\color{blue}{0.5} \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    5. Applied egg-rr70.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}}\right) \]
    6. Step-by-step derivation
      1. clear-num70.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      2. sqrt-div70.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      3. metadata-eval70.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    7. Applied egg-rr70.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    8. Taylor expanded in d around -inf 67.1%

      \[\leadsto \color{blue}{\left(-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    9. Step-by-step derivation
      1. mul-1-neg67.1%

        \[\leadsto \color{blue}{\left(-d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      2. unpow-167.1%

        \[\leadsto \left(-d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      3. metadata-eval67.1%

        \[\leadsto \left(-d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      4. pow-sqr67.1%

        \[\leadsto \left(-d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      5. rem-sqrt-square67.6%

        \[\leadsto \left(-d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      6. metadata-eval67.6%

        \[\leadsto \left(-d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right|\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      7. pow-sqr67.4%

        \[\leadsto \left(-d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right|\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      8. fabs-sqr67.4%

        \[\leadsto \left(-d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      9. pow-sqr67.6%

        \[\leadsto \left(-d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(2 \cdot -0.25\right)}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      10. metadata-eval67.6%

        \[\leadsto \left(-d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      11. distribute-rgt-neg-in67.6%

        \[\leadsto \color{blue}{\left(d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    10. Simplified67.6%

      \[\leadsto \color{blue}{\left(d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    11. Step-by-step derivation
      1. *-un-lft-identity70.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(1 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right)}\right) \]
      2. associate-/l*67.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(1 \cdot \color{blue}{\left({\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot \frac{h}{\ell}\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 \left(1 \cdot \left({\color{blue}{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \]
      4. metadata-eval67.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(1 \cdot \left({\left(\left(M \cdot \color{blue}{\frac{1}{2}}\right) \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \]
      5. div-inv67.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(1 \cdot \left({\left(\color{blue}{\frac{M}{2}} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\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(1 \cdot \left({\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \]
      7. div-inv67.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(1 \cdot \left({\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \]
      8. metadata-eval67.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(1 \cdot \left({\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \]
    12. Applied egg-rr62.8%

      \[\leadsto \left(d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(1 \cdot \left({\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
    13. Step-by-step derivation
      1. *-lft-identity67.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left({\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2} \cdot \frac{h}{\ell}\right)}\right) \]
      2. *-commutative67.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{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)}\right) \]
      3. associate-*l/70.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 \left(M \cdot 0.5\right)\right)}^{2}}{\ell}}\right) \]
      4. associate-/l*69.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}}{\ell}\right)}\right) \]
      5. unpow269.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{\color{blue}{\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}}{\ell}\right)\right) \]
      6. associate-*l/68.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{\color{blue}{\frac{D \cdot \left(M \cdot 0.5\right)}{d}} \cdot \left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}{\ell}\right)\right) \]
      7. associate-*r*68.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{\frac{\color{blue}{\left(D \cdot M\right) \cdot 0.5}}{d} \cdot \left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}{\ell}\right)\right) \]
      8. associate-*l/68.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{\color{blue}{\left(\frac{D \cdot M}{d} \cdot 0.5\right)} \cdot \left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}{\ell}\right)\right) \]
      9. *-commutative68.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{\color{blue}{\left(0.5 \cdot \frac{D \cdot M}{d}\right)} \cdot \left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}{\ell}\right)\right) \]
      10. associate-*l/69.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{\left(0.5 \cdot \frac{D \cdot M}{d}\right) \cdot \color{blue}{\frac{D \cdot \left(M \cdot 0.5\right)}{d}}}{\ell}\right)\right) \]
      11. associate-*r*69.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{\left(0.5 \cdot \frac{D \cdot M}{d}\right) \cdot \frac{\color{blue}{\left(D \cdot M\right) \cdot 0.5}}{d}}{\ell}\right)\right) \]
      12. associate-*l/69.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{\left(0.5 \cdot \frac{D \cdot M}{d}\right) \cdot \color{blue}{\left(\frac{D \cdot M}{d} \cdot 0.5\right)}}{\ell}\right)\right) \]
      13. *-commutative69.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{\left(0.5 \cdot \frac{D \cdot M}{d}\right) \cdot \color{blue}{\left(0.5 \cdot \frac{D \cdot M}{d}\right)}}{\ell}\right)\right) \]
      14. swap-sqr69.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{\color{blue}{\left(0.5 \cdot 0.5\right) \cdot \left(\frac{D \cdot M}{d} \cdot \frac{D \cdot M}{d}\right)}}{\ell}\right)\right) \]
      15. metadata-eval69.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{\color{blue}{0.25} \cdot \left(\frac{D \cdot M}{d} \cdot \frac{D \cdot M}{d}\right)}{\ell}\right)\right) \]
      16. unpow269.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{0.25 \cdot \color{blue}{{\left(\frac{D \cdot M}{d}\right)}^{2}}}{\ell}\right)\right) \]
      17. associate-/l*70.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{0.25 \cdot {\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}}{\ell}\right)\right) \]
    14. Simplified68.3%

      \[\leadsto \left(d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{0.25 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}\right)}\right) \]

    if -4.999999999999985e-310 < l < 1.55e194

    1. Initial program 68.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. Simplified68.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-*r/75.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}}\right) \]
      2. frac-times75.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot h}{\ell}\right) \]
      3. associate-/l*75.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{2} \cdot h}{\ell}\right) \]
      4. *-un-lft-identity75.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \frac{\color{blue}{1 \cdot D}}{2 \cdot d}\right)}^{2} \cdot h}{\ell}\right) \]
      5. times-frac75.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \color{blue}{\left(\frac{1}{2} \cdot \frac{D}{d}\right)}\right)}^{2} \cdot h}{\ell}\right) \]
      6. metadata-eval75.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(\color{blue}{0.5} \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    5. Applied egg-rr75.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}}\right) \]
    6. Step-by-step derivation
      1. clear-num75.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      2. sqrt-div75.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      3. metadata-eval75.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    7. Applied egg-rr75.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    8. Taylor expanded in d around 0 79.6%

      \[\leadsto \color{blue}{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    9. Step-by-step derivation
      1. unpow-179.6%

        \[\leadsto \left(d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      2. metadata-eval79.6%

        \[\leadsto \left(d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      3. pow-sqr79.6%

        \[\leadsto \left(d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      4. rem-sqrt-square80.2%

        \[\leadsto \left(d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      5. metadata-eval80.2%

        \[\leadsto \left(d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right|\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      6. pow-sqr80.1%

        \[\leadsto \left(d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right|\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      7. fabs-sqr80.1%

        \[\leadsto \left(d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      8. pow-sqr80.2%

        \[\leadsto \left(d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(2 \cdot -0.25\right)}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
      9. metadata-eval80.2%

        \[\leadsto \left(d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]
    10. Simplified80.2%

      \[\leadsto \color{blue}{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)} \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}\right) \]

    if 1.55e194 < l

    1. Initial program 62.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified58.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 d around inf 58.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div58.3%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval58.3%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative58.3%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod89.9%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv89.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. associate-/r*90.2%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr90.2%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification75.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left(d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right) \cdot \left(-1 + 0.5 \cdot \left(h \cdot \frac{0.25 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+194}:\\ \;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\ell}\right) \cdot \left(d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 49.8% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -2.1 \cdot 10^{-48}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{0}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= d -2.1e-48)
   (* d (- (sqrt (/ (/ 1.0 h) l))))
   (if (<= d -5e-310)
     (* d (sqrt (/ 1.0 0.0)))
     (* d (/ (pow h -0.5) (sqrt l))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -2.1e-48) {
		tmp = d * -sqrt(((1.0 / h) / l));
	} else if (d <= -5e-310) {
		tmp = d * sqrt((1.0 / 0.0));
	} else {
		tmp = d * (pow(h, -0.5) / sqrt(l));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (d <= (-2.1d-48)) then
        tmp = d * -sqrt(((1.0d0 / h) / l))
    else if (d <= (-5d-310)) then
        tmp = d * sqrt((1.0d0 / 0.0d0))
    else
        tmp = d * ((h ** (-0.5d0)) / sqrt(l))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -2.1e-48) {
		tmp = d * -Math.sqrt(((1.0 / h) / l));
	} else if (d <= -5e-310) {
		tmp = d * Math.sqrt((1.0 / 0.0));
	} else {
		tmp = d * (Math.pow(h, -0.5) / Math.sqrt(l));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if d <= -2.1e-48:
		tmp = d * -math.sqrt(((1.0 / h) / l))
	elif d <= -5e-310:
		tmp = d * math.sqrt((1.0 / 0.0))
	else:
		tmp = d * (math.pow(h, -0.5) / math.sqrt(l))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (d <= -2.1e-48)
		tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / h) / l))));
	elseif (d <= -5e-310)
		tmp = Float64(d * sqrt(Float64(1.0 / 0.0)));
	else
		tmp = Float64(d * Float64((h ^ -0.5) / sqrt(l)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (d <= -2.1e-48)
		tmp = d * -sqrt(((1.0 / h) / l));
	elseif (d <= -5e-310)
		tmp = d * sqrt((1.0 / 0.0));
	else
		tmp = d * ((h ^ -0.5) / sqrt(l));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, -2.1e-48], N[(d * (-N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[d, -5e-310], N[(d * N[Sqrt[N[(1.0 / 0.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[h, -0.5], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.1 \cdot 10^{-48}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\

\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{0}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.09999999999999989e-48

    1. Initial program 79.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. Simplified81.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 d around inf 0.7%

      \[\leadsto \color{blue}{d \cdot \left(\sqrt{\frac{1}{h \cdot \ell}} + -0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.7%

        \[\leadsto d \cdot \color{blue}{\left(-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) + \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. fma-define0.7%

        \[\leadsto d \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. *-commutative0.7%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \color{blue}{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. *-commutative0.7%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      5. associate-/l*0.8%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      6. unpow20.8%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      7. unpow20.8%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{\color{blue}{D \cdot D}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      8. unpow20.8%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\color{blue}{d \cdot d}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      9. times-frac0.9%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      10. swap-sqr1.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      11. unpow21.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      12. associate-*r/1.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      13. *-commutative1.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      14. associate-/l*1.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    6. Simplified1.0%

      \[\leadsto \color{blue}{d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    7. Taylor expanded in h around 0 3.6%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/r*3.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. unpow1/23.6%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
      3. associate-/r*3.6%

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{h \cdot \ell}\right)}}^{0.5} \]
      4. rem-exp-log3.6%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      5. exp-neg3.6%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      6. exp-prod3.6%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      7. distribute-lft-neg-out3.6%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in3.6%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval3.6%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      10. exp-to-pow3.6%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Simplified3.6%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Step-by-step derivation
      1. unpow-prod-down0.0%

        \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
      2. metadata-eval0.0%

        \[\leadsto d \cdot \left({h}^{\color{blue}{\left(\frac{-1}{2}\right)}} \cdot {\ell}^{-0.5}\right) \]
      3. sqrt-pow10.0%

        \[\leadsto d \cdot \left(\color{blue}{\sqrt{{h}^{-1}}} \cdot {\ell}^{-0.5}\right) \]
      4. inv-pow0.0%

        \[\leadsto d \cdot \left(\sqrt{\color{blue}{\frac{1}{h}}} \cdot {\ell}^{-0.5}\right) \]
      5. metadata-eval0.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot {\ell}^{\color{blue}{\left(\frac{-1}{2}\right)}}\right) \]
      6. sqrt-pow10.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \color{blue}{\sqrt{{\ell}^{-1}}}\right) \]
      7. inv-pow0.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\ell}}}\right) \]
      8. sqrt-prod3.6%

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}} \]
      9. div-inv3.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      10. sqrt-div0.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      11. inv-pow0.0%

        \[\leadsto d \cdot \frac{\sqrt{\color{blue}{{h}^{-1}}}}{\sqrt{\ell}} \]
      12. sqrt-pow10.0%

        \[\leadsto d \cdot \frac{\color{blue}{{h}^{\left(\frac{-1}{2}\right)}}}{\sqrt{\ell}} \]
      13. metadata-eval0.0%

        \[\leadsto d \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}} \]
    11. Applied egg-rr0.0%

      \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
    12. Taylor expanded in h around -inf 0.0%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
    13. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto d \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt56.4%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. mul-1-neg56.4%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. associate-/r*57.5%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
    14. Simplified57.5%

      \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)} \]

    if -2.09999999999999989e-48 < d < -4.999999999999985e-310

    1. Initial program 47.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. Simplified47.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 d around inf 18.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. add-log-exp24.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\log \left(e^{h \cdot \ell}\right)}}} \]
      2. *-commutative24.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\log \left(e^{\color{blue}{\ell \cdot h}}\right)}} \]
      3. exp-prod31.0%

        \[\leadsto d \cdot \sqrt{\frac{1}{\log \color{blue}{\left({\left(e^{\ell}\right)}^{h}\right)}}} \]
    6. Applied egg-rr31.0%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\log \left({\left(e^{\ell}\right)}^{h}\right)}}} \]
    7. Taylor expanded in l around 0 49.1%

      \[\leadsto d \cdot \sqrt{\frac{1}{\log \color{blue}{1}}} \]

    if -4.999999999999985e-310 < d

    1. Initial program 67.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. Simplified66.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 d around inf 26.2%

      \[\leadsto \color{blue}{d \cdot \left(\sqrt{\frac{1}{h \cdot \ell}} + -0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative26.2%

        \[\leadsto d \cdot \color{blue}{\left(-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) + \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. fma-define26.2%

        \[\leadsto d \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. *-commutative26.2%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \color{blue}{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. *-commutative26.2%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      5. associate-/l*25.7%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      6. unpow225.7%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      7. unpow225.7%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{\color{blue}{D \cdot D}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      8. unpow225.7%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\color{blue}{d \cdot d}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      9. times-frac39.2%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      10. swap-sqr49.6%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      11. unpow249.6%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      12. associate-*r/49.6%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      13. *-commutative49.6%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      14. associate-/l*49.6%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    6. Simplified49.6%

      \[\leadsto \color{blue}{d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    7. Taylor expanded in h around 0 43.5%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/r*44.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. unpow1/244.9%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
      3. associate-/r*43.5%

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{h \cdot \ell}\right)}}^{0.5} \]
      4. rem-exp-log41.4%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      5. exp-neg41.4%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      6. exp-prod41.9%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      7. distribute-lft-neg-out41.9%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in41.9%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval41.9%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      10. exp-to-pow44.0%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Simplified44.0%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Step-by-step derivation
      1. unpow-prod-down52.6%

        \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
      2. metadata-eval52.6%

        \[\leadsto d \cdot \left({h}^{\color{blue}{\left(\frac{-1}{2}\right)}} \cdot {\ell}^{-0.5}\right) \]
      3. sqrt-pow152.5%

        \[\leadsto d \cdot \left(\color{blue}{\sqrt{{h}^{-1}}} \cdot {\ell}^{-0.5}\right) \]
      4. inv-pow52.5%

        \[\leadsto d \cdot \left(\sqrt{\color{blue}{\frac{1}{h}}} \cdot {\ell}^{-0.5}\right) \]
      5. metadata-eval52.5%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot {\ell}^{\color{blue}{\left(\frac{-1}{2}\right)}}\right) \]
      6. sqrt-pow152.6%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \color{blue}{\sqrt{{\ell}^{-1}}}\right) \]
      7. inv-pow52.6%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\ell}}}\right) \]
      8. sqrt-prod44.9%

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}} \]
      9. div-inv44.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      10. sqrt-div52.5%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      11. inv-pow52.5%

        \[\leadsto d \cdot \frac{\sqrt{\color{blue}{{h}^{-1}}}}{\sqrt{\ell}} \]
      12. sqrt-pow152.5%

        \[\leadsto d \cdot \frac{\color{blue}{{h}^{\left(\frac{-1}{2}\right)}}}{\sqrt{\ell}} \]
      13. metadata-eval52.5%

        \[\leadsto d \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}} \]
    11. Applied egg-rr52.5%

      \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification53.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.1 \cdot 10^{-48}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{0}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 49.8% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -1.65 \cdot 10^{-53}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= d -1.65e-53)
   (* d (- (sqrt (/ (/ 1.0 h) l))))
   (if (<= d -5e-310) (* d (sqrt (/ 1.0 0.0))) (/ d (* (sqrt l) (sqrt h))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -1.65e-53) {
		tmp = d * -sqrt(((1.0 / h) / l));
	} else if (d <= -5e-310) {
		tmp = d * sqrt((1.0 / 0.0));
	} else {
		tmp = d / (sqrt(l) * sqrt(h));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (d <= (-1.65d-53)) then
        tmp = d * -sqrt(((1.0d0 / h) / l))
    else if (d <= (-5d-310)) then
        tmp = d * sqrt((1.0d0 / 0.0d0))
    else
        tmp = d / (sqrt(l) * sqrt(h))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -1.65e-53) {
		tmp = d * -Math.sqrt(((1.0 / h) / l));
	} else if (d <= -5e-310) {
		tmp = d * Math.sqrt((1.0 / 0.0));
	} else {
		tmp = d / (Math.sqrt(l) * Math.sqrt(h));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if d <= -1.65e-53:
		tmp = d * -math.sqrt(((1.0 / h) / l))
	elif d <= -5e-310:
		tmp = d * math.sqrt((1.0 / 0.0))
	else:
		tmp = d / (math.sqrt(l) * math.sqrt(h))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (d <= -1.65e-53)
		tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / h) / l))));
	elseif (d <= -5e-310)
		tmp = Float64(d * sqrt(Float64(1.0 / 0.0)));
	else
		tmp = Float64(d / Float64(sqrt(l) * sqrt(h)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (d <= -1.65e-53)
		tmp = d * -sqrt(((1.0 / h) / l));
	elseif (d <= -5e-310)
		tmp = d * sqrt((1.0 / 0.0));
	else
		tmp = d / (sqrt(l) * sqrt(h));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, -1.65e-53], N[(d * (-N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[d, -5e-310], N[(d * N[Sqrt[N[(1.0 / 0.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.65 \cdot 10^{-53}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\

\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{0}}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.65000000000000002e-53

    1. Initial program 79.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. Simplified81.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 d around inf 0.7%

      \[\leadsto \color{blue}{d \cdot \left(\sqrt{\frac{1}{h \cdot \ell}} + -0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.7%

        \[\leadsto d \cdot \color{blue}{\left(-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) + \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. fma-define0.7%

        \[\leadsto d \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. *-commutative0.7%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \color{blue}{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. *-commutative0.7%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      5. associate-/l*0.8%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      6. unpow20.8%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      7. unpow20.8%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{\color{blue}{D \cdot D}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      8. unpow20.8%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\color{blue}{d \cdot d}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      9. times-frac0.9%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      10. swap-sqr1.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      11. unpow21.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      12. associate-*r/1.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      13. *-commutative1.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      14. associate-/l*1.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    6. Simplified1.0%

      \[\leadsto \color{blue}{d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    7. Taylor expanded in h around 0 3.6%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/r*3.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. unpow1/23.6%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
      3. associate-/r*3.6%

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{h \cdot \ell}\right)}}^{0.5} \]
      4. rem-exp-log3.6%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      5. exp-neg3.6%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      6. exp-prod3.6%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      7. distribute-lft-neg-out3.6%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in3.6%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval3.6%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      10. exp-to-pow3.6%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Simplified3.6%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Step-by-step derivation
      1. unpow-prod-down0.0%

        \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
      2. metadata-eval0.0%

        \[\leadsto d \cdot \left({h}^{\color{blue}{\left(\frac{-1}{2}\right)}} \cdot {\ell}^{-0.5}\right) \]
      3. sqrt-pow10.0%

        \[\leadsto d \cdot \left(\color{blue}{\sqrt{{h}^{-1}}} \cdot {\ell}^{-0.5}\right) \]
      4. inv-pow0.0%

        \[\leadsto d \cdot \left(\sqrt{\color{blue}{\frac{1}{h}}} \cdot {\ell}^{-0.5}\right) \]
      5. metadata-eval0.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot {\ell}^{\color{blue}{\left(\frac{-1}{2}\right)}}\right) \]
      6. sqrt-pow10.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \color{blue}{\sqrt{{\ell}^{-1}}}\right) \]
      7. inv-pow0.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\ell}}}\right) \]
      8. sqrt-prod3.6%

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}} \]
      9. div-inv3.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      10. sqrt-div0.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      11. inv-pow0.0%

        \[\leadsto d \cdot \frac{\sqrt{\color{blue}{{h}^{-1}}}}{\sqrt{\ell}} \]
      12. sqrt-pow10.0%

        \[\leadsto d \cdot \frac{\color{blue}{{h}^{\left(\frac{-1}{2}\right)}}}{\sqrt{\ell}} \]
      13. metadata-eval0.0%

        \[\leadsto d \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}} \]
    11. Applied egg-rr0.0%

      \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
    12. Taylor expanded in h around -inf 0.0%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
    13. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto d \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt56.4%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. mul-1-neg56.4%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. associate-/r*57.5%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
    14. Simplified57.5%

      \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)} \]

    if -1.65000000000000002e-53 < d < -4.999999999999985e-310

    1. Initial program 47.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. Simplified47.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 d around inf 18.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. add-log-exp24.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\log \left(e^{h \cdot \ell}\right)}}} \]
      2. *-commutative24.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\log \left(e^{\color{blue}{\ell \cdot h}}\right)}} \]
      3. exp-prod31.0%

        \[\leadsto d \cdot \sqrt{\frac{1}{\log \color{blue}{\left({\left(e^{\ell}\right)}^{h}\right)}}} \]
    6. Applied egg-rr31.0%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\log \left({\left(e^{\ell}\right)}^{h}\right)}}} \]
    7. Taylor expanded in l around 0 49.1%

      \[\leadsto d \cdot \sqrt{\frac{1}{\log \color{blue}{1}}} \]

    if -4.999999999999985e-310 < d

    1. Initial program 67.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. Simplified66.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 d around inf 43.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div44.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval44.0%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative44.0%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod52.5%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv52.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. associate-/r*50.5%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr50.5%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    7. Step-by-step derivation
      1. associate-/l/52.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      2. *-commutative52.5%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    8. Simplified52.5%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification53.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.65 \cdot 10^{-53}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 46.2% accurate, 2.8× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{if}\;d \leq -2.2 \cdot 10^{-51}:\\ \;\;\;\;d \cdot \left(-t\_0\right)\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{0}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot t\_0\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (/ (/ 1.0 h) l))))
   (if (<= d -2.2e-51)
     (* d (- t_0))
     (if (<= d -5e-310) (* d (sqrt (/ 1.0 0.0))) (* d t_0)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt(((1.0 / h) / l));
	double tmp;
	if (d <= -2.2e-51) {
		tmp = d * -t_0;
	} else if (d <= -5e-310) {
		tmp = d * sqrt((1.0 / 0.0));
	} else {
		tmp = d * t_0;
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt(((1.0d0 / h) / l))
    if (d <= (-2.2d-51)) then
        tmp = d * -t_0
    else if (d <= (-5d-310)) then
        tmp = d * sqrt((1.0d0 / 0.0d0))
    else
        tmp = d * t_0
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = Math.sqrt(((1.0 / h) / l));
	double tmp;
	if (d <= -2.2e-51) {
		tmp = d * -t_0;
	} else if (d <= -5e-310) {
		tmp = d * Math.sqrt((1.0 / 0.0));
	} else {
		tmp = d * t_0;
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = math.sqrt(((1.0 / h) / l))
	tmp = 0
	if d <= -2.2e-51:
		tmp = d * -t_0
	elif d <= -5e-310:
		tmp = d * math.sqrt((1.0 / 0.0))
	else:
		tmp = d * t_0
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = sqrt(Float64(Float64(1.0 / h) / l))
	tmp = 0.0
	if (d <= -2.2e-51)
		tmp = Float64(d * Float64(-t_0));
	elseif (d <= -5e-310)
		tmp = Float64(d * sqrt(Float64(1.0 / 0.0)));
	else
		tmp = Float64(d * t_0);
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = sqrt(((1.0 / h) / l));
	tmp = 0.0;
	if (d <= -2.2e-51)
		tmp = d * -t_0;
	elseif (d <= -5e-310)
		tmp = d * sqrt((1.0 / 0.0));
	else
		tmp = d * t_0;
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -2.2e-51], N[(d * (-t$95$0)), $MachinePrecision], If[LessEqual[d, -5e-310], N[(d * N[Sqrt[N[(1.0 / 0.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{\frac{1}{h}}{\ell}}\\
\mathbf{if}\;d \leq -2.2 \cdot 10^{-51}:\\
\;\;\;\;d \cdot \left(-t\_0\right)\\

\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{0}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.2e-51

    1. Initial program 79.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. Simplified81.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 d around inf 0.7%

      \[\leadsto \color{blue}{d \cdot \left(\sqrt{\frac{1}{h \cdot \ell}} + -0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.7%

        \[\leadsto d \cdot \color{blue}{\left(-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) + \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. fma-define0.7%

        \[\leadsto d \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. *-commutative0.7%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \color{blue}{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. *-commutative0.7%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      5. associate-/l*0.8%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      6. unpow20.8%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      7. unpow20.8%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{\color{blue}{D \cdot D}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      8. unpow20.8%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\color{blue}{d \cdot d}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      9. times-frac0.9%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      10. swap-sqr1.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      11. unpow21.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      12. associate-*r/1.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      13. *-commutative1.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      14. associate-/l*1.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    6. Simplified1.0%

      \[\leadsto \color{blue}{d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    7. Taylor expanded in h around 0 3.6%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/r*3.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. unpow1/23.6%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
      3. associate-/r*3.6%

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{h \cdot \ell}\right)}}^{0.5} \]
      4. rem-exp-log3.6%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      5. exp-neg3.6%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      6. exp-prod3.6%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      7. distribute-lft-neg-out3.6%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in3.6%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval3.6%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      10. exp-to-pow3.6%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Simplified3.6%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Step-by-step derivation
      1. unpow-prod-down0.0%

        \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
      2. metadata-eval0.0%

        \[\leadsto d \cdot \left({h}^{\color{blue}{\left(\frac{-1}{2}\right)}} \cdot {\ell}^{-0.5}\right) \]
      3. sqrt-pow10.0%

        \[\leadsto d \cdot \left(\color{blue}{\sqrt{{h}^{-1}}} \cdot {\ell}^{-0.5}\right) \]
      4. inv-pow0.0%

        \[\leadsto d \cdot \left(\sqrt{\color{blue}{\frac{1}{h}}} \cdot {\ell}^{-0.5}\right) \]
      5. metadata-eval0.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot {\ell}^{\color{blue}{\left(\frac{-1}{2}\right)}}\right) \]
      6. sqrt-pow10.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \color{blue}{\sqrt{{\ell}^{-1}}}\right) \]
      7. inv-pow0.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\ell}}}\right) \]
      8. sqrt-prod3.6%

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}} \]
      9. div-inv3.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      10. sqrt-div0.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      11. inv-pow0.0%

        \[\leadsto d \cdot \frac{\sqrt{\color{blue}{{h}^{-1}}}}{\sqrt{\ell}} \]
      12. sqrt-pow10.0%

        \[\leadsto d \cdot \frac{\color{blue}{{h}^{\left(\frac{-1}{2}\right)}}}{\sqrt{\ell}} \]
      13. metadata-eval0.0%

        \[\leadsto d \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}} \]
    11. Applied egg-rr0.0%

      \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
    12. Taylor expanded in h around -inf 0.0%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
    13. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto d \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt56.4%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. mul-1-neg56.4%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. associate-/r*57.5%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
    14. Simplified57.5%

      \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)} \]

    if -2.2e-51 < d < -4.999999999999985e-310

    1. Initial program 47.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. Simplified47.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 d around inf 18.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. add-log-exp24.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\log \left(e^{h \cdot \ell}\right)}}} \]
      2. *-commutative24.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\log \left(e^{\color{blue}{\ell \cdot h}}\right)}} \]
      3. exp-prod31.0%

        \[\leadsto d \cdot \sqrt{\frac{1}{\log \color{blue}{\left({\left(e^{\ell}\right)}^{h}\right)}}} \]
    6. Applied egg-rr31.0%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\log \left({\left(e^{\ell}\right)}^{h}\right)}}} \]
    7. Taylor expanded in l around 0 49.1%

      \[\leadsto d \cdot \sqrt{\frac{1}{\log \color{blue}{1}}} \]

    if -4.999999999999985e-310 < d

    1. Initial program 67.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. Simplified66.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 d around inf 26.2%

      \[\leadsto \color{blue}{d \cdot \left(\sqrt{\frac{1}{h \cdot \ell}} + -0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative26.2%

        \[\leadsto d \cdot \color{blue}{\left(-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) + \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. fma-define26.2%

        \[\leadsto d \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. *-commutative26.2%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \color{blue}{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. *-commutative26.2%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      5. associate-/l*25.7%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      6. unpow225.7%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      7. unpow225.7%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{\color{blue}{D \cdot D}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      8. unpow225.7%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\color{blue}{d \cdot d}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      9. times-frac39.2%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      10. swap-sqr49.6%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      11. unpow249.6%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      12. associate-*r/49.6%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      13. *-commutative49.6%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      14. associate-/l*49.6%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    6. Simplified49.6%

      \[\leadsto \color{blue}{d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    7. Taylor expanded in h around 0 43.5%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/r*44.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    9. Simplified44.9%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification49.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.2 \cdot 10^{-51}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{0}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 42.7% accurate, 2.9× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{if}\;\ell \leq -5.6 \cdot 10^{-241}:\\ \;\;\;\;d \cdot \left(-t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot t\_0\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (/ (/ 1.0 h) l))))
   (if (<= l -5.6e-241) (* d (- t_0)) (* d t_0))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt(((1.0 / h) / l));
	double tmp;
	if (l <= -5.6e-241) {
		tmp = d * -t_0;
	} else {
		tmp = d * t_0;
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt(((1.0d0 / h) / l))
    if (l <= (-5.6d-241)) then
        tmp = d * -t_0
    else
        tmp = d * t_0
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = Math.sqrt(((1.0 / h) / l));
	double tmp;
	if (l <= -5.6e-241) {
		tmp = d * -t_0;
	} else {
		tmp = d * t_0;
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = math.sqrt(((1.0 / h) / l))
	tmp = 0
	if l <= -5.6e-241:
		tmp = d * -t_0
	else:
		tmp = d * t_0
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = sqrt(Float64(Float64(1.0 / h) / l))
	tmp = 0.0
	if (l <= -5.6e-241)
		tmp = Float64(d * Float64(-t_0));
	else
		tmp = Float64(d * t_0);
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = sqrt(((1.0 / h) / l));
	tmp = 0.0;
	if (l <= -5.6e-241)
		tmp = d * -t_0;
	else
		tmp = d * t_0;
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -5.6e-241], N[(d * (-t$95$0)), $MachinePrecision], N[(d * t$95$0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{\frac{1}{h}}{\ell}}\\
\mathbf{if}\;\ell \leq -5.6 \cdot 10^{-241}:\\
\;\;\;\;d \cdot \left(-t\_0\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -5.5999999999999998e-241

    1. Initial program 63.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.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 d around inf 1.4%

      \[\leadsto \color{blue}{d \cdot \left(\sqrt{\frac{1}{h \cdot \ell}} + -0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative1.4%

        \[\leadsto d \cdot \color{blue}{\left(-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) + \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. fma-define1.4%

        \[\leadsto d \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. *-commutative1.4%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \color{blue}{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. *-commutative1.4%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      5. associate-/l*1.5%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      6. unpow21.5%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      7. unpow21.5%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{\color{blue}{D \cdot D}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      8. unpow21.5%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\color{blue}{d \cdot d}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      9. times-frac1.7%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      10. swap-sqr1.8%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      11. unpow21.8%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      12. associate-*r/1.7%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      13. *-commutative1.7%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      14. associate-/l*1.8%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    6. Simplified1.8%

      \[\leadsto \color{blue}{d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    7. Taylor expanded in h around 0 6.9%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/r*6.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. unpow1/26.9%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
      3. associate-/r*6.9%

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{h \cdot \ell}\right)}}^{0.5} \]
      4. rem-exp-log6.9%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      5. exp-neg6.9%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      6. exp-prod6.9%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      7. distribute-lft-neg-out6.9%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in6.9%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval6.9%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      10. exp-to-pow6.9%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Simplified6.9%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Step-by-step derivation
      1. unpow-prod-down0.0%

        \[\leadsto d \cdot \color{blue}{\left({h}^{-0.5} \cdot {\ell}^{-0.5}\right)} \]
      2. metadata-eval0.0%

        \[\leadsto d \cdot \left({h}^{\color{blue}{\left(\frac{-1}{2}\right)}} \cdot {\ell}^{-0.5}\right) \]
      3. sqrt-pow10.0%

        \[\leadsto d \cdot \left(\color{blue}{\sqrt{{h}^{-1}}} \cdot {\ell}^{-0.5}\right) \]
      4. inv-pow0.0%

        \[\leadsto d \cdot \left(\sqrt{\color{blue}{\frac{1}{h}}} \cdot {\ell}^{-0.5}\right) \]
      5. metadata-eval0.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot {\ell}^{\color{blue}{\left(\frac{-1}{2}\right)}}\right) \]
      6. sqrt-pow10.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \color{blue}{\sqrt{{\ell}^{-1}}}\right) \]
      7. inv-pow0.0%

        \[\leadsto d \cdot \left(\sqrt{\frac{1}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\ell}}}\right) \]
      8. sqrt-prod6.9%

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}} \]
      9. div-inv6.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      10. sqrt-div0.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      11. inv-pow0.0%

        \[\leadsto d \cdot \frac{\sqrt{\color{blue}{{h}^{-1}}}}{\sqrt{\ell}} \]
      12. sqrt-pow10.0%

        \[\leadsto d \cdot \frac{\color{blue}{{h}^{\left(\frac{-1}{2}\right)}}}{\sqrt{\ell}} \]
      13. metadata-eval0.0%

        \[\leadsto d \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}} \]
    11. Applied egg-rr0.0%

      \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
    12. Taylor expanded in h around -inf 0.0%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
    13. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto d \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt44.3%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. mul-1-neg44.3%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. associate-/r*45.1%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
    14. Simplified45.1%

      \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)} \]

    if -5.5999999999999998e-241 < l

    1. Initial program 70.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. 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 d around inf 23.0%

      \[\leadsto \color{blue}{d \cdot \left(\sqrt{\frac{1}{h \cdot \ell}} + -0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative23.0%

        \[\leadsto d \cdot \color{blue}{\left(-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) + \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. fma-define23.0%

        \[\leadsto d \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. *-commutative23.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \color{blue}{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. *-commutative23.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      5. associate-/l*22.5%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      6. unpow222.5%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      7. unpow222.5%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{\color{blue}{D \cdot D}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      8. unpow222.5%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\color{blue}{d \cdot d}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      9. times-frac34.3%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      10. swap-sqr43.4%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      11. unpow243.4%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      12. associate-*r/43.4%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      13. *-commutative43.4%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      14. associate-/l*43.4%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    6. Simplified43.4%

      \[\leadsto \color{blue}{d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    7. Taylor expanded in h around 0 41.3%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/r*42.5%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    9. Simplified42.5%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 21: 42.6% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2.9 \cdot 10^{-239}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l -2.9e-239) (/ d (- (sqrt (* l h)))) (* d (sqrt (/ (/ 1.0 h) l)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -2.9e-239) {
		tmp = d / -sqrt((l * h));
	} else {
		tmp = d * sqrt(((1.0 / h) / l));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= (-2.9d-239)) then
        tmp = d / -sqrt((l * h))
    else
        tmp = d * sqrt(((1.0d0 / h) / l))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -2.9e-239) {
		tmp = d / -Math.sqrt((l * h));
	} else {
		tmp = d * Math.sqrt(((1.0 / h) / l));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= -2.9e-239:
		tmp = d / -math.sqrt((l * h))
	else:
		tmp = d * math.sqrt(((1.0 / h) / l))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -2.9e-239)
		tmp = Float64(d / Float64(-sqrt(Float64(l * h))));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / h) / l)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= -2.9e-239)
		tmp = d / -sqrt((l * h));
	else
		tmp = d * sqrt(((1.0 / h) / l));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -2.9e-239], N[(d / (-N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.9 \cdot 10^{-239}:\\
\;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.9000000000000002e-239

    1. Initial program 63.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.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 d around inf 6.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    6. Step-by-step derivation
      1. associate-*l*0.0%

        \[\leadsto \color{blue}{d \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt44.3%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. mul-1-neg44.3%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. distribute-rgt-neg-out44.3%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. *-commutative44.3%

        \[\leadsto -\color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      7. associate-/r*45.1%

        \[\leadsto -\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot d \]
      8. unpow1/245.1%

        \[\leadsto -\color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \cdot d \]
      9. associate-/r*44.3%

        \[\leadsto -{\color{blue}{\left(\frac{1}{h \cdot \ell}\right)}}^{0.5} \cdot d \]
      10. rem-exp-log42.1%

        \[\leadsto -{\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \cdot d \]
      11. exp-neg42.1%

        \[\leadsto -{\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot d \]
      12. exp-prod42.1%

        \[\leadsto -\color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \cdot d \]
      13. distribute-lft-neg-out42.1%

        \[\leadsto -e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot d \]
      14. exp-neg42.1%

        \[\leadsto -\color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \cdot d \]
      15. exp-to-pow44.2%

        \[\leadsto -\frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \cdot d \]
      16. unpow1/244.2%

        \[\leadsto -\frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot d \]
      17. unpow-144.2%

        \[\leadsto -\color{blue}{{\left(\sqrt{h \cdot \ell}\right)}^{-1}} \cdot d \]
      18. unpow-144.2%

        \[\leadsto -\color{blue}{\frac{1}{\sqrt{h \cdot \ell}}} \cdot d \]
      19. associate-*l/44.3%

        \[\leadsto -\color{blue}{\frac{1 \cdot d}{\sqrt{h \cdot \ell}}} \]
      20. *-lft-identity44.3%

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified44.3%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if -2.9000000000000002e-239 < l

    1. Initial program 70.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. 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 d around inf 23.0%

      \[\leadsto \color{blue}{d \cdot \left(\sqrt{\frac{1}{h \cdot \ell}} + -0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative23.0%

        \[\leadsto d \cdot \color{blue}{\left(-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) + \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. fma-define23.0%

        \[\leadsto d \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. *-commutative23.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \color{blue}{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. *-commutative23.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      5. associate-/l*22.5%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      6. unpow222.5%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      7. unpow222.5%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{\color{blue}{D \cdot D}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      8. unpow222.5%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\color{blue}{d \cdot d}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      9. times-frac34.3%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      10. swap-sqr43.4%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      11. unpow243.4%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      12. associate-*r/43.4%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      13. *-commutative43.4%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      14. associate-/l*43.4%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    6. Simplified43.4%

      \[\leadsto \color{blue}{d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    7. Taylor expanded in h around 0 41.3%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/r*42.5%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    9. Simplified42.5%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification43.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.9 \cdot 10^{-239}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 22: 42.5% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;\ell \leq -5.4 \cdot 10^{-244}:\\ \;\;\;\;\frac{d}{-t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{t\_0}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (* l h)))) (if (<= l -5.4e-244) (/ d (- t_0)) (/ d t_0))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt((l * h));
	double tmp;
	if (l <= -5.4e-244) {
		tmp = d / -t_0;
	} else {
		tmp = d / t_0;
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((l * h))
    if (l <= (-5.4d-244)) then
        tmp = d / -t_0
    else
        tmp = d / t_0
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = Math.sqrt((l * h));
	double tmp;
	if (l <= -5.4e-244) {
		tmp = d / -t_0;
	} else {
		tmp = d / t_0;
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = math.sqrt((l * h))
	tmp = 0
	if l <= -5.4e-244:
		tmp = d / -t_0
	else:
		tmp = d / t_0
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = sqrt(Float64(l * h))
	tmp = 0.0
	if (l <= -5.4e-244)
		tmp = Float64(d / Float64(-t_0));
	else
		tmp = Float64(d / t_0);
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = sqrt((l * h));
	tmp = 0.0;
	if (l <= -5.4e-244)
		tmp = d / -t_0;
	else
		tmp = d / t_0;
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -5.4e-244], N[(d / (-t$95$0)), $MachinePrecision], N[(d / t$95$0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;\ell \leq -5.4 \cdot 10^{-244}:\\
\;\;\;\;\frac{d}{-t\_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -5.3999999999999999e-244

    1. Initial program 63.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.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 d around inf 6.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    6. Step-by-step derivation
      1. associate-*l*0.0%

        \[\leadsto \color{blue}{d \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt44.3%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. mul-1-neg44.3%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. distribute-rgt-neg-out44.3%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. *-commutative44.3%

        \[\leadsto -\color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      7. associate-/r*45.1%

        \[\leadsto -\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot d \]
      8. unpow1/245.1%

        \[\leadsto -\color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \cdot d \]
      9. associate-/r*44.3%

        \[\leadsto -{\color{blue}{\left(\frac{1}{h \cdot \ell}\right)}}^{0.5} \cdot d \]
      10. rem-exp-log42.1%

        \[\leadsto -{\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \cdot d \]
      11. exp-neg42.1%

        \[\leadsto -{\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot d \]
      12. exp-prod42.1%

        \[\leadsto -\color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \cdot d \]
      13. distribute-lft-neg-out42.1%

        \[\leadsto -e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot d \]
      14. exp-neg42.1%

        \[\leadsto -\color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \cdot d \]
      15. exp-to-pow44.2%

        \[\leadsto -\frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \cdot d \]
      16. unpow1/244.2%

        \[\leadsto -\frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot d \]
      17. unpow-144.2%

        \[\leadsto -\color{blue}{{\left(\sqrt{h \cdot \ell}\right)}^{-1}} \cdot d \]
      18. unpow-144.2%

        \[\leadsto -\color{blue}{\frac{1}{\sqrt{h \cdot \ell}}} \cdot d \]
      19. associate-*l/44.3%

        \[\leadsto -\color{blue}{\frac{1 \cdot d}{\sqrt{h \cdot \ell}}} \]
      20. *-lft-identity44.3%

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    7. Simplified44.3%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if -5.3999999999999999e-244 < l

    1. Initial program 70.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. 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 d around inf 23.0%

      \[\leadsto \color{blue}{d \cdot \left(\sqrt{\frac{1}{h \cdot \ell}} + -0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative23.0%

        \[\leadsto d \cdot \color{blue}{\left(-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) + \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. fma-define23.0%

        \[\leadsto d \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. *-commutative23.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \color{blue}{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. *-commutative23.0%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      5. associate-/l*22.5%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      6. unpow222.5%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      7. unpow222.5%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{\color{blue}{D \cdot D}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      8. unpow222.5%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\color{blue}{d \cdot d}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      9. times-frac34.3%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      10. swap-sqr43.4%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      11. unpow243.4%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      12. associate-*r/43.4%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      13. *-commutative43.4%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      14. associate-/l*43.4%

        \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    6. Simplified43.4%

      \[\leadsto \color{blue}{d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    7. Taylor expanded in h around 0 41.3%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/r*42.5%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. unpow1/242.5%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
      3. associate-/r*41.3%

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{h \cdot \ell}\right)}}^{0.5} \]
      4. rem-exp-log39.4%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      5. exp-neg39.4%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      6. exp-prod39.8%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      7. distribute-lft-neg-out39.8%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in39.8%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval39.8%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      10. exp-to-pow41.7%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Simplified41.7%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Step-by-step derivation
      1. metadata-eval41.7%

        \[\leadsto d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{\left(\frac{-1}{2}\right)}} \]
      2. sqrt-pow141.3%

        \[\leadsto d \cdot \color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-1}}} \]
      3. add-log-exp10.1%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \color{blue}{\log \left(e^{\ell}\right)}\right)}^{-1}} \]
      4. log-pow17.3%

        \[\leadsto d \cdot \sqrt{{\color{blue}{\log \left({\left(e^{\ell}\right)}^{h}\right)}}^{-1}} \]
      5. inv-pow17.3%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{\log \left({\left(e^{\ell}\right)}^{h}\right)}}} \]
      6. sqrt-div17.3%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\log \left({\left(e^{\ell}\right)}^{h}\right)}}} \]
      7. metadata-eval17.3%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{\log \left({\left(e^{\ell}\right)}^{h}\right)}} \]
      8. un-div-inv17.3%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\log \left({\left(e^{\ell}\right)}^{h}\right)}}} \]
      9. log-pow11.5%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \log \left(e^{\ell}\right)}}} \]
      10. add-log-exp41.7%

        \[\leadsto \frac{d}{\sqrt{h \cdot \color{blue}{\ell}}} \]
    11. Applied egg-rr41.7%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification42.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5.4 \cdot 10^{-244}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 23: 26.3% accurate, 3.2× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \frac{d}{\sqrt{\ell \cdot h}} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (/ d (sqrt (* l h))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d / sqrt((l * h));
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d / sqrt((l * h))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d / Math.sqrt((l * h));
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d / math.sqrt((l * h))
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d / sqrt(Float64(l * h)))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d / sqrt((l * h));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Derivation
  1. Initial program 67.1%

    \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  2. Simplified67.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 d around inf 13.5%

    \[\leadsto \color{blue}{d \cdot \left(\sqrt{\frac{1}{h \cdot \ell}} + -0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
  5. Step-by-step derivation
    1. +-commutative13.5%

      \[\leadsto d \cdot \color{blue}{\left(-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) + \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    2. fma-define13.5%

      \[\leadsto d \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    3. *-commutative13.5%

      \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \color{blue}{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    4. *-commutative13.5%

      \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    5. associate-/l*13.3%

      \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    6. unpow213.3%

      \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    7. unpow213.3%

      \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{\color{blue}{D \cdot D}}{{d}^{2}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    8. unpow213.3%

      \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\color{blue}{d \cdot d}}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    9. times-frac20.0%

      \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right), \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    10. swap-sqr25.2%

      \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    11. unpow225.2%

      \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot \color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    12. associate-*r/25.2%

      \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    13. *-commutative25.2%

      \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
    14. associate-/l*25.2%

      \[\leadsto d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right) \]
  6. Simplified25.2%

    \[\leadsto \color{blue}{d \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{h}{{\ell}^{3}}} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}, \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
  7. Taylor expanded in h around 0 26.2%

    \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
  8. Step-by-step derivation
    1. associate-/r*26.9%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    2. unpow1/226.9%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
    3. associate-/r*26.2%

      \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{h \cdot \ell}\right)}}^{0.5} \]
    4. rem-exp-log25.2%

      \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
    5. exp-neg25.2%

      \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
    6. exp-prod25.4%

      \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
    7. distribute-lft-neg-out25.4%

      \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
    8. distribute-rgt-neg-in25.4%

      \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
    9. metadata-eval25.4%

      \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
    10. exp-to-pow26.5%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  9. Simplified26.5%

    \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  10. Step-by-step derivation
    1. metadata-eval26.5%

      \[\leadsto d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{\left(\frac{-1}{2}\right)}} \]
    2. sqrt-pow126.2%

      \[\leadsto d \cdot \color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-1}}} \]
    3. add-log-exp6.9%

      \[\leadsto d \cdot \sqrt{{\left(h \cdot \color{blue}{\log \left(e^{\ell}\right)}\right)}^{-1}} \]
    4. log-pow17.4%

      \[\leadsto d \cdot \sqrt{{\color{blue}{\log \left({\left(e^{\ell}\right)}^{h}\right)}}^{-1}} \]
    5. inv-pow17.4%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{\log \left({\left(e^{\ell}\right)}^{h}\right)}}} \]
    6. sqrt-div17.4%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\log \left({\left(e^{\ell}\right)}^{h}\right)}}} \]
    7. metadata-eval17.4%

      \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{\log \left({\left(e^{\ell}\right)}^{h}\right)}} \]
    8. un-div-inv17.4%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\log \left({\left(e^{\ell}\right)}^{h}\right)}}} \]
    9. log-pow9.8%

      \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \log \left(e^{\ell}\right)}}} \]
    10. add-log-exp26.5%

      \[\leadsto \frac{d}{\sqrt{h \cdot \color{blue}{\ell}}} \]
  11. Applied egg-rr26.5%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  12. Final simplification26.5%

    \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
  13. Add Preprocessing

Reproduce

?
herbie shell --seed 2024182 
(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)))))