Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.1% → 82.2%
Time: 33.0s
Alternatives: 30
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 30 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.1% 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: 82.2% accurate, 0.6× speedup?

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

\mathbf{elif}\;d \leq -7.8 \cdot 10^{-308}:\\
\;\;\;\;\frac{t\_2}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{{t\_0}^{2}}{\ell}, h \cdot -0.125, 1\right)\right)\\

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

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


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

    1. Initial program 73.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.50000000000000008e-211 < d < -7.7999999999999999e-308

    1. Initial program 43.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. Simplified37.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.7999999999999999e-308 < d < 2.20000000000000013e-200

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.20000000000000013e-200 < d

    1. Initial program 81.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. Simplified80.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. Applied egg-rr86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 82.3% 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 := D\_m \cdot \frac{M\_m}{d}\\ t_1 := \mathsf{fma}\left(t\_0 \cdot \frac{t\_0}{\ell}, h \cdot -0.125, 1\right)\\ t_2 := \sqrt{\ell} \cdot \sqrt{h}\\ t_3 := \sqrt{-d}\\ \mathbf{if}\;d \leq -1.15 \cdot 10^{-210}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{t\_3}{\sqrt{-\ell}} \cdot t\_1\right)\\ \mathbf{elif}\;d \leq -7.8 \cdot 10^{-308}:\\ \;\;\;\;\frac{t\_3}{\sqrt{-h}} \cdot \left(t\_1 \cdot \sqrt{\frac{d}{\ell}}\right)\\ \mathbf{elif}\;d \leq 6.5 \cdot 10^{-199}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\left(D\_m \cdot M\_m\right) \cdot \frac{1}{d \cdot 2}\right)}^{2}, 1\right)}{t\_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{t\_2} \cdot \left(1 + h \cdot \frac{-0.5 \cdot {\left(\frac{2 \cdot \frac{d}{D\_m}}{M\_m}\right)}^{-2}}{\ell}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (* D_m (/ M_m d)))
        (t_1 (fma (* t_0 (/ t_0 l)) (* h -0.125) 1.0))
        (t_2 (* (sqrt l) (sqrt h)))
        (t_3 (sqrt (- d))))
   (if (<= d -1.15e-210)
     (* (sqrt (/ d h)) (* (/ t_3 (sqrt (- l))) t_1))
     (if (<= d -7.8e-308)
       (* (/ t_3 (sqrt (- h))) (* t_1 (sqrt (/ d l))))
       (if (<= d 6.5e-199)
         (*
          d
          (/
           (fma
            (* (/ h l) -0.5)
            (pow (* (* D_m M_m) (/ 1.0 (* d 2.0))) 2.0)
            1.0)
           t_2))
         (*
          (/ d t_2)
          (+
           1.0
           (* h (/ (* -0.5 (pow (/ (* 2.0 (/ d D_m)) M_m) -2.0)) l)))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = D_m * (M_m / d);
	double t_1 = fma((t_0 * (t_0 / l)), (h * -0.125), 1.0);
	double t_2 = sqrt(l) * sqrt(h);
	double t_3 = sqrt(-d);
	double tmp;
	if (d <= -1.15e-210) {
		tmp = sqrt((d / h)) * ((t_3 / sqrt(-l)) * t_1);
	} else if (d <= -7.8e-308) {
		tmp = (t_3 / sqrt(-h)) * (t_1 * sqrt((d / l)));
	} else if (d <= 6.5e-199) {
		tmp = d * (fma(((h / l) * -0.5), pow(((D_m * M_m) * (1.0 / (d * 2.0))), 2.0), 1.0) / t_2);
	} else {
		tmp = (d / t_2) * (1.0 + (h * ((-0.5 * pow(((2.0 * (d / D_m)) / M_m), -2.0)) / l)));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(D_m * Float64(M_m / d))
	t_1 = fma(Float64(t_0 * Float64(t_0 / l)), Float64(h * -0.125), 1.0)
	t_2 = Float64(sqrt(l) * sqrt(h))
	t_3 = sqrt(Float64(-d))
	tmp = 0.0
	if (d <= -1.15e-210)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(t_3 / sqrt(Float64(-l))) * t_1));
	elseif (d <= -7.8e-308)
		tmp = Float64(Float64(t_3 / sqrt(Float64(-h))) * Float64(t_1 * sqrt(Float64(d / l))));
	elseif (d <= 6.5e-199)
		tmp = Float64(d * Float64(fma(Float64(Float64(h / l) * -0.5), (Float64(Float64(D_m * M_m) * Float64(1.0 / Float64(d * 2.0))) ^ 2.0), 1.0) / t_2));
	else
		tmp = Float64(Float64(d / t_2) * Float64(1.0 + Float64(h * Float64(Float64(-0.5 * (Float64(Float64(2.0 * Float64(d / D_m)) / M_m) ^ -2.0)) / l))));
	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[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision] * N[(h * -0.125), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[d, -1.15e-210], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(t$95$3 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -7.8e-308], N[(N[(t$95$3 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.5e-199], N[(d * N[(N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(1.0 / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(d / t$95$2), $MachinePrecision] * N[(1.0 + N[(h * N[(N[(-0.5 * N[Power[N[(N[(2.0 * N[(d / D$95$m), $MachinePrecision]), $MachinePrecision] / M$95$m), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := D\_m \cdot \frac{M\_m}{d}\\
t_1 := \mathsf{fma}\left(t\_0 \cdot \frac{t\_0}{\ell}, h \cdot -0.125, 1\right)\\
t_2 := \sqrt{\ell} \cdot \sqrt{h}\\
t_3 := \sqrt{-d}\\
\mathbf{if}\;d \leq -1.15 \cdot 10^{-210}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{t\_3}{\sqrt{-\ell}} \cdot t\_1\right)\\

\mathbf{elif}\;d \leq -7.8 \cdot 10^{-308}:\\
\;\;\;\;\frac{t\_3}{\sqrt{-h}} \cdot \left(t\_1 \cdot \sqrt{\frac{d}{\ell}}\right)\\

\mathbf{elif}\;d \leq 6.5 \cdot 10^{-199}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\left(D\_m \cdot M\_m\right) \cdot \frac{1}{d \cdot 2}\right)}^{2}, 1\right)}{t\_2}\\

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


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

    1. Initial program 73.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.15e-210 < d < -7.7999999999999999e-308

    1. Initial program 43.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. Simplified37.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.7999999999999999e-308 < d < 6.50000000000000017e-199

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.50000000000000017e-199 < d

    1. Initial program 81.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. Simplified80.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. Applied egg-rr86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 82.3% 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 := D\_m \cdot \frac{M\_m}{d}\\ t_1 := \sqrt{\ell} \cdot \sqrt{h}\\ t_2 := \sqrt{-d}\\ \mathbf{if}\;d \leq -7.5 \cdot 10^{-211}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{t\_2}{\sqrt{-\ell}} \cdot \mathsf{fma}\left(t\_0 \cdot \frac{t\_0}{\ell}, h \cdot -0.125, 1\right)\right)\\ \mathbf{elif}\;d \leq -7.8 \cdot 10^{-308}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\frac{t\_2}{\sqrt{-h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D\_m \cdot \frac{\frac{M\_m}{2}}{d}\right)}^{2}\right)\right)\right)\\ \mathbf{elif}\;d \leq 5.8 \cdot 10^{-198}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\left(D\_m \cdot M\_m\right) \cdot \frac{1}{d \cdot 2}\right)}^{2}, 1\right)}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{t\_1} \cdot \left(1 + h \cdot \frac{-0.5 \cdot {\left(\frac{2 \cdot \frac{d}{D\_m}}{M\_m}\right)}^{-2}}{\ell}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (* D_m (/ M_m d))) (t_1 (* (sqrt l) (sqrt h))) (t_2 (sqrt (- d))))
   (if (<= d -7.5e-211)
     (*
      (sqrt (/ d h))
      (* (/ t_2 (sqrt (- l))) (fma (* t_0 (/ t_0 l)) (* h -0.125) 1.0)))
     (if (<= d -7.8e-308)
       (*
        (sqrt (/ d l))
        (*
         (/ t_2 (sqrt (- h)))
         (+ 1.0 (* (/ h l) (* -0.5 (pow (* D_m (/ (/ M_m 2.0) d)) 2.0))))))
       (if (<= d 5.8e-198)
         (*
          d
          (/
           (fma
            (* (/ h l) -0.5)
            (pow (* (* D_m M_m) (/ 1.0 (* d 2.0))) 2.0)
            1.0)
           t_1))
         (*
          (/ d t_1)
          (+
           1.0
           (* h (/ (* -0.5 (pow (/ (* 2.0 (/ d D_m)) M_m) -2.0)) l)))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = D_m * (M_m / d);
	double t_1 = sqrt(l) * sqrt(h);
	double t_2 = sqrt(-d);
	double tmp;
	if (d <= -7.5e-211) {
		tmp = sqrt((d / h)) * ((t_2 / sqrt(-l)) * fma((t_0 * (t_0 / l)), (h * -0.125), 1.0));
	} else if (d <= -7.8e-308) {
		tmp = sqrt((d / l)) * ((t_2 / sqrt(-h)) * (1.0 + ((h / l) * (-0.5 * pow((D_m * ((M_m / 2.0) / d)), 2.0)))));
	} else if (d <= 5.8e-198) {
		tmp = d * (fma(((h / l) * -0.5), pow(((D_m * M_m) * (1.0 / (d * 2.0))), 2.0), 1.0) / t_1);
	} else {
		tmp = (d / t_1) * (1.0 + (h * ((-0.5 * pow(((2.0 * (d / D_m)) / M_m), -2.0)) / l)));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(D_m * Float64(M_m / d))
	t_1 = Float64(sqrt(l) * sqrt(h))
	t_2 = sqrt(Float64(-d))
	tmp = 0.0
	if (d <= -7.5e-211)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(t_2 / sqrt(Float64(-l))) * fma(Float64(t_0 * Float64(t_0 / l)), Float64(h * -0.125), 1.0)));
	elseif (d <= -7.8e-308)
		tmp = Float64(sqrt(Float64(d / l)) * Float64(Float64(t_2 / sqrt(Float64(-h))) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(D_m * Float64(Float64(M_m / 2.0) / d)) ^ 2.0))))));
	elseif (d <= 5.8e-198)
		tmp = Float64(d * Float64(fma(Float64(Float64(h / l) * -0.5), (Float64(Float64(D_m * M_m) * Float64(1.0 / Float64(d * 2.0))) ^ 2.0), 1.0) / t_1));
	else
		tmp = Float64(Float64(d / t_1) * Float64(1.0 + Float64(h * Float64(Float64(-0.5 * (Float64(Float64(2.0 * Float64(d / D_m)) / M_m) ^ -2.0)) / l))));
	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[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[d, -7.5e-211], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(t$95$2 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[(N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision] * N[(h * -0.125), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -7.8e-308], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(t$95$2 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(D$95$m * N[(N[(M$95$m / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.8e-198], N[(d * N[(N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(1.0 / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(d / t$95$1), $MachinePrecision] * N[(1.0 + N[(h * N[(N[(-0.5 * N[Power[N[(N[(2.0 * N[(d / D$95$m), $MachinePrecision]), $MachinePrecision] / M$95$m), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := D\_m \cdot \frac{M\_m}{d}\\
t_1 := \sqrt{\ell} \cdot \sqrt{h}\\
t_2 := \sqrt{-d}\\
\mathbf{if}\;d \leq -7.5 \cdot 10^{-211}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{t\_2}{\sqrt{-\ell}} \cdot \mathsf{fma}\left(t\_0 \cdot \frac{t\_0}{\ell}, h \cdot -0.125, 1\right)\right)\\

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

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

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


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

    1. Initial program 73.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.5000000000000003e-211 < d < -7.7999999999999999e-308

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

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

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

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

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

    if -7.7999999999999999e-308 < d < 5.80000000000000001e-198

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.80000000000000001e-198 < d

    1. Initial program 81.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. Simplified80.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. Applied egg-rr86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 79.4% 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 := 1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D\_m \cdot \frac{\frac{M\_m}{2}}{d}\right)}^{2}\right)\\ t_1 := \sqrt{\ell} \cdot \sqrt{h}\\ t_2 := \sqrt{-d}\\ \mathbf{if}\;d \leq -1.4 \cdot 10^{-209}:\\ \;\;\;\;\frac{t\_2}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot t\_0\right)\\ \mathbf{elif}\;d \leq -7.8 \cdot 10^{-308}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\frac{t\_2}{\sqrt{-h}} \cdot t\_0\right)\\ \mathbf{elif}\;d \leq 4 \cdot 10^{-198}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\left(D\_m \cdot M\_m\right) \cdot \frac{1}{d \cdot 2}\right)}^{2}, 1\right)}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{t\_1} \cdot \left(1 + h \cdot \frac{-0.5 \cdot {\left(\frac{2 \cdot \frac{d}{D\_m}}{M\_m}\right)}^{-2}}{\ell}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (+ 1.0 (* (/ h l) (* -0.5 (pow (* D_m (/ (/ M_m 2.0) d)) 2.0)))))
        (t_1 (* (sqrt l) (sqrt h)))
        (t_2 (sqrt (- d))))
   (if (<= d -1.4e-209)
     (* (/ t_2 (sqrt (- l))) (* (sqrt (/ d h)) t_0))
     (if (<= d -7.8e-308)
       (* (sqrt (/ d l)) (* (/ t_2 (sqrt (- h))) t_0))
       (if (<= d 4e-198)
         (*
          d
          (/
           (fma
            (* (/ h l) -0.5)
            (pow (* (* D_m M_m) (/ 1.0 (* d 2.0))) 2.0)
            1.0)
           t_1))
         (*
          (/ d t_1)
          (+
           1.0
           (* h (/ (* -0.5 (pow (/ (* 2.0 (/ d D_m)) M_m) -2.0)) l)))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = 1.0 + ((h / l) * (-0.5 * pow((D_m * ((M_m / 2.0) / d)), 2.0)));
	double t_1 = sqrt(l) * sqrt(h);
	double t_2 = sqrt(-d);
	double tmp;
	if (d <= -1.4e-209) {
		tmp = (t_2 / sqrt(-l)) * (sqrt((d / h)) * t_0);
	} else if (d <= -7.8e-308) {
		tmp = sqrt((d / l)) * ((t_2 / sqrt(-h)) * t_0);
	} else if (d <= 4e-198) {
		tmp = d * (fma(((h / l) * -0.5), pow(((D_m * M_m) * (1.0 / (d * 2.0))), 2.0), 1.0) / t_1);
	} else {
		tmp = (d / t_1) * (1.0 + (h * ((-0.5 * pow(((2.0 * (d / D_m)) / M_m), -2.0)) / l)));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(D_m * Float64(Float64(M_m / 2.0) / d)) ^ 2.0))))
	t_1 = Float64(sqrt(l) * sqrt(h))
	t_2 = sqrt(Float64(-d))
	tmp = 0.0
	if (d <= -1.4e-209)
		tmp = Float64(Float64(t_2 / sqrt(Float64(-l))) * Float64(sqrt(Float64(d / h)) * t_0));
	elseif (d <= -7.8e-308)
		tmp = Float64(sqrt(Float64(d / l)) * Float64(Float64(t_2 / sqrt(Float64(-h))) * t_0));
	elseif (d <= 4e-198)
		tmp = Float64(d * Float64(fma(Float64(Float64(h / l) * -0.5), (Float64(Float64(D_m * M_m) * Float64(1.0 / Float64(d * 2.0))) ^ 2.0), 1.0) / t_1));
	else
		tmp = Float64(Float64(d / t_1) * Float64(1.0 + Float64(h * Float64(Float64(-0.5 * (Float64(Float64(2.0 * Float64(d / D_m)) / M_m) ^ -2.0)) / l))));
	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[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(D$95$m * N[(N[(M$95$m / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[d, -1.4e-209], N[(N[(t$95$2 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -7.8e-308], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(t$95$2 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4e-198], N[(d * N[(N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(1.0 / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(d / t$95$1), $MachinePrecision] * N[(1.0 + N[(h * N[(N[(-0.5 * N[Power[N[(N[(2.0 * N[(d / D$95$m), $MachinePrecision]), $MachinePrecision] / M$95$m), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := 1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D\_m \cdot \frac{\frac{M\_m}{2}}{d}\right)}^{2}\right)\\
t_1 := \sqrt{\ell} \cdot \sqrt{h}\\
t_2 := \sqrt{-d}\\
\mathbf{if}\;d \leq -1.4 \cdot 10^{-209}:\\
\;\;\;\;\frac{t\_2}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot t\_0\right)\\

\mathbf{elif}\;d \leq -7.8 \cdot 10^{-308}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\frac{t\_2}{\sqrt{-h}} \cdot t\_0\right)\\

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

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


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

    1. Initial program 73.3%

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\frac{\sqrt{-d}}{\sqrt{-\ell}}} \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right) \]
    5. Applied egg-rr81.6%

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

    if -1.40000000000000006e-209 < d < -7.7999999999999999e-308

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

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

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

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

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

    if -7.7999999999999999e-308 < d < 3.9999999999999996e-198

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.9999999999999996e-198 < d

    1. Initial program 81.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. Simplified80.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. Applied egg-rr86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 77.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. Simplified77.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.500000000000001e-157 < d < -1.999999999999994e-310

    1. Initial program 41.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. Simplified37.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. Taylor expanded in h around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < d < 1.59999999999999997e-198

    1. Initial program 38.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. Simplified38.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. Applied egg-rr46.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.59999999999999997e-198 < d

    1. Initial program 81.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. Simplified80.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. Applied egg-rr86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

\mathbf{elif}\;d \leq 5.8 \cdot 10^{-198}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\left(D\_m \cdot M\_m\right) \cdot \frac{1}{d \cdot 2}\right)}^{2}, 1\right)}{t\_0}\\

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


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

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

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

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

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

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

    if -7.7999999999999999e-308 < d < 5.80000000000000001e-198

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.80000000000000001e-198 < d

    1. Initial program 81.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. Simplified80.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. Applied egg-rr86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 77.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. Simplified77.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.00000000000000031e-155 < d < -1.999999999999994e-310

    1. Initial program 41.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. Simplified37.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. Taylor expanded in h around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < d < 2.05000000000000011e-199

    1. Initial program 38.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. Simplified38.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. Applied egg-rr46.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.05000000000000011e-199 < d

    1. Initial program 81.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. Simplified80.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. Applied egg-rr86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 77.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. Simplified77.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.6000000000000002e-159 < d < -1.999999999999994e-310

    1. Initial program 41.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. Simplified37.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. Taylor expanded in h around -inf 0.0%

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < d < 2e-200

    1. Initial program 38.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. Simplified38.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. Applied egg-rr46.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e-200 < d

    1. Initial program 81.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. Simplified80.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. Applied egg-rr86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 71.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(D\_m \cdot \frac{M\_m}{d}\right)}^{2}\\ t_1 := \sqrt{\ell} \cdot \sqrt{h}\\ \mathbf{if}\;d \leq -8.2 \cdot 10^{+203}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;d \leq -1.65 \cdot 10^{-137}:\\ \;\;\;\;\mathsf{fma}\left(\frac{t\_0}{\ell}, h \cdot -0.125, 1\right) \cdot \sqrt{\frac{d \cdot \frac{d}{h}}{\ell}}\\ \mathbf{elif}\;d \leq -7.5 \cdot 10^{-278}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(t\_0 \cdot \frac{h}{\ell}\right)\right)\right)\\ \mathbf{elif}\;d \leq 1.15 \cdot 10^{-198}:\\ \;\;\;\;d \cdot \frac{1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D\_m \cdot \left(\frac{M\_m}{d} \cdot 0.5\right)\right)}^{2}\right)}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{t\_1} \cdot \left(1 + h \cdot \frac{-0.5 \cdot {\left(\frac{2 \cdot \frac{d}{D\_m}}{M\_m}\right)}^{-2}}{\ell}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (pow (* D_m (/ M_m d)) 2.0)) (t_1 (* (sqrt l) (sqrt h))))
   (if (<= d -8.2e+203)
     (* (- d) (sqrt (/ (/ 1.0 h) l)))
     (if (<= d -1.65e-137)
       (* (fma (/ t_0 l) (* h -0.125) 1.0) (sqrt (/ (* d (/ d h)) l)))
       (if (<= d -7.5e-278)
         (* (sqrt (/ d h)) (* (sqrt (/ d l)) (* -0.125 (* t_0 (/ h l)))))
         (if (<= d 1.15e-198)
           (*
            d
            (/
             (+ 1.0 (* (/ h l) (* -0.5 (pow (* D_m (* (/ M_m d) 0.5)) 2.0))))
             t_1))
           (*
            (/ d t_1)
            (+
             1.0
             (* h (/ (* -0.5 (pow (/ (* 2.0 (/ d D_m)) M_m) -2.0)) l))))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = pow((D_m * (M_m / d)), 2.0);
	double t_1 = sqrt(l) * sqrt(h);
	double tmp;
	if (d <= -8.2e+203) {
		tmp = -d * sqrt(((1.0 / h) / l));
	} else if (d <= -1.65e-137) {
		tmp = fma((t_0 / l), (h * -0.125), 1.0) * sqrt(((d * (d / h)) / l));
	} else if (d <= -7.5e-278) {
		tmp = sqrt((d / h)) * (sqrt((d / l)) * (-0.125 * (t_0 * (h / l))));
	} else if (d <= 1.15e-198) {
		tmp = d * ((1.0 + ((h / l) * (-0.5 * pow((D_m * ((M_m / d) * 0.5)), 2.0)))) / t_1);
	} else {
		tmp = (d / t_1) * (1.0 + (h * ((-0.5 * pow(((2.0 * (d / D_m)) / M_m), -2.0)) / l)));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(D_m * Float64(M_m / d)) ^ 2.0
	t_1 = Float64(sqrt(l) * sqrt(h))
	tmp = 0.0
	if (d <= -8.2e+203)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l)));
	elseif (d <= -1.65e-137)
		tmp = Float64(fma(Float64(t_0 / l), Float64(h * -0.125), 1.0) * sqrt(Float64(Float64(d * Float64(d / h)) / l)));
	elseif (d <= -7.5e-278)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(-0.125 * Float64(t_0 * Float64(h / l)))));
	elseif (d <= 1.15e-198)
		tmp = Float64(d * Float64(Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(D_m * Float64(Float64(M_m / d) * 0.5)) ^ 2.0)))) / t_1));
	else
		tmp = Float64(Float64(d / t_1) * Float64(1.0 + Float64(h * Float64(Float64(-0.5 * (Float64(Float64(2.0 * Float64(d / D_m)) / M_m) ^ -2.0)) / l))));
	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[Power[N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -8.2e+203], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.65e-137], N[(N[(N[(t$95$0 / l), $MachinePrecision] * N[(h * -0.125), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d * N[(d / h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -7.5e-278], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(-0.125 * N[(t$95$0 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.15e-198], N[(d * N[(N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(D$95$m * N[(N[(M$95$m / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(d / t$95$1), $MachinePrecision] * N[(1.0 + N[(h * N[(N[(-0.5 * N[Power[N[(N[(2.0 * N[(d / D$95$m), $MachinePrecision]), $MachinePrecision] / M$95$m), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := {\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}\\
t_1 := \sqrt{\ell} \cdot \sqrt{h}\\
\mathbf{if}\;d \leq -8.2 \cdot 10^{+203}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

\mathbf{elif}\;d \leq -1.65 \cdot 10^{-137}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t\_0}{\ell}, h \cdot -0.125, 1\right) \cdot \sqrt{\frac{d \cdot \frac{d}{h}}{\ell}}\\

\mathbf{elif}\;d \leq -7.5 \cdot 10^{-278}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(t\_0 \cdot \frac{h}{\ell}\right)\right)\right)\\

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

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


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

    1. Initial program 69.0%

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

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

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

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

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

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

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

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

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

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

    if -8.20000000000000033e203 < d < -1.6500000000000001e-137

    1. Initial program 79.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. Simplified79.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\left({\left(\frac{d}{h}\right)}^{0.5} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}\right) \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      5. pow-prod-down76.7%

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

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

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

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

        \[\leadsto {\left({\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, \color{blue}{h \cdot -0.125}, 1\right)\right)}^{1} \]
    10. Applied egg-rr75.4%

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

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

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

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

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

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

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

    if -1.6500000000000001e-137 < d < -7.49999999999999946e-278

    1. Initial program 49.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. Simplified45.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.49999999999999946e-278 < d < 1.15000000000000007e-198

    1. Initial program 33.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. Simplified33.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. Applied egg-rr39.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.15000000000000007e-198 < d

    1. Initial program 81.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. Simplified80.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. Applied egg-rr86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -7.60000000000000018e258

    1. Initial program 45.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. Simplified45.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. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

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

    if -7.60000000000000018e258 < d < -7.49999999999999946e-278

    1. Initial program 73.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. Simplified73.2%

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

    if -7.49999999999999946e-278 < d < 2.39999999999999996e-199

    1. Initial program 33.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. Simplified33.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. Applied egg-rr39.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.39999999999999996e-199 < d

    1. Initial program 81.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. Simplified80.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. Applied egg-rr86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

\mathbf{elif}\;d \leq -9.5 \cdot 10^{-138}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t\_0}{\ell}, h \cdot -0.125, 1\right) \cdot \sqrt{\frac{d \cdot \frac{d}{h}}{\ell}}\\

\mathbf{elif}\;d \leq -7.5 \cdot 10^{-278}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(t\_0 \cdot \frac{h}{\ell}\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -3.7999999999999999e206

    1. Initial program 69.0%

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

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

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

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

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

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

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

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

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

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

    if -3.7999999999999999e206 < d < -9.49999999999999997e-138

    1. Initial program 79.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. Simplified79.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\color{blue}{\left(D \cdot \frac{M}{d}\right)} \cdot \frac{\frac{D \cdot M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right) \]
      5. associate-*r/84.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{\color{blue}{D \cdot \frac{M}{d}}}{\ell}, -0.125 \cdot h, 1\right)\right) \]
    8. Applied egg-rr84.7%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\color{blue}{\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}}, -0.125 \cdot h, 1\right)\right) \]
    9. Step-by-step derivation
      1. pow184.7%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right)\right)}^{1}} \]
      2. associate-*r*84.7%

        \[\leadsto {\color{blue}{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right)}}^{1} \]
      3. pow1/284.7%

        \[\leadsto {\left(\left(\color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      4. pow1/284.7%

        \[\leadsto {\left(\left({\left(\frac{d}{h}\right)}^{0.5} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}\right) \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      5. pow-prod-down76.7%

        \[\leadsto {\left(\color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5}} \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      6. associate-*r/75.4%

        \[\leadsto {\left({\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\color{blue}{\frac{\left(D \cdot \frac{M}{d}\right) \cdot \left(D \cdot \frac{M}{d}\right)}{\ell}}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      7. pow275.4%

        \[\leadsto {\left({\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\frac{\color{blue}{{\left(D \cdot \frac{M}{d}\right)}^{2}}}{\ell}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      8. associate-*r/75.4%

        \[\leadsto {\left({\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\frac{{\color{blue}{\left(\frac{D \cdot M}{d}\right)}}^{2}}{\ell}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      9. *-commutative75.4%

        \[\leadsto {\left({\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, \color{blue}{h \cdot -0.125}, 1\right)\right)}^{1} \]
    10. Applied egg-rr75.4%

      \[\leadsto \color{blue}{{\left({\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, h \cdot -0.125, 1\right)\right)}^{1}} \]
    11. Step-by-step derivation
      1. unpow175.4%

        \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, h \cdot -0.125, 1\right)} \]
      2. unpow1/275.4%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot \mathsf{fma}\left(\frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, h \cdot -0.125, 1\right) \]
      3. associate-*r/78.2%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{d}{h} \cdot d}{\ell}}} \cdot \mathsf{fma}\left(\frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, h \cdot -0.125, 1\right) \]
      4. associate-/l*78.2%

        \[\leadsto \sqrt{\frac{\frac{d}{h} \cdot d}{\ell}} \cdot \mathsf{fma}\left(\frac{{\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}}{\ell}, h \cdot -0.125, 1\right) \]
      5. *-commutative78.2%

        \[\leadsto \sqrt{\frac{\frac{d}{h} \cdot d}{\ell}} \cdot \mathsf{fma}\left(\frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}, \color{blue}{-0.125 \cdot h}, 1\right) \]
    12. Simplified78.2%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{d}{h} \cdot d}{\ell}} \cdot \mathsf{fma}\left(\frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}, -0.125 \cdot h, 1\right)} \]

    if -9.49999999999999997e-138 < d < -7.49999999999999946e-278

    1. Initial program 49.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. Simplified45.6%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around inf 30.2%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*30.2%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2} \cdot \ell}\right)\right) \]
      2. times-frac30.2%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \color{blue}{\left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \frac{h}{\ell}\right)}\right)\right) \]
      3. *-commutative30.2%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}} \cdot \frac{h}{\ell}\right)\right)\right) \]
      4. associate-/l*30.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)} \cdot \frac{h}{\ell}\right)\right)\right) \]
      5. unpow230.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right) \cdot \frac{h}{\ell}\right)\right)\right) \]
      6. unpow230.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\left(\left(M \cdot M\right) \cdot \frac{\color{blue}{D \cdot D}}{{d}^{2}}\right) \cdot \frac{h}{\ell}\right)\right)\right) \]
      7. unpow230.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\color{blue}{d \cdot d}}\right) \cdot \frac{h}{\ell}\right)\right)\right) \]
      8. times-frac38.2%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right) \cdot \frac{h}{\ell}\right)\right)\right) \]
      9. swap-sqr42.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)} \cdot \frac{h}{\ell}\right)\right)\right) \]
      10. unpow242.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}} \cdot \frac{h}{\ell}\right)\right)\right) \]
      11. associate-*r/45.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left({\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \]
      12. *-commutative45.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left({\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \]
      13. associate-/l*45.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left({\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \]
    6. Simplified45.8%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(-0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]

    if -7.49999999999999946e-278 < d

    1. Initial program 70.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. Simplified69.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Applied egg-rr76.4%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow176.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)} \]
      2. associate-*l/79.4%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      3. associate-/l*80.7%

        \[\leadsto \color{blue}{d \cdot \frac{1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      4. +-commutative80.7%

        \[\leadsto d \cdot \frac{\color{blue}{-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right) + 1}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      5. associate-*r*80.7%

        \[\leadsto d \cdot \frac{\color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      6. fma-define80.7%

        \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(-0.5 \cdot \frac{h}{\ell}, {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}, 1\right)}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      7. *-commutative80.7%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{\frac{h}{\ell} \cdot -0.5}, {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      8. associate-*r/81.5%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      9. *-commutative81.5%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
    6. Simplified81.5%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    7. Step-by-step derivation
      1. fma-undefine81.5%

        \[\leadsto d \cdot \frac{\color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2} + 1}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      2. associate-/l*80.8%

        \[\leadsto d \cdot \frac{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)}}^{2} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. *-commutative80.8%

        \[\leadsto d \cdot \frac{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{\color{blue}{2 \cdot d}}\right)}^{2} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      4. associate-/l/80.8%

        \[\leadsto d \cdot \frac{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      5. associate-*l*80.8%

        \[\leadsto d \cdot \frac{\color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      6. div-inv80.8%

        \[\leadsto d \cdot \frac{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \color{blue}{\left(\frac{M}{d} \cdot \frac{1}{2}\right)}\right)}^{2}\right) + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      7. metadata-eval80.8%

        \[\leadsto d \cdot \frac{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot \color{blue}{0.5}\right)\right)}^{2}\right) + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
    8. Applied egg-rr80.8%

      \[\leadsto d \cdot \frac{\color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right) + 1}}{\sqrt{\ell} \cdot \sqrt{h}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification76.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.8 \cdot 10^{+206}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;d \leq -9.5 \cdot 10^{-138}:\\ \;\;\;\;\mathsf{fma}\left(\frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}, h \cdot -0.125, 1\right) \cdot \sqrt{\frac{d \cdot \frac{d}{h}}{\ell}}\\ \mathbf{elif}\;d \leq -7.5 \cdot 10^{-278}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 68.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} t_0 := {\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}\\ \mathbf{if}\;d \leq -3.6 \cdot 10^{+206}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;d \leq -2.6 \cdot 10^{-137}:\\ \;\;\;\;\mathsf{fma}\left(\frac{t\_0}{\ell}, h \cdot -0.125, 1\right) \cdot \sqrt{\frac{d \cdot \frac{d}{h}}{\ell}}\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{-286}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(t\_0 \cdot \frac{h}{\ell}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + t\_0 \cdot \frac{h \cdot -0.125}{\ell}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (pow (* D_m (/ M_m d)) 2.0)))
   (if (<= d -3.6e+206)
     (* (- d) (sqrt (/ (/ 1.0 h) l)))
     (if (<= d -2.6e-137)
       (* (fma (/ t_0 l) (* h -0.125) 1.0) (sqrt (/ (* d (/ d h)) l)))
       (if (<= d 2.7e-286)
         (* (sqrt (/ d h)) (* (sqrt (/ d l)) (* -0.125 (* t_0 (/ h l)))))
         (*
          (/ d (* (sqrt l) (sqrt h)))
          (+ 1.0 (* t_0 (/ (* h -0.125) 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 t_0 = pow((D_m * (M_m / d)), 2.0);
	double tmp;
	if (d <= -3.6e+206) {
		tmp = -d * sqrt(((1.0 / h) / l));
	} else if (d <= -2.6e-137) {
		tmp = fma((t_0 / l), (h * -0.125), 1.0) * sqrt(((d * (d / h)) / l));
	} else if (d <= 2.7e-286) {
		tmp = sqrt((d / h)) * (sqrt((d / l)) * (-0.125 * (t_0 * (h / l))));
	} else {
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (t_0 * ((h * -0.125) / 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)
	t_0 = Float64(D_m * Float64(M_m / d)) ^ 2.0
	tmp = 0.0
	if (d <= -3.6e+206)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l)));
	elseif (d <= -2.6e-137)
		tmp = Float64(fma(Float64(t_0 / l), Float64(h * -0.125), 1.0) * sqrt(Float64(Float64(d * Float64(d / h)) / l)));
	elseif (d <= 2.7e-286)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(-0.125 * Float64(t_0 * Float64(h / l)))));
	else
		tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(t_0 * Float64(Float64(h * -0.125) / l))));
	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[Power[N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[d, -3.6e+206], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.6e-137], N[(N[(N[(t$95$0 / l), $MachinePrecision] * N[(h * -0.125), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d * N[(d / h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.7e-286], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(-0.125 * N[(t$95$0 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(t$95$0 * N[(N[(h * -0.125), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := {\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}\\
\mathbf{if}\;d \leq -3.6 \cdot 10^{+206}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

\mathbf{elif}\;d \leq -2.6 \cdot 10^{-137}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t\_0}{\ell}, h \cdot -0.125, 1\right) \cdot \sqrt{\frac{d \cdot \frac{d}{h}}{\ell}}\\

\mathbf{elif}\;d \leq 2.7 \cdot 10^{-286}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(t\_0 \cdot \frac{h}{\ell}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + t\_0 \cdot \frac{h \cdot -0.125}{\ell}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -3.60000000000000028e206

    1. Initial program 69.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified69.0%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      2. associate-/r*0.0%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt80.6%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-180.6%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified80.6%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if -3.60000000000000028e206 < d < -2.6e-137

    1. Initial program 79.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. Simplified79.6%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 51.1%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(1 + -0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    5. Step-by-step derivation
      1. +-commutative51.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} + 1\right)}\right) \]
      2. associate-*r/51.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}} + 1\right)\right) \]
      3. associate-*r*52.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\frac{-0.125 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2} \cdot \ell} + 1\right)\right) \]
      4. associate-*r*52.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\frac{\color{blue}{\left(-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)\right) \cdot h}}{{d}^{2} \cdot \ell} + 1\right)\right) \]
      5. associate-*l/52.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)}{{d}^{2} \cdot \ell} \cdot h} + 1\right)\right) \]
      6. associate-*r/52.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)} \cdot h + 1\right)\right) \]
      7. *-commutative52.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} \cdot -0.125\right)} \cdot h + 1\right)\right) \]
      8. associate-*l*52.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} \cdot \left(-0.125 \cdot h\right)} + 1\right)\right) \]
      9. fma-define52.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}, -0.125 \cdot h, 1\right)}\right) \]
    6. Simplified82.3%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(\frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}, -0.125 \cdot h, 1\right)}\right) \]
    7. Step-by-step derivation
      1. associate-*r/82.2%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{{\color{blue}{\left(\frac{D \cdot M}{d}\right)}}^{2}}{\ell}, -0.125 \cdot h, 1\right)\right) \]
      2. pow282.2%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{\color{blue}{\frac{D \cdot M}{d} \cdot \frac{D \cdot M}{d}}}{\ell}, -0.125 \cdot h, 1\right)\right) \]
      3. associate-/l*83.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\color{blue}{\frac{D \cdot M}{d} \cdot \frac{\frac{D \cdot M}{d}}{\ell}}, -0.125 \cdot h, 1\right)\right) \]
      4. associate-*r/83.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\color{blue}{\left(D \cdot \frac{M}{d}\right)} \cdot \frac{\frac{D \cdot M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right) \]
      5. associate-*r/84.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{\color{blue}{D \cdot \frac{M}{d}}}{\ell}, -0.125 \cdot h, 1\right)\right) \]
    8. Applied egg-rr84.7%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\color{blue}{\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}}, -0.125 \cdot h, 1\right)\right) \]
    9. Step-by-step derivation
      1. pow184.7%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right)\right)}^{1}} \]
      2. associate-*r*84.7%

        \[\leadsto {\color{blue}{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right)}}^{1} \]
      3. pow1/284.7%

        \[\leadsto {\left(\left(\color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      4. pow1/284.7%

        \[\leadsto {\left(\left({\left(\frac{d}{h}\right)}^{0.5} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}\right) \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      5. pow-prod-down76.7%

        \[\leadsto {\left(\color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5}} \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      6. associate-*r/75.4%

        \[\leadsto {\left({\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\color{blue}{\frac{\left(D \cdot \frac{M}{d}\right) \cdot \left(D \cdot \frac{M}{d}\right)}{\ell}}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      7. pow275.4%

        \[\leadsto {\left({\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\frac{\color{blue}{{\left(D \cdot \frac{M}{d}\right)}^{2}}}{\ell}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      8. associate-*r/75.4%

        \[\leadsto {\left({\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\frac{{\color{blue}{\left(\frac{D \cdot M}{d}\right)}}^{2}}{\ell}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      9. *-commutative75.4%

        \[\leadsto {\left({\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, \color{blue}{h \cdot -0.125}, 1\right)\right)}^{1} \]
    10. Applied egg-rr75.4%

      \[\leadsto \color{blue}{{\left({\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, h \cdot -0.125, 1\right)\right)}^{1}} \]
    11. Step-by-step derivation
      1. unpow175.4%

        \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, h \cdot -0.125, 1\right)} \]
      2. unpow1/275.4%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot \mathsf{fma}\left(\frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, h \cdot -0.125, 1\right) \]
      3. associate-*r/78.2%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{d}{h} \cdot d}{\ell}}} \cdot \mathsf{fma}\left(\frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, h \cdot -0.125, 1\right) \]
      4. associate-/l*78.2%

        \[\leadsto \sqrt{\frac{\frac{d}{h} \cdot d}{\ell}} \cdot \mathsf{fma}\left(\frac{{\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}}{\ell}, h \cdot -0.125, 1\right) \]
      5. *-commutative78.2%

        \[\leadsto \sqrt{\frac{\frac{d}{h} \cdot d}{\ell}} \cdot \mathsf{fma}\left(\frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}, \color{blue}{-0.125 \cdot h}, 1\right) \]
    12. Simplified78.2%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{d}{h} \cdot d}{\ell}} \cdot \mathsf{fma}\left(\frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}, -0.125 \cdot h, 1\right)} \]

    if -2.6e-137 < d < 2.7000000000000002e-286

    1. Initial program 40.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. Simplified37.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 M around inf 24.0%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*24.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2} \cdot \ell}\right)\right) \]
      2. times-frac24.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \color{blue}{\left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \frac{h}{\ell}\right)}\right)\right) \]
      3. *-commutative24.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}} \cdot \frac{h}{\ell}\right)\right)\right) \]
      4. associate-/l*24.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)} \cdot \frac{h}{\ell}\right)\right)\right) \]
      5. unpow224.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right) \cdot \frac{h}{\ell}\right)\right)\right) \]
      6. unpow224.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\left(\left(M \cdot M\right) \cdot \frac{\color{blue}{D \cdot D}}{{d}^{2}}\right) \cdot \frac{h}{\ell}\right)\right)\right) \]
      7. unpow224.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\color{blue}{d \cdot d}}\right) \cdot \frac{h}{\ell}\right)\right)\right) \]
      8. times-frac30.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right) \cdot \frac{h}{\ell}\right)\right)\right) \]
      9. swap-sqr34.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)} \cdot \frac{h}{\ell}\right)\right)\right) \]
      10. unpow234.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}} \cdot \frac{h}{\ell}\right)\right)\right) \]
      11. associate-*r/37.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left({\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \]
      12. *-commutative37.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left({\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \]
      13. associate-/l*37.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left({\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \]
    6. Simplified37.5%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(-0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]

    if 2.7000000000000002e-286 < d

    1. Initial program 74.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified73.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Applied egg-rr80.4%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow180.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)} \]
      2. associate-*r*80.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}\right) \]
      3. *-commutative80.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right)} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right) \]
      4. associate-*r/81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}\right) \]
      5. *-commutative81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}\right) \]
      6. associate-*r/81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)}}^{2}\right) \]
      7. associate-*r*81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right)}\right) \]
      8. associate-*r*81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}\right) \]
      9. associate-/r*81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2}\right) \]
    6. Simplified81.3%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)} \]
    7. Step-by-step derivation
      1. associate-/l/81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{M}{2 \cdot d}}\right)}^{2}\right) \]
      2. *-commutative81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{\color{blue}{d \cdot 2}}\right)}^{2}\right) \]
      3. associate-/l*81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{D \cdot M}{d \cdot 2}\right)}}^{2}\right) \]
      4. associate-/r*81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{\frac{D \cdot M}{d}}{2}\right)}}^{2}\right) \]
    8. Applied egg-rr81.3%

      \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{\frac{D \cdot M}{d}}{2}\right)}}^{2}\right) \]
    9. Step-by-step derivation
      1. associate-*l*81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{\frac{D \cdot M}{d}}{2}\right)}^{2}\right)}\right) \]
      2. clear-num81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{1}{\frac{\ell}{h}}} \cdot \left(-0.5 \cdot {\left(\frac{\frac{D \cdot M}{d}}{2}\right)}^{2}\right)\right) \]
      3. associate-*l/81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{1 \cdot \left(-0.5 \cdot {\left(\frac{\frac{D \cdot M}{d}}{2}\right)}^{2}\right)}{\frac{\ell}{h}}}\right) \]
      4. *-un-lft-identity81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \frac{\color{blue}{-0.5 \cdot {\left(\frac{\frac{D \cdot M}{d}}{2}\right)}^{2}}}{\frac{\ell}{h}}\right) \]
      5. div-inv81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \frac{-0.5 \cdot {\color{blue}{\left(\frac{D \cdot M}{d} \cdot \frac{1}{2}\right)}}^{2}}{\frac{\ell}{h}}\right) \]
      6. metadata-eval81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(\frac{D \cdot M}{d} \cdot \color{blue}{0.5}\right)}^{2}}{\frac{\ell}{h}}\right) \]
      7. unpow-prod-down81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \frac{-0.5 \cdot \color{blue}{\left({\left(\frac{D \cdot M}{d}\right)}^{2} \cdot {0.5}^{2}\right)}}{\frac{\ell}{h}}\right) \]
      8. associate-*r/81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \frac{-0.5 \cdot \left({\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2} \cdot {0.5}^{2}\right)}{\frac{\ell}{h}}\right) \]
      9. metadata-eval81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \frac{-0.5 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \color{blue}{0.25}\right)}{\frac{\ell}{h}}\right) \]
    10. Applied egg-rr81.3%

      \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{-0.5 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot 0.25\right)}{\frac{\ell}{h}}}\right) \]
    11. Step-by-step derivation
      1. associate-/r/86.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{-0.5 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot 0.25\right)}{\ell} \cdot h}\right) \]
      2. associate-*l/85.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{\left(-0.5 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot 0.25\right)\right) \cdot h}{\ell}}\right) \]
      3. *-commutative85.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \frac{\color{blue}{h \cdot \left(-0.5 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot 0.25\right)\right)}}{\ell}\right) \]
      4. associate-*r*85.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \frac{\color{blue}{\left(h \cdot -0.5\right) \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot 0.25\right)}}{\ell}\right) \]
      5. *-commutative85.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \frac{\color{blue}{\left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot 0.25\right) \cdot \left(h \cdot -0.5\right)}}{\ell}\right) \]
      6. associate-*l*85.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \frac{\color{blue}{{\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \left(0.25 \cdot \left(h \cdot -0.5\right)\right)}}{\ell}\right) \]
      7. associate-/l*81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{{\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{0.25 \cdot \left(h \cdot -0.5\right)}{\ell}}\right) \]
      8. *-commutative81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{0.25 \cdot \color{blue}{\left(-0.5 \cdot h\right)}}{\ell}\right) \]
      9. associate-*r*81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{\color{blue}{\left(0.25 \cdot -0.5\right) \cdot h}}{\ell}\right) \]
      10. metadata-eval81.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{\color{blue}{-0.125} \cdot h}{\ell}\right) \]
    12. Simplified81.3%

      \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{{\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{-0.125 \cdot h}{\ell}}\right) \]
  3. Recombined 4 regimes into one program.
  4. Final simplification74.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.6 \cdot 10^{+206}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;d \leq -2.6 \cdot 10^{-137}:\\ \;\;\;\;\mathsf{fma}\left(\frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}, h \cdot -0.125, 1\right) \cdot \sqrt{\frac{d \cdot \frac{d}{h}}{\ell}}\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{-286}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h \cdot -0.125}{\ell}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 62.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} t_0 := \sqrt{h \cdot \ell}\\ \mathbf{if}\;\ell \leq -4.4 \cdot 10^{+117}:\\ \;\;\;\;\frac{-d}{t\_0}\\ \mathbf{elif}\;\ell \leq 2.65 \cdot 10^{-163}:\\ \;\;\;\;\mathsf{fma}\left(\frac{{\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}}{\ell}, h \cdot -0.125, 1\right) \cdot \sqrt{\frac{d \cdot \frac{d}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq 1.7 \cdot 10^{+160}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D\_m \cdot M\_m}{d \cdot 2}\right)}^{2}, 1\right)}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;{h}^{-0.5} \cdot \frac{d}{\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
 (let* ((t_0 (sqrt (* h l))))
   (if (<= l -4.4e+117)
     (/ (- d) t_0)
     (if (<= l 2.65e-163)
       (*
        (fma (/ (pow (* D_m (/ M_m d)) 2.0) l) (* h -0.125) 1.0)
        (sqrt (/ (* d (/ d h)) l)))
       (if (<= l 1.7e+160)
         (*
          d
          (/
           (fma (* (/ h l) -0.5) (pow (/ (* D_m M_m) (* d 2.0)) 2.0) 1.0)
           t_0))
         (* (pow h -0.5) (/ d (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 t_0 = sqrt((h * l));
	double tmp;
	if (l <= -4.4e+117) {
		tmp = -d / t_0;
	} else if (l <= 2.65e-163) {
		tmp = fma((pow((D_m * (M_m / d)), 2.0) / l), (h * -0.125), 1.0) * sqrt(((d * (d / h)) / l));
	} else if (l <= 1.7e+160) {
		tmp = d * (fma(((h / l) * -0.5), pow(((D_m * M_m) / (d * 2.0)), 2.0), 1.0) / t_0);
	} else {
		tmp = pow(h, -0.5) * (d / 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)
	t_0 = sqrt(Float64(h * l))
	tmp = 0.0
	if (l <= -4.4e+117)
		tmp = Float64(Float64(-d) / t_0);
	elseif (l <= 2.65e-163)
		tmp = Float64(fma(Float64((Float64(D_m * Float64(M_m / d)) ^ 2.0) / l), Float64(h * -0.125), 1.0) * sqrt(Float64(Float64(d * Float64(d / h)) / l)));
	elseif (l <= 1.7e+160)
		tmp = Float64(d * Float64(fma(Float64(Float64(h / l) * -0.5), (Float64(Float64(D_m * M_m) / Float64(d * 2.0)) ^ 2.0), 1.0) / t_0));
	else
		tmp = Float64((h ^ -0.5) * Float64(d / sqrt(l)));
	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[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -4.4e+117], N[((-d) / t$95$0), $MachinePrecision], If[LessEqual[l, 2.65e-163], N[(N[(N[(N[Power[N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision] * N[(h * -0.125), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d * N[(d / h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.7e+160], N[(d * N[(N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(N[(D$95$m * M$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Power[h, -0.5], $MachinePrecision] * N[(d / 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}
t_0 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;\ell \leq -4.4 \cdot 10^{+117}:\\
\;\;\;\;\frac{-d}{t\_0}\\

\mathbf{elif}\;\ell \leq 2.65 \cdot 10^{-163}:\\
\;\;\;\;\mathsf{fma}\left(\frac{{\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}}{\ell}, h \cdot -0.125, 1\right) \cdot \sqrt{\frac{d \cdot \frac{d}{h}}{\ell}}\\

\mathbf{elif}\;\ell \leq 1.7 \cdot 10^{+160}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D\_m \cdot M\_m}{d \cdot 2}\right)}^{2}, 1\right)}{t\_0}\\

\mathbf{else}:\\
\;\;\;\;{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -4.40000000000000028e117

    1. Initial program 46.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. Simplified46.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-*r/49.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}}\right) \]
      2. frac-times49.1%

        \[\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*49.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{2} \cdot h}{\ell}\right) \]
      4. *-commutative49.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right)}^{2} \cdot h}{\ell}\right) \]
    5. Applied egg-rr49.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2} \cdot h}{\ell}}\right) \]
    6. Step-by-step derivation
      1. *-commutative49.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{h \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}}{\ell}\right) \]
      2. associate-/l*49.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
      3. associate-*r/49.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}}{\ell}\right)\right) \]
      4. *-commutative49.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}}{\ell}\right)\right) \]
    7. Simplified49.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
    8. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. remove-double-neg0.0%

        \[\leadsto \color{blue}{-\left(-\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. associate-*l*0.0%

        \[\leadsto -\left(-\color{blue}{d \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}\right) \]
      3. *-commutative0.0%

        \[\leadsto -\left(-d \cdot \color{blue}{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)}\right) \]
      4. distribute-rgt-neg-in0.0%

        \[\leadsto -\color{blue}{d \cdot \left(-\sqrt{\frac{1}{h \cdot \ell}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      5. *-commutative0.0%

        \[\leadsto -d \cdot \left(-\color{blue}{{\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}}\right) \]
      6. unpow20.0%

        \[\leadsto -d \cdot \left(-\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      7. rem-square-sqrt50.7%

        \[\leadsto -d \cdot \left(-\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      8. mul-1-neg50.7%

        \[\leadsto -d \cdot \left(-\color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)}\right) \]
      9. remove-double-neg50.7%

        \[\leadsto -d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
      10. unpow1/250.7%

        \[\leadsto -d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      11. rem-exp-log47.1%

        \[\leadsto -d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      12. exp-neg47.1%

        \[\leadsto -d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      13. exp-prod47.1%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      14. distribute-lft-neg-out47.1%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      15. exp-neg47.1%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      16. exp-to-pow50.7%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      17. unpow1/250.7%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
    10. Simplified50.7%

      \[\leadsto \color{blue}{\frac{-d}{\sqrt{h \cdot \ell}}} \]

    if -4.40000000000000028e117 < l < 2.65000000000000008e-163

    1. Initial program 77.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. Simplified75.9%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 48.1%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(1 + -0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    5. Step-by-step derivation
      1. +-commutative48.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} + 1\right)}\right) \]
      2. associate-*r/48.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}} + 1\right)\right) \]
      3. associate-*r*48.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\frac{-0.125 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2} \cdot \ell} + 1\right)\right) \]
      4. associate-*r*48.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\frac{\color{blue}{\left(-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)\right) \cdot h}}{{d}^{2} \cdot \ell} + 1\right)\right) \]
      5. associate-*l/49.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)}{{d}^{2} \cdot \ell} \cdot h} + 1\right)\right) \]
      6. associate-*r/49.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)} \cdot h + 1\right)\right) \]
      7. *-commutative49.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} \cdot -0.125\right)} \cdot h + 1\right)\right) \]
      8. associate-*l*49.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} \cdot \left(-0.125 \cdot h\right)} + 1\right)\right) \]
      9. fma-define49.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}, -0.125 \cdot h, 1\right)}\right) \]
    6. Simplified80.8%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(\frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}, -0.125 \cdot h, 1\right)}\right) \]
    7. Step-by-step derivation
      1. associate-*r/80.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{{\color{blue}{\left(\frac{D \cdot M}{d}\right)}}^{2}}{\ell}, -0.125 \cdot h, 1\right)\right) \]
      2. pow280.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{\color{blue}{\frac{D \cdot M}{d} \cdot \frac{D \cdot M}{d}}}{\ell}, -0.125 \cdot h, 1\right)\right) \]
      3. associate-/l*80.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\color{blue}{\frac{D \cdot M}{d} \cdot \frac{\frac{D \cdot M}{d}}{\ell}}, -0.125 \cdot h, 1\right)\right) \]
      4. associate-*r/80.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\color{blue}{\left(D \cdot \frac{M}{d}\right)} \cdot \frac{\frac{D \cdot M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right) \]
      5. associate-*r/80.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{\color{blue}{D \cdot \frac{M}{d}}}{\ell}, -0.125 \cdot h, 1\right)\right) \]
    8. Applied egg-rr80.8%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\color{blue}{\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}}, -0.125 \cdot h, 1\right)\right) \]
    9. Step-by-step derivation
      1. pow180.8%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right)\right)}^{1}} \]
      2. associate-*r*80.8%

        \[\leadsto {\color{blue}{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right)}}^{1} \]
      3. pow1/280.8%

        \[\leadsto {\left(\left(\color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      4. pow1/280.8%

        \[\leadsto {\left(\left({\left(\frac{d}{h}\right)}^{0.5} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}\right) \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      5. pow-prod-down73.9%

        \[\leadsto {\left(\color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5}} \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      6. associate-*r/73.9%

        \[\leadsto {\left({\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\color{blue}{\frac{\left(D \cdot \frac{M}{d}\right) \cdot \left(D \cdot \frac{M}{d}\right)}{\ell}}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      7. pow273.9%

        \[\leadsto {\left({\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\frac{\color{blue}{{\left(D \cdot \frac{M}{d}\right)}^{2}}}{\ell}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      8. associate-*r/73.9%

        \[\leadsto {\left({\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\frac{{\color{blue}{\left(\frac{D \cdot M}{d}\right)}}^{2}}{\ell}, -0.125 \cdot h, 1\right)\right)}^{1} \]
      9. *-commutative73.9%

        \[\leadsto {\left({\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, \color{blue}{h \cdot -0.125}, 1\right)\right)}^{1} \]
    10. Applied egg-rr73.9%

      \[\leadsto \color{blue}{{\left({\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, h \cdot -0.125, 1\right)\right)}^{1}} \]
    11. Step-by-step derivation
      1. unpow173.9%

        \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \mathsf{fma}\left(\frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, h \cdot -0.125, 1\right)} \]
      2. unpow1/273.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot \mathsf{fma}\left(\frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, h \cdot -0.125, 1\right) \]
      3. associate-*r/71.5%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{d}{h} \cdot d}{\ell}}} \cdot \mathsf{fma}\left(\frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, h \cdot -0.125, 1\right) \]
      4. associate-/l*71.5%

        \[\leadsto \sqrt{\frac{\frac{d}{h} \cdot d}{\ell}} \cdot \mathsf{fma}\left(\frac{{\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}}{\ell}, h \cdot -0.125, 1\right) \]
      5. *-commutative71.5%

        \[\leadsto \sqrt{\frac{\frac{d}{h} \cdot d}{\ell}} \cdot \mathsf{fma}\left(\frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}, \color{blue}{-0.125 \cdot h}, 1\right) \]
    12. Simplified71.5%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{d}{h} \cdot d}{\ell}} \cdot \mathsf{fma}\left(\frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}, -0.125 \cdot h, 1\right)} \]

    if 2.65000000000000008e-163 < l < 1.70000000000000015e160

    1. Initial program 74.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. Simplified74.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. Applied egg-rr84.0%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow184.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)} \]
      2. associate-*l/87.3%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      3. associate-/l*89.8%

        \[\leadsto \color{blue}{d \cdot \frac{1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      4. +-commutative89.8%

        \[\leadsto d \cdot \frac{\color{blue}{-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right) + 1}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      5. associate-*r*89.8%

        \[\leadsto d \cdot \frac{\color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      6. fma-define89.8%

        \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(-0.5 \cdot \frac{h}{\ell}, {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}, 1\right)}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      7. *-commutative89.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{\frac{h}{\ell} \cdot -0.5}, {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      8. associate-*r/89.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      9. *-commutative89.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
    6. Simplified89.9%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    7. Taylor expanded in l around 0 83.1%

      \[\leadsto d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}, 1\right)}{\color{blue}{\sqrt{h \cdot \ell}}} \]

    if 1.70000000000000015e160 < l

    1. Initial program 61.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. Simplified61.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. Taylor expanded in d around inf 38.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div38.8%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval38.8%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative38.8%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod67.3%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv67.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-cube-cbrt66.6%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}\right) \cdot \sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}} \]
      7. pow366.6%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}\right)}^{3}} \]
      8. sqrt-unprod38.5%

        \[\leadsto {\left(\sqrt[3]{\frac{d}{\color{blue}{\sqrt{\ell \cdot h}}}}\right)}^{3} \]
      9. *-commutative38.5%

        \[\leadsto {\left(\sqrt[3]{\frac{d}{\sqrt{\color{blue}{h \cdot \ell}}}}\right)}^{3} \]
    6. Applied egg-rr38.5%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{d}{\sqrt{h \cdot \ell}}}\right)}^{3}} \]
    7. Step-by-step derivation
      1. rem-cube-cbrt38.7%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      2. sqrt-prod67.5%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. associate-/l/67.4%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
      4. clear-num66.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
    8. Applied egg-rr66.4%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity66.4%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
      2. associate-/r/67.5%

        \[\leadsto 1 \cdot \color{blue}{\left(\frac{1}{\sqrt{h}} \cdot \frac{d}{\sqrt{\ell}}\right)} \]
      3. pow1/267.5%

        \[\leadsto 1 \cdot \left(\frac{1}{\color{blue}{{h}^{0.5}}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
      4. pow-flip67.6%

        \[\leadsto 1 \cdot \left(\color{blue}{{h}^{\left(-0.5\right)}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
      5. metadata-eval67.6%

        \[\leadsto 1 \cdot \left({h}^{\color{blue}{-0.5}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
    10. Applied egg-rr67.6%

      \[\leadsto \color{blue}{1 \cdot \left({h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\right)} \]
    11. Step-by-step derivation
      1. *-lft-identity67.6%

        \[\leadsto \color{blue}{{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}} \]
    12. Simplified67.6%

      \[\leadsto \color{blue}{{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification71.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.4 \cdot 10^{+117}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq 2.65 \cdot 10^{-163}:\\ \;\;\;\;\mathsf{fma}\left(\frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}, h \cdot -0.125, 1\right) \cdot \sqrt{\frac{d \cdot \frac{d}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq 1.7 \cdot 10^{+160}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 59.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} \mathbf{if}\;\ell \leq -7.4 \cdot 10^{-184}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}\\ \mathbf{elif}\;\ell \leq 1.16 \cdot 10^{+162}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D\_m \cdot M\_m}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;{h}^{-0.5} \cdot \frac{d}{\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 (<= l -7.4e-184)
   (* (- d) (sqrt (/ (/ 1.0 h) l)))
   (if (<= l -5e-311)
     (* d (sqrt (log (exp (/ 1.0 (* h l))))))
     (if (<= l 1.16e+162)
       (*
        d
        (/
         (fma (* (/ h l) -0.5) (pow (/ (* D_m M_m) (* d 2.0)) 2.0) 1.0)
         (sqrt (* h l))))
       (* (pow h -0.5) (/ d (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 (l <= -7.4e-184) {
		tmp = -d * sqrt(((1.0 / h) / l));
	} else if (l <= -5e-311) {
		tmp = d * sqrt(log(exp((1.0 / (h * l)))));
	} else if (l <= 1.16e+162) {
		tmp = d * (fma(((h / l) * -0.5), pow(((D_m * M_m) / (d * 2.0)), 2.0), 1.0) / sqrt((h * l)));
	} else {
		tmp = pow(h, -0.5) * (d / 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 (l <= -7.4e-184)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l)));
	elseif (l <= -5e-311)
		tmp = Float64(d * sqrt(log(exp(Float64(1.0 / Float64(h * l))))));
	elseif (l <= 1.16e+162)
		tmp = Float64(d * Float64(fma(Float64(Float64(h / l) * -0.5), (Float64(Float64(D_m * M_m) / Float64(d * 2.0)) ^ 2.0), 1.0) / sqrt(Float64(h * l))));
	else
		tmp = Float64((h ^ -0.5) * Float64(d / sqrt(l)));
	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, -7.4e-184], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-311], N[(d * N[Sqrt[N[Log[N[Exp[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.16e+162], N[(d * N[(N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(N[(D$95$m * M$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[h, -0.5], $MachinePrecision] * N[(d / 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}\;\ell \leq -7.4 \cdot 10^{-184}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\
\;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}\\

\mathbf{elif}\;\ell \leq 1.16 \cdot 10^{+162}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D\_m \cdot M\_m}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{h \cdot \ell}}\\

\mathbf{else}:\\
\;\;\;\;{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -7.3999999999999997e-184

    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. 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. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      2. associate-/r*0.0%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt47.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-147.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified47.5%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if -7.3999999999999997e-184 < l < -5.00000000000023e-311

    1. Initial program 71.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified71.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 19.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. add-log-exp55.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}} \]
    6. Applied egg-rr55.0%

      \[\leadsto d \cdot \sqrt{\color{blue}{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}} \]

    if -5.00000000000023e-311 < l < 1.16000000000000006e162

    1. Initial program 75.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. Simplified74.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. Applied egg-rr81.5%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow181.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)} \]
      2. associate-*l/83.7%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      3. associate-/l*85.4%

        \[\leadsto \color{blue}{d \cdot \frac{1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      4. +-commutative85.4%

        \[\leadsto d \cdot \frac{\color{blue}{-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right) + 1}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      5. associate-*r*85.4%

        \[\leadsto d \cdot \frac{\color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      6. fma-define85.4%

        \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(-0.5 \cdot \frac{h}{\ell}, {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}, 1\right)}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      7. *-commutative85.4%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{\frac{h}{\ell} \cdot -0.5}, {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      8. associate-*r/86.4%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      9. *-commutative86.4%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
    6. Simplified86.4%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    7. Taylor expanded in l around 0 79.2%

      \[\leadsto d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}, 1\right)}{\color{blue}{\sqrt{h \cdot \ell}}} \]

    if 1.16000000000000006e162 < l

    1. Initial program 61.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. Simplified61.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. Taylor expanded in d around inf 38.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div38.8%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval38.8%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative38.8%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod67.3%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv67.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-cube-cbrt66.6%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}\right) \cdot \sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}} \]
      7. pow366.6%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}\right)}^{3}} \]
      8. sqrt-unprod38.5%

        \[\leadsto {\left(\sqrt[3]{\frac{d}{\color{blue}{\sqrt{\ell \cdot h}}}}\right)}^{3} \]
      9. *-commutative38.5%

        \[\leadsto {\left(\sqrt[3]{\frac{d}{\sqrt{\color{blue}{h \cdot \ell}}}}\right)}^{3} \]
    6. Applied egg-rr38.5%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{d}{\sqrt{h \cdot \ell}}}\right)}^{3}} \]
    7. Step-by-step derivation
      1. rem-cube-cbrt38.7%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      2. sqrt-prod67.5%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. associate-/l/67.4%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
      4. clear-num66.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
    8. Applied egg-rr66.4%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity66.4%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
      2. associate-/r/67.5%

        \[\leadsto 1 \cdot \color{blue}{\left(\frac{1}{\sqrt{h}} \cdot \frac{d}{\sqrt{\ell}}\right)} \]
      3. pow1/267.5%

        \[\leadsto 1 \cdot \left(\frac{1}{\color{blue}{{h}^{0.5}}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
      4. pow-flip67.6%

        \[\leadsto 1 \cdot \left(\color{blue}{{h}^{\left(-0.5\right)}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
      5. metadata-eval67.6%

        \[\leadsto 1 \cdot \left({h}^{\color{blue}{-0.5}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
    10. Applied egg-rr67.6%

      \[\leadsto \color{blue}{1 \cdot \left({h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\right)} \]
    11. Step-by-step derivation
      1. *-lft-identity67.6%

        \[\leadsto \color{blue}{{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}} \]
    12. Simplified67.6%

      \[\leadsto \color{blue}{{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification62.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7.4 \cdot 10^{-184}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}\\ \mathbf{elif}\;\ell \leq 1.16 \cdot 10^{+162}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 77.0% 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 := D\_m \cdot \frac{M\_m}{d}\\ t_1 := \sqrt{\ell} \cdot \sqrt{h}\\ \mathbf{if}\;d \leq -7.5 \cdot 10^{-278}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\mathsf{fma}\left(t\_0 \cdot \frac{t\_0}{\ell}, h \cdot -0.125, 1\right) \cdot \sqrt{\frac{d}{\ell}}\right)\\ \mathbf{elif}\;d \leq 2.6 \cdot 10^{-198}:\\ \;\;\;\;d \cdot \frac{1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D\_m \cdot \left(\frac{M\_m}{d} \cdot 0.5\right)\right)}^{2}\right)}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{t\_1} \cdot \left(1 + h \cdot \frac{-0.5 \cdot {\left(\frac{2 \cdot \frac{d}{D\_m}}{M\_m}\right)}^{-2}}{\ell}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (* D_m (/ M_m d))) (t_1 (* (sqrt l) (sqrt h))))
   (if (<= d -7.5e-278)
     (*
      (sqrt (/ d h))
      (* (fma (* t_0 (/ t_0 l)) (* h -0.125) 1.0) (sqrt (/ d l))))
     (if (<= d 2.6e-198)
       (*
        d
        (/
         (+ 1.0 (* (/ h l) (* -0.5 (pow (* D_m (* (/ M_m d) 0.5)) 2.0))))
         t_1))
       (*
        (/ d t_1)
        (+ 1.0 (* h (/ (* -0.5 (pow (/ (* 2.0 (/ d D_m)) M_m) -2.0)) l))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = D_m * (M_m / d);
	double t_1 = sqrt(l) * sqrt(h);
	double tmp;
	if (d <= -7.5e-278) {
		tmp = sqrt((d / h)) * (fma((t_0 * (t_0 / l)), (h * -0.125), 1.0) * sqrt((d / l)));
	} else if (d <= 2.6e-198) {
		tmp = d * ((1.0 + ((h / l) * (-0.5 * pow((D_m * ((M_m / d) * 0.5)), 2.0)))) / t_1);
	} else {
		tmp = (d / t_1) * (1.0 + (h * ((-0.5 * pow(((2.0 * (d / D_m)) / M_m), -2.0)) / l)));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(D_m * Float64(M_m / d))
	t_1 = Float64(sqrt(l) * sqrt(h))
	tmp = 0.0
	if (d <= -7.5e-278)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(fma(Float64(t_0 * Float64(t_0 / l)), Float64(h * -0.125), 1.0) * sqrt(Float64(d / l))));
	elseif (d <= 2.6e-198)
		tmp = Float64(d * Float64(Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(D_m * Float64(Float64(M_m / d) * 0.5)) ^ 2.0)))) / t_1));
	else
		tmp = Float64(Float64(d / t_1) * Float64(1.0 + Float64(h * Float64(Float64(-0.5 * (Float64(Float64(2.0 * Float64(d / D_m)) / M_m) ^ -2.0)) / l))));
	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[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7.5e-278], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision] * N[(h * -0.125), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.6e-198], N[(d * N[(N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(D$95$m * N[(N[(M$95$m / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(d / t$95$1), $MachinePrecision] * N[(1.0 + N[(h * N[(N[(-0.5 * N[Power[N[(N[(2.0 * N[(d / D$95$m), $MachinePrecision]), $MachinePrecision] / M$95$m), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := D\_m \cdot \frac{M\_m}{d}\\
t_1 := \sqrt{\ell} \cdot \sqrt{h}\\
\mathbf{if}\;d \leq -7.5 \cdot 10^{-278}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\mathsf{fma}\left(t\_0 \cdot \frac{t\_0}{\ell}, h \cdot -0.125, 1\right) \cdot \sqrt{\frac{d}{\ell}}\right)\\

\mathbf{elif}\;d \leq 2.6 \cdot 10^{-198}:\\
\;\;\;\;d \cdot \frac{1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D\_m \cdot \left(\frac{M\_m}{d} \cdot 0.5\right)\right)}^{2}\right)}{t\_1}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_1} \cdot \left(1 + h \cdot \frac{-0.5 \cdot {\left(\frac{2 \cdot \frac{d}{D\_m}}{M\_m}\right)}^{-2}}{\ell}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -7.49999999999999946e-278

    1. Initial program 71.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified70.5%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 42.6%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(1 + -0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    5. Step-by-step derivation
      1. +-commutative42.6%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} + 1\right)}\right) \]
      2. associate-*r/42.6%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}} + 1\right)\right) \]
      3. associate-*r*44.2%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\frac{-0.125 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2} \cdot \ell} + 1\right)\right) \]
      4. associate-*r*44.2%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\frac{\color{blue}{\left(-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)\right) \cdot h}}{{d}^{2} \cdot \ell} + 1\right)\right) \]
      5. associate-*l/44.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)}{{d}^{2} \cdot \ell} \cdot h} + 1\right)\right) \]
      6. associate-*r/44.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)} \cdot h + 1\right)\right) \]
      7. *-commutative44.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} \cdot -0.125\right)} \cdot h + 1\right)\right) \]
      8. associate-*l*44.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} \cdot \left(-0.125 \cdot h\right)} + 1\right)\right) \]
      9. fma-define44.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}, -0.125 \cdot h, 1\right)}\right) \]
    6. Simplified73.8%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(\frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}, -0.125 \cdot h, 1\right)}\right) \]
    7. Step-by-step derivation
      1. associate-*r/73.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{{\color{blue}{\left(\frac{D \cdot M}{d}\right)}}^{2}}{\ell}, -0.125 \cdot h, 1\right)\right) \]
      2. pow273.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{\color{blue}{\frac{D \cdot M}{d} \cdot \frac{D \cdot M}{d}}}{\ell}, -0.125 \cdot h, 1\right)\right) \]
      3. associate-/l*74.6%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\color{blue}{\frac{D \cdot M}{d} \cdot \frac{\frac{D \cdot M}{d}}{\ell}}, -0.125 \cdot h, 1\right)\right) \]
      4. associate-*r/74.6%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\color{blue}{\left(D \cdot \frac{M}{d}\right)} \cdot \frac{\frac{D \cdot M}{d}}{\ell}, -0.125 \cdot h, 1\right)\right) \]
      5. associate-*r/75.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{\color{blue}{D \cdot \frac{M}{d}}}{\ell}, -0.125 \cdot h, 1\right)\right) \]
    8. Applied egg-rr75.3%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\color{blue}{\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}}, -0.125 \cdot h, 1\right)\right) \]

    if -7.49999999999999946e-278 < d < 2.60000000000000007e-198

    1. Initial program 33.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. Simplified33.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. Applied egg-rr39.9%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow139.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)} \]
      2. associate-*l/59.6%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      3. associate-/l*59.7%

        \[\leadsto \color{blue}{d \cdot \frac{1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      4. +-commutative59.7%

        \[\leadsto d \cdot \frac{\color{blue}{-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right) + 1}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      5. associate-*r*59.7%

        \[\leadsto d \cdot \frac{\color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      6. fma-define59.7%

        \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(-0.5 \cdot \frac{h}{\ell}, {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}, 1\right)}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      7. *-commutative59.7%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{\frac{h}{\ell} \cdot -0.5}, {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      8. associate-*r/59.7%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      9. *-commutative59.7%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
    6. Simplified59.7%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    7. Step-by-step derivation
      1. fma-undefine59.7%

        \[\leadsto d \cdot \frac{\color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2} + 1}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      2. associate-/l*56.4%

        \[\leadsto d \cdot \frac{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)}}^{2} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. *-commutative56.4%

        \[\leadsto d \cdot \frac{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{\color{blue}{2 \cdot d}}\right)}^{2} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      4. associate-/l/56.4%

        \[\leadsto d \cdot \frac{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      5. associate-*l*56.4%

        \[\leadsto d \cdot \frac{\color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      6. div-inv56.4%

        \[\leadsto d \cdot \frac{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \color{blue}{\left(\frac{M}{d} \cdot \frac{1}{2}\right)}\right)}^{2}\right) + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      7. metadata-eval56.4%

        \[\leadsto d \cdot \frac{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot \color{blue}{0.5}\right)\right)}^{2}\right) + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
    8. Applied egg-rr56.4%

      \[\leadsto d \cdot \frac{\color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right) + 1}}{\sqrt{\ell} \cdot \sqrt{h}} \]

    if 2.60000000000000007e-198 < d

    1. Initial program 81.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. Simplified80.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. Applied egg-rr86.9%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow186.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)} \]
      2. associate-*r*86.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}\right) \]
      3. *-commutative86.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right)} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right) \]
      4. associate-*r/87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}\right) \]
      5. *-commutative87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}\right) \]
      6. associate-*r/87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)}}^{2}\right) \]
      7. associate-*r*87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right)}\right) \]
      8. associate-*r*87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}\right) \]
      9. associate-/r*87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2}\right) \]
    6. Simplified87.9%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)} \]
    7. Step-by-step derivation
      1. expm1-log1p-u57.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)\right)}\right) \]
      2. log1p-define57.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \mathsf{expm1}\left(\color{blue}{\log \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)}\right)\right) \]
      3. +-commutative57.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \mathsf{expm1}\left(\log \color{blue}{\left(\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2} + 1\right)}\right)\right) \]
      4. associate-/l/57.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \mathsf{expm1}\left(\log \left(\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{M}{2 \cdot d}}\right)}^{2} + 1\right)\right)\right) \]
      5. *-commutative57.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \mathsf{expm1}\left(\log \left(\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{\color{blue}{d \cdot 2}}\right)}^{2} + 1\right)\right)\right) \]
      6. associate-/l*57.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \mathsf{expm1}\left(\log \left(\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{D \cdot M}{d \cdot 2}\right)}}^{2} + 1\right)\right)\right) \]
      7. fma-undefine57.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \mathsf{expm1}\left(\log \color{blue}{\left(\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}, 1\right)\right)}\right)\right) \]
      8. expm1-undefine57.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(e^{\log \left(\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}, 1\right)\right)} - 1\right)}\right) \]
    8. Applied egg-rr87.9%

      \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}, 1\right) - 1\right)}\right) \]
    9. Step-by-step derivation
      1. fma-undefine87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\color{blue}{\left(\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2} + 1\right)} - 1\right)\right) \]
      2. associate-*r*87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\left(\color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right)} + 1\right) - 1\right)\right) \]
      3. associate--l+87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right) + \left(1 - 1\right)\right)}\right) \]
      4. metadata-eval87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right) + \color{blue}{0}\right)\right) \]
      5. +-rgt-identity87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right)}\right) \]
      6. associate-*l/93.0%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{h \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right)}{\ell}}\right) \]
      7. associate-/l*93.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{h \cdot \frac{-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}}{\ell}}\right) \]
    10. Simplified92.9%

      \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{h \cdot \frac{-0.5 \cdot {\left(\frac{2 \cdot \frac{d}{D}}{M}\right)}^{-2}}{\ell}}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification80.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.5 \cdot 10^{-278}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\mathsf{fma}\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}, h \cdot -0.125, 1\right) \cdot \sqrt{\frac{d}{\ell}}\right)\\ \mathbf{elif}\;d \leq 2.6 \cdot 10^{-198}:\\ \;\;\;\;d \cdot \frac{1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + h \cdot \frac{-0.5 \cdot {\left(\frac{2 \cdot \frac{d}{D}}{M}\right)}^{-2}}{\ell}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 76.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 := \sqrt{\ell} \cdot \sqrt{h}\\ \mathbf{if}\;d \leq -7.5 \cdot 10^{-278}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{D\_m \cdot M\_m}{d \cdot 2}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{elif}\;d \leq 2.6 \cdot 10^{-199}:\\ \;\;\;\;d \cdot \frac{1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D\_m \cdot \left(\frac{M\_m}{d} \cdot 0.5\right)\right)}^{2}\right)}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{t\_0} \cdot \left(1 + h \cdot \frac{-0.5 \cdot {\left(\frac{2 \cdot \frac{d}{D\_m}}{M\_m}\right)}^{-2}}{\ell}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (* (sqrt l) (sqrt h))))
   (if (<= d -7.5e-278)
     (*
      (* (sqrt (/ d h)) (sqrt (/ d l)))
      (- 1.0 (* 0.5 (* h (/ (pow (/ (* D_m M_m) (* d 2.0)) 2.0) l)))))
     (if (<= d 2.6e-199)
       (*
        d
        (/
         (+ 1.0 (* (/ h l) (* -0.5 (pow (* D_m (* (/ M_m d) 0.5)) 2.0))))
         t_0))
       (*
        (/ d t_0)
        (+ 1.0 (* h (/ (* -0.5 (pow (/ (* 2.0 (/ d D_m)) M_m) -2.0)) l))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt(l) * sqrt(h);
	double tmp;
	if (d <= -7.5e-278) {
		tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * (h * (pow(((D_m * M_m) / (d * 2.0)), 2.0) / l))));
	} else if (d <= 2.6e-199) {
		tmp = d * ((1.0 + ((h / l) * (-0.5 * pow((D_m * ((M_m / d) * 0.5)), 2.0)))) / t_0);
	} else {
		tmp = (d / t_0) * (1.0 + (h * ((-0.5 * pow(((2.0 * (d / D_m)) / M_m), -2.0)) / l)));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt(l) * sqrt(h)
    if (d <= (-7.5d-278)) then
        tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0d0 - (0.5d0 * (h * ((((d_m * m_m) / (d * 2.0d0)) ** 2.0d0) / l))))
    else if (d <= 2.6d-199) then
        tmp = d * ((1.0d0 + ((h / l) * ((-0.5d0) * ((d_m * ((m_m / d) * 0.5d0)) ** 2.0d0)))) / t_0)
    else
        tmp = (d / t_0) * (1.0d0 + (h * (((-0.5d0) * (((2.0d0 * (d / d_m)) / m_m) ** (-2.0d0))) / l)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = Math.sqrt(l) * Math.sqrt(h);
	double tmp;
	if (d <= -7.5e-278) {
		tmp = (Math.sqrt((d / h)) * Math.sqrt((d / l))) * (1.0 - (0.5 * (h * (Math.pow(((D_m * M_m) / (d * 2.0)), 2.0) / l))));
	} else if (d <= 2.6e-199) {
		tmp = d * ((1.0 + ((h / l) * (-0.5 * Math.pow((D_m * ((M_m / d) * 0.5)), 2.0)))) / t_0);
	} else {
		tmp = (d / t_0) * (1.0 + (h * ((-0.5 * Math.pow(((2.0 * (d / D_m)) / M_m), -2.0)) / l)));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = math.sqrt(l) * math.sqrt(h)
	tmp = 0
	if d <= -7.5e-278:
		tmp = (math.sqrt((d / h)) * math.sqrt((d / l))) * (1.0 - (0.5 * (h * (math.pow(((D_m * M_m) / (d * 2.0)), 2.0) / l))))
	elif d <= 2.6e-199:
		tmp = d * ((1.0 + ((h / l) * (-0.5 * math.pow((D_m * ((M_m / d) * 0.5)), 2.0)))) / t_0)
	else:
		tmp = (d / t_0) * (1.0 + (h * ((-0.5 * math.pow(((2.0 * (d / D_m)) / M_m), -2.0)) / l)))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(sqrt(l) * sqrt(h))
	tmp = 0.0
	if (d <= -7.5e-278)
		tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * Float64(h * Float64((Float64(Float64(D_m * M_m) / Float64(d * 2.0)) ^ 2.0) / l)))));
	elseif (d <= 2.6e-199)
		tmp = Float64(d * Float64(Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(D_m * Float64(Float64(M_m / d) * 0.5)) ^ 2.0)))) / t_0));
	else
		tmp = Float64(Float64(d / t_0) * Float64(1.0 + Float64(h * Float64(Float64(-0.5 * (Float64(Float64(2.0 * Float64(d / D_m)) / M_m) ^ -2.0)) / l))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = sqrt(l) * sqrt(h);
	tmp = 0.0;
	if (d <= -7.5e-278)
		tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * (h * ((((D_m * M_m) / (d * 2.0)) ^ 2.0) / l))));
	elseif (d <= 2.6e-199)
		tmp = d * ((1.0 + ((h / l) * (-0.5 * ((D_m * ((M_m / d) * 0.5)) ^ 2.0)))) / t_0);
	else
		tmp = (d / t_0) * (1.0 + (h * ((-0.5 * (((2.0 * (d / D_m)) / M_m) ^ -2.0)) / l)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7.5e-278], 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[Power[N[(N[(D$95$m * M$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.6e-199], N[(d * N[(N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(D$95$m * N[(N[(M$95$m / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(d / t$95$0), $MachinePrecision] * N[(1.0 + N[(h * N[(N[(-0.5 * N[Power[N[(N[(2.0 * N[(d / D$95$m), $MachinePrecision]), $MachinePrecision] / M$95$m), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell} \cdot \sqrt{h}\\
\mathbf{if}\;d \leq -7.5 \cdot 10^{-278}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{D\_m \cdot M\_m}{d \cdot 2}\right)}^{2}}{\ell}\right)\right)\\

\mathbf{elif}\;d \leq 2.6 \cdot 10^{-199}:\\
\;\;\;\;d \cdot \frac{1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D\_m \cdot \left(\frac{M\_m}{d} \cdot 0.5\right)\right)}^{2}\right)}{t\_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_0} \cdot \left(1 + h \cdot \frac{-0.5 \cdot {\left(\frac{2 \cdot \frac{d}{D\_m}}{M\_m}\right)}^{-2}}{\ell}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -7.49999999999999946e-278

    1. Initial program 71.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified70.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/73.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}}\right) \]
      2. frac-times74.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.7%

        \[\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. *-commutative73.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right)}^{2} \cdot h}{\ell}\right) \]
    5. Applied egg-rr73.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2} \cdot h}{\ell}}\right) \]
    6. Step-by-step derivation
      1. *-commutative73.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{h \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}}{\ell}\right) \]
      2. associate-/l*73.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
      3. associate-*r/73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}}{\ell}\right)\right) \]
      4. *-commutative73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}}{\ell}\right)\right) \]
    7. Simplified73.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]

    if -7.49999999999999946e-278 < d < 2.6000000000000001e-199

    1. Initial program 33.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. Simplified33.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. Applied egg-rr39.9%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow139.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)} \]
      2. associate-*l/59.6%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      3. associate-/l*59.7%

        \[\leadsto \color{blue}{d \cdot \frac{1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      4. +-commutative59.7%

        \[\leadsto d \cdot \frac{\color{blue}{-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right) + 1}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      5. associate-*r*59.7%

        \[\leadsto d \cdot \frac{\color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      6. fma-define59.7%

        \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(-0.5 \cdot \frac{h}{\ell}, {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}, 1\right)}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      7. *-commutative59.7%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{\frac{h}{\ell} \cdot -0.5}, {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      8. associate-*r/59.7%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      9. *-commutative59.7%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
    6. Simplified59.7%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    7. Step-by-step derivation
      1. fma-undefine59.7%

        \[\leadsto d \cdot \frac{\color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2} + 1}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      2. associate-/l*56.4%

        \[\leadsto d \cdot \frac{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)}}^{2} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. *-commutative56.4%

        \[\leadsto d \cdot \frac{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{\color{blue}{2 \cdot d}}\right)}^{2} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      4. associate-/l/56.4%

        \[\leadsto d \cdot \frac{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      5. associate-*l*56.4%

        \[\leadsto d \cdot \frac{\color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      6. div-inv56.4%

        \[\leadsto d \cdot \frac{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \color{blue}{\left(\frac{M}{d} \cdot \frac{1}{2}\right)}\right)}^{2}\right) + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      7. metadata-eval56.4%

        \[\leadsto d \cdot \frac{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot \color{blue}{0.5}\right)\right)}^{2}\right) + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
    8. Applied egg-rr56.4%

      \[\leadsto d \cdot \frac{\color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right) + 1}}{\sqrt{\ell} \cdot \sqrt{h}} \]

    if 2.6000000000000001e-199 < d

    1. Initial program 81.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. Simplified80.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. Applied egg-rr86.9%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow186.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)} \]
      2. associate-*r*86.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}\right) \]
      3. *-commutative86.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right)} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right) \]
      4. associate-*r/87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}\right) \]
      5. *-commutative87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}\right) \]
      6. associate-*r/87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)}}^{2}\right) \]
      7. associate-*r*87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right)}\right) \]
      8. associate-*r*87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}\right) \]
      9. associate-/r*87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2}\right) \]
    6. Simplified87.9%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)} \]
    7. Step-by-step derivation
      1. expm1-log1p-u57.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)\right)}\right) \]
      2. log1p-define57.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \mathsf{expm1}\left(\color{blue}{\log \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)}\right)\right) \]
      3. +-commutative57.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \mathsf{expm1}\left(\log \color{blue}{\left(\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2} + 1\right)}\right)\right) \]
      4. associate-/l/57.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \mathsf{expm1}\left(\log \left(\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{M}{2 \cdot d}}\right)}^{2} + 1\right)\right)\right) \]
      5. *-commutative57.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \mathsf{expm1}\left(\log \left(\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{\color{blue}{d \cdot 2}}\right)}^{2} + 1\right)\right)\right) \]
      6. associate-/l*57.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \mathsf{expm1}\left(\log \left(\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{D \cdot M}{d \cdot 2}\right)}}^{2} + 1\right)\right)\right) \]
      7. fma-undefine57.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \mathsf{expm1}\left(\log \color{blue}{\left(\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}, 1\right)\right)}\right)\right) \]
      8. expm1-undefine57.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(e^{\log \left(\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}, 1\right)\right)} - 1\right)}\right) \]
    8. Applied egg-rr87.9%

      \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}, 1\right) - 1\right)}\right) \]
    9. Step-by-step derivation
      1. fma-undefine87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\color{blue}{\left(\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2} + 1\right)} - 1\right)\right) \]
      2. associate-*r*87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\left(\color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right)} + 1\right) - 1\right)\right) \]
      3. associate--l+87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right) + \left(1 - 1\right)\right)}\right) \]
      4. metadata-eval87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right) + \color{blue}{0}\right)\right) \]
      5. +-rgt-identity87.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right)}\right) \]
      6. associate-*l/93.0%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{h \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right)}{\ell}}\right) \]
      7. associate-/l*93.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{h \cdot \frac{-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}}{\ell}}\right) \]
    10. Simplified92.9%

      \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{h \cdot \frac{-0.5 \cdot {\left(\frac{2 \cdot \frac{d}{D}}{M}\right)}^{-2}}{\ell}}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification79.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.5 \cdot 10^{-278}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{elif}\;d \leq 2.6 \cdot 10^{-199}:\\ \;\;\;\;d \cdot \frac{1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + h \cdot \frac{-0.5 \cdot {\left(\frac{2 \cdot \frac{d}{D}}{M}\right)}^{-2}}{\ell}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 53.9% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h}}\\ t_1 := \sqrt{\frac{d}{\ell}}\\ \mathbf{if}\;M\_m \leq 1.35 \cdot 10^{-44}:\\ \;\;\;\;t\_0 \cdot t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(t\_1 \cdot \left(-0.125 \cdot \left({\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (/ d h))) (t_1 (sqrt (/ d l))))
   (if (<= M_m 1.35e-44)
     (* t_0 t_1)
     (* t_0 (* t_1 (* -0.125 (* (pow (* D_m (/ M_m d)) 2.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 t_0 = sqrt((d / h));
	double t_1 = sqrt((d / l));
	double tmp;
	if (M_m <= 1.35e-44) {
		tmp = t_0 * t_1;
	} else {
		tmp = t_0 * (t_1 * (-0.125 * (pow((D_m * (M_m / d)), 2.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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = sqrt((d / h))
    t_1 = sqrt((d / l))
    if (m_m <= 1.35d-44) then
        tmp = t_0 * t_1
    else
        tmp = t_0 * (t_1 * ((-0.125d0) * (((d_m * (m_m / d)) ** 2.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 t_0 = Math.sqrt((d / h));
	double t_1 = Math.sqrt((d / l));
	double tmp;
	if (M_m <= 1.35e-44) {
		tmp = t_0 * t_1;
	} else {
		tmp = t_0 * (t_1 * (-0.125 * (Math.pow((D_m * (M_m / d)), 2.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):
	t_0 = math.sqrt((d / h))
	t_1 = math.sqrt((d / l))
	tmp = 0
	if M_m <= 1.35e-44:
		tmp = t_0 * t_1
	else:
		tmp = t_0 * (t_1 * (-0.125 * (math.pow((D_m * (M_m / d)), 2.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)
	t_0 = sqrt(Float64(d / h))
	t_1 = sqrt(Float64(d / l))
	tmp = 0.0
	if (M_m <= 1.35e-44)
		tmp = Float64(t_0 * t_1);
	else
		tmp = Float64(t_0 * Float64(t_1 * Float64(-0.125 * Float64((Float64(D_m * Float64(M_m / d)) ^ 2.0) * Float64(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)
	t_0 = sqrt((d / h));
	t_1 = sqrt((d / l));
	tmp = 0.0;
	if (M_m <= 1.35e-44)
		tmp = t_0 * t_1;
	else
		tmp = t_0 * (t_1 * (-0.125 * (((D_m * (M_m / d)) ^ 2.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_] := Block[{t$95$0 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M$95$m, 1.35e-44], N[(t$95$0 * t$95$1), $MachinePrecision], N[(t$95$0 * N[(t$95$1 * N[(-0.125 * N[(N[Power[N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $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 := \sqrt{\frac{d}{h}}\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;M\_m \leq 1.35 \cdot 10^{-44}:\\
\;\;\;\;t\_0 \cdot t\_1\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(t\_1 \cdot \left(-0.125 \cdot \left({\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 1.35e-44

    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. Simplified67.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 M around 0 48.2%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]

    if 1.35e-44 < M

    1. Initial program 76.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. Simplified76.6%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around inf 30.9%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*32.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2} \cdot \ell}\right)\right) \]
      2. times-frac36.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \color{blue}{\left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \frac{h}{\ell}\right)}\right)\right) \]
      3. *-commutative36.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}} \cdot \frac{h}{\ell}\right)\right)\right) \]
      4. associate-/l*36.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)} \cdot \frac{h}{\ell}\right)\right)\right) \]
      5. unpow236.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right) \cdot \frac{h}{\ell}\right)\right)\right) \]
      6. unpow236.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\left(\left(M \cdot M\right) \cdot \frac{\color{blue}{D \cdot D}}{{d}^{2}}\right) \cdot \frac{h}{\ell}\right)\right)\right) \]
      7. unpow236.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\color{blue}{d \cdot d}}\right) \cdot \frac{h}{\ell}\right)\right)\right) \]
      8. times-frac48.2%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right) \cdot \frac{h}{\ell}\right)\right)\right) \]
      9. swap-sqr53.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)} \cdot \frac{h}{\ell}\right)\right)\right) \]
      10. unpow253.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left(\color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}} \cdot \frac{h}{\ell}\right)\right)\right) \]
      11. associate-*r/53.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left({\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \]
      12. *-commutative53.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left({\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \]
      13. associate-/l*53.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left({\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \]
    6. Simplified53.3%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(-0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification49.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 1.35 \cdot 10^{-44}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(-0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 59.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 -1 \cdot 10^{-184}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}\\ \mathbf{elif}\;\ell \leq 5.2 \cdot 10^{+164}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\frac{D\_m \cdot M\_m}{d}}{2}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;{h}^{-0.5} \cdot \frac{d}{\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 (<= l -1e-184)
   (* (- d) (sqrt (/ (/ 1.0 h) l)))
   (if (<= l -5e-311)
     (* d (sqrt (log (exp (/ 1.0 (* h l))))))
     (if (<= l 5.2e+164)
       (*
        (/ d (sqrt (* h l)))
        (+ 1.0 (* (* (/ h l) -0.5) (pow (/ (/ (* D_m M_m) d) 2.0) 2.0))))
       (* (pow h -0.5) (/ d (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 (l <= -1e-184) {
		tmp = -d * sqrt(((1.0 / h) / l));
	} else if (l <= -5e-311) {
		tmp = d * sqrt(log(exp((1.0 / (h * l)))));
	} else if (l <= 5.2e+164) {
		tmp = (d / sqrt((h * l))) * (1.0 + (((h / l) * -0.5) * pow((((D_m * M_m) / d) / 2.0), 2.0)));
	} else {
		tmp = pow(h, -0.5) * (d / 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 (l <= (-1d-184)) then
        tmp = -d * sqrt(((1.0d0 / h) / l))
    else if (l <= (-5d-311)) then
        tmp = d * sqrt(log(exp((1.0d0 / (h * l)))))
    else if (l <= 5.2d+164) then
        tmp = (d / sqrt((h * l))) * (1.0d0 + (((h / l) * (-0.5d0)) * ((((d_m * m_m) / d) / 2.0d0) ** 2.0d0)))
    else
        tmp = (h ** (-0.5d0)) * (d / 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 (l <= -1e-184) {
		tmp = -d * Math.sqrt(((1.0 / h) / l));
	} else if (l <= -5e-311) {
		tmp = d * Math.sqrt(Math.log(Math.exp((1.0 / (h * l)))));
	} else if (l <= 5.2e+164) {
		tmp = (d / Math.sqrt((h * l))) * (1.0 + (((h / l) * -0.5) * Math.pow((((D_m * M_m) / d) / 2.0), 2.0)));
	} else {
		tmp = Math.pow(h, -0.5) * (d / 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 l <= -1e-184:
		tmp = -d * math.sqrt(((1.0 / h) / l))
	elif l <= -5e-311:
		tmp = d * math.sqrt(math.log(math.exp((1.0 / (h * l)))))
	elif l <= 5.2e+164:
		tmp = (d / math.sqrt((h * l))) * (1.0 + (((h / l) * -0.5) * math.pow((((D_m * M_m) / d) / 2.0), 2.0)))
	else:
		tmp = math.pow(h, -0.5) * (d / 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 (l <= -1e-184)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l)));
	elseif (l <= -5e-311)
		tmp = Float64(d * sqrt(log(exp(Float64(1.0 / Float64(h * l))))));
	elseif (l <= 5.2e+164)
		tmp = Float64(Float64(d / sqrt(Float64(h * l))) * Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(Float64(Float64(D_m * M_m) / d) / 2.0) ^ 2.0))));
	else
		tmp = Float64((h ^ -0.5) * Float64(d / 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 (l <= -1e-184)
		tmp = -d * sqrt(((1.0 / h) / l));
	elseif (l <= -5e-311)
		tmp = d * sqrt(log(exp((1.0 / (h * l)))));
	elseif (l <= 5.2e+164)
		tmp = (d / sqrt((h * l))) * (1.0 + (((h / l) * -0.5) * ((((D_m * M_m) / d) / 2.0) ^ 2.0)));
	else
		tmp = (h ^ -0.5) * (d / 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[l, -1e-184], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-311], N[(d * N[Sqrt[N[Log[N[Exp[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.2e+164], N[(N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision] / 2.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[h, -0.5], $MachinePrecision] * N[(d / 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}\;\ell \leq -1 \cdot 10^{-184}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\
\;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}\\

\mathbf{elif}\;\ell \leq 5.2 \cdot 10^{+164}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\frac{D\_m \cdot M\_m}{d}}{2}\right)}^{2}\right)\\

\mathbf{else}:\\
\;\;\;\;{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -1.0000000000000001e-184

    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. 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. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      2. associate-/r*0.0%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt47.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-147.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified47.5%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if -1.0000000000000001e-184 < l < -5.00000000000023e-311

    1. Initial program 71.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified71.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 19.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. add-log-exp55.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}} \]
    6. Applied egg-rr55.0%

      \[\leadsto d \cdot \sqrt{\color{blue}{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}} \]

    if -5.00000000000023e-311 < l < 5.1999999999999998e164

    1. Initial program 75.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. Simplified74.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. Applied egg-rr81.5%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow181.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)} \]
      2. associate-*r*81.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}\right) \]
      3. *-commutative81.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right)} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right) \]
      4. associate-*r/82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}\right) \]
      5. *-commutative82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}\right) \]
      6. associate-*r/82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)}}^{2}\right) \]
      7. associate-*r*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right)}\right) \]
      8. associate-*r*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}\right) \]
      9. associate-/r*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2}\right) \]
    6. Simplified82.5%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)} \]
    7. Step-by-step derivation
      1. associate-/l/82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{M}{2 \cdot d}}\right)}^{2}\right) \]
      2. *-commutative82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{\color{blue}{d \cdot 2}}\right)}^{2}\right) \]
      3. associate-/l*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{D \cdot M}{d \cdot 2}\right)}}^{2}\right) \]
      4. associate-/r*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{\frac{D \cdot M}{d}}{2}\right)}}^{2}\right) \]
    8. Applied egg-rr82.5%

      \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{\frac{D \cdot M}{d}}{2}\right)}}^{2}\right) \]
    9. Taylor expanded in l around 0 77.1%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\frac{D \cdot M}{d}}{2}\right)}^{2}\right) \]

    if 5.1999999999999998e164 < l

    1. Initial program 61.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. Simplified61.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. Taylor expanded in d around inf 38.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div38.8%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval38.8%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative38.8%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod67.3%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv67.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-cube-cbrt66.6%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}\right) \cdot \sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}} \]
      7. pow366.6%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}\right)}^{3}} \]
      8. sqrt-unprod38.5%

        \[\leadsto {\left(\sqrt[3]{\frac{d}{\color{blue}{\sqrt{\ell \cdot h}}}}\right)}^{3} \]
      9. *-commutative38.5%

        \[\leadsto {\left(\sqrt[3]{\frac{d}{\sqrt{\color{blue}{h \cdot \ell}}}}\right)}^{3} \]
    6. Applied egg-rr38.5%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{d}{\sqrt{h \cdot \ell}}}\right)}^{3}} \]
    7. Step-by-step derivation
      1. rem-cube-cbrt38.7%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      2. sqrt-prod67.5%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. associate-/l/67.4%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
      4. clear-num66.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
    8. Applied egg-rr66.4%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity66.4%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
      2. associate-/r/67.5%

        \[\leadsto 1 \cdot \color{blue}{\left(\frac{1}{\sqrt{h}} \cdot \frac{d}{\sqrt{\ell}}\right)} \]
      3. pow1/267.5%

        \[\leadsto 1 \cdot \left(\frac{1}{\color{blue}{{h}^{0.5}}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
      4. pow-flip67.6%

        \[\leadsto 1 \cdot \left(\color{blue}{{h}^{\left(-0.5\right)}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
      5. metadata-eval67.6%

        \[\leadsto 1 \cdot \left({h}^{\color{blue}{-0.5}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
    10. Applied egg-rr67.6%

      \[\leadsto \color{blue}{1 \cdot \left({h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\right)} \]
    11. Step-by-step derivation
      1. *-lft-identity67.6%

        \[\leadsto \color{blue}{{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}} \]
    12. Simplified67.6%

      \[\leadsto \color{blue}{{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification61.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1 \cdot 10^{-184}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}\\ \mathbf{elif}\;\ell \leq 5.2 \cdot 10^{+164}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\frac{D \cdot M}{d}}{2}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 59.1% accurate, 1.1× 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{h \cdot \ell}\\ \mathbf{if}\;\ell \leq -2.35 \cdot 10^{-183}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\frac{d}{\log \left(e^{t\_0}\right)}\\ \mathbf{elif}\;\ell \leq 1.9 \cdot 10^{+161}:\\ \;\;\;\;\frac{d}{t\_0} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\frac{D\_m \cdot M\_m}{d}}{2}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;{h}^{-0.5} \cdot \frac{d}{\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
 (let* ((t_0 (sqrt (* h l))))
   (if (<= l -2.35e-183)
     (* (- d) (sqrt (/ (/ 1.0 h) l)))
     (if (<= l -5e-311)
       (/ d (log (exp t_0)))
       (if (<= l 1.9e+161)
         (*
          (/ d t_0)
          (+ 1.0 (* (* (/ h l) -0.5) (pow (/ (/ (* D_m M_m) d) 2.0) 2.0))))
         (* (pow h -0.5) (/ d (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 t_0 = sqrt((h * l));
	double tmp;
	if (l <= -2.35e-183) {
		tmp = -d * sqrt(((1.0 / h) / l));
	} else if (l <= -5e-311) {
		tmp = d / log(exp(t_0));
	} else if (l <= 1.9e+161) {
		tmp = (d / t_0) * (1.0 + (((h / l) * -0.5) * pow((((D_m * M_m) / d) / 2.0), 2.0)));
	} else {
		tmp = pow(h, -0.5) * (d / 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) :: t_0
    real(8) :: tmp
    t_0 = sqrt((h * l))
    if (l <= (-2.35d-183)) then
        tmp = -d * sqrt(((1.0d0 / h) / l))
    else if (l <= (-5d-311)) then
        tmp = d / log(exp(t_0))
    else if (l <= 1.9d+161) then
        tmp = (d / t_0) * (1.0d0 + (((h / l) * (-0.5d0)) * ((((d_m * m_m) / d) / 2.0d0) ** 2.0d0)))
    else
        tmp = (h ** (-0.5d0)) * (d / 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 t_0 = Math.sqrt((h * l));
	double tmp;
	if (l <= -2.35e-183) {
		tmp = -d * Math.sqrt(((1.0 / h) / l));
	} else if (l <= -5e-311) {
		tmp = d / Math.log(Math.exp(t_0));
	} else if (l <= 1.9e+161) {
		tmp = (d / t_0) * (1.0 + (((h / l) * -0.5) * Math.pow((((D_m * M_m) / d) / 2.0), 2.0)));
	} else {
		tmp = Math.pow(h, -0.5) * (d / 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):
	t_0 = math.sqrt((h * l))
	tmp = 0
	if l <= -2.35e-183:
		tmp = -d * math.sqrt(((1.0 / h) / l))
	elif l <= -5e-311:
		tmp = d / math.log(math.exp(t_0))
	elif l <= 1.9e+161:
		tmp = (d / t_0) * (1.0 + (((h / l) * -0.5) * math.pow((((D_m * M_m) / d) / 2.0), 2.0)))
	else:
		tmp = math.pow(h, -0.5) * (d / 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)
	t_0 = sqrt(Float64(h * l))
	tmp = 0.0
	if (l <= -2.35e-183)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l)));
	elseif (l <= -5e-311)
		tmp = Float64(d / log(exp(t_0)));
	elseif (l <= 1.9e+161)
		tmp = Float64(Float64(d / t_0) * Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(Float64(Float64(D_m * M_m) / d) / 2.0) ^ 2.0))));
	else
		tmp = Float64((h ^ -0.5) * Float64(d / 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)
	t_0 = sqrt((h * l));
	tmp = 0.0;
	if (l <= -2.35e-183)
		tmp = -d * sqrt(((1.0 / h) / l));
	elseif (l <= -5e-311)
		tmp = d / log(exp(t_0));
	elseif (l <= 1.9e+161)
		tmp = (d / t_0) * (1.0 + (((h / l) * -0.5) * ((((D_m * M_m) / d) / 2.0) ^ 2.0)));
	else
		tmp = (h ^ -0.5) * (d / 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_] := Block[{t$95$0 = N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -2.35e-183], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-311], N[(d / N[Log[N[Exp[t$95$0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.9e+161], N[(N[(d / t$95$0), $MachinePrecision] * N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision] / 2.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[h, -0.5], $MachinePrecision] * N[(d / 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}
t_0 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;\ell \leq -2.35 \cdot 10^{-183}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\frac{d}{\log \left(e^{t\_0}\right)}\\

\mathbf{elif}\;\ell \leq 1.9 \cdot 10^{+161}:\\
\;\;\;\;\frac{d}{t\_0} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\frac{D\_m \cdot M\_m}{d}}{2}\right)}^{2}\right)\\

\mathbf{else}:\\
\;\;\;\;{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -2.35e-183

    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. 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. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      2. associate-/r*0.0%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt47.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-147.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified47.5%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if -2.35e-183 < l < -5.00000000000023e-311

    1. Initial program 71.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified71.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/83.7%

        \[\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-times83.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*83.7%

        \[\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. *-commutative83.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right)}^{2} \cdot h}{\ell}\right) \]
    5. Applied egg-rr83.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2} \cdot h}{\ell}}\right) \]
    6. Step-by-step derivation
      1. *-commutative83.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{h \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}}{\ell}\right) \]
      2. associate-/l*83.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
      3. associate-*r/83.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}}{\ell}\right)\right) \]
      4. *-commutative83.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}}{\ell}\right)\right) \]
    7. Simplified83.9%

      \[\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 \cdot M}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
    8. Taylor expanded in d around inf 19.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. unpow1/219.3%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      2. rem-exp-log19.3%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      3. exp-neg19.3%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod19.3%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out19.3%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. exp-neg19.3%

        \[\leadsto d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      7. exp-to-pow19.3%

        \[\leadsto d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      8. unpow1/219.3%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      9. associate-/l*19.3%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      10. *-rgt-identity19.3%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    10. Simplified19.3%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    11. Step-by-step derivation
      1. add-log-exp51.1%

        \[\leadsto \frac{d}{\color{blue}{\log \left(e^{\sqrt{h \cdot \ell}}\right)}} \]
      2. *-commutative51.1%

        \[\leadsto \frac{d}{\log \left(e^{\sqrt{\color{blue}{\ell \cdot h}}}\right)} \]
    12. Applied egg-rr51.1%

      \[\leadsto \frac{d}{\color{blue}{\log \left(e^{\sqrt{\ell \cdot h}}\right)}} \]

    if -5.00000000000023e-311 < l < 1.9000000000000001e161

    1. Initial program 75.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. Simplified74.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. Applied egg-rr81.5%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow181.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)} \]
      2. associate-*r*81.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}\right) \]
      3. *-commutative81.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right)} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right) \]
      4. associate-*r/82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}\right) \]
      5. *-commutative82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}\right) \]
      6. associate-*r/82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)}}^{2}\right) \]
      7. associate-*r*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right)}\right) \]
      8. associate-*r*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}\right) \]
      9. associate-/r*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2}\right) \]
    6. Simplified82.5%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)} \]
    7. Step-by-step derivation
      1. associate-/l/82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{M}{2 \cdot d}}\right)}^{2}\right) \]
      2. *-commutative82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{\color{blue}{d \cdot 2}}\right)}^{2}\right) \]
      3. associate-/l*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{D \cdot M}{d \cdot 2}\right)}}^{2}\right) \]
      4. associate-/r*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{\frac{D \cdot M}{d}}{2}\right)}}^{2}\right) \]
    8. Applied egg-rr82.5%

      \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{\frac{D \cdot M}{d}}{2}\right)}}^{2}\right) \]
    9. Taylor expanded in l around 0 77.1%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\frac{D \cdot M}{d}}{2}\right)}^{2}\right) \]

    if 1.9000000000000001e161 < l

    1. Initial program 61.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. Simplified61.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. Taylor expanded in d around inf 38.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div38.8%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval38.8%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative38.8%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod67.3%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv67.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-cube-cbrt66.6%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}\right) \cdot \sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}} \]
      7. pow366.6%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}\right)}^{3}} \]
      8. sqrt-unprod38.5%

        \[\leadsto {\left(\sqrt[3]{\frac{d}{\color{blue}{\sqrt{\ell \cdot h}}}}\right)}^{3} \]
      9. *-commutative38.5%

        \[\leadsto {\left(\sqrt[3]{\frac{d}{\sqrt{\color{blue}{h \cdot \ell}}}}\right)}^{3} \]
    6. Applied egg-rr38.5%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{d}{\sqrt{h \cdot \ell}}}\right)}^{3}} \]
    7. Step-by-step derivation
      1. rem-cube-cbrt38.7%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      2. sqrt-prod67.5%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. associate-/l/67.4%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
      4. clear-num66.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
    8. Applied egg-rr66.4%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity66.4%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
      2. associate-/r/67.5%

        \[\leadsto 1 \cdot \color{blue}{\left(\frac{1}{\sqrt{h}} \cdot \frac{d}{\sqrt{\ell}}\right)} \]
      3. pow1/267.5%

        \[\leadsto 1 \cdot \left(\frac{1}{\color{blue}{{h}^{0.5}}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
      4. pow-flip67.6%

        \[\leadsto 1 \cdot \left(\color{blue}{{h}^{\left(-0.5\right)}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
      5. metadata-eval67.6%

        \[\leadsto 1 \cdot \left({h}^{\color{blue}{-0.5}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
    10. Applied egg-rr67.6%

      \[\leadsto \color{blue}{1 \cdot \left({h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\right)} \]
    11. Step-by-step derivation
      1. *-lft-identity67.6%

        \[\leadsto \color{blue}{{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}} \]
    12. Simplified67.6%

      \[\leadsto \color{blue}{{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification61.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.35 \cdot 10^{-183}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\frac{d}{\log \left(e^{\sqrt{h \cdot \ell}}\right)}\\ \mathbf{elif}\;\ell \leq 1.9 \cdot 10^{+161}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\frac{D \cdot M}{d}}{2}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 58.3% accurate, 1.1× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{if}\;\ell \leq -9.6 \cdot 10^{-186}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(t\_0\right)\right)\\ \mathbf{elif}\;\ell \leq 3.1 \cdot 10^{+166}:\\ \;\;\;\;t\_0 \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\frac{D\_m \cdot M\_m}{d}}{2}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;{h}^{-0.5} \cdot \frac{d}{\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
 (let* ((t_0 (/ d (sqrt (* h l)))))
   (if (<= l -9.6e-186)
     (* (- d) (sqrt (/ (/ 1.0 h) l)))
     (if (<= l -5e-311)
       (log1p (expm1 t_0))
       (if (<= l 3.1e+166)
         (*
          t_0
          (+ 1.0 (* (* (/ h l) -0.5) (pow (/ (/ (* D_m M_m) d) 2.0) 2.0))))
         (* (pow h -0.5) (/ d (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 t_0 = d / sqrt((h * l));
	double tmp;
	if (l <= -9.6e-186) {
		tmp = -d * sqrt(((1.0 / h) / l));
	} else if (l <= -5e-311) {
		tmp = log1p(expm1(t_0));
	} else if (l <= 3.1e+166) {
		tmp = t_0 * (1.0 + (((h / l) * -0.5) * pow((((D_m * M_m) / d) / 2.0), 2.0)));
	} else {
		tmp = pow(h, -0.5) * (d / sqrt(l));
	}
	return tmp;
}
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.sqrt((h * l));
	double tmp;
	if (l <= -9.6e-186) {
		tmp = -d * Math.sqrt(((1.0 / h) / l));
	} else if (l <= -5e-311) {
		tmp = Math.log1p(Math.expm1(t_0));
	} else if (l <= 3.1e+166) {
		tmp = t_0 * (1.0 + (((h / l) * -0.5) * Math.pow((((D_m * M_m) / d) / 2.0), 2.0)));
	} else {
		tmp = Math.pow(h, -0.5) * (d / 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):
	t_0 = d / math.sqrt((h * l))
	tmp = 0
	if l <= -9.6e-186:
		tmp = -d * math.sqrt(((1.0 / h) / l))
	elif l <= -5e-311:
		tmp = math.log1p(math.expm1(t_0))
	elif l <= 3.1e+166:
		tmp = t_0 * (1.0 + (((h / l) * -0.5) * math.pow((((D_m * M_m) / d) / 2.0), 2.0)))
	else:
		tmp = math.pow(h, -0.5) * (d / 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)
	t_0 = Float64(d / sqrt(Float64(h * l)))
	tmp = 0.0
	if (l <= -9.6e-186)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l)));
	elseif (l <= -5e-311)
		tmp = log1p(expm1(t_0));
	elseif (l <= 3.1e+166)
		tmp = Float64(t_0 * Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(Float64(Float64(D_m * M_m) / d) / 2.0) ^ 2.0))));
	else
		tmp = Float64((h ^ -0.5) * Float64(d / sqrt(l)));
	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[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -9.6e-186], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-311], N[Log[1 + N[(Exp[t$95$0] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, 3.1e+166], N[(t$95$0 * N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision] / 2.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[h, -0.5], $MachinePrecision] * N[(d / 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}
t_0 := \frac{d}{\sqrt{h \cdot \ell}}\\
\mathbf{if}\;\ell \leq -9.6 \cdot 10^{-186}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(t\_0\right)\right)\\

\mathbf{elif}\;\ell \leq 3.1 \cdot 10^{+166}:\\
\;\;\;\;t\_0 \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\frac{D\_m \cdot M\_m}{d}}{2}\right)}^{2}\right)\\

\mathbf{else}:\\
\;\;\;\;{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -9.60000000000000012e-186

    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. 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. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      2. associate-/r*0.0%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt47.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-147.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified47.5%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if -9.60000000000000012e-186 < l < -5.00000000000023e-311

    1. Initial program 71.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified71.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 19.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div19.3%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval19.3%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative19.3%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod0.0%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv0.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. log1p-expm1-u0.0%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right)\right)} \]
      7. sqrt-unprod46.9%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{d}{\color{blue}{\sqrt{\ell \cdot h}}}\right)\right) \]
      8. *-commutative46.9%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{d}{\sqrt{\color{blue}{h \cdot \ell}}}\right)\right) \]
    6. Applied egg-rr46.9%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)\right)} \]

    if -5.00000000000023e-311 < l < 3.09999999999999983e166

    1. Initial program 75.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. Simplified74.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. Applied egg-rr81.5%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow181.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)} \]
      2. associate-*r*81.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}\right) \]
      3. *-commutative81.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right)} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right) \]
      4. associate-*r/82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}\right) \]
      5. *-commutative82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}\right) \]
      6. associate-*r/82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)}}^{2}\right) \]
      7. associate-*r*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right)}\right) \]
      8. associate-*r*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}\right) \]
      9. associate-/r*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2}\right) \]
    6. Simplified82.5%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)} \]
    7. Step-by-step derivation
      1. associate-/l/82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{M}{2 \cdot d}}\right)}^{2}\right) \]
      2. *-commutative82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{\color{blue}{d \cdot 2}}\right)}^{2}\right) \]
      3. associate-/l*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{D \cdot M}{d \cdot 2}\right)}}^{2}\right) \]
      4. associate-/r*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{\frac{D \cdot M}{d}}{2}\right)}}^{2}\right) \]
    8. Applied egg-rr82.5%

      \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{\frac{D \cdot M}{d}}{2}\right)}}^{2}\right) \]
    9. Taylor expanded in l around 0 77.1%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\frac{D \cdot M}{d}}{2}\right)}^{2}\right) \]

    if 3.09999999999999983e166 < l

    1. Initial program 61.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. Simplified61.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. Taylor expanded in d around inf 38.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div38.8%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval38.8%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative38.8%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod67.3%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv67.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-cube-cbrt66.6%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}\right) \cdot \sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}} \]
      7. pow366.6%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}\right)}^{3}} \]
      8. sqrt-unprod38.5%

        \[\leadsto {\left(\sqrt[3]{\frac{d}{\color{blue}{\sqrt{\ell \cdot h}}}}\right)}^{3} \]
      9. *-commutative38.5%

        \[\leadsto {\left(\sqrt[3]{\frac{d}{\sqrt{\color{blue}{h \cdot \ell}}}}\right)}^{3} \]
    6. Applied egg-rr38.5%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{d}{\sqrt{h \cdot \ell}}}\right)}^{3}} \]
    7. Step-by-step derivation
      1. rem-cube-cbrt38.7%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      2. sqrt-prod67.5%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. associate-/l/67.4%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
      4. clear-num66.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
    8. Applied egg-rr66.4%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity66.4%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
      2. associate-/r/67.5%

        \[\leadsto 1 \cdot \color{blue}{\left(\frac{1}{\sqrt{h}} \cdot \frac{d}{\sqrt{\ell}}\right)} \]
      3. pow1/267.5%

        \[\leadsto 1 \cdot \left(\frac{1}{\color{blue}{{h}^{0.5}}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
      4. pow-flip67.6%

        \[\leadsto 1 \cdot \left(\color{blue}{{h}^{\left(-0.5\right)}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
      5. metadata-eval67.6%

        \[\leadsto 1 \cdot \left({h}^{\color{blue}{-0.5}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
    10. Applied egg-rr67.6%

      \[\leadsto \color{blue}{1 \cdot \left({h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\right)} \]
    11. Step-by-step derivation
      1. *-lft-identity67.6%

        \[\leadsto \color{blue}{{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}} \]
    12. Simplified67.6%

      \[\leadsto \color{blue}{{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification61.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9.6 \cdot 10^{-186}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)\right)\\ \mathbf{elif}\;\ell \leq 3.1 \cdot 10^{+166}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\frac{D \cdot M}{d}}{2}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 21: 57.9% accurate, 1.4× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2.35 \cdot 10^{-185}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{elif}\;\ell \leq 1.16 \cdot 10^{+162}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\frac{D\_m \cdot M\_m}{d}}{2}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;{h}^{-0.5} \cdot \frac{d}{\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 (<= l -2.35e-185)
   (* (- d) (sqrt (/ (/ 1.0 h) l)))
   (if (<= l -5e-311)
     (* d (pow (pow (* h l) 2.0) -0.25))
     (if (<= l 1.16e+162)
       (*
        (/ d (sqrt (* h l)))
        (+ 1.0 (* (* (/ h l) -0.5) (pow (/ (/ (* D_m M_m) d) 2.0) 2.0))))
       (* (pow h -0.5) (/ d (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 (l <= -2.35e-185) {
		tmp = -d * sqrt(((1.0 / h) / l));
	} else if (l <= -5e-311) {
		tmp = d * pow(pow((h * l), 2.0), -0.25);
	} else if (l <= 1.16e+162) {
		tmp = (d / sqrt((h * l))) * (1.0 + (((h / l) * -0.5) * pow((((D_m * M_m) / d) / 2.0), 2.0)));
	} else {
		tmp = pow(h, -0.5) * (d / 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 (l <= (-2.35d-185)) then
        tmp = -d * sqrt(((1.0d0 / h) / l))
    else if (l <= (-5d-311)) then
        tmp = d * (((h * l) ** 2.0d0) ** (-0.25d0))
    else if (l <= 1.16d+162) then
        tmp = (d / sqrt((h * l))) * (1.0d0 + (((h / l) * (-0.5d0)) * ((((d_m * m_m) / d) / 2.0d0) ** 2.0d0)))
    else
        tmp = (h ** (-0.5d0)) * (d / 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 (l <= -2.35e-185) {
		tmp = -d * Math.sqrt(((1.0 / h) / l));
	} else if (l <= -5e-311) {
		tmp = d * Math.pow(Math.pow((h * l), 2.0), -0.25);
	} else if (l <= 1.16e+162) {
		tmp = (d / Math.sqrt((h * l))) * (1.0 + (((h / l) * -0.5) * Math.pow((((D_m * M_m) / d) / 2.0), 2.0)));
	} else {
		tmp = Math.pow(h, -0.5) * (d / 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 l <= -2.35e-185:
		tmp = -d * math.sqrt(((1.0 / h) / l))
	elif l <= -5e-311:
		tmp = d * math.pow(math.pow((h * l), 2.0), -0.25)
	elif l <= 1.16e+162:
		tmp = (d / math.sqrt((h * l))) * (1.0 + (((h / l) * -0.5) * math.pow((((D_m * M_m) / d) / 2.0), 2.0)))
	else:
		tmp = math.pow(h, -0.5) * (d / 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 (l <= -2.35e-185)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l)));
	elseif (l <= -5e-311)
		tmp = Float64(d * ((Float64(h * l) ^ 2.0) ^ -0.25));
	elseif (l <= 1.16e+162)
		tmp = Float64(Float64(d / sqrt(Float64(h * l))) * Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(Float64(Float64(D_m * M_m) / d) / 2.0) ^ 2.0))));
	else
		tmp = Float64((h ^ -0.5) * Float64(d / 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 (l <= -2.35e-185)
		tmp = -d * sqrt(((1.0 / h) / l));
	elseif (l <= -5e-311)
		tmp = d * (((h * l) ^ 2.0) ^ -0.25);
	elseif (l <= 1.16e+162)
		tmp = (d / sqrt((h * l))) * (1.0 + (((h / l) * -0.5) * ((((D_m * M_m) / d) / 2.0) ^ 2.0)));
	else
		tmp = (h ^ -0.5) * (d / 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[l, -2.35e-185], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-311], N[(d * N[Power[N[Power[N[(h * l), $MachinePrecision], 2.0], $MachinePrecision], -0.25], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.16e+162], N[(N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision] / 2.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[h, -0.5], $MachinePrecision] * N[(d / 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}\;\ell \leq -2.35 \cdot 10^{-185}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\
\;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\

\mathbf{elif}\;\ell \leq 1.16 \cdot 10^{+162}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\frac{D\_m \cdot M\_m}{d}}{2}\right)}^{2}\right)\\

\mathbf{else}:\\
\;\;\;\;{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -2.3500000000000001e-185

    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. 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. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      2. associate-/r*0.0%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt47.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-147.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified47.5%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if -2.3500000000000001e-185 < l < -5.00000000000023e-311

    1. Initial program 71.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified71.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 19.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. add-log-exp55.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}} \]
    6. Applied egg-rr55.0%

      \[\leadsto d \cdot \sqrt{\color{blue}{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}} \]
    7. Step-by-step derivation
      1. rem-log-exp19.3%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \]
      2. inv-pow19.3%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      3. sqrt-pow119.3%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}} \]
      4. metadata-eval19.3%

        \[\leadsto d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \]
      5. add-sqr-sqrt19.3%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      6. sqrt-pow119.3%

        \[\leadsto d \cdot \left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right) \]
      7. sqrt-pow119.3%

        \[\leadsto d \cdot \left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right) \]
      8. pow-prod-down38.9%

        \[\leadsto d \cdot \color{blue}{{\left(\left(h \cdot \ell\right) \cdot \left(h \cdot \ell\right)\right)}^{\left(\frac{-0.5}{2}\right)}} \]
      9. pow238.9%

        \[\leadsto d \cdot {\color{blue}{\left({\left(h \cdot \ell\right)}^{2}\right)}}^{\left(\frac{-0.5}{2}\right)} \]
      10. metadata-eval38.9%

        \[\leadsto d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{\color{blue}{-0.25}} \]
    8. Applied egg-rr38.9%

      \[\leadsto d \cdot \color{blue}{{\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}} \]

    if -5.00000000000023e-311 < l < 1.16000000000000006e162

    1. Initial program 75.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. Simplified74.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. Applied egg-rr81.5%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow181.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)} \]
      2. associate-*r*81.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}\right) \]
      3. *-commutative81.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right)} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right) \]
      4. associate-*r/82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}\right) \]
      5. *-commutative82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}\right) \]
      6. associate-*r/82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)}}^{2}\right) \]
      7. associate-*r*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right)}\right) \]
      8. associate-*r*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}\right) \]
      9. associate-/r*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2}\right) \]
    6. Simplified82.5%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)} \]
    7. Step-by-step derivation
      1. associate-/l/82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{M}{2 \cdot d}}\right)}^{2}\right) \]
      2. *-commutative82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{\color{blue}{d \cdot 2}}\right)}^{2}\right) \]
      3. associate-/l*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{D \cdot M}{d \cdot 2}\right)}}^{2}\right) \]
      4. associate-/r*82.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{\frac{D \cdot M}{d}}{2}\right)}}^{2}\right) \]
    8. Applied egg-rr82.5%

      \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{\frac{D \cdot M}{d}}{2}\right)}}^{2}\right) \]
    9. Taylor expanded in l around 0 77.1%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\frac{D \cdot M}{d}}{2}\right)}^{2}\right) \]

    if 1.16000000000000006e162 < l

    1. Initial program 61.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. Simplified61.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. Taylor expanded in d around inf 38.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div38.8%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval38.8%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative38.8%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod67.3%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv67.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-cube-cbrt66.6%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}\right) \cdot \sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}} \]
      7. pow366.6%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}\right)}^{3}} \]
      8. sqrt-unprod38.5%

        \[\leadsto {\left(\sqrt[3]{\frac{d}{\color{blue}{\sqrt{\ell \cdot h}}}}\right)}^{3} \]
      9. *-commutative38.5%

        \[\leadsto {\left(\sqrt[3]{\frac{d}{\sqrt{\color{blue}{h \cdot \ell}}}}\right)}^{3} \]
    6. Applied egg-rr38.5%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{d}{\sqrt{h \cdot \ell}}}\right)}^{3}} \]
    7. Step-by-step derivation
      1. rem-cube-cbrt38.7%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      2. sqrt-prod67.5%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. associate-/l/67.4%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
      4. clear-num66.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
    8. Applied egg-rr66.4%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity66.4%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
      2. associate-/r/67.5%

        \[\leadsto 1 \cdot \color{blue}{\left(\frac{1}{\sqrt{h}} \cdot \frac{d}{\sqrt{\ell}}\right)} \]
      3. pow1/267.5%

        \[\leadsto 1 \cdot \left(\frac{1}{\color{blue}{{h}^{0.5}}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
      4. pow-flip67.6%

        \[\leadsto 1 \cdot \left(\color{blue}{{h}^{\left(-0.5\right)}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
      5. metadata-eval67.6%

        \[\leadsto 1 \cdot \left({h}^{\color{blue}{-0.5}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
    10. Applied egg-rr67.6%

      \[\leadsto \color{blue}{1 \cdot \left({h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\right)} \]
    11. Step-by-step derivation
      1. *-lft-identity67.6%

        \[\leadsto \color{blue}{{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}} \]
    12. Simplified67.6%

      \[\leadsto \color{blue}{{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification60.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.35 \cdot 10^{-185}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{elif}\;\ell \leq 1.16 \cdot 10^{+162}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\frac{D \cdot M}{d}}{2}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 22: 57.8% 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 -4.2 \cdot 10^{-184}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq 6.9 \cdot 10^{-307}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{elif}\;\ell \leq 3.1 \cdot 10^{+161}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D\_m \cdot \frac{\frac{M\_m}{d}}{2}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;{h}^{-0.5} \cdot \frac{d}{\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 (<= l -4.2e-184)
   (* (- d) (sqrt (/ (/ 1.0 h) l)))
   (if (<= l 6.9e-307)
     (* d (pow (pow (* h l) 2.0) -0.25))
     (if (<= l 3.1e+161)
       (*
        (/ d (sqrt (* h l)))
        (+ 1.0 (* (* (/ h l) -0.5) (pow (* D_m (/ (/ M_m d) 2.0)) 2.0))))
       (* (pow h -0.5) (/ d (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 (l <= -4.2e-184) {
		tmp = -d * sqrt(((1.0 / h) / l));
	} else if (l <= 6.9e-307) {
		tmp = d * pow(pow((h * l), 2.0), -0.25);
	} else if (l <= 3.1e+161) {
		tmp = (d / sqrt((h * l))) * (1.0 + (((h / l) * -0.5) * pow((D_m * ((M_m / d) / 2.0)), 2.0)));
	} else {
		tmp = pow(h, -0.5) * (d / 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 (l <= (-4.2d-184)) then
        tmp = -d * sqrt(((1.0d0 / h) / l))
    else if (l <= 6.9d-307) then
        tmp = d * (((h * l) ** 2.0d0) ** (-0.25d0))
    else if (l <= 3.1d+161) then
        tmp = (d / sqrt((h * l))) * (1.0d0 + (((h / l) * (-0.5d0)) * ((d_m * ((m_m / d) / 2.0d0)) ** 2.0d0)))
    else
        tmp = (h ** (-0.5d0)) * (d / 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 (l <= -4.2e-184) {
		tmp = -d * Math.sqrt(((1.0 / h) / l));
	} else if (l <= 6.9e-307) {
		tmp = d * Math.pow(Math.pow((h * l), 2.0), -0.25);
	} else if (l <= 3.1e+161) {
		tmp = (d / Math.sqrt((h * l))) * (1.0 + (((h / l) * -0.5) * Math.pow((D_m * ((M_m / d) / 2.0)), 2.0)));
	} else {
		tmp = Math.pow(h, -0.5) * (d / 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 l <= -4.2e-184:
		tmp = -d * math.sqrt(((1.0 / h) / l))
	elif l <= 6.9e-307:
		tmp = d * math.pow(math.pow((h * l), 2.0), -0.25)
	elif l <= 3.1e+161:
		tmp = (d / math.sqrt((h * l))) * (1.0 + (((h / l) * -0.5) * math.pow((D_m * ((M_m / d) / 2.0)), 2.0)))
	else:
		tmp = math.pow(h, -0.5) * (d / 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 (l <= -4.2e-184)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l)));
	elseif (l <= 6.9e-307)
		tmp = Float64(d * ((Float64(h * l) ^ 2.0) ^ -0.25));
	elseif (l <= 3.1e+161)
		tmp = Float64(Float64(d / sqrt(Float64(h * l))) * Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(D_m * Float64(Float64(M_m / d) / 2.0)) ^ 2.0))));
	else
		tmp = Float64((h ^ -0.5) * Float64(d / 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 (l <= -4.2e-184)
		tmp = -d * sqrt(((1.0 / h) / l));
	elseif (l <= 6.9e-307)
		tmp = d * (((h * l) ^ 2.0) ^ -0.25);
	elseif (l <= 3.1e+161)
		tmp = (d / sqrt((h * l))) * (1.0 + (((h / l) * -0.5) * ((D_m * ((M_m / d) / 2.0)) ^ 2.0)));
	else
		tmp = (h ^ -0.5) * (d / 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[l, -4.2e-184], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6.9e-307], N[(d * N[Power[N[Power[N[(h * l), $MachinePrecision], 2.0], $MachinePrecision], -0.25], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.1e+161], N[(N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(D$95$m * N[(N[(M$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[h, -0.5], $MachinePrecision] * N[(d / 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}\;\ell \leq -4.2 \cdot 10^{-184}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

\mathbf{elif}\;\ell \leq 6.9 \cdot 10^{-307}:\\
\;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\

\mathbf{elif}\;\ell \leq 3.1 \cdot 10^{+161}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D\_m \cdot \frac{\frac{M\_m}{d}}{2}\right)}^{2}\right)\\

\mathbf{else}:\\
\;\;\;\;{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -4.1999999999999998e-184

    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. 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. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      2. associate-/r*0.0%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt47.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-147.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified47.5%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if -4.1999999999999998e-184 < l < 6.8999999999999997e-307

    1. Initial program 72.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. Taylor expanded in d around inf 18.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. add-log-exp52.8%

        \[\leadsto d \cdot \sqrt{\color{blue}{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}} \]
    6. Applied egg-rr52.8%

      \[\leadsto d \cdot \sqrt{\color{blue}{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}} \]
    7. Step-by-step derivation
      1. rem-log-exp18.5%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \]
      2. inv-pow18.5%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      3. sqrt-pow118.5%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}} \]
      4. metadata-eval18.5%

        \[\leadsto d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \]
      5. add-sqr-sqrt18.5%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      6. sqrt-pow118.5%

        \[\leadsto d \cdot \left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right) \]
      7. sqrt-pow118.5%

        \[\leadsto d \cdot \left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right) \]
      8. pow-prod-down37.3%

        \[\leadsto d \cdot \color{blue}{{\left(\left(h \cdot \ell\right) \cdot \left(h \cdot \ell\right)\right)}^{\left(\frac{-0.5}{2}\right)}} \]
      9. pow237.3%

        \[\leadsto d \cdot {\color{blue}{\left({\left(h \cdot \ell\right)}^{2}\right)}}^{\left(\frac{-0.5}{2}\right)} \]
      10. metadata-eval37.3%

        \[\leadsto d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{\color{blue}{-0.25}} \]
    8. Applied egg-rr37.3%

      \[\leadsto d \cdot \color{blue}{{\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}} \]

    if 6.8999999999999997e-307 < l < 3.10000000000000007e161

    1. Initial program 74.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. Simplified74.8%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Applied egg-rr82.3%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow182.3%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)} \]
      2. associate-*r*82.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}\right) \]
      3. *-commutative82.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right)} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right) \]
      4. associate-*r/82.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}\right) \]
      5. *-commutative82.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}\right) \]
      6. associate-*r/82.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)}}^{2}\right) \]
      7. associate-*r*82.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right)}\right) \]
      8. associate-*r*82.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}\right) \]
      9. associate-/r*82.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2}\right) \]
    6. Simplified82.3%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)} \]
    7. Taylor expanded in l around 0 76.8%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right) \]

    if 3.10000000000000007e161 < l

    1. Initial program 61.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. Simplified61.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. Taylor expanded in d around inf 38.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div38.8%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval38.8%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative38.8%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod67.3%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv67.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-cube-cbrt66.6%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}\right) \cdot \sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}} \]
      7. pow366.6%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}\right)}^{3}} \]
      8. sqrt-unprod38.5%

        \[\leadsto {\left(\sqrt[3]{\frac{d}{\color{blue}{\sqrt{\ell \cdot h}}}}\right)}^{3} \]
      9. *-commutative38.5%

        \[\leadsto {\left(\sqrt[3]{\frac{d}{\sqrt{\color{blue}{h \cdot \ell}}}}\right)}^{3} \]
    6. Applied egg-rr38.5%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{d}{\sqrt{h \cdot \ell}}}\right)}^{3}} \]
    7. Step-by-step derivation
      1. rem-cube-cbrt38.7%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      2. sqrt-prod67.5%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. associate-/l/67.4%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
      4. clear-num66.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
    8. Applied egg-rr66.4%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity66.4%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\frac{\sqrt{h}}{\frac{d}{\sqrt{\ell}}}}} \]
      2. associate-/r/67.5%

        \[\leadsto 1 \cdot \color{blue}{\left(\frac{1}{\sqrt{h}} \cdot \frac{d}{\sqrt{\ell}}\right)} \]
      3. pow1/267.5%

        \[\leadsto 1 \cdot \left(\frac{1}{\color{blue}{{h}^{0.5}}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
      4. pow-flip67.6%

        \[\leadsto 1 \cdot \left(\color{blue}{{h}^{\left(-0.5\right)}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
      5. metadata-eval67.6%

        \[\leadsto 1 \cdot \left({h}^{\color{blue}{-0.5}} \cdot \frac{d}{\sqrt{\ell}}\right) \]
    10. Applied egg-rr67.6%

      \[\leadsto \color{blue}{1 \cdot \left({h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\right)} \]
    11. Step-by-step derivation
      1. *-lft-identity67.6%

        \[\leadsto \color{blue}{{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}} \]
    12. Simplified67.6%

      \[\leadsto \color{blue}{{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification60.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.2 \cdot 10^{-184}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq 6.9 \cdot 10^{-307}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{elif}\;\ell \leq 3.1 \cdot 10^{+161}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;{h}^{-0.5} \cdot \frac{d}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 23: 46.2% 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}\;\ell \leq -5.8 \cdot 10^{-185}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq 1.3 \cdot 10^{-286}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \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 (<= l -5.8e-185)
   (* (- d) (sqrt (/ (/ 1.0 h) l)))
   (if (<= l 1.3e-286)
     (* d (pow (pow (* h l) 2.0) -0.25))
     (/ 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.8e-185) {
		tmp = -d * sqrt(((1.0 / h) / l));
	} else if (l <= 1.3e-286) {
		tmp = d * pow(pow((h * l), 2.0), -0.25);
	} 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.8d-185)) then
        tmp = -d * sqrt(((1.0d0 / h) / l))
    else if (l <= 1.3d-286) then
        tmp = d * (((h * l) ** 2.0d0) ** (-0.25d0))
    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.8e-185) {
		tmp = -d * Math.sqrt(((1.0 / h) / l));
	} else if (l <= 1.3e-286) {
		tmp = d * Math.pow(Math.pow((h * l), 2.0), -0.25);
	} 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.8e-185:
		tmp = -d * math.sqrt(((1.0 / h) / l))
	elif l <= 1.3e-286:
		tmp = d * math.pow(math.pow((h * l), 2.0), -0.25)
	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.8e-185)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l)));
	elseif (l <= 1.3e-286)
		tmp = Float64(d * ((Float64(h * l) ^ 2.0) ^ -0.25));
	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 (l <= -5.8e-185)
		tmp = -d * sqrt(((1.0 / h) / l));
	elseif (l <= 1.3e-286)
		tmp = d * (((h * l) ^ 2.0) ^ -0.25);
	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.8e-185], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.3e-286], N[(d * N[Power[N[Power[N[(h * l), $MachinePrecision], 2.0], $MachinePrecision], -0.25], $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}\;\ell \leq -5.8 \cdot 10^{-185}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

\mathbf{elif}\;\ell \leq 1.3 \cdot 10^{-286}:\\
\;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -5.79999999999999989e-185

    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. 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. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      2. associate-/r*0.0%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt47.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-147.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified47.5%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if -5.79999999999999989e-185 < l < 1.3e-286

    1. Initial program 77.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. Simplified74.0%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 25.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. add-log-exp47.8%

        \[\leadsto d \cdot \sqrt{\color{blue}{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}} \]
    6. Applied egg-rr47.8%

      \[\leadsto d \cdot \sqrt{\color{blue}{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}} \]
    7. Step-by-step derivation
      1. rem-log-exp25.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \]
      2. inv-pow25.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      3. sqrt-pow125.4%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}} \]
      4. metadata-eval25.4%

        \[\leadsto d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \]
      5. add-sqr-sqrt25.4%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      6. sqrt-pow125.4%

        \[\leadsto d \cdot \left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right) \]
      7. sqrt-pow125.4%

        \[\leadsto d \cdot \left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right) \]
      8. pow-prod-down39.2%

        \[\leadsto d \cdot \color{blue}{{\left(\left(h \cdot \ell\right) \cdot \left(h \cdot \ell\right)\right)}^{\left(\frac{-0.5}{2}\right)}} \]
      9. pow239.2%

        \[\leadsto d \cdot {\color{blue}{\left({\left(h \cdot \ell\right)}^{2}\right)}}^{\left(\frac{-0.5}{2}\right)} \]
      10. metadata-eval39.2%

        \[\leadsto d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{\color{blue}{-0.25}} \]
    8. Applied egg-rr39.2%

      \[\leadsto d \cdot \color{blue}{{\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}} \]

    if 1.3e-286 < l

    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.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 46.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div46.1%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval46.1%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative46.1%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod54.9%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv54.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. associate-/r*52.8%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr52.8%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    7. Step-by-step derivation
      1. associate-/l/54.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      2. *-commutative54.9%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    8. Simplified54.9%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification49.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5.8 \cdot 10^{-185}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq 1.3 \cdot 10^{-286}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 24: 46.0% 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}\;\ell \leq -2.9 \cdot 10^{-185}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\frac{d}{\sqrt[3]{{\left(h \cdot \ell\right)}^{1.5}}}\\ \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 (<= l -2.9e-185)
   (* (- d) (sqrt (/ (/ 1.0 h) l)))
   (if (<= l -5e-311)
     (/ d (cbrt (pow (* h l) 1.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 <= -2.9e-185) {
		tmp = -d * sqrt(((1.0 / h) / l));
	} else if (l <= -5e-311) {
		tmp = d / cbrt(pow((h * l), 1.5));
	} else {
		tmp = d / (sqrt(l) * sqrt(h));
	}
	return tmp;
}
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-185) {
		tmp = -d * Math.sqrt(((1.0 / h) / l));
	} else if (l <= -5e-311) {
		tmp = d / Math.cbrt(Math.pow((h * l), 1.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 <= -2.9e-185)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l)));
	elseif (l <= -5e-311)
		tmp = Float64(d / cbrt((Float64(h * l) ^ 1.5)));
	else
		tmp = Float64(d / Float64(sqrt(l) * sqrt(h)));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -2.9e-185], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-311], N[(d / N[Power[N[Power[N[(h * l), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $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}\;\ell \leq -2.9 \cdot 10^{-185}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\frac{d}{\sqrt[3]{{\left(h \cdot \ell\right)}^{1.5}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -2.89999999999999995e-185

    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. 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. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      2. associate-/r*0.0%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt47.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-147.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified47.5%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if -2.89999999999999995e-185 < l < -5.00000000000023e-311

    1. Initial program 71.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified71.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/83.7%

        \[\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-times83.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*83.7%

        \[\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. *-commutative83.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right)}^{2} \cdot h}{\ell}\right) \]
    5. Applied egg-rr83.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2} \cdot h}{\ell}}\right) \]
    6. Step-by-step derivation
      1. *-commutative83.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{h \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}}{\ell}\right) \]
      2. associate-/l*83.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
      3. associate-*r/83.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}}{\ell}\right)\right) \]
      4. *-commutative83.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}}{\ell}\right)\right) \]
    7. Simplified83.9%

      \[\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 \cdot M}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
    8. Taylor expanded in d around inf 19.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. unpow1/219.3%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      2. rem-exp-log19.3%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      3. exp-neg19.3%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod19.3%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out19.3%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. exp-neg19.3%

        \[\leadsto d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      7. exp-to-pow19.3%

        \[\leadsto d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      8. unpow1/219.3%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      9. associate-/l*19.3%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      10. *-rgt-identity19.3%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    10. Simplified19.3%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    11. Step-by-step derivation
      1. add-cbrt-cube34.9%

        \[\leadsto \frac{d}{\color{blue}{\sqrt[3]{\left(\sqrt{h \cdot \ell} \cdot \sqrt{h \cdot \ell}\right) \cdot \sqrt{h \cdot \ell}}}} \]
      2. pow1/334.9%

        \[\leadsto \frac{d}{\color{blue}{{\left(\left(\sqrt{h \cdot \ell} \cdot \sqrt{h \cdot \ell}\right) \cdot \sqrt{h \cdot \ell}\right)}^{0.3333333333333333}}} \]
      3. add-sqr-sqrt34.9%

        \[\leadsto \frac{d}{{\left(\color{blue}{\left(h \cdot \ell\right)} \cdot \sqrt{h \cdot \ell}\right)}^{0.3333333333333333}} \]
      4. pow134.9%

        \[\leadsto \frac{d}{{\left(\color{blue}{{\left(h \cdot \ell\right)}^{1}} \cdot \sqrt{h \cdot \ell}\right)}^{0.3333333333333333}} \]
      5. pow1/234.9%

        \[\leadsto \frac{d}{{\left({\left(h \cdot \ell\right)}^{1} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{0.5}}\right)}^{0.3333333333333333}} \]
      6. pow-prod-up34.9%

        \[\leadsto \frac{d}{{\color{blue}{\left({\left(h \cdot \ell\right)}^{\left(1 + 0.5\right)}\right)}}^{0.3333333333333333}} \]
      7. *-commutative34.9%

        \[\leadsto \frac{d}{{\left({\color{blue}{\left(\ell \cdot h\right)}}^{\left(1 + 0.5\right)}\right)}^{0.3333333333333333}} \]
      8. metadata-eval34.9%

        \[\leadsto \frac{d}{{\left({\left(\ell \cdot h\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333}} \]
    12. Applied egg-rr34.9%

      \[\leadsto \frac{d}{\color{blue}{{\left({\left(\ell \cdot h\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
    13. Step-by-step derivation
      1. unpow1/334.9%

        \[\leadsto \frac{d}{\color{blue}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}} \]
    14. Simplified34.9%

      \[\leadsto \frac{d}{\color{blue}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}} \]

    if -5.00000000000023e-311 < l

    1. Initial program 72.6%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified71.8%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 45.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div45.6%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval45.6%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative45.6%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod53.7%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv53.7%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. associate-/r*51.8%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr51.8%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    7. Step-by-step derivation
      1. associate-/l/53.7%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      2. *-commutative53.7%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    8. Simplified53.7%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification49.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.9 \cdot 10^{-185}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\frac{d}{\sqrt[3]{{\left(h \cdot \ell\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 25: 45.9% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq 9.8 \cdot 10^{-245}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \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 9.8e-245) (/ (- d) (sqrt (* h 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 (d <= 9.8e-245) {
		tmp = -d / sqrt((h * l));
	} 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 <= 9.8d-245) then
        tmp = -d / sqrt((h * l))
    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 <= 9.8e-245) {
		tmp = -d / Math.sqrt((h * l));
	} 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 <= 9.8e-245:
		tmp = -d / math.sqrt((h * l))
	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 <= 9.8e-245)
		tmp = Float64(Float64(-d) / sqrt(Float64(h * l)));
	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 <= 9.8e-245)
		tmp = -d / sqrt((h * l));
	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, 9.8e-245], N[((-d) / N[Sqrt[N[(h * l), $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 9.8 \cdot 10^{-245}:\\
\;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 9.7999999999999996e-245

    1. Initial program 64.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.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/66.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-times67.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*66.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. *-commutative66.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right)}^{2} \cdot h}{\ell}\right) \]
    5. Applied egg-rr66.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2} \cdot h}{\ell}}\right) \]
    6. Step-by-step derivation
      1. *-commutative66.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{h \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}}{\ell}\right) \]
      2. associate-/l*66.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
      3. associate-*r/66.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}}{\ell}\right)\right) \]
      4. *-commutative66.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}}{\ell}\right)\right) \]
    7. Simplified66.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
    8. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. remove-double-neg0.0%

        \[\leadsto \color{blue}{-\left(-\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. associate-*l*0.0%

        \[\leadsto -\left(-\color{blue}{d \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}\right) \]
      3. *-commutative0.0%

        \[\leadsto -\left(-d \cdot \color{blue}{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)}\right) \]
      4. distribute-rgt-neg-in0.0%

        \[\leadsto -\color{blue}{d \cdot \left(-\sqrt{\frac{1}{h \cdot \ell}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      5. *-commutative0.0%

        \[\leadsto -d \cdot \left(-\color{blue}{{\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}}\right) \]
      6. unpow20.0%

        \[\leadsto -d \cdot \left(-\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      7. rem-square-sqrt38.3%

        \[\leadsto -d \cdot \left(-\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      8. mul-1-neg38.3%

        \[\leadsto -d \cdot \left(-\color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)}\right) \]
      9. remove-double-neg38.3%

        \[\leadsto -d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
      10. unpow1/238.3%

        \[\leadsto -d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      11. rem-exp-log36.2%

        \[\leadsto -d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      12. exp-neg36.3%

        \[\leadsto -d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      13. exp-prod36.8%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      14. distribute-lft-neg-out36.8%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      15. exp-neg36.8%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      16. exp-to-pow38.8%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      17. unpow1/238.8%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
    10. Simplified38.9%

      \[\leadsto \color{blue}{\frac{-d}{\sqrt{h \cdot \ell}}} \]

    if 9.7999999999999996e-245 < d

    1. Initial program 78.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. Simplified78.0%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 49.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div49.8%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval49.8%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative49.8%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod58.8%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv58.8%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. associate-/r*56.7%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr56.7%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    7. Step-by-step derivation
      1. associate-/l/58.8%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      2. *-commutative58.8%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    8. Simplified58.8%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 26: 42.6% 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 -1.9 \cdot 10^{-237}:\\ \;\;\;\;\left(-d\right) \cdot t\_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 (<= l -1.9e-237) (* (- 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 <= -1.9e-237) {
		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 <= (-1.9d-237)) 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 <= -1.9e-237) {
		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 <= -1.9e-237:
		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 <= -1.9e-237)
		tmp = Float64(Float64(-d) * 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 <= -1.9e-237)
		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, -1.9e-237], 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 -1.9 \cdot 10^{-237}:\\
\;\;\;\;\left(-d\right) \cdot t\_0\\

\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -1.90000000000000012e-237

    1. Initial program 69.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified68.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. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      2. associate-/r*0.0%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt44.8%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-144.8%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified44.8%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if -1.90000000000000012e-237 < l

    1. Initial program 72.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.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. Taylor expanded in d around inf 43.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*44.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified44.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification44.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.9 \cdot 10^{-237}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 27: 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} \mathbf{if}\;\ell \leq -2.4 \cdot 10^{-237}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \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.4e-237) (/ (- d) (sqrt (* h l))) (* 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.4e-237) {
		tmp = -d / sqrt((h * l));
	} 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.4d-237)) then
        tmp = -d / sqrt((h * l))
    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.4e-237) {
		tmp = -d / Math.sqrt((h * l));
	} 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.4e-237:
		tmp = -d / math.sqrt((h * l))
	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.4e-237)
		tmp = Float64(Float64(-d) / sqrt(Float64(h * l)));
	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.4e-237)
		tmp = -d / sqrt((h * l));
	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.4e-237], N[((-d) / N[Sqrt[N[(h * l), $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.4 \cdot 10^{-237}:\\
\;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\

\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.4e-237

    1. Initial program 69.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified68.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.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-times71.1%

        \[\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.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. *-commutative70.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right)}^{2} \cdot h}{\ell}\right) \]
    5. Applied egg-rr70.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2} \cdot h}{\ell}}\right) \]
    6. Step-by-step derivation
      1. *-commutative70.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{h \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}}{\ell}\right) \]
      2. associate-/l*70.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(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
      3. associate-*r/70.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}}{\ell}\right)\right) \]
      4. *-commutative70.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}}{\ell}\right)\right) \]
    7. Simplified70.3%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
    8. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. remove-double-neg0.0%

        \[\leadsto \color{blue}{-\left(-\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. associate-*l*0.0%

        \[\leadsto -\left(-\color{blue}{d \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}\right) \]
      3. *-commutative0.0%

        \[\leadsto -\left(-d \cdot \color{blue}{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)}\right) \]
      4. distribute-rgt-neg-in0.0%

        \[\leadsto -\color{blue}{d \cdot \left(-\sqrt{\frac{1}{h \cdot \ell}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      5. *-commutative0.0%

        \[\leadsto -d \cdot \left(-\color{blue}{{\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}}\right) \]
      6. unpow20.0%

        \[\leadsto -d \cdot \left(-\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      7. rem-square-sqrt44.7%

        \[\leadsto -d \cdot \left(-\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      8. mul-1-neg44.7%

        \[\leadsto -d \cdot \left(-\color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)}\right) \]
      9. remove-double-neg44.7%

        \[\leadsto -d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
      10. unpow1/244.7%

        \[\leadsto -d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      11. rem-exp-log42.2%

        \[\leadsto -d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      12. exp-neg42.2%

        \[\leadsto -d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      13. exp-prod42.2%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      14. distribute-lft-neg-out42.2%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      15. exp-neg42.2%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      16. exp-to-pow44.7%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      17. unpow1/244.7%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
    10. Simplified44.8%

      \[\leadsto \color{blue}{\frac{-d}{\sqrt{h \cdot \ell}}} \]

    if -2.4e-237 < l

    1. Initial program 72.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.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. Taylor expanded in d around inf 43.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*44.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified44.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 28: 42.3% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2.3 \cdot 10^{-237}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \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.3e-237) (/ (- d) (sqrt (* h l))) (* d (pow (* h l) -0.5))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -2.3e-237) {
		tmp = -d / sqrt((h * l));
	} else {
		tmp = d * pow((h * l), -0.5);
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= (-2.3d-237)) then
        tmp = -d / sqrt((h * l))
    else
        tmp = d * ((h * l) ** (-0.5d0))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -2.3e-237) {
		tmp = -d / Math.sqrt((h * l));
	} else {
		tmp = d * Math.pow((h * l), -0.5);
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= -2.3e-237:
		tmp = -d / math.sqrt((h * l))
	else:
		tmp = d * math.pow((h * l), -0.5)
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -2.3e-237)
		tmp = Float64(Float64(-d) / sqrt(Float64(h * l)));
	else
		tmp = Float64(d * (Float64(h * l) ^ -0.5));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= -2.3e-237)
		tmp = -d / sqrt((h * l));
	else
		tmp = d * ((h * l) ^ -0.5);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -2.3e-237], N[((-d) / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $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.3 \cdot 10^{-237}:\\
\;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.30000000000000011e-237

    1. Initial program 69.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified68.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.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-times71.1%

        \[\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.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. *-commutative70.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right)}^{2} \cdot h}{\ell}\right) \]
    5. Applied egg-rr70.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2} \cdot h}{\ell}}\right) \]
    6. Step-by-step derivation
      1. *-commutative70.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{h \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}}{\ell}\right) \]
      2. associate-/l*70.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(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
      3. associate-*r/70.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}}{\ell}\right)\right) \]
      4. *-commutative70.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}}{\ell}\right)\right) \]
    7. Simplified70.3%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
    8. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. remove-double-neg0.0%

        \[\leadsto \color{blue}{-\left(-\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. associate-*l*0.0%

        \[\leadsto -\left(-\color{blue}{d \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}\right) \]
      3. *-commutative0.0%

        \[\leadsto -\left(-d \cdot \color{blue}{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)}\right) \]
      4. distribute-rgt-neg-in0.0%

        \[\leadsto -\color{blue}{d \cdot \left(-\sqrt{\frac{1}{h \cdot \ell}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      5. *-commutative0.0%

        \[\leadsto -d \cdot \left(-\color{blue}{{\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}}\right) \]
      6. unpow20.0%

        \[\leadsto -d \cdot \left(-\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      7. rem-square-sqrt44.7%

        \[\leadsto -d \cdot \left(-\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      8. mul-1-neg44.7%

        \[\leadsto -d \cdot \left(-\color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)}\right) \]
      9. remove-double-neg44.7%

        \[\leadsto -d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
      10. unpow1/244.7%

        \[\leadsto -d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      11. rem-exp-log42.2%

        \[\leadsto -d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      12. exp-neg42.2%

        \[\leadsto -d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      13. exp-prod42.2%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      14. distribute-lft-neg-out42.2%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      15. exp-neg42.2%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      16. exp-to-pow44.7%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      17. unpow1/244.7%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
    10. Simplified44.8%

      \[\leadsto \color{blue}{\frac{-d}{\sqrt{h \cdot \ell}}} \]

    if -2.30000000000000011e-237 < l

    1. Initial program 72.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.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. Applied egg-rr70.5%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow170.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)} \]
      2. associate-*l/73.2%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      3. associate-/l*74.4%

        \[\leadsto \color{blue}{d \cdot \frac{1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      4. +-commutative74.4%

        \[\leadsto d \cdot \frac{\color{blue}{-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right) + 1}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      5. associate-*r*74.4%

        \[\leadsto d \cdot \frac{\color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
      6. fma-define74.4%

        \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(-0.5 \cdot \frac{h}{\ell}, {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}, 1\right)}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      7. *-commutative74.4%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{\frac{h}{\ell} \cdot -0.5}, {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      8. associate-*r/75.2%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      9. *-commutative75.2%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
    6. Simplified75.2%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    7. Taylor expanded in h around 0 43.8%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. unpow-143.8%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. metadata-eval43.8%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr43.8%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square43.8%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt43.7%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr43.7%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt43.8%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Simplified43.8%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 29: 25.8% accurate, 3.1× 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])\\ \\ d \cdot {\left(h \cdot \ell\right)}^{-0.5} \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 (pow (* h l) -0.5)))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d * pow((h * l), -0.5);
}
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 * ((h * l) ** (-0.5d0))
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.pow((h * l), -0.5);
}
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.pow((h * l), -0.5)
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 * (Float64(h * l) ^ -0.5))
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 * ((h * l) ^ -0.5);
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[Power[N[(h * l), $MachinePrecision], -0.5], $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])\\
\\
d \cdot {\left(h \cdot \ell\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 70.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. Simplified70.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. Applied egg-rr38.8%

    \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
  5. Step-by-step derivation
    1. unpow138.8%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)} \]
    2. associate-*l/40.3%

      \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    3. associate-/l*41.0%

      \[\leadsto \color{blue}{d \cdot \frac{1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    4. +-commutative41.0%

      \[\leadsto d \cdot \frac{\color{blue}{-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right) + 1}}{\sqrt{\ell} \cdot \sqrt{h}} \]
    5. associate-*r*41.0%

      \[\leadsto d \cdot \frac{\color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}} + 1}{\sqrt{\ell} \cdot \sqrt{h}} \]
    6. fma-define41.0%

      \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(-0.5 \cdot \frac{h}{\ell}, {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}, 1\right)}}{\sqrt{\ell} \cdot \sqrt{h}} \]
    7. *-commutative41.0%

      \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{\frac{h}{\ell} \cdot -0.5}, {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
    8. associate-*r/41.4%

      \[\leadsto d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
    9. *-commutative41.4%

      \[\leadsto d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
  6. Simplified41.4%

    \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  7. Taylor expanded in h around 0 26.8%

    \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
  8. Step-by-step derivation
    1. unpow-126.8%

      \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
    2. metadata-eval26.8%

      \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
    3. pow-sqr26.8%

      \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
    4. rem-sqrt-square26.8%

      \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
    5. rem-square-sqrt26.8%

      \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
    6. fabs-sqr26.8%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
    7. rem-square-sqrt26.8%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  9. Simplified26.8%

    \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  10. Add Preprocessing

Alternative 30: 25.8% 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{h \cdot \ell}} \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 (* 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) {
	return d / sqrt((h * l));
}
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((h * l))
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((h * l));
}
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((h * l))
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(h * l)))
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((h * l));
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[(h * 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])\\
\\
\frac{d}{\sqrt{h \cdot \ell}}
\end{array}
Derivation
  1. Initial program 70.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. Simplified70.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/72.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.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*72.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. *-commutative72.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right)}^{2} \cdot h}{\ell}\right) \]
  5. Applied egg-rr72.5%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2} \cdot h}{\ell}}\right) \]
  6. Step-by-step derivation
    1. *-commutative72.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{h \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}}{\ell}\right) \]
    2. associate-/l*72.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
    3. associate-*r/73.3%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{d \cdot 2}\right)}}^{2}}{\ell}\right)\right) \]
    4. *-commutative73.3%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2}}{\ell}\right)\right) \]
  7. Simplified73.3%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
  8. Taylor expanded in d around inf 26.8%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  9. Step-by-step derivation
    1. unpow1/226.8%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    2. rem-exp-log25.7%

      \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
    3. exp-neg25.7%

      \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
    4. exp-prod25.7%

      \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
    5. distribute-lft-neg-out25.7%

      \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
    6. exp-neg25.8%

      \[\leadsto d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
    7. exp-to-pow26.8%

      \[\leadsto d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
    8. unpow1/226.8%

      \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
    9. associate-/l*26.8%

      \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
    10. *-rgt-identity26.8%

      \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
  10. Simplified26.8%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  11. Add Preprocessing

Reproduce

?
herbie shell --seed 2024090 
(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)))))