Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.0% → 82.0%
Time: 26.6s
Alternatives: 20
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 20 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.0% 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.0% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 67.5%

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

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

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

      \[\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 -5e-175 < l < -3.79999999999999975e-308

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

      \[\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. associate-*r/46.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.79999999999999975e-308 < l < 1.70000000000000005e-120

    1. Initial program 60.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. Simplified53.2%

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

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

        \[\leadsto \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}}\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. sqrt-div67.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.70000000000000005e-120 < l

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

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

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

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

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

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

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      6. add-sqr-sqrt74.6%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      7. unpow-prod-down74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 82.6% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 64.7%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 41.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. associate-*r/41.5%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < l < 3.7000000000000002e-121

    1. Initial program 62.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. Simplified54.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. *-commutative54.5%

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

        \[\leadsto \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}}\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. sqrt-div69.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.7000000000000002e-121 < l

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

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

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

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

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

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

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      6. add-sqr-sqrt74.6%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      7. unpow-prod-down74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 76.9% accurate, 0.8× speedup?

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

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

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

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

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


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

    1. Initial program 54.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. Simplified58.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 36.0%

      \[\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. associate-*r/36.0%

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, 1\right)}\right) \]
    7. 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}}} \]
    8. 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. *-commutative0.0%

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

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

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

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

        \[\leadsto \color{blue}{-\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      7. unpow1/292.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
      17. distribute-frac-neg292.2%

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

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

    if -9.9999999999999995e196 < d < -8.19999999999999962e-203

    1. Initial program 74.6%

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

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

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

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

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

        \[\leadsto \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)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. associate-*l/79.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.19999999999999962e-203 < d < -4.999999999999985e-310

    1. Initial program 37.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. Simplified37.3%

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{e^{\log \left(\frac{d}{\ell}\right) \cdot 0.5}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Taylor expanded in 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)} \]
    7. Step-by-step derivation
      1. associate-*r*0.0%

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < d < 3.9000000000000001e-116

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

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

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

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

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

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

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      6. add-sqr-sqrt51.8%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      7. unpow-prod-down51.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.9000000000000001e-116 < d

    1. Initial program 66.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 76.0% accurate, 0.8× speedup?

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

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

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

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

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


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

    1. Initial program 54.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. Simplified58.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 36.0%

      \[\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. associate-*r/36.0%

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, 1\right)}\right) \]
    7. 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}}} \]
    8. 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. *-commutative0.0%

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

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

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

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

        \[\leadsto \color{blue}{-\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      7. unpow1/292.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
      17. distribute-frac-neg292.2%

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

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

    if -1.9000000000000001e197 < d < -8.50000000000000031e-203

    1. Initial program 74.6%

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

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

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

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

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

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

    if -8.50000000000000031e-203 < d < -4.999999999999985e-310

    1. Initial program 37.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. Simplified37.3%

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{e^{\log \left(\frac{d}{\ell}\right) \cdot 0.5}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Taylor expanded in 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)} \]
    7. Step-by-step derivation
      1. associate-*r*0.0%

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < d < 4.5000000000000001e-113

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

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

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

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

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

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

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      6. add-sqr-sqrt51.8%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      7. unpow-prod-down51.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.5000000000000001e-113 < d

    1. Initial program 66.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 75.7% accurate, 0.8× speedup?

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

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

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

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

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


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

    1. Initial program 54.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. Simplified58.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 36.0%

      \[\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. associate-*r/36.0%

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, 1\right)}\right) \]
    7. 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}}} \]
    8. 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. *-commutative0.0%

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

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

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

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

        \[\leadsto \color{blue}{-\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      7. unpow1/292.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
      17. distribute-frac-neg292.2%

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

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

    if -3.4999999999999998e196 < d < -8.19999999999999962e-203

    1. Initial program 74.6%

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

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

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

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

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

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

    if -8.19999999999999962e-203 < d < -4.999999999999985e-310

    1. Initial program 37.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. Simplified37.3%

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{e^{\log \left(\frac{d}{\ell}\right) \cdot 0.5}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Taylor expanded in 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)} \]
    7. Step-by-step derivation
      1. associate-*r*0.0%

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < d < 1.2499999999999999e-130

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

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

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

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

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

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

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      6. add-sqr-sqrt50.7%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      7. unpow-prod-down50.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.2499999999999999e-130 < d

    1. Initial program 66.9%

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

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

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

        \[\leadsto \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}}\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. sqrt-div82.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 80.2% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 54.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. Simplified58.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 36.0%

      \[\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. associate-*r/36.0%

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, 1\right)}\right) \]
    7. 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}}} \]
    8. 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. *-commutative0.0%

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

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

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

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

        \[\leadsto \color{blue}{-\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      7. unpow1/292.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
      17. distribute-frac-neg292.2%

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

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

    if -9.00000000000000003e198 < d < -4.999999999999985e-310

    1. Initial program 67.3%

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

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

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

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

      \[\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 -4.999999999999985e-310 < d < 1.34999999999999997e-118

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

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

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

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

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

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

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      6. add-sqr-sqrt51.8%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      7. unpow-prod-down51.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.34999999999999997e-118 < d

    1. Initial program 66.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 75.0% accurate, 0.8× speedup?

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

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

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

\mathbf{elif}\;d \leq 8.6 \cdot 10^{-197}:\\
\;\;\;\;d \cdot \frac{h \cdot \left(\frac{-0.125}{\ell} \cdot {\left(M\_m \cdot \frac{D}{d}\right)}^{2}\right)}{t\_0}\\

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


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

    1. Initial program 54.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. Simplified58.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 36.0%

      \[\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. associate-*r/36.0%

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, 1\right)}\right) \]
    7. 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}}} \]
    8. 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. *-commutative0.0%

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

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

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

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

        \[\leadsto \color{blue}{-\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      7. unpow1/292.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
      17. distribute-frac-neg292.2%

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

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

    if -7.3999999999999998e196 < d < -8.50000000000000031e-203

    1. Initial program 74.6%

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

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

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

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

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

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

    if -8.50000000000000031e-203 < d < -4.999999999999985e-310

    1. Initial program 37.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. Simplified37.3%

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{e^{\log \left(\frac{d}{\ell}\right) \cdot 0.5}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Taylor expanded in 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)} \]
    7. Step-by-step derivation
      1. associate-*r*0.0%

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < d < 8.6000000000000001e-197

    1. Initial program 26.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. Simplified22.1%

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

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

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

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

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

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      6. add-sqr-sqrt35.6%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      7. unpow-prod-down35.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.6000000000000001e-197 < d

    1. Initial program 65.8%

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

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

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

        \[\leadsto \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}}\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. sqrt-div80.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 78.1% accurate, 1.0× speedup?

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

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

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

\mathbf{elif}\;d \leq 1.2 \cdot 10^{-197}:\\
\;\;\;\;d \cdot \frac{h \cdot \left(\frac{-0.125}{\ell} \cdot t\_0\right)}{t\_1}\\

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


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

    1. Initial program 54.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. Simplified58.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 36.0%

      \[\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. associate-*r/36.0%

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, 1\right)}\right) \]
    7. 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}}} \]
    8. 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. *-commutative0.0%

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

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

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

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

        \[\leadsto \color{blue}{-\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      7. unpow1/292.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
      17. distribute-frac-neg292.2%

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

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

    if -5.59999999999999999e198 < d < -2.1000000000000001e-43

    1. Initial program 77.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. Simplified77.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 M around 0 49.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(0.25 \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*51.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.1000000000000001e-43 < d < -4.999999999999985e-310

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < d < 1.2e-197

    1. Initial program 26.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. Simplified22.1%

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

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

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

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

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

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      6. add-sqr-sqrt35.6%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      7. unpow-prod-down35.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.2e-197 < d

    1. Initial program 65.8%

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

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

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

        \[\leadsto \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}}\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. sqrt-div80.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 76.2% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;d \leq 7.6 \cdot 10^{-198}:\\
\;\;\;\;d \cdot \frac{h \cdot \left(\frac{-0.125}{\ell} \cdot {\left(M\_m \cdot \frac{D}{d}\right)}^{2}\right)}{t\_0}\\

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


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

    1. Initial program 56.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. Simplified61.0%

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

      \[\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. associate-*r/37.2%

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, 1\right)}\right) \]
    7. 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}}} \]
    8. 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. *-commutative0.0%

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

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

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

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

        \[\leadsto \color{blue}{-\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      7. unpow1/291.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
      17. distribute-frac-neg291.9%

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

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

    if -4.4999999999999997e199 < d < -4.999999999999985e-310

    1. Initial program 66.7%

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < d < 7.6000000000000004e-198

    1. Initial program 26.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. Simplified22.1%

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

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

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

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

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

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      6. add-sqr-sqrt35.6%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      7. unpow-prod-down35.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \frac{h \cdot \left(\color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)} \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      12. unpow249.0%

        \[\leadsto d \cdot \frac{h \cdot \left(\left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right) \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      13. unpow249.0%

        \[\leadsto d \cdot \frac{h \cdot \left(\left(\left(M \cdot M\right) \cdot \frac{\color{blue}{D \cdot D}}{{d}^{2}}\right) \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      14. unpow249.0%

        \[\leadsto d \cdot \frac{h \cdot \left(\left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\color{blue}{d \cdot d}}\right) \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      15. times-frac62.0%

        \[\leadsto d \cdot \frac{h \cdot \left(\left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right) \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      16. swap-sqr66.7%

        \[\leadsto d \cdot \frac{h \cdot \left(\color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)} \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      17. unpow266.7%

        \[\leadsto d \cdot \frac{h \cdot \left(\color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}} \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    10. Simplified66.7%

      \[\leadsto d \cdot \frac{\color{blue}{h \cdot \left({\left(M \cdot \frac{D}{d}\right)}^{2} \cdot \frac{-0.125}{\ell}\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]

    if 7.6000000000000004e-198 < d

    1. Initial program 65.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative63.9%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. sqrt-div68.8%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}}\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. sqrt-div80.7%

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. frac-times80.7%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. add-sqr-sqrt80.9%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr80.9%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. associate-*r/87.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}}\right) \]
      2. associate-*l/87.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(\frac{M \cdot \frac{D}{d}}{2}\right)}}^{2} \cdot h}{\ell}\right) \]
      3. div-inv87.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \frac{1}{2}\right)}}^{2} \cdot h}{\ell}\right) \]
      4. metadata-eval87.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \frac{{\left(\left(M \cdot \frac{D}{d}\right) \cdot \color{blue}{0.5}\right)}^{2} \cdot h}{\ell}\right) \]
      5. *-commutative87.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}}^{2} \cdot h}{\ell}\right) \]
      6. unpow-prod-down87.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{\left({0.5}^{2} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right)} \cdot h}{\ell}\right) \]
      7. metadata-eval87.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \frac{\left(\color{blue}{0.25} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right) \cdot h}{\ell}\right) \]
      8. clear-num86.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \frac{\left(0.25 \cdot {\left(M \cdot \color{blue}{\frac{1}{\frac{d}{D}}}\right)}^{2}\right) \cdot h}{\ell}\right) \]
      9. un-div-inv86.5%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \frac{\left(0.25 \cdot {\color{blue}{\left(\frac{M}{\frac{d}{D}}\right)}}^{2}\right) \cdot h}{\ell}\right) \]
    7. Applied egg-rr86.5%

      \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot h}{\ell}}\right) \]
  3. Recombined 4 regimes into one program.
  4. Final simplification79.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.5 \cdot 10^{+199}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right) + -1\right)\\ \mathbf{elif}\;d \leq 7.6 \cdot 10^{-198}:\\ \;\;\;\;d \cdot \frac{h \cdot \left(\frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot \left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right)}{\ell}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 74.3% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} t_0 := 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right)\\ t_1 := \sqrt{\ell} \cdot \sqrt{h}\\ \mathbf{if}\;d \leq -3.6 \cdot 10^{+199}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(t\_0 + -1\right)\\ \mathbf{elif}\;d \leq 3.2 \cdot 10^{-196}:\\ \;\;\;\;d \cdot \frac{h \cdot \left(\frac{-0.125}{\ell} \cdot {\left(M\_m \cdot \frac{D}{d}\right)}^{2}\right)}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{t\_1} \cdot \left(1 - t\_0\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (let* ((t_0 (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M_m 2.0)) 2.0))))
        (t_1 (* (sqrt l) (sqrt h))))
   (if (<= d -3.6e+199)
     (/ (- d) (sqrt (* l h)))
     (if (<= d -5e-310)
       (* (* d (sqrt (/ 1.0 (* l h)))) (+ t_0 -1.0))
       (if (<= d 3.2e-196)
         (* d (/ (* h (* (/ -0.125 l) (pow (* M_m (/ D d)) 2.0))) t_1))
         (* (/ d t_1) (- 1.0 t_0)))))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double t_0 = 0.5 * ((h / l) * pow(((D / d) * (M_m / 2.0)), 2.0));
	double t_1 = sqrt(l) * sqrt(h);
	double tmp;
	if (d <= -3.6e+199) {
		tmp = -d / sqrt((l * h));
	} else if (d <= -5e-310) {
		tmp = (d * sqrt((1.0 / (l * h)))) * (t_0 + -1.0);
	} else if (d <= 3.2e-196) {
		tmp = d * ((h * ((-0.125 / l) * pow((M_m * (D / d)), 2.0))) / t_1);
	} else {
		tmp = (d / t_1) * (1.0 - t_0);
	}
	return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 0.5d0 * ((h / l) * (((d_1 / d) * (m_m / 2.0d0)) ** 2.0d0))
    t_1 = sqrt(l) * sqrt(h)
    if (d <= (-3.6d+199)) then
        tmp = -d / sqrt((l * h))
    else if (d <= (-5d-310)) then
        tmp = (d * sqrt((1.0d0 / (l * h)))) * (t_0 + (-1.0d0))
    else if (d <= 3.2d-196) then
        tmp = d * ((h * (((-0.125d0) / l) * ((m_m * (d_1 / d)) ** 2.0d0))) / t_1)
    else
        tmp = (d / t_1) * (1.0d0 - t_0)
    end if
    code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double t_0 = 0.5 * ((h / l) * Math.pow(((D / d) * (M_m / 2.0)), 2.0));
	double t_1 = Math.sqrt(l) * Math.sqrt(h);
	double tmp;
	if (d <= -3.6e+199) {
		tmp = -d / Math.sqrt((l * h));
	} else if (d <= -5e-310) {
		tmp = (d * Math.sqrt((1.0 / (l * h)))) * (t_0 + -1.0);
	} else if (d <= 3.2e-196) {
		tmp = d * ((h * ((-0.125 / l) * Math.pow((M_m * (D / d)), 2.0))) / t_1);
	} else {
		tmp = (d / t_1) * (1.0 - t_0);
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	t_0 = 0.5 * ((h / l) * math.pow(((D / d) * (M_m / 2.0)), 2.0))
	t_1 = math.sqrt(l) * math.sqrt(h)
	tmp = 0
	if d <= -3.6e+199:
		tmp = -d / math.sqrt((l * h))
	elif d <= -5e-310:
		tmp = (d * math.sqrt((1.0 / (l * h)))) * (t_0 + -1.0)
	elif d <= 3.2e-196:
		tmp = d * ((h * ((-0.125 / l) * math.pow((M_m * (D / d)), 2.0))) / t_1)
	else:
		tmp = (d / t_1) * (1.0 - t_0)
	return tmp
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	t_0 = Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M_m / 2.0)) ^ 2.0)))
	t_1 = Float64(sqrt(l) * sqrt(h))
	tmp = 0.0
	if (d <= -3.6e+199)
		tmp = Float64(Float64(-d) / sqrt(Float64(l * h)));
	elseif (d <= -5e-310)
		tmp = Float64(Float64(d * sqrt(Float64(1.0 / Float64(l * h)))) * Float64(t_0 + -1.0));
	elseif (d <= 3.2e-196)
		tmp = Float64(d * Float64(Float64(h * Float64(Float64(-0.125 / l) * (Float64(M_m * Float64(D / d)) ^ 2.0))) / t_1));
	else
		tmp = Float64(Float64(d / t_1) * Float64(1.0 - t_0));
	end
	return tmp
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
	t_0 = 0.5 * ((h / l) * (((D / d) * (M_m / 2.0)) ^ 2.0));
	t_1 = sqrt(l) * sqrt(h);
	tmp = 0.0;
	if (d <= -3.6e+199)
		tmp = -d / sqrt((l * h));
	elseif (d <= -5e-310)
		tmp = (d * sqrt((1.0 / (l * h)))) * (t_0 + -1.0);
	elseif (d <= 3.2e-196)
		tmp = d * ((h * ((-0.125 / l) * ((M_m * (D / d)) ^ 2.0))) / t_1);
	else
		tmp = (d / t_1) * (1.0 - t_0);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.6e+199], N[((-d) / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-310], N[(N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.2e-196], N[(d * N[(N[(h * N[(N[(-0.125 / l), $MachinePrecision] * N[Power[N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(d / t$95$1), $MachinePrecision] * N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right)\\
t_1 := \sqrt{\ell} \cdot \sqrt{h}\\
\mathbf{if}\;d \leq -3.6 \cdot 10^{+199}:\\
\;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\

\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(t\_0 + -1\right)\\

\mathbf{elif}\;d \leq 3.2 \cdot 10^{-196}:\\
\;\;\;\;d \cdot \frac{h \cdot \left(\frac{-0.125}{\ell} \cdot {\left(M\_m \cdot \frac{D}{d}\right)}^{2}\right)}{t\_1}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_1} \cdot \left(1 - t\_0\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -3.60000000000000001e199

    1. Initial program 56.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. Simplified61.0%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 37.2%

      \[\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. associate-*r/37.2%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}}\right)\right) \]
      2. associate-*r*45.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{-0.125 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2} \cdot \ell}\right)\right) \]
      3. associate-*r*45.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{\color{blue}{\left(-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)\right) \cdot h}}{{d}^{2} \cdot \ell}\right)\right) \]
      4. associate-*l/45.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)}{{d}^{2} \cdot \ell} \cdot h}\right)\right) \]
      5. associate-*r/45.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)} \cdot h\right)\right) \]
      6. *-commutative45.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)}\right)\right) \]
      7. +-commutative45.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) + 1\right)}\right) \]
      8. fma-undefine45.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, -0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}, 1\right)}\right) \]
    6. Simplified70.1%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, 1\right)}\right) \]
    7. 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}}} \]
    8. 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. *-commutative0.0%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      3. unpow20.0%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      4. rem-square-sqrt91.9%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      5. neg-mul-191.9%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \color{blue}{\left(-d\right)} \]
      6. distribute-rgt-neg-in91.9%

        \[\leadsto \color{blue}{-\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      7. unpow1/291.9%

        \[\leadsto -\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \cdot d \]
      8. rem-exp-log90.0%

        \[\leadsto -{\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \cdot d \]
      9. exp-neg90.1%

        \[\leadsto -{\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot d \]
      10. exp-prod90.1%

        \[\leadsto -\color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \cdot d \]
      11. distribute-lft-neg-out90.1%

        \[\leadsto -e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot d \]
      12. exp-neg90.1%

        \[\leadsto -\color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \cdot d \]
      13. exp-to-pow91.9%

        \[\leadsto -\frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \cdot d \]
      14. unpow1/291.9%

        \[\leadsto -\frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot d \]
      15. associate-*l/91.9%

        \[\leadsto -\color{blue}{\frac{1 \cdot d}{\sqrt{h \cdot \ell}}} \]
      16. *-lft-identity91.9%

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
      17. distribute-frac-neg291.9%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]
    9. Simplified91.9%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if -3.60000000000000001e199 < d < -4.999999999999985e-310

    1. Initial program 66.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified67.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. clear-num67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. sqrt-div67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      3. metadata-eval67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr67.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Taylor expanded in d around -inf 70.5%

      \[\leadsto \color{blue}{\left(-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]

    if -4.999999999999985e-310 < d < 3.2e-196

    1. Initial program 26.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. Simplified22.1%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow122.1%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\right)}^{1}} \]
      2. associate-*r*22.1%

        \[\leadsto {\color{blue}{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \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)}}^{1} \]
      3. sqrt-div35.3%

        \[\leadsto {\left(\left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}}\right) \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)}^{1} \]
      4. sqrt-div35.6%

        \[\leadsto {\left(\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}}\right) \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)}^{1} \]
      5. frac-times35.6%

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      6. add-sqr-sqrt35.6%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      7. unpow-prod-down35.6%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{{0.5}^{2} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      8. metadata-eval35.6%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{0.25} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      9. clear-num35.6%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(M \cdot \color{blue}{\frac{1}{\frac{d}{D}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      10. un-div-inv39.8%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\color{blue}{\left(\frac{M}{\frac{d}{D}}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
    5. Applied egg-rr39.8%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow139.8%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \]
      2. associate-*l/70.9%

        \[\leadsto \color{blue}{\frac{d \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. associate-/l*70.8%

        \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      4. fma-define70.8%

        \[\leadsto d \cdot \frac{\color{blue}{\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot \left(-0.5 \cdot \frac{h}{\ell}\right) + 1}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. associate-*r*70.8%

        \[\leadsto d \cdot \frac{\color{blue}{\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5\right) \cdot \frac{h}{\ell}} + 1}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. fma-define70.8%

        \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5, \frac{h}{\ell}, 1\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      7. *-commutative70.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot 0.25\right)} \cdot -0.5, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      8. associate-*l*70.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{{\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \left(0.25 \cdot -0.5\right)}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      9. metadata-eval70.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \color{blue}{-0.125}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      10. *-commutative70.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{-0.125 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      11. associate-/r/70.7%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M}{d} \cdot D\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      12. associate-*l/70.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      13. associate-/l*66.7%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(M \cdot \frac{D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. Simplified66.7%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Taylor expanded in M around inf 48.7%

      \[\leadsto d \cdot \frac{\color{blue}{-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}}}{\sqrt{h} \cdot \sqrt{\ell}} \]
    9. Step-by-step derivation
      1. associate-*r/48.7%

        \[\leadsto d \cdot \frac{\color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      2. associate-*r*48.7%

        \[\leadsto d \cdot \frac{\frac{-0.125 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2} \cdot \ell}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      3. associate-*r*48.7%

        \[\leadsto d \cdot \frac{\frac{\color{blue}{\left(-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)\right) \cdot h}}{{d}^{2} \cdot \ell}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      4. associate-*l/48.7%

        \[\leadsto d \cdot \frac{\color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)}{{d}^{2} \cdot \ell} \cdot h}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. associate-*r/48.7%

        \[\leadsto d \cdot \frac{\color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)} \cdot h}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. *-commutative48.7%

        \[\leadsto d \cdot \frac{\color{blue}{h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      7. *-commutative48.7%

        \[\leadsto d \cdot \frac{h \cdot \color{blue}{\left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} \cdot -0.125\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      8. associate-*l/48.7%

        \[\leadsto d \cdot \frac{h \cdot \color{blue}{\frac{\left({D}^{2} \cdot {M}^{2}\right) \cdot -0.125}{{d}^{2} \cdot \ell}}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      9. times-frac48.7%

        \[\leadsto d \cdot \frac{h \cdot \color{blue}{\left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \frac{-0.125}{\ell}\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      10. *-commutative48.7%

        \[\leadsto d \cdot \frac{h \cdot \left(\frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}} \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      11. associate-/l*49.0%

        \[\leadsto d \cdot \frac{h \cdot \left(\color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)} \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      12. unpow249.0%

        \[\leadsto d \cdot \frac{h \cdot \left(\left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right) \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      13. unpow249.0%

        \[\leadsto d \cdot \frac{h \cdot \left(\left(\left(M \cdot M\right) \cdot \frac{\color{blue}{D \cdot D}}{{d}^{2}}\right) \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      14. unpow249.0%

        \[\leadsto d \cdot \frac{h \cdot \left(\left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\color{blue}{d \cdot d}}\right) \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      15. times-frac62.0%

        \[\leadsto d \cdot \frac{h \cdot \left(\left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right) \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      16. swap-sqr66.7%

        \[\leadsto d \cdot \frac{h \cdot \left(\color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)} \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      17. unpow266.7%

        \[\leadsto d \cdot \frac{h \cdot \left(\color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}} \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    10. Simplified66.7%

      \[\leadsto d \cdot \frac{\color{blue}{h \cdot \left({\left(M \cdot \frac{D}{d}\right)}^{2} \cdot \frac{-0.125}{\ell}\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]

    if 3.2e-196 < d

    1. Initial program 65.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative63.9%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. sqrt-div68.8%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}}\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. sqrt-div80.7%

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. frac-times80.7%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. add-sqr-sqrt80.9%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr80.9%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
  3. Recombined 4 regimes into one program.
  4. Final simplification76.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.6 \cdot 10^{+199}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right) + -1\right)\\ \mathbf{elif}\;d \leq 3.2 \cdot 10^{-196}:\\ \;\;\;\;d \cdot \frac{h \cdot \left(\frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 71.5% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;d \leq -7.5 \cdot 10^{+199}:\\ \;\;\;\;\frac{-d}{t\_0}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right) + -1\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \frac{\frac{M\_m}{d}}{2}\right)}^{2}}{\ell}, 1\right)}{t\_0}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (let* ((t_0 (sqrt (* l h))))
   (if (<= d -7.5e+199)
     (/ (- d) t_0)
     (if (<= d -5e-310)
       (*
        (* d (sqrt (/ 1.0 (* l h))))
        (+ (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M_m 2.0)) 2.0))) -1.0))
       (*
        d
        (/
         (fma -0.5 (* h (/ (pow (* D (/ (/ M_m d) 2.0)) 2.0) l)) 1.0)
         t_0))))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double t_0 = sqrt((l * h));
	double tmp;
	if (d <= -7.5e+199) {
		tmp = -d / t_0;
	} else if (d <= -5e-310) {
		tmp = (d * sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0);
	} else {
		tmp = d * (fma(-0.5, (h * (pow((D * ((M_m / d) / 2.0)), 2.0) / l)), 1.0) / t_0);
	}
	return tmp;
}
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	t_0 = sqrt(Float64(l * h))
	tmp = 0.0
	if (d <= -7.5e+199)
		tmp = Float64(Float64(-d) / t_0);
	elseif (d <= -5e-310)
		tmp = Float64(Float64(d * sqrt(Float64(1.0 / Float64(l * h)))) * Float64(Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M_m / 2.0)) ^ 2.0))) + -1.0));
	else
		tmp = Float64(d * Float64(fma(-0.5, Float64(h * Float64((Float64(D * Float64(Float64(M_m / d) / 2.0)) ^ 2.0) / l)), 1.0) / t_0));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -7.5e+199], N[((-d) / t$95$0), $MachinePrecision], If[LessEqual[d, -5e-310], N[(N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(-0.5 * N[(h * N[(N[Power[N[(D * N[(N[(M$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;d \leq -7.5 \cdot 10^{+199}:\\
\;\;\;\;\frac{-d}{t\_0}\\

\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right) + -1\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \frac{\frac{M\_m}{d}}{2}\right)}^{2}}{\ell}, 1\right)}{t\_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -7.49999999999999977e199

    1. Initial program 56.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. Simplified61.0%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 37.2%

      \[\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. associate-*r/37.2%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}}\right)\right) \]
      2. associate-*r*45.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{-0.125 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2} \cdot \ell}\right)\right) \]
      3. associate-*r*45.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{\color{blue}{\left(-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)\right) \cdot h}}{{d}^{2} \cdot \ell}\right)\right) \]
      4. associate-*l/45.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)}{{d}^{2} \cdot \ell} \cdot h}\right)\right) \]
      5. associate-*r/45.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)} \cdot h\right)\right) \]
      6. *-commutative45.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)}\right)\right) \]
      7. +-commutative45.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) + 1\right)}\right) \]
      8. fma-undefine45.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, -0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}, 1\right)}\right) \]
    6. Simplified70.1%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, 1\right)}\right) \]
    7. 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}}} \]
    8. 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. *-commutative0.0%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      3. unpow20.0%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      4. rem-square-sqrt91.9%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      5. neg-mul-191.9%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \color{blue}{\left(-d\right)} \]
      6. distribute-rgt-neg-in91.9%

        \[\leadsto \color{blue}{-\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      7. unpow1/291.9%

        \[\leadsto -\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \cdot d \]
      8. rem-exp-log90.0%

        \[\leadsto -{\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \cdot d \]
      9. exp-neg90.1%

        \[\leadsto -{\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot d \]
      10. exp-prod90.1%

        \[\leadsto -\color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \cdot d \]
      11. distribute-lft-neg-out90.1%

        \[\leadsto -e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot d \]
      12. exp-neg90.1%

        \[\leadsto -\color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \cdot d \]
      13. exp-to-pow91.9%

        \[\leadsto -\frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \cdot d \]
      14. unpow1/291.9%

        \[\leadsto -\frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot d \]
      15. associate-*l/91.9%

        \[\leadsto -\color{blue}{\frac{1 \cdot d}{\sqrt{h \cdot \ell}}} \]
      16. *-lft-identity91.9%

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
      17. distribute-frac-neg291.9%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]
    9. Simplified91.9%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if -7.49999999999999977e199 < d < -4.999999999999985e-310

    1. Initial program 66.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified67.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. clear-num67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. sqrt-div67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      3. metadata-eval67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr67.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Taylor expanded in d around -inf 70.5%

      \[\leadsto \color{blue}{\left(-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]

    if -4.999999999999985e-310 < d

    1. Initial program 58.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified56.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative56.7%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. sqrt-div60.8%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}}\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. sqrt-div72.9%

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. frac-times72.9%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. add-sqr-sqrt73.1%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr73.1%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. associate-*l/79.2%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      2. cancel-sign-sub-inv79.2%

        \[\leadsto \frac{d \cdot \color{blue}{\left(1 + \left(-0.5\right) \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. metadata-eval79.2%

        \[\leadsto \frac{d \cdot \left(1 + \color{blue}{-0.5} \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      4. *-commutative79.2%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right)}\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      5. associate-*l/79.2%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{M \cdot \frac{D}{d}}{2}\right)}}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      6. sqrt-unprod63.4%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\color{blue}{\sqrt{\ell \cdot h}}} \]
      7. *-commutative63.4%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    7. Applied egg-rr63.4%

      \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/l*63.3%

        \[\leadsto \color{blue}{d \cdot \frac{1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}\right)}{\sqrt{h \cdot \ell}}} \]
      2. +-commutative63.3%

        \[\leadsto d \cdot \frac{\color{blue}{-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}\right) + 1}}{\sqrt{h \cdot \ell}} \]
      3. fma-define63.3%

        \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}, 1\right)}}{\sqrt{h \cdot \ell}} \]
      4. associate-*l/70.0%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.5, \color{blue}{\frac{h \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}}{\ell}}, 1\right)}{\sqrt{h \cdot \ell}} \]
      5. associate-/l*70.1%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.5, \color{blue}{h \cdot \frac{{\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}}{\ell}}, 1\right)}{\sqrt{h \cdot \ell}} \]
      6. associate-*r/72.3%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(\frac{\color{blue}{\frac{M \cdot D}{d}}}{2}\right)}^{2}}{\ell}, 1\right)}{\sqrt{h \cdot \ell}} \]
      7. *-commutative72.3%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(\frac{\frac{\color{blue}{D \cdot M}}{d}}{2}\right)}^{2}}{\ell}, 1\right)}{\sqrt{h \cdot \ell}} \]
      8. associate-/l*71.6%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(\frac{\color{blue}{D \cdot \frac{M}{d}}}{2}\right)}^{2}}{\ell}, 1\right)}{\sqrt{h \cdot \ell}} \]
      9. associate-/l*71.6%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\color{blue}{\left(D \cdot \frac{\frac{M}{d}}{2}\right)}}^{2}}{\ell}, 1\right)}{\sqrt{h \cdot \ell}} \]
    9. Simplified71.6%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}}{\ell}, 1\right)}{\sqrt{h \cdot \ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification73.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.5 \cdot 10^{+199}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right) + -1\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell \cdot h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 70.7% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} t_0 := M\_m \cdot \frac{D}{d}\\ \mathbf{if}\;h \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right) + -1\right)\\ \mathbf{elif}\;h \leq 1.35 \cdot 10^{+187}:\\ \;\;\;\;\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{t\_0}{2}\right)}^{2}\right)\right)}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{h \cdot \left(\frac{-0.125}{\ell} \cdot {t\_0}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (let* ((t_0 (* M_m (/ D d))))
   (if (<= h -4e-310)
     (*
      (* d (sqrt (/ 1.0 (* l h))))
      (+ (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M_m 2.0)) 2.0))) -1.0))
     (if (<= h 1.35e+187)
       (/
        (* d (+ 1.0 (* -0.5 (* (/ h l) (pow (/ t_0 2.0) 2.0)))))
        (sqrt (* l h)))
       (* d (/ (* h (* (/ -0.125 l) (pow t_0 2.0))) (* (sqrt l) (sqrt h))))))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double t_0 = M_m * (D / d);
	double tmp;
	if (h <= -4e-310) {
		tmp = (d * sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0);
	} else if (h <= 1.35e+187) {
		tmp = (d * (1.0 + (-0.5 * ((h / l) * pow((t_0 / 2.0), 2.0))))) / sqrt((l * h));
	} else {
		tmp = d * ((h * ((-0.125 / l) * pow(t_0, 2.0))) / (sqrt(l) * sqrt(h)));
	}
	return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = m_m * (d_1 / d)
    if (h <= (-4d-310)) then
        tmp = (d * sqrt((1.0d0 / (l * h)))) * ((0.5d0 * ((h / l) * (((d_1 / d) * (m_m / 2.0d0)) ** 2.0d0))) + (-1.0d0))
    else if (h <= 1.35d+187) then
        tmp = (d * (1.0d0 + ((-0.5d0) * ((h / l) * ((t_0 / 2.0d0) ** 2.0d0))))) / sqrt((l * h))
    else
        tmp = d * ((h * (((-0.125d0) / l) * (t_0 ** 2.0d0))) / (sqrt(l) * sqrt(h)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double t_0 = M_m * (D / d);
	double tmp;
	if (h <= -4e-310) {
		tmp = (d * Math.sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * Math.pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0);
	} else if (h <= 1.35e+187) {
		tmp = (d * (1.0 + (-0.5 * ((h / l) * Math.pow((t_0 / 2.0), 2.0))))) / Math.sqrt((l * h));
	} else {
		tmp = d * ((h * ((-0.125 / l) * Math.pow(t_0, 2.0))) / (Math.sqrt(l) * Math.sqrt(h)));
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	t_0 = M_m * (D / d)
	tmp = 0
	if h <= -4e-310:
		tmp = (d * math.sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * math.pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0)
	elif h <= 1.35e+187:
		tmp = (d * (1.0 + (-0.5 * ((h / l) * math.pow((t_0 / 2.0), 2.0))))) / math.sqrt((l * h))
	else:
		tmp = d * ((h * ((-0.125 / l) * math.pow(t_0, 2.0))) / (math.sqrt(l) * math.sqrt(h)))
	return tmp
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	t_0 = Float64(M_m * Float64(D / d))
	tmp = 0.0
	if (h <= -4e-310)
		tmp = Float64(Float64(d * sqrt(Float64(1.0 / Float64(l * h)))) * Float64(Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M_m / 2.0)) ^ 2.0))) + -1.0));
	elseif (h <= 1.35e+187)
		tmp = Float64(Float64(d * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(t_0 / 2.0) ^ 2.0))))) / sqrt(Float64(l * h)));
	else
		tmp = Float64(d * Float64(Float64(h * Float64(Float64(-0.125 / l) * (t_0 ^ 2.0))) / Float64(sqrt(l) * sqrt(h))));
	end
	return tmp
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
	t_0 = M_m * (D / d);
	tmp = 0.0;
	if (h <= -4e-310)
		tmp = (d * sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * (((D / d) * (M_m / 2.0)) ^ 2.0))) + -1.0);
	elseif (h <= 1.35e+187)
		tmp = (d * (1.0 + (-0.5 * ((h / l) * ((t_0 / 2.0) ^ 2.0))))) / sqrt((l * h));
	else
		tmp = d * ((h * ((-0.125 / l) * (t_0 ^ 2.0))) / (sqrt(l) * sqrt(h)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -4e-310], N[(N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 1.35e+187], N[(N[(d * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(t$95$0 / 2.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(h * N[(N[(-0.125 / l), $MachinePrecision] * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := M\_m \cdot \frac{D}{d}\\
\mathbf{if}\;h \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right) + -1\right)\\

\mathbf{elif}\;h \leq 1.35 \cdot 10^{+187}:\\
\;\;\;\;\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{t\_0}{2}\right)}^{2}\right)\right)}{\sqrt{\ell \cdot h}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{h \cdot \left(\frac{-0.125}{\ell} \cdot {t\_0}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -3.999999999999988e-310

    1. Initial program 64.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified66.0%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. clear-num66.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. sqrt-div66.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      3. metadata-eval66.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr66.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Taylor expanded in d around -inf 70.8%

      \[\leadsto \color{blue}{\left(-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]

    if -3.999999999999988e-310 < h < 1.35000000000000004e187

    1. Initial program 63.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified61.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative61.1%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. sqrt-div66.5%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}}\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. sqrt-div79.3%

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. frac-times79.4%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. add-sqr-sqrt79.6%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr79.6%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. associate-*l/83.6%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      2. cancel-sign-sub-inv83.6%

        \[\leadsto \frac{d \cdot \color{blue}{\left(1 + \left(-0.5\right) \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. metadata-eval83.6%

        \[\leadsto \frac{d \cdot \left(1 + \color{blue}{-0.5} \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      4. *-commutative83.6%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right)}\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      5. associate-*l/83.6%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{M \cdot \frac{D}{d}}{2}\right)}}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      6. sqrt-unprod72.7%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\color{blue}{\sqrt{\ell \cdot h}}} \]
      7. *-commutative72.7%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    7. Applied egg-rr72.7%

      \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\sqrt{h \cdot \ell}}} \]

    if 1.35000000000000004e187 < h

    1. Initial program 45.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. Simplified42.1%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow142.1%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\right)}^{1}} \]
      2. associate-*r*42.0%

        \[\leadsto {\color{blue}{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \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)}}^{1} \]
      3. sqrt-div51.7%

        \[\leadsto {\left(\left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}}\right) \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)}^{1} \]
      4. sqrt-div51.7%

        \[\leadsto {\left(\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}}\right) \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)}^{1} \]
      5. frac-times51.7%

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      6. add-sqr-sqrt51.7%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\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)}^{1} \]
      7. unpow-prod-down51.7%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{{0.5}^{2} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      8. metadata-eval51.7%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{0.25} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      9. clear-num48.5%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(M \cdot \color{blue}{\frac{1}{\frac{d}{D}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      10. un-div-inv48.5%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\color{blue}{\left(\frac{M}{\frac{d}{D}}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
    5. Applied egg-rr48.5%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow148.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \]
      2. associate-*l/61.7%

        \[\leadsto \color{blue}{\frac{d \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. associate-/l*61.7%

        \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      4. fma-define61.7%

        \[\leadsto d \cdot \frac{\color{blue}{\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot \left(-0.5 \cdot \frac{h}{\ell}\right) + 1}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. associate-*r*61.7%

        \[\leadsto d \cdot \frac{\color{blue}{\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5\right) \cdot \frac{h}{\ell}} + 1}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. fma-define61.7%

        \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5, \frac{h}{\ell}, 1\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      7. *-commutative61.7%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot 0.25\right)} \cdot -0.5, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      8. associate-*l*61.7%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{{\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \left(0.25 \cdot -0.5\right)}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      9. metadata-eval61.7%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \color{blue}{-0.125}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      10. *-commutative61.7%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{-0.125 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      11. associate-/r/68.1%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M}{d} \cdot D\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      12. associate-*l/68.1%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      13. associate-/l*64.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(M \cdot \frac{D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. Simplified64.9%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Taylor expanded in M around inf 33.4%

      \[\leadsto d \cdot \frac{\color{blue}{-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}}}{\sqrt{h} \cdot \sqrt{\ell}} \]
    9. Step-by-step derivation
      1. associate-*r/33.4%

        \[\leadsto d \cdot \frac{\color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      2. associate-*r*33.6%

        \[\leadsto d \cdot \frac{\frac{-0.125 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2} \cdot \ell}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      3. associate-*r*33.6%

        \[\leadsto d \cdot \frac{\frac{\color{blue}{\left(-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)\right) \cdot h}}{{d}^{2} \cdot \ell}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      4. associate-*l/33.7%

        \[\leadsto d \cdot \frac{\color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)}{{d}^{2} \cdot \ell} \cdot h}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. associate-*r/33.7%

        \[\leadsto d \cdot \frac{\color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)} \cdot h}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. *-commutative33.7%

        \[\leadsto d \cdot \frac{\color{blue}{h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      7. *-commutative33.7%

        \[\leadsto d \cdot \frac{h \cdot \color{blue}{\left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} \cdot -0.125\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      8. associate-*l/33.7%

        \[\leadsto d \cdot \frac{h \cdot \color{blue}{\frac{\left({D}^{2} \cdot {M}^{2}\right) \cdot -0.125}{{d}^{2} \cdot \ell}}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      9. times-frac37.1%

        \[\leadsto d \cdot \frac{h \cdot \color{blue}{\left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \frac{-0.125}{\ell}\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      10. *-commutative37.1%

        \[\leadsto d \cdot \frac{h \cdot \left(\frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}} \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      11. associate-/l*37.0%

        \[\leadsto d \cdot \frac{h \cdot \left(\color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)} \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      12. unpow237.0%

        \[\leadsto d \cdot \frac{h \cdot \left(\left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right) \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      13. unpow237.0%

        \[\leadsto d \cdot \frac{h \cdot \left(\left(\left(M \cdot M\right) \cdot \frac{\color{blue}{D \cdot D}}{{d}^{2}}\right) \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      14. unpow237.0%

        \[\leadsto d \cdot \frac{h \cdot \left(\left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\color{blue}{d \cdot d}}\right) \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      15. times-frac43.4%

        \[\leadsto d \cdot \frac{h \cdot \left(\left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right) \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      16. swap-sqr56.1%

        \[\leadsto d \cdot \frac{h \cdot \left(\color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)} \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      17. unpow256.1%

        \[\leadsto d \cdot \frac{h \cdot \left(\color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}} \cdot \frac{-0.125}{\ell}\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    10. Simplified56.1%

      \[\leadsto d \cdot \frac{\color{blue}{h \cdot \left({\left(M \cdot \frac{D}{d}\right)}^{2} \cdot \frac{-0.125}{\ell}\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification69.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right) + -1\right)\\ \mathbf{elif}\;h \leq 1.35 \cdot 10^{+187}:\\ \;\;\;\;\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{h \cdot \left(\frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 71.1% accurate, 1.4× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right) + -1\right)\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{+166}:\\ \;\;\;\;\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M\_m \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (if (<= l -2e-310)
   (*
    (* d (sqrt (/ 1.0 (* l h))))
    (+ (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M_m 2.0)) 2.0))) -1.0))
   (if (<= l 6e+166)
     (/
      (* d (+ 1.0 (* -0.5 (* (/ h l) (pow (/ (* M_m (/ D d)) 2.0) 2.0)))))
      (sqrt (* l h)))
     (/ d (* (sqrt l) (sqrt h))))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (l <= -2e-310) {
		tmp = (d * sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0);
	} else if (l <= 6e+166) {
		tmp = (d * (1.0 + (-0.5 * ((h / l) * pow(((M_m * (D / d)) / 2.0), 2.0))))) / sqrt((l * h));
	} else {
		tmp = d / (sqrt(l) * sqrt(h));
	}
	return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (l <= (-2d-310)) then
        tmp = (d * sqrt((1.0d0 / (l * h)))) * ((0.5d0 * ((h / l) * (((d_1 / d) * (m_m / 2.0d0)) ** 2.0d0))) + (-1.0d0))
    else if (l <= 6d+166) then
        tmp = (d * (1.0d0 + ((-0.5d0) * ((h / l) * (((m_m * (d_1 / d)) / 2.0d0) ** 2.0d0))))) / sqrt((l * h))
    else
        tmp = d / (sqrt(l) * sqrt(h))
    end if
    code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (l <= -2e-310) {
		tmp = (d * Math.sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * Math.pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0);
	} else if (l <= 6e+166) {
		tmp = (d * (1.0 + (-0.5 * ((h / l) * Math.pow(((M_m * (D / d)) / 2.0), 2.0))))) / Math.sqrt((l * h));
	} else {
		tmp = d / (Math.sqrt(l) * Math.sqrt(h));
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	tmp = 0
	if l <= -2e-310:
		tmp = (d * math.sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * math.pow(((D / d) * (M_m / 2.0)), 2.0))) + -1.0)
	elif l <= 6e+166:
		tmp = (d * (1.0 + (-0.5 * ((h / l) * math.pow(((M_m * (D / d)) / 2.0), 2.0))))) / math.sqrt((l * h))
	else:
		tmp = d / (math.sqrt(l) * math.sqrt(h))
	return tmp
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	tmp = 0.0
	if (l <= -2e-310)
		tmp = Float64(Float64(d * sqrt(Float64(1.0 / Float64(l * h)))) * Float64(Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M_m / 2.0)) ^ 2.0))) + -1.0));
	elseif (l <= 6e+166)
		tmp = Float64(Float64(d * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(M_m * Float64(D / d)) / 2.0) ^ 2.0))))) / sqrt(Float64(l * h)));
	else
		tmp = Float64(d / Float64(sqrt(l) * sqrt(h)));
	end
	return tmp
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
	tmp = 0.0;
	if (l <= -2e-310)
		tmp = (d * sqrt((1.0 / (l * h)))) * ((0.5 * ((h / l) * (((D / d) * (M_m / 2.0)) ^ 2.0))) + -1.0);
	elseif (l <= 6e+166)
		tmp = (d * (1.0 + (-0.5 * ((h / l) * (((M_m * (D / d)) / 2.0) ^ 2.0))))) / sqrt((l * h));
	else
		tmp = d / (sqrt(l) * sqrt(h));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, -2e-310], N[(N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6e+166], N[(N[(d * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right) + -1\right)\\

\mathbf{elif}\;\ell \leq 6 \cdot 10^{+166}:\\
\;\;\;\;\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M\_m \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\sqrt{\ell \cdot h}}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1.999999999999994e-310

    1. Initial program 64.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified66.0%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. clear-num66.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. sqrt-div66.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      3. metadata-eval66.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr66.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Taylor expanded in d around -inf 70.8%

      \[\leadsto \color{blue}{\left(-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]

    if -1.999999999999994e-310 < l < 5.99999999999999997e166

    1. Initial program 63.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. Simplified60.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. *-commutative60.0%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. sqrt-div61.8%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}}\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. sqrt-div73.5%

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. frac-times73.5%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. add-sqr-sqrt73.7%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr73.7%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. associate-*l/78.9%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      2. cancel-sign-sub-inv78.9%

        \[\leadsto \frac{d \cdot \color{blue}{\left(1 + \left(-0.5\right) \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. metadata-eval78.9%

        \[\leadsto \frac{d \cdot \left(1 + \color{blue}{-0.5} \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      4. *-commutative78.9%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right)}\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      5. associate-*l/78.9%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{M \cdot \frac{D}{d}}{2}\right)}}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      6. sqrt-unprod70.8%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\color{blue}{\sqrt{\ell \cdot h}}} \]
      7. *-commutative70.8%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    7. Applied egg-rr70.8%

      \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\sqrt{h \cdot \ell}}} \]

    if 5.99999999999999997e166 < l

    1. Initial program 47.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. Simplified47.4%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 48.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div48.2%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval48.2%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative48.2%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod62.0%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv62.1%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. associate-/r*61.9%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr61.9%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    7. Step-by-step derivation
      1. associate-/l/62.1%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      2. *-commutative62.1%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    8. Simplified62.1%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification69.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right) + -1\right)\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{+166}:\\ \;\;\;\;\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 62.1% accurate, 1.4× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -7.2 \cdot 10^{+60}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-274}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.125 \cdot {\left(D \cdot \frac{M\_m}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M\_m \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\sqrt{\ell \cdot h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (if (<= d -7.2e+60)
   (* (- d) (pow (* l h) -0.5))
   (if (<= d -2e-274)
     (*
      (sqrt (* (/ d l) (/ d h)))
      (- 1.0 (* (/ h l) (* 0.125 (pow (* D (/ M_m d)) 2.0)))))
     (/
      (* d (+ 1.0 (* -0.5 (* (/ h l) (pow (/ (* M_m (/ D d)) 2.0) 2.0)))))
      (sqrt (* l h))))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (d <= -7.2e+60) {
		tmp = -d * pow((l * h), -0.5);
	} else if (d <= -2e-274) {
		tmp = sqrt(((d / l) * (d / h))) * (1.0 - ((h / l) * (0.125 * pow((D * (M_m / d)), 2.0))));
	} else {
		tmp = (d * (1.0 + (-0.5 * ((h / l) * pow(((M_m * (D / d)) / 2.0), 2.0))))) / sqrt((l * h));
	}
	return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (d <= (-7.2d+60)) then
        tmp = -d * ((l * h) ** (-0.5d0))
    else if (d <= (-2d-274)) then
        tmp = sqrt(((d / l) * (d / h))) * (1.0d0 - ((h / l) * (0.125d0 * ((d_1 * (m_m / d)) ** 2.0d0))))
    else
        tmp = (d * (1.0d0 + ((-0.5d0) * ((h / l) * (((m_m * (d_1 / d)) / 2.0d0) ** 2.0d0))))) / sqrt((l * h))
    end if
    code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (d <= -7.2e+60) {
		tmp = -d * Math.pow((l * h), -0.5);
	} else if (d <= -2e-274) {
		tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 - ((h / l) * (0.125 * Math.pow((D * (M_m / d)), 2.0))));
	} else {
		tmp = (d * (1.0 + (-0.5 * ((h / l) * Math.pow(((M_m * (D / d)) / 2.0), 2.0))))) / Math.sqrt((l * h));
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	tmp = 0
	if d <= -7.2e+60:
		tmp = -d * math.pow((l * h), -0.5)
	elif d <= -2e-274:
		tmp = math.sqrt(((d / l) * (d / h))) * (1.0 - ((h / l) * (0.125 * math.pow((D * (M_m / d)), 2.0))))
	else:
		tmp = (d * (1.0 + (-0.5 * ((h / l) * math.pow(((M_m * (D / d)) / 2.0), 2.0))))) / math.sqrt((l * h))
	return tmp
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	tmp = 0.0
	if (d <= -7.2e+60)
		tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5));
	elseif (d <= -2e-274)
		tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.125 * (Float64(D * Float64(M_m / d)) ^ 2.0)))));
	else
		tmp = Float64(Float64(d * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(M_m * Float64(D / d)) / 2.0) ^ 2.0))))) / sqrt(Float64(l * h)));
	end
	return tmp
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
	tmp = 0.0;
	if (d <= -7.2e+60)
		tmp = -d * ((l * h) ^ -0.5);
	elseif (d <= -2e-274)
		tmp = sqrt(((d / l) * (d / h))) * (1.0 - ((h / l) * (0.125 * ((D * (M_m / d)) ^ 2.0))));
	else
		tmp = (d * (1.0 + (-0.5 * ((h / l) * (((M_m * (D / d)) / 2.0) ^ 2.0))))) / sqrt((l * h));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[d, -7.2e+60], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2e-274], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.125 * N[Power[N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.2 \cdot 10^{+60}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

\mathbf{elif}\;d \leq -2 \cdot 10^{-274}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.125 \cdot {\left(D \cdot \frac{M\_m}{d}\right)}^{2}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M\_m \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\sqrt{\ell \cdot h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -7.19999999999999935e60

    1. Initial program 67.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified69.1%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 3.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
    6. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto d \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt75.1%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. mul-1-neg75.1%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. unpow1/275.1%

        \[\leadsto d \cdot \left(-\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right) \]
      6. rem-exp-log71.6%

        \[\leadsto d \cdot \left(-{\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5}\right) \]
      7. exp-neg71.6%

        \[\leadsto d \cdot \left(-{\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5}\right) \]
      8. exp-prod71.6%

        \[\leadsto d \cdot \left(-\color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}}\right) \]
      9. distribute-lft-neg-out71.6%

        \[\leadsto d \cdot \left(-e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \]
      10. distribute-rgt-neg-in71.6%

        \[\leadsto d \cdot \left(-e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}}\right) \]
      11. metadata-eval71.6%

        \[\leadsto d \cdot \left(-e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}}\right) \]
      12. exp-to-pow75.1%

        \[\leadsto d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{-0.5}}\right) \]
    7. Simplified75.1%

      \[\leadsto d \cdot \color{blue}{\left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]

    if -7.19999999999999935e60 < d < -1.99999999999999993e-274

    1. Initial program 66.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified67.2%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow267.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow171.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval71.9%

        \[\leadsto \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)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. associate-*l/71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot \frac{D}{d}}{2}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. div-inv71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \frac{1}{2}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. metadata-eval71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\left(M \cdot \frac{D}{d}\right) \cdot \color{blue}{0.5}\right)}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      10. pow171.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      11. clear-num71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(0.5 \cdot \left(M \cdot \color{blue}{\frac{1}{\frac{d}{D}}}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      12. un-div-inv71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(0.5 \cdot \color{blue}{\frac{M}{\frac{d}{D}}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr71.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. metadata-eval71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{\color{blue}{\left(1 + 1\right)}}\right) \]
      2. pow-prod-up71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left({\left(\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{1} \cdot {\left(\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{1}\right)}\right) \]
      3. associate-*l*71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\color{blue}{\left(0.5 \cdot \left(\frac{M}{\frac{d}{D}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{1} \cdot {\left(\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{1}\right)\right) \]
      4. pow171.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\color{blue}{\left(0.5 \cdot \left(\frac{M}{\frac{d}{D}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)} \cdot {\left(\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{1}\right)\right) \]
      5. div-inv71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(0.5 \cdot \left(\color{blue}{\left(M \cdot \frac{1}{\frac{d}{D}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right) \cdot {\left(\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{1}\right)\right) \]
      6. clear-num71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(0.5 \cdot \left(\left(M \cdot \color{blue}{\frac{D}{d}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right) \cdot {\left(\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{1}\right)\right) \]
      7. associate-*l*71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(0.5 \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right) \cdot {\color{blue}{\left(0.5 \cdot \left(\frac{M}{\frac{d}{D}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{1}\right)\right) \]
      8. pow171.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(0.5 \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right) \cdot \color{blue}{\left(0.5 \cdot \left(\frac{M}{\frac{d}{D}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}\right)\right) \]
      9. div-inv71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(0.5 \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right) \cdot \left(0.5 \cdot \left(\color{blue}{\left(M \cdot \frac{1}{\frac{d}{D}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)\right)\right) \]
      10. clear-num71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(0.5 \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right) \cdot \left(0.5 \cdot \left(\left(M \cdot \color{blue}{\frac{D}{d}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)\right)\right) \]
    7. Applied egg-rr71.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\left(0.5 \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right) \cdot \left(0.5 \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)\right)}\right) \]
    8. Step-by-step derivation
      1. swap-sqr71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\left(0.5 \cdot 0.5\right) \cdot \left(\left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right) \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)\right)}\right) \]
      2. metadata-eval71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\color{blue}{0.25} \cdot \left(\left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right) \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)\right)\right) \]
      3. unpow271.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right)\right) \]
      4. associate-*r/72.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot {\left(\color{blue}{\frac{M \cdot D}{d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\right) \]
      5. *-commutative72.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot {\left(\frac{\color{blue}{D \cdot M}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\right) \]
      6. associate-/l*70.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\right) \]
      7. associate-*l*70.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right)\right) \]
    9. Simplified70.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(0.25 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)}\right) \]
    10. Step-by-step derivation
      1. pow170.1%

        \[\leadsto \color{blue}{{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)\right)}^{1}} \]
      2. sqrt-unprod62.1%

        \[\leadsto {\left(\color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)\right)}^{1} \]
      3. associate-*r*62.1%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - \color{blue}{\left(0.5 \cdot 0.25\right) \cdot {\left(D \cdot \left(\frac{M}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right)\right)}^{1} \]
      4. metadata-eval62.1%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - \color{blue}{0.125} \cdot {\left(D \cdot \left(\frac{M}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1} \]
      5. associate-*r*62.2%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.125 \cdot {\color{blue}{\left(\left(D \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right)\right)}^{1} \]
      6. unpow-prod-down57.5%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.125 \cdot \color{blue}{\left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot {\left(\sqrt{\frac{h}{\ell}}\right)}^{2}\right)}\right)\right)}^{1} \]
      7. pow257.5%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \color{blue}{\left(\sqrt{\frac{h}{\ell}} \cdot \sqrt{\frac{h}{\ell}}\right)}\right)\right)\right)}^{1} \]
      8. add-sqr-sqrt57.6%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \color{blue}{\frac{h}{\ell}}\right)\right)\right)}^{1} \]
    11. Applied egg-rr57.6%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}^{1}} \]
    12. Step-by-step derivation
      1. unpow157.6%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
      2. *-commutative57.6%

        \[\leadsto \sqrt{\color{blue}{\frac{d}{\ell} \cdot \frac{d}{h}}} \cdot \left(1 - 0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      3. associate-*r*57.6%

        \[\leadsto \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \color{blue}{\left(0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right) \cdot \frac{h}{\ell}}\right) \]
    13. Simplified57.6%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \left(0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]

    if -1.99999999999999993e-274 < d

    1. Initial program 57.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified55.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. *-commutative55.1%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. sqrt-div59.0%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}}\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. sqrt-div70.7%

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. frac-times70.8%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. add-sqr-sqrt71.0%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr71.0%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. associate-*l/76.9%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      2. cancel-sign-sub-inv76.9%

        \[\leadsto \frac{d \cdot \color{blue}{\left(1 + \left(-0.5\right) \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. metadata-eval76.9%

        \[\leadsto \frac{d \cdot \left(1 + \color{blue}{-0.5} \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      4. *-commutative76.9%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right)}\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      5. associate-*l/76.9%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{M \cdot \frac{D}{d}}{2}\right)}}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}} \]
      6. sqrt-unprod61.5%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\color{blue}{\sqrt{\ell \cdot h}}} \]
      7. *-commutative61.5%

        \[\leadsto \frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    7. Applied egg-rr61.5%

      \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\sqrt{h \cdot \ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification63.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.2 \cdot 10^{+60}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-274}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \frac{D}{d}}{2}\right)}^{2}\right)\right)}{\sqrt{\ell \cdot h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 57.2% accurate, 1.4× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -7.2 \cdot 10^{+60}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{elif}\;d \leq 10^{+101}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.125 \cdot {\left(D \cdot \frac{M\_m}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (if (<= d -7.2e+60)
   (* (- d) (pow (* l h) -0.5))
   (if (<= d 1e+101)
     (*
      (sqrt (* (/ d l) (/ d h)))
      (- 1.0 (* (/ h l) (* 0.125 (pow (* D (/ M_m d)) 2.0)))))
     (/ d (* (sqrt l) (sqrt h))))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (d <= -7.2e+60) {
		tmp = -d * pow((l * h), -0.5);
	} else if (d <= 1e+101) {
		tmp = sqrt(((d / l) * (d / h))) * (1.0 - ((h / l) * (0.125 * pow((D * (M_m / d)), 2.0))));
	} else {
		tmp = d / (sqrt(l) * sqrt(h));
	}
	return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (d <= (-7.2d+60)) then
        tmp = -d * ((l * h) ** (-0.5d0))
    else if (d <= 1d+101) then
        tmp = sqrt(((d / l) * (d / h))) * (1.0d0 - ((h / l) * (0.125d0 * ((d_1 * (m_m / d)) ** 2.0d0))))
    else
        tmp = d / (sqrt(l) * sqrt(h))
    end if
    code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (d <= -7.2e+60) {
		tmp = -d * Math.pow((l * h), -0.5);
	} else if (d <= 1e+101) {
		tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 - ((h / l) * (0.125 * Math.pow((D * (M_m / d)), 2.0))));
	} else {
		tmp = d / (Math.sqrt(l) * Math.sqrt(h));
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	tmp = 0
	if d <= -7.2e+60:
		tmp = -d * math.pow((l * h), -0.5)
	elif d <= 1e+101:
		tmp = math.sqrt(((d / l) * (d / h))) * (1.0 - ((h / l) * (0.125 * math.pow((D * (M_m / d)), 2.0))))
	else:
		tmp = d / (math.sqrt(l) * math.sqrt(h))
	return tmp
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	tmp = 0.0
	if (d <= -7.2e+60)
		tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5));
	elseif (d <= 1e+101)
		tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.125 * (Float64(D * Float64(M_m / d)) ^ 2.0)))));
	else
		tmp = Float64(d / Float64(sqrt(l) * sqrt(h)));
	end
	return tmp
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
	tmp = 0.0;
	if (d <= -7.2e+60)
		tmp = -d * ((l * h) ^ -0.5);
	elseif (d <= 1e+101)
		tmp = sqrt(((d / l) * (d / h))) * (1.0 - ((h / l) * (0.125 * ((D * (M_m / d)) ^ 2.0))));
	else
		tmp = d / (sqrt(l) * sqrt(h));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[d, -7.2e+60], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1e+101], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.125 * N[Power[N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $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, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.2 \cdot 10^{+60}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

\mathbf{elif}\;d \leq 10^{+101}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.125 \cdot {\left(D \cdot \frac{M\_m}{d}\right)}^{2}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -7.19999999999999935e60

    1. Initial program 67.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified69.1%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 3.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
    6. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto d \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt75.1%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. mul-1-neg75.1%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. unpow1/275.1%

        \[\leadsto d \cdot \left(-\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right) \]
      6. rem-exp-log71.6%

        \[\leadsto d \cdot \left(-{\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5}\right) \]
      7. exp-neg71.6%

        \[\leadsto d \cdot \left(-{\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5}\right) \]
      8. exp-prod71.6%

        \[\leadsto d \cdot \left(-\color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}}\right) \]
      9. distribute-lft-neg-out71.6%

        \[\leadsto d \cdot \left(-e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \]
      10. distribute-rgt-neg-in71.6%

        \[\leadsto d \cdot \left(-e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}}\right) \]
      11. metadata-eval71.6%

        \[\leadsto d \cdot \left(-e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}}\right) \]
      12. exp-to-pow75.1%

        \[\leadsto d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{-0.5}}\right) \]
    7. Simplified75.1%

      \[\leadsto d \cdot \color{blue}{\left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]

    if -7.19999999999999935e60 < d < 9.9999999999999998e100

    1. Initial program 58.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. Simplified58.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. add-sqr-sqrt58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow258.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod58.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow161.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval61.3%

        \[\leadsto \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)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. associate-*l/61.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot \frac{D}{d}}{2}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. div-inv61.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \frac{1}{2}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. metadata-eval61.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\left(M \cdot \frac{D}{d}\right) \cdot \color{blue}{0.5}\right)}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative61.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      10. pow161.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      11. clear-num61.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(0.5 \cdot \left(M \cdot \color{blue}{\frac{1}{\frac{d}{D}}}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      12. un-div-inv61.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(0.5 \cdot \color{blue}{\frac{M}{\frac{d}{D}}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr61.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. metadata-eval61.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{\color{blue}{\left(1 + 1\right)}}\right) \]
      2. pow-prod-up61.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left({\left(\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{1} \cdot {\left(\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{1}\right)}\right) \]
      3. associate-*l*61.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\color{blue}{\left(0.5 \cdot \left(\frac{M}{\frac{d}{D}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{1} \cdot {\left(\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{1}\right)\right) \]
      4. pow161.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\color{blue}{\left(0.5 \cdot \left(\frac{M}{\frac{d}{D}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)} \cdot {\left(\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{1}\right)\right) \]
      5. div-inv61.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(0.5 \cdot \left(\color{blue}{\left(M \cdot \frac{1}{\frac{d}{D}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right) \cdot {\left(\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{1}\right)\right) \]
      6. clear-num61.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(0.5 \cdot \left(\left(M \cdot \color{blue}{\frac{D}{d}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right) \cdot {\left(\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{1}\right)\right) \]
      7. associate-*l*61.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(0.5 \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right) \cdot {\color{blue}{\left(0.5 \cdot \left(\frac{M}{\frac{d}{D}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{1}\right)\right) \]
      8. pow161.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(0.5 \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right) \cdot \color{blue}{\left(0.5 \cdot \left(\frac{M}{\frac{d}{D}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}\right)\right) \]
      9. div-inv61.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(0.5 \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right) \cdot \left(0.5 \cdot \left(\color{blue}{\left(M \cdot \frac{1}{\frac{d}{D}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)\right)\right) \]
      10. clear-num61.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\left(0.5 \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right) \cdot \left(0.5 \cdot \left(\left(M \cdot \color{blue}{\frac{D}{d}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)\right)\right) \]
    7. Applied egg-rr61.3%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\left(0.5 \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right) \cdot \left(0.5 \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)\right)}\right) \]
    8. Step-by-step derivation
      1. swap-sqr61.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\left(0.5 \cdot 0.5\right) \cdot \left(\left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right) \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)\right)}\right) \]
      2. metadata-eval61.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\color{blue}{0.25} \cdot \left(\left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right) \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)\right)\right) \]
      3. unpow261.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right)\right) \]
      4. associate-*r/62.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot {\left(\color{blue}{\frac{M \cdot D}{d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\right) \]
      5. *-commutative62.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot {\left(\frac{\color{blue}{D \cdot M}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\right) \]
      6. associate-/l*60.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\right) \]
      7. associate-*l*60.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right)\right) \]
    9. Simplified60.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(0.25 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)}\right) \]
    10. Step-by-step derivation
      1. pow160.5%

        \[\leadsto \color{blue}{{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)\right)}^{1}} \]
      2. sqrt-unprod51.9%

        \[\leadsto {\left(\color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot {\left(D \cdot \left(\frac{M}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)\right)}^{1} \]
      3. associate-*r*51.9%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - \color{blue}{\left(0.5 \cdot 0.25\right) \cdot {\left(D \cdot \left(\frac{M}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right)\right)}^{1} \]
      4. metadata-eval51.9%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - \color{blue}{0.125} \cdot {\left(D \cdot \left(\frac{M}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1} \]
      5. associate-*r*51.8%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.125 \cdot {\color{blue}{\left(\left(D \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right)\right)}^{1} \]
      6. unpow-prod-down48.7%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.125 \cdot \color{blue}{\left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot {\left(\sqrt{\frac{h}{\ell}}\right)}^{2}\right)}\right)\right)}^{1} \]
      7. pow248.7%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \color{blue}{\left(\sqrt{\frac{h}{\ell}} \cdot \sqrt{\frac{h}{\ell}}\right)}\right)\right)\right)}^{1} \]
      8. add-sqr-sqrt48.7%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \color{blue}{\frac{h}{\ell}}\right)\right)\right)}^{1} \]
    11. Applied egg-rr48.7%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}^{1}} \]
    12. Step-by-step derivation
      1. unpow148.7%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
      2. *-commutative48.7%

        \[\leadsto \sqrt{\color{blue}{\frac{d}{\ell} \cdot \frac{d}{h}}} \cdot \left(1 - 0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      3. associate-*r*48.7%

        \[\leadsto \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \color{blue}{\left(0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right) \cdot \frac{h}{\ell}}\right) \]
    13. Simplified48.7%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \left(0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]

    if 9.9999999999999998e100 < d

    1. Initial program 65.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified60.9%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 60.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div61.2%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval61.2%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative61.2%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod73.3%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv73.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. associate-/r*65.6%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr65.6%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    7. Step-by-step derivation
      1. associate-/l/73.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      2. *-commutative73.5%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    8. Simplified73.5%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification59.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.2 \cdot 10^{+60}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{elif}\;d \leq 10^{+101}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 48.4% accurate, 1.4× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -5.2 \cdot 10^{+39}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 1.02 \cdot 10^{-131}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left({\left(D \cdot \frac{M\_m}{d}\right)}^{2} \cdot \left(-0.125 \cdot \frac{h}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (if (<= d -5.2e+39)
   (/ (- d) (sqrt (* l h)))
   (if (<= d 1.02e-131)
     (*
      (sqrt (* (/ d l) (/ d h)))
      (* (pow (* D (/ M_m d)) 2.0) (* -0.125 (/ h l))))
     (/ d (* (sqrt l) (sqrt h))))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (d <= -5.2e+39) {
		tmp = -d / sqrt((l * h));
	} else if (d <= 1.02e-131) {
		tmp = sqrt(((d / l) * (d / h))) * (pow((D * (M_m / d)), 2.0) * (-0.125 * (h / l)));
	} else {
		tmp = d / (sqrt(l) * sqrt(h));
	}
	return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (d <= (-5.2d+39)) then
        tmp = -d / sqrt((l * h))
    else if (d <= 1.02d-131) then
        tmp = sqrt(((d / l) * (d / h))) * (((d_1 * (m_m / d)) ** 2.0d0) * ((-0.125d0) * (h / l)))
    else
        tmp = d / (sqrt(l) * sqrt(h))
    end if
    code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (d <= -5.2e+39) {
		tmp = -d / Math.sqrt((l * h));
	} else if (d <= 1.02e-131) {
		tmp = Math.sqrt(((d / l) * (d / h))) * (Math.pow((D * (M_m / d)), 2.0) * (-0.125 * (h / l)));
	} else {
		tmp = d / (Math.sqrt(l) * Math.sqrt(h));
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	tmp = 0
	if d <= -5.2e+39:
		tmp = -d / math.sqrt((l * h))
	elif d <= 1.02e-131:
		tmp = math.sqrt(((d / l) * (d / h))) * (math.pow((D * (M_m / d)), 2.0) * (-0.125 * (h / l)))
	else:
		tmp = d / (math.sqrt(l) * math.sqrt(h))
	return tmp
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	tmp = 0.0
	if (d <= -5.2e+39)
		tmp = Float64(Float64(-d) / sqrt(Float64(l * h)));
	elseif (d <= 1.02e-131)
		tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64((Float64(D * Float64(M_m / d)) ^ 2.0) * Float64(-0.125 * Float64(h / l))));
	else
		tmp = Float64(d / Float64(sqrt(l) * sqrt(h)));
	end
	return tmp
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
	tmp = 0.0;
	if (d <= -5.2e+39)
		tmp = -d / sqrt((l * h));
	elseif (d <= 1.02e-131)
		tmp = sqrt(((d / l) * (d / h))) * (((D * (M_m / d)) ^ 2.0) * (-0.125 * (h / l)));
	else
		tmp = d / (sqrt(l) * sqrt(h));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[d, -5.2e+39], N[((-d) / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.02e-131], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Power[N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.125 * N[(h / l), $MachinePrecision]), $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, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.2 \cdot 10^{+39}:\\
\;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\

\mathbf{elif}\;d \leq 1.02 \cdot 10^{-131}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left({\left(D \cdot \frac{M\_m}{d}\right)}^{2} \cdot \left(-0.125 \cdot \frac{h}{\ell}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -5.2e39

    1. Initial program 66.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified68.7%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 37.2%

      \[\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. associate-*r/37.2%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}}\right)\right) \]
      2. associate-*r*43.9%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{-0.125 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2} \cdot \ell}\right)\right) \]
      3. associate-*r*43.9%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{\color{blue}{\left(-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)\right) \cdot h}}{{d}^{2} \cdot \ell}\right)\right) \]
      4. associate-*l/43.9%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)}{{d}^{2} \cdot \ell} \cdot h}\right)\right) \]
      5. associate-*r/43.9%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)} \cdot h\right)\right) \]
      6. *-commutative43.9%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)}\right)\right) \]
      7. +-commutative43.9%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) + 1\right)}\right) \]
      8. fma-undefine43.9%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, -0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}, 1\right)}\right) \]
    6. Simplified74.1%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, 1\right)}\right) \]
    7. 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}}} \]
    8. 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. *-commutative0.0%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      3. unpow20.0%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      4. rem-square-sqrt74.4%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      5. neg-mul-174.4%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \color{blue}{\left(-d\right)} \]
      6. distribute-rgt-neg-in74.4%

        \[\leadsto \color{blue}{-\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      7. unpow1/274.4%

        \[\leadsto -\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \cdot d \]
      8. rem-exp-log70.9%

        \[\leadsto -{\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \cdot d \]
      9. exp-neg71.0%

        \[\leadsto -{\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot d \]
      10. exp-prod71.0%

        \[\leadsto -\color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \cdot d \]
      11. distribute-lft-neg-out71.0%

        \[\leadsto -e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot d \]
      12. exp-neg71.0%

        \[\leadsto -\color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \cdot d \]
      13. exp-to-pow74.4%

        \[\leadsto -\frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \cdot d \]
      14. unpow1/274.4%

        \[\leadsto -\frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot d \]
      15. associate-*l/74.4%

        \[\leadsto -\color{blue}{\frac{1 \cdot d}{\sqrt{h \cdot \ell}}} \]
      16. *-lft-identity74.4%

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
      17. distribute-frac-neg274.4%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]
    9. Simplified74.4%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if -5.2e39 < d < 1.02000000000000001e-131

    1. Initial program 53.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. Simplified53.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. add-sqr-sqrt53.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow253.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod53.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow157.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval57.2%

        \[\leadsto \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)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. associate-*l/57.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot \frac{D}{d}}{2}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. div-inv57.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \frac{1}{2}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. metadata-eval57.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\left(M \cdot \frac{D}{d}\right) \cdot \color{blue}{0.5}\right)}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative57.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      10. pow157.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      11. clear-num57.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(0.5 \cdot \left(M \cdot \color{blue}{\frac{1}{\frac{d}{D}}}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      12. un-div-inv58.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(0.5 \cdot \color{blue}{\frac{M}{\frac{d}{D}}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr58.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Taylor expanded in M around inf 28.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)} \]
    7. Step-by-step derivation
      1. associate-/l*30.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(-0.125 \cdot \color{blue}{\left({D}^{2} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)}\right) \]
      2. times-frac31.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(-0.125 \cdot \left({D}^{2} \cdot \color{blue}{\left(\frac{{M}^{2}}{{d}^{2}} \cdot \frac{h}{\ell}\right)}\right)\right) \]
      3. associate-*r*29.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(-0.125 \cdot \color{blue}{\left(\left({D}^{2} \cdot \frac{{M}^{2}}{{d}^{2}}\right) \cdot \frac{h}{\ell}\right)}\right) \]
      4. associate-/l*29.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(-0.125 \cdot \left(\color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}}} \cdot \frac{h}{\ell}\right)\right) \]
      5. *-commutative29.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(-0.125 \cdot \left(\frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}} \cdot \frac{h}{\ell}\right)\right) \]
      6. associate-/l*29.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(-0.125 \cdot \left(\color{blue}{\left({M}^{2} \cdot \frac{{D}^{2}}{{d}^{2}}\right)} \cdot \frac{h}{\ell}\right)\right) \]
      7. unpow229.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \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) \]
      8. unpow229.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \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) \]
      9. unpow229.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \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) \]
      10. times-frac34.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \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) \]
      11. swap-sqr38.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \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) \]
      12. unpow238.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(-0.125 \cdot \left(\color{blue}{{\left(M \cdot \frac{D}{d}\right)}^{2}} \cdot \frac{h}{\ell}\right)\right) \]
      13. *-commutative38.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(-0.125 \cdot \color{blue}{\left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right)}\right) \]
      14. associate-*r/39.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(-0.125 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}\right)\right) \]
      15. *-commutative39.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(-0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2}\right)\right) \]
      16. associate-/l*38.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(-0.125 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}\right)\right) \]
    8. Simplified38.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \color{blue}{\left(-0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right)} \]
    9. Step-by-step derivation
      1. pow138.6%

        \[\leadsto \color{blue}{{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(-0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right)\right)}^{1}} \]
      2. sqrt-unprod33.6%

        \[\leadsto {\left(\color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot \left(-0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right)\right)}^{1} \]
      3. associate-*r*33.6%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left(\left(-0.125 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)}\right)}^{1} \]
    10. Applied egg-rr33.6%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\left(-0.125 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right)}^{1}} \]
    11. Step-by-step derivation
      1. unpow133.6%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\left(-0.125 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)} \]
      2. *-commutative33.6%

        \[\leadsto \sqrt{\color{blue}{\frac{d}{\ell} \cdot \frac{d}{h}}} \cdot \left(\left(-0.125 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right) \]
      3. *-commutative33.6%

        \[\leadsto \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \color{blue}{\left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \left(-0.125 \cdot \frac{h}{\ell}\right)\right)} \]
    12. Simplified33.6%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \left(-0.125 \cdot \frac{h}{\ell}\right)\right)} \]

    if 1.02000000000000001e-131 < d

    1. Initial program 66.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified64.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 d around inf 51.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div52.5%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval52.5%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative52.5%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod61.9%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv62.1%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. associate-/r*58.0%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr58.0%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    7. Step-by-step derivation
      1. associate-/l/62.1%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      2. *-commutative62.1%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    8. Simplified62.1%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification53.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5.2 \cdot 10^{+39}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 1.02 \cdot 10^{-131}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \left(-0.125 \cdot \frac{h}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 48.6% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -5.5 \cdot 10^{-52}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot e^{\mathsf{log1p}\left(\ell \cdot h + -1\right) \cdot \left(-0.5\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (if (<= d -5.5e-52)
   (/ (- d) (sqrt (* l h)))
   (if (<= d -5e-310)
     (* d (exp (* (log1p (+ (* l h) -1.0)) (- 0.5))))
     (/ d (* (sqrt l) (sqrt h))))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (d <= -5.5e-52) {
		tmp = -d / sqrt((l * h));
	} else if (d <= -5e-310) {
		tmp = d * exp((log1p(((l * h) + -1.0)) * -0.5));
	} else {
		tmp = d / (sqrt(l) * sqrt(h));
	}
	return tmp;
}
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (d <= -5.5e-52) {
		tmp = -d / Math.sqrt((l * h));
	} else if (d <= -5e-310) {
		tmp = d * Math.exp((Math.log1p(((l * h) + -1.0)) * -0.5));
	} else {
		tmp = d / (Math.sqrt(l) * Math.sqrt(h));
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	tmp = 0
	if d <= -5.5e-52:
		tmp = -d / math.sqrt((l * h))
	elif d <= -5e-310:
		tmp = d * math.exp((math.log1p(((l * h) + -1.0)) * -0.5))
	else:
		tmp = d / (math.sqrt(l) * math.sqrt(h))
	return tmp
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	tmp = 0.0
	if (d <= -5.5e-52)
		tmp = Float64(Float64(-d) / sqrt(Float64(l * h)));
	elseif (d <= -5e-310)
		tmp = Float64(d * exp(Float64(log1p(Float64(Float64(l * h) + -1.0)) * Float64(-0.5))));
	else
		tmp = Float64(d / Float64(sqrt(l) * sqrt(h)));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[d, -5.5e-52], N[((-d) / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-310], N[(d * N[Exp[N[(N[Log[1 + N[(N[(l * h), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] * (-0.5)), $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, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.5 \cdot 10^{-52}:\\
\;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\

\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot e^{\mathsf{log1p}\left(\ell \cdot h + -1\right) \cdot \left(-0.5\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -5.5e-52

    1. Initial program 69.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. Simplified71.2%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 44.4%

      \[\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. associate-*r/44.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}}\right)\right) \]
      2. associate-*r*48.2%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{-0.125 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2} \cdot \ell}\right)\right) \]
      3. associate-*r*48.2%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{\color{blue}{\left(-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)\right) \cdot h}}{{d}^{2} \cdot \ell}\right)\right) \]
      4. associate-*l/49.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)}{{d}^{2} \cdot \ell} \cdot h}\right)\right) \]
      5. associate-*r/49.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)} \cdot h\right)\right) \]
      6. *-commutative49.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)}\right)\right) \]
      7. +-commutative49.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) + 1\right)}\right) \]
      8. fma-undefine49.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, -0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}, 1\right)}\right) \]
    6. Simplified76.4%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, 1\right)}\right) \]
    7. 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}}} \]
    8. 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. *-commutative0.0%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      3. unpow20.0%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      4. rem-square-sqrt62.2%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      5. neg-mul-162.2%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \color{blue}{\left(-d\right)} \]
      6. distribute-rgt-neg-in62.2%

        \[\leadsto \color{blue}{-\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      7. unpow1/262.2%

        \[\leadsto -\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \cdot d \]
      8. rem-exp-log59.1%

        \[\leadsto -{\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \cdot d \]
      9. exp-neg59.1%

        \[\leadsto -{\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot d \]
      10. exp-prod59.1%

        \[\leadsto -\color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \cdot d \]
      11. distribute-lft-neg-out59.1%

        \[\leadsto -e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot d \]
      12. exp-neg59.1%

        \[\leadsto -\color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \cdot d \]
      13. exp-to-pow62.2%

        \[\leadsto -\frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \cdot d \]
      14. unpow1/262.2%

        \[\leadsto -\frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot d \]
      15. associate-*l/62.3%

        \[\leadsto -\color{blue}{\frac{1 \cdot d}{\sqrt{h \cdot \ell}}} \]
      16. *-lft-identity62.3%

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
      17. distribute-frac-neg262.3%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]
    9. Simplified62.3%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if -5.5e-52 < d < -4.999999999999985e-310

    1. Initial program 53.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified55.2%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 12.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. pow1/212.5%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      2. pow-to-exp12.5%

        \[\leadsto d \cdot \color{blue}{e^{\log \left(\frac{1}{h \cdot \ell}\right) \cdot 0.5}} \]
      3. log-rec10.1%

        \[\leadsto d \cdot e^{\color{blue}{\left(-\log \left(h \cdot \ell\right)\right)} \cdot 0.5} \]
    6. Applied egg-rr10.1%

      \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
    7. Step-by-step derivation
      1. log1p-expm1-u39.0%

        \[\leadsto d \cdot e^{\left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(h \cdot \ell\right)\right)\right)}\right) \cdot 0.5} \]
      2. expm1-undefine39.0%

        \[\leadsto d \cdot e^{\left(-\mathsf{log1p}\left(\color{blue}{e^{\log \left(h \cdot \ell\right)} - 1}\right)\right) \cdot 0.5} \]
      3. add-exp-log39.0%

        \[\leadsto d \cdot e^{\left(-\mathsf{log1p}\left(\color{blue}{h \cdot \ell} - 1\right)\right) \cdot 0.5} \]
    8. Applied egg-rr39.0%

      \[\leadsto d \cdot e^{\left(-\color{blue}{\mathsf{log1p}\left(h \cdot \ell - 1\right)}\right) \cdot 0.5} \]

    if -4.999999999999985e-310 < d

    1. Initial program 58.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified56.7%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 41.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div41.6%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval41.6%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative41.6%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod48.9%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv49.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. associate-/r*46.2%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr46.2%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    7. Step-by-step derivation
      1. associate-/l/49.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      2. *-commutative49.0%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    8. Simplified49.0%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification51.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5.5 \cdot 10^{-52}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot e^{\mathsf{log1p}\left(\ell \cdot h + -1\right) \cdot \left(-0.5\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 46.8% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq 9.6 \cdot 10^{-200}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (if (<= d 9.6e-200) (/ (- d) (sqrt (* l h))) (/ d (* (sqrt l) (sqrt h)))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (d <= 9.6e-200) {
		tmp = -d / sqrt((l * h));
	} else {
		tmp = d / (sqrt(l) * sqrt(h));
	}
	return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (d <= 9.6d-200) then
        tmp = -d / sqrt((l * h))
    else
        tmp = d / (sqrt(l) * sqrt(h))
    end if
    code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (d <= 9.6e-200) {
		tmp = -d / Math.sqrt((l * h));
	} else {
		tmp = d / (Math.sqrt(l) * Math.sqrt(h));
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	tmp = 0
	if d <= 9.6e-200:
		tmp = -d / math.sqrt((l * h))
	else:
		tmp = d / (math.sqrt(l) * math.sqrt(h))
	return tmp
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	tmp = 0.0
	if (d <= 9.6e-200)
		tmp = Float64(Float64(-d) / sqrt(Float64(l * h)));
	else
		tmp = Float64(d / Float64(sqrt(l) * sqrt(h)));
	end
	return tmp
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
	tmp = 0.0;
	if (d <= 9.6e-200)
		tmp = -d / sqrt((l * h));
	else
		tmp = d / (sqrt(l) * sqrt(h));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[d, 9.6e-200], N[((-d) / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 9.6 \cdot 10^{-200}:\\
\;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 9.60000000000000006e-200

    1. Initial program 59.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified59.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 37.2%

      \[\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. associate-*r/37.2%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}}\right)\right) \]
      2. associate-*r*40.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{-0.125 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2} \cdot \ell}\right)\right) \]
      3. associate-*r*40.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{\color{blue}{\left(-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)\right) \cdot h}}{{d}^{2} \cdot \ell}\right)\right) \]
      4. associate-*l/40.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)}{{d}^{2} \cdot \ell} \cdot h}\right)\right) \]
      5. associate-*r/40.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)} \cdot h\right)\right) \]
      6. *-commutative40.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)}\right)\right) \]
      7. +-commutative40.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) + 1\right)}\right) \]
      8. fma-undefine40.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, -0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}, 1\right)}\right) \]
    6. Simplified62.0%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, 1\right)}\right) \]
    7. 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}}} \]
    8. 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. *-commutative0.0%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      3. unpow20.0%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      4. rem-square-sqrt44.7%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      5. neg-mul-144.7%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \color{blue}{\left(-d\right)} \]
      6. distribute-rgt-neg-in44.7%

        \[\leadsto \color{blue}{-\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      7. unpow1/244.7%

        \[\leadsto -\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \cdot d \]
      8. rem-exp-log42.6%

        \[\leadsto -{\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \cdot d \]
      9. exp-neg42.6%

        \[\leadsto -{\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot d \]
      10. exp-prod42.6%

        \[\leadsto -\color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \cdot d \]
      11. distribute-lft-neg-out42.6%

        \[\leadsto -e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot d \]
      12. exp-neg42.6%

        \[\leadsto -\color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \cdot d \]
      13. exp-to-pow44.7%

        \[\leadsto -\frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \cdot d \]
      14. unpow1/244.7%

        \[\leadsto -\frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot d \]
      15. associate-*l/44.7%

        \[\leadsto -\color{blue}{\frac{1 \cdot d}{\sqrt{h \cdot \ell}}} \]
      16. *-lft-identity44.7%

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
      17. distribute-frac-neg244.7%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]
    9. Simplified44.7%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if 9.60000000000000006e-200 < d

    1. Initial program 65.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.3%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 47.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div47.8%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval47.8%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative47.8%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod56.5%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv56.6%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. associate-/r*53.2%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr53.2%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    7. Step-by-step derivation
      1. associate-/l/56.6%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      2. *-commutative56.6%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    8. Simplified56.6%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification49.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 9.6 \cdot 10^{-200}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 42.6% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;\ell \leq 4.1 \cdot 10^{-225}:\\ \;\;\;\;\frac{-d}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{t\_0}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (let* ((t_0 (sqrt (* l h)))) (if (<= l 4.1e-225) (/ (- d) t_0) (/ d t_0))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double t_0 = sqrt((l * h));
	double tmp;
	if (l <= 4.1e-225) {
		tmp = -d / t_0;
	} else {
		tmp = d / t_0;
	}
	return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((l * h))
    if (l <= 4.1d-225) then
        tmp = -d / t_0
    else
        tmp = d / t_0
    end if
    code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double t_0 = Math.sqrt((l * h));
	double tmp;
	if (l <= 4.1e-225) {
		tmp = -d / t_0;
	} else {
		tmp = d / t_0;
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	t_0 = math.sqrt((l * h))
	tmp = 0
	if l <= 4.1e-225:
		tmp = -d / t_0
	else:
		tmp = d / t_0
	return tmp
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	t_0 = sqrt(Float64(l * h))
	tmp = 0.0
	if (l <= 4.1e-225)
		tmp = Float64(Float64(-d) / t_0);
	else
		tmp = Float64(d / t_0);
	end
	return tmp
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
	t_0 = sqrt((l * h));
	tmp = 0.0;
	if (l <= 4.1e-225)
		tmp = -d / t_0;
	else
		tmp = d / t_0;
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, 4.1e-225], N[((-d) / t$95$0), $MachinePrecision], N[(d / t$95$0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;\ell \leq 4.1 \cdot 10^{-225}:\\
\;\;\;\;\frac{-d}{t\_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 4.10000000000000022e-225

    1. Initial program 66.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified66.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 40.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. associate-*r/40.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}}\right)\right) \]
      2. associate-*r*43.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{-0.125 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2} \cdot \ell}\right)\right) \]
      3. associate-*r*43.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{\color{blue}{\left(-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)\right) \cdot h}}{{d}^{2} \cdot \ell}\right)\right) \]
      4. associate-*l/44.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)}{{d}^{2} \cdot \ell} \cdot h}\right)\right) \]
      5. associate-*r/44.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)} \cdot h\right)\right) \]
      6. *-commutative44.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)}\right)\right) \]
      7. +-commutative44.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) + 1\right)}\right) \]
      8. fma-undefine44.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, -0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}, 1\right)}\right) \]
    6. Simplified69.3%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, 1\right)}\right) \]
    7. 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}}} \]
    8. 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. *-commutative0.0%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      3. unpow20.0%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      4. rem-square-sqrt47.1%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      5. neg-mul-147.1%

        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot \color{blue}{\left(-d\right)} \]
      6. distribute-rgt-neg-in47.1%

        \[\leadsto \color{blue}{-\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      7. unpow1/247.1%

        \[\leadsto -\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \cdot d \]
      8. rem-exp-log44.8%

        \[\leadsto -{\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \cdot d \]
      9. exp-neg44.8%

        \[\leadsto -{\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot d \]
      10. exp-prod44.8%

        \[\leadsto -\color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \cdot d \]
      11. distribute-lft-neg-out44.8%

        \[\leadsto -e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot d \]
      12. exp-neg44.9%

        \[\leadsto -\color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \cdot d \]
      13. exp-to-pow47.0%

        \[\leadsto -\frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \cdot d \]
      14. unpow1/247.0%

        \[\leadsto -\frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot d \]
      15. associate-*l/47.1%

        \[\leadsto -\color{blue}{\frac{1 \cdot d}{\sqrt{h \cdot \ell}}} \]
      16. *-lft-identity47.1%

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
      17. distribute-frac-neg247.1%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]
    9. Simplified47.1%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if 4.10000000000000022e-225 < l

    1. Initial program 56.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. Simplified54.5%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 33.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. associate-*r/33.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}}\right)\right) \]
      2. associate-*r*33.6%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{-0.125 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2} \cdot \ell}\right)\right) \]
      3. associate-*r*33.6%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{\color{blue}{\left(-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)\right) \cdot h}}{{d}^{2} \cdot \ell}\right)\right) \]
      4. associate-*l/34.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)}{{d}^{2} \cdot \ell} \cdot h}\right)\right) \]
      5. associate-*r/34.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)} \cdot h\right)\right) \]
      6. *-commutative34.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)}\right)\right) \]
      7. +-commutative34.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) + 1\right)}\right) \]
      8. fma-undefine34.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, -0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}, 1\right)}\right) \]
    6. Simplified56.6%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, 1\right)}\right) \]
    7. Taylor expanded in d around inf 45.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. *-commutative45.2%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      2. unpow1/245.2%

        \[\leadsto \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \cdot d \]
      3. rem-exp-log43.1%

        \[\leadsto {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \cdot d \]
      4. exp-neg43.1%

        \[\leadsto {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot d \]
      5. exp-prod43.1%

        \[\leadsto \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \cdot d \]
      6. distribute-lft-neg-out43.1%

        \[\leadsto e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot d \]
      7. exp-neg43.1%

        \[\leadsto \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \cdot d \]
      8. exp-to-pow45.3%

        \[\leadsto \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \cdot d \]
      9. unpow1/245.3%

        \[\leadsto \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot d \]
      10. unpow-145.3%

        \[\leadsto \color{blue}{{\left(\sqrt{h \cdot \ell}\right)}^{-1}} \cdot d \]
      11. unpow-145.3%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{h \cdot \ell}}} \cdot d \]
      12. associate-*l/45.4%

        \[\leadsto \color{blue}{\frac{1 \cdot d}{\sqrt{h \cdot \ell}}} \]
      13. *-lft-identity45.4%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    9. Simplified45.4%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification46.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 4.1 \cdot 10^{-225}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 26.5% accurate, 3.2× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \frac{d}{\sqrt{\ell \cdot h}} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D) :precision binary64 (/ d (sqrt (* l h))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	return d / sqrt((l * h));
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_1
    code = d / sqrt((l * h))
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	return d / Math.sqrt((l * h));
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	return d / math.sqrt((l * h))
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	return Float64(d / sqrt(Float64(l * h)))
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
	tmp = d / sqrt((l * h));
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Derivation
  1. Initial program 61.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. Simplified61.1%

    \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in M around 0 37.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. associate-*r/37.5%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}}\right)\right) \]
    2. associate-*r*39.2%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{-0.125 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2} \cdot \ell}\right)\right) \]
    3. associate-*r*39.2%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{\color{blue}{\left(-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)\right) \cdot h}}{{d}^{2} \cdot \ell}\right)\right) \]
    4. associate-*l/40.0%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.125 \cdot \left({D}^{2} \cdot {M}^{2}\right)}{{d}^{2} \cdot \ell} \cdot h}\right)\right) \]
    5. associate-*r/40.0%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)} \cdot h\right)\right) \]
    6. *-commutative40.0%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)}\right)\right) \]
    7. +-commutative40.0%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(h \cdot \left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) + 1\right)}\right) \]
    8. fma-undefine40.0%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, -0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}, 1\right)}\right) \]
  6. Simplified63.5%

    \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, 1\right)}\right) \]
  7. Taylor expanded in d around inf 24.6%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  8. Step-by-step derivation
    1. *-commutative24.6%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
    2. unpow1/224.6%

      \[\leadsto \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \cdot d \]
    3. rem-exp-log23.7%

      \[\leadsto {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \cdot d \]
    4. exp-neg23.7%

      \[\leadsto {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot d \]
    5. exp-prod23.5%

      \[\leadsto \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \cdot d \]
    6. distribute-lft-neg-out23.5%

      \[\leadsto e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot d \]
    7. exp-neg23.5%

      \[\leadsto \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \cdot d \]
    8. exp-to-pow24.5%

      \[\leadsto \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \cdot d \]
    9. unpow1/224.5%

      \[\leadsto \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot d \]
    10. unpow-124.5%

      \[\leadsto \color{blue}{{\left(\sqrt{h \cdot \ell}\right)}^{-1}} \cdot d \]
    11. unpow-124.5%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{h \cdot \ell}}} \cdot d \]
    12. associate-*l/24.6%

      \[\leadsto \color{blue}{\frac{1 \cdot d}{\sqrt{h \cdot \ell}}} \]
    13. *-lft-identity24.6%

      \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
  9. Simplified24.6%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  10. Final simplification24.6%

    \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
  11. Add Preprocessing

Reproduce

?
herbie shell --seed 2024151 
(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)))))