Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.5% → 77.1%
Time: 15.8s
Alternatives: 18
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 18 alternatives:

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

Initial Program: 66.5% accurate, 1.0× speedup?

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

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

Alternative 1: 77.1% accurate, 1.0× speedup?

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

\mathbf{elif}\;d \leq 2.7 \cdot 10^{-151}:\\
\;\;\;\;\mathsf{fma}\left(\left(M \cdot M\right) \cdot \left(\frac{\frac{D\_m \cdot D\_m}{\ell}}{d} \cdot -0.125\right), \sqrt{h}, t\_0 \cdot d\right) \cdot {\ell}^{-0.5}\\

\mathbf{elif}\;d \leq 1.82 \cdot 10^{-22}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot \sqrt{h}, \left(\left(M \cdot M\right) \cdot D\_m\right) \cdot \frac{D\_m}{\ell}, t\_0 \cdot \left(d \cdot d\right)\right)}{d} \cdot {\ell}^{-0.5}\\

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


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

    1. Initial program 65.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. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \color{blue}{\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
      2. sub-negN/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \color{blue}{\left(1 + \left(\mathsf{neg}\left(\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\right)\right)} \]
      3. +-commutativeN/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\right) + 1\right)} \]
      4. lift-*.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}}\right)\right) + 1\right) \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \frac{h}{\ell}} + 1\right) \]
      6. lift-/.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(\left(\mathsf{neg}\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \color{blue}{\frac{h}{\ell}} + 1\right) \]
      7. clear-numN/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(\left(\mathsf{neg}\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \color{blue}{\frac{1}{\frac{\ell}{h}}} + 1\right) \]
      8. associate-*r/N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(\color{blue}{\frac{\left(\mathsf{neg}\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot 1}{\frac{\ell}{h}}} + 1\right) \]
      9. div-invN/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(\frac{\left(\mathsf{neg}\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot 1}{\color{blue}{\ell \cdot \frac{1}{h}}} + 1\right) \]
      10. times-fracN/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(\color{blue}{\frac{\mathsf{neg}\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)}{\ell} \cdot \frac{1}{\frac{1}{h}}} + 1\right) \]
      11. clear-numN/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(\frac{\mathsf{neg}\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)}{\ell} \cdot \color{blue}{\frac{h}{1}} + 1\right) \]
      12. /-rgt-identityN/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(\frac{\mathsf{neg}\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)}{\ell} \cdot \color{blue}{h} + 1\right) \]
      13. lower-fma.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \color{blue}{\mathsf{fma}\left(\frac{\mathsf{neg}\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)}{\ell}, h, 1\right)} \]
    4. Applied rewrites69.4%

      \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \color{blue}{\mathsf{fma}\left(\frac{-0.5 \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}, h, 1\right)} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right) \cdot \mathsf{fma}\left(\frac{\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}, h, 1\right) \]
      2. lift-pow.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}}\right) \cdot \mathsf{fma}\left(\frac{\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}, h, 1\right) \]
      3. metadata-evalN/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\frac{1}{2}}}\right) \cdot \mathsf{fma}\left(\frac{\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}, h, 1\right) \]
      4. pow1/2N/A

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

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

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

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{\frac{\sqrt{\mathsf{neg}\left(d\right)}}{\sqrt{\mathsf{neg}\left(\ell\right)}}}\right) \cdot \mathsf{fma}\left(\frac{\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}, h, 1\right) \]
      8. lower-/.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{\frac{\sqrt{\mathsf{neg}\left(d\right)}}{\sqrt{\mathsf{neg}\left(\ell\right)}}}\right) \cdot \mathsf{fma}\left(\frac{\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}, h, 1\right) \]
      9. lower-sqrt.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \frac{\color{blue}{\sqrt{\mathsf{neg}\left(d\right)}}}{\sqrt{\mathsf{neg}\left(\ell\right)}}\right) \cdot \mathsf{fma}\left(\frac{\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}, h, 1\right) \]
      10. lower-neg.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \frac{\sqrt{\color{blue}{-d}}}{\sqrt{\mathsf{neg}\left(\ell\right)}}\right) \cdot \mathsf{fma}\left(\frac{\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}, h, 1\right) \]
      11. lower-sqrt.f64N/A

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

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

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

    if -1.999999999999994e-310 < d < 2.70000000000000007e-151

    1. Initial program 42.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. Add Preprocessing
    3. Applied rewrites56.1%

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

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

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

      if 2.70000000000000007e-151 < d < 1.82e-22

      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. Add Preprocessing
      3. Applied rewrites66.1%

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

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

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

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

      if 1.82e-22 < d

      1. Initial program 78.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. Add Preprocessing
      3. Applied rewrites83.3%

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

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

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

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

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

          \[\leadsto \left(\left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{d}\right) \cdot {\ell}^{\frac{-1}{2}} \]
        6. lift-*.f64N/A

          \[\leadsto \left(\left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{d}\right) \cdot {\ell}^{\frac{-1}{2}} \]
        7. lift-/.f64N/A

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

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

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

          \[\leadsto \left(\left(\left(\color{blue}{h \cdot \frac{\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{d}\right) \cdot {\ell}^{\frac{-1}{2}} \]
        11. lift-/.f64N/A

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

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

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

    Alternative 2: 66.6% accurate, 0.3× speedup?

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

      1. Initial program 82.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. Add Preprocessing
      3. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}}\right) \]
        2. *-commutativeN/A

          \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{\frac{h}{\ell} \cdot \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)}\right) \]
        3. lift-*.f64N/A

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

          \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right) \]
        5. lift-pow.f64N/A

          \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right) \]
        6. unpow2N/A

          \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)}\right) \]
        7. lift-/.f64N/A

          \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \]
        8. lift-/.f64N/A

          \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot \color{blue}{\frac{M \cdot D}{2 \cdot d}}\right)\right) \]
        9. clear-numN/A

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

          \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \color{blue}{\frac{\left(M \cdot D\right) \cdot 1}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}}\right) \]
        11. *-rgt-identityN/A

          \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \frac{\color{blue}{M \cdot D}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}\right) \]
        12. associate-*r/N/A

          \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{\frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(M \cdot D\right)}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}}\right) \]
        13. associate-*r/N/A

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

          \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(M \cdot D\right)}{\color{blue}{\frac{2 \cdot d}{M \cdot D} \cdot \left(2 \cdot d\right)}}\right) \]
        15. lower-/.f64N/A

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

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{\frac{\left(\frac{h}{\ell} \cdot 0.5\right) \cdot \left(D \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D \cdot M}}}\right) \]
      5. Step-by-step derivation
        1. lift-/.f64N/A

          \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(D \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D \cdot M}}\right) \]
        2. lift-pow.f64N/A

          \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(D \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D \cdot M}}\right) \]
        3. metadata-evalN/A

          \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\frac{1}{2}}}\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(D \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D \cdot M}}\right) \]
        4. pow1/2N/A

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\frac{h}{\ell} \cdot 0.5, \frac{M}{\frac{4}{D}} \cdot \frac{D}{\frac{d \cdot d}{M}}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}} \]
      8. Step-by-step derivation
        1. metadata-evalN/A

          \[\leadsto \left(\mathsf{fma}\left(-\frac{h}{\ell} \cdot \color{blue}{\frac{1}{2}}, \frac{M}{\frac{4}{D}} \cdot \frac{D}{\frac{d \cdot d}{M}}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
        2. lift-fma.f64N/A

          \[\leadsto \left(\color{blue}{\left(\left(-\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(\frac{M}{\frac{4}{D}} \cdot \frac{D}{\frac{d \cdot d}{M}}\right) + 1\right)} \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
        3. lift-*.f64N/A

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

          \[\leadsto \left(\left(\color{blue}{\left(\left(-\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \frac{M}{\frac{4}{D}}\right) \cdot \frac{D}{\frac{d \cdot d}{M}}} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
        5. lift-/.f64N/A

          \[\leadsto \left(\left(\left(\left(-\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \frac{M}{\frac{4}{D}}\right) \cdot \color{blue}{\frac{D}{\frac{d \cdot d}{M}}} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
        6. lift-/.f64N/A

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

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

          \[\leadsto \left(\left(\color{blue}{\left(\left(\left(-\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \frac{M}{\frac{4}{D}}\right) \cdot \frac{D}{d \cdot d}\right) \cdot M} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
        9. lower-fma.f64N/A

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

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

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

      1. Initial program 37.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. Add Preprocessing
      3. Taylor expanded in d around inf

        \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      4. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
        2. lower-*.f64N/A

          \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
        3. lower-sqrt.f64N/A

          \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \cdot d \]
        4. lower-/.f64N/A

          \[\leadsto \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \cdot d \]
        5. *-commutativeN/A

          \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
        6. lower-*.f6472.3

          \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
      5. Applied rewrites72.3%

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

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

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

        1. Initial program 60.2%

          \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in d around inf

          \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
          2. lower-*.f64N/A

            \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
          3. lower-sqrt.f64N/A

            \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \cdot d \]
          4. lower-/.f64N/A

            \[\leadsto \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \cdot d \]
          5. *-commutativeN/A

            \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
          6. lower-*.f6436.2

            \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
        5. Applied rewrites36.2%

          \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
        6. Step-by-step derivation
          1. Applied rewrites63.1%

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

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

        Alternative 3: 62.6% accurate, 0.3× speedup?

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

          1. Initial program 83.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. Add Preprocessing
          3. Step-by-step derivation
            1. lift-*.f64N/A

              \[\leadsto \color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
            2. *-commutativeN/A

              \[\leadsto \color{blue}{\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} \]
            3. lift-*.f64N/A

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

              \[\leadsto \color{blue}{\left(\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \]
            5. lower-*.f64N/A

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

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

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

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

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

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

              \[\leadsto \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
            6. lift-*.f64N/A

              \[\leadsto \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
            7. lift-/.f64N/A

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

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

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

              \[\leadsto \left(\left(\color{blue}{h \cdot \frac{\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
            11. lift-/.f64N/A

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

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

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

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

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

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

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

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

              \[\leadsto \left(\color{blue}{\frac{\left(\frac{-1}{8} \cdot \left({D}^{2} \cdot h\right)\right) \cdot {M}^{2}}{{d}^{2} \cdot \ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
            7. times-fracN/A

              \[\leadsto \left(\color{blue}{\left(\frac{\frac{-1}{8} \cdot \left({D}^{2} \cdot h\right)}{{d}^{2}} \cdot \frac{{M}^{2}}{\ell}\right)} \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
            8. lower-*.f64N/A

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

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

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

          1. Initial program 47.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. Add Preprocessing
          3. Taylor expanded in d around inf

            \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
          4. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
            2. lower-*.f64N/A

              \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
            3. lower-sqrt.f64N/A

              \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \cdot d \]
            4. lower-/.f64N/A

              \[\leadsto \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \cdot d \]
            5. *-commutativeN/A

              \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
            6. lower-*.f6456.0

              \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
          5. Applied rewrites56.0%

            \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
          6. Step-by-step derivation
            1. Applied rewrites56.0%

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

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

            1. Initial program 60.2%

              \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
            2. Add Preprocessing
            3. Taylor expanded in d around inf

              \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
              2. lower-*.f64N/A

                \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
              3. lower-sqrt.f64N/A

                \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \cdot d \]
              4. lower-/.f64N/A

                \[\leadsto \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \cdot d \]
              5. *-commutativeN/A

                \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
              6. lower-*.f6436.2

                \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
            5. Applied rewrites36.2%

              \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
            6. Step-by-step derivation
              1. Applied rewrites63.1%

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

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

            Alternative 4: 72.9% accurate, 0.4× speedup?

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

              1. Initial program 80.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. Add Preprocessing
              3. Step-by-step derivation
                1. lift-*.f64N/A

                  \[\leadsto \color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
                2. *-commutativeN/A

                  \[\leadsto \color{blue}{\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} \]
                3. lift-*.f64N/A

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

                  \[\leadsto \color{blue}{\left(\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \]
                5. lower-*.f64N/A

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

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

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

                  \[\leadsto \left(\left(\color{blue}{{\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right)} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                3. lift-pow.f64N/A

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

                  \[\leadsto \left(\left({\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{\color{blue}{\left(-1 \cdot 2\right)}} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                5. pow-powN/A

                  \[\leadsto \left(\left(\color{blue}{{\left({\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-1}\right)}^{2}} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                6. inv-powN/A

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

                  \[\leadsto \left(\left({\left(\frac{1}{\color{blue}{\frac{2}{M} \cdot \frac{d}{D}}}\right)}^{2} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                8. lift-/.f64N/A

                  \[\leadsto \left(\left({\left(\frac{1}{\color{blue}{\frac{2}{M}} \cdot \frac{d}{D}}\right)}^{2} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                9. lift-/.f64N/A

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

                  \[\leadsto \left(\left({\left(\frac{1}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}}\right)}^{2} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                11. clear-numN/A

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

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

                  \[\leadsto \left(\left(\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right)\right)} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                14. lower-fma.f64N/A

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

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

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

              1. Initial program 0.0%

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

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

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

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

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

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

            Alternative 5: 72.8% accurate, 0.4× speedup?

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

              1. Initial program 80.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. Add Preprocessing
              3. Step-by-step derivation
                1. lift-*.f64N/A

                  \[\leadsto \color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
                2. *-commutativeN/A

                  \[\leadsto \color{blue}{\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} \]
                3. lift-*.f64N/A

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

                  \[\leadsto \color{blue}{\left(\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \]
                5. lower-*.f64N/A

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

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

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

                  \[\leadsto \left(\left(\color{blue}{{\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right)} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                3. lift-pow.f64N/A

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

                  \[\leadsto \left(\left({\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{\color{blue}{\left(-1 \cdot 2\right)}} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                5. pow-powN/A

                  \[\leadsto \left(\left(\color{blue}{{\left({\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-1}\right)}^{2}} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                6. inv-powN/A

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

                  \[\leadsto \left(\left({\left(\frac{1}{\color{blue}{\frac{2}{M} \cdot \frac{d}{D}}}\right)}^{2} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                8. lift-/.f64N/A

                  \[\leadsto \left(\left({\left(\frac{1}{\color{blue}{\frac{2}{M}} \cdot \frac{d}{D}}\right)}^{2} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                9. lift-/.f64N/A

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

                  \[\leadsto \left(\left({\left(\frac{1}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}}\right)}^{2} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                11. clear-numN/A

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

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

                  \[\leadsto \left(\left(\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right)\right)} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                14. lower-fma.f64N/A

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

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

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

              1. Initial program 0.0%

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

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

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

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

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

              Alternative 6: 71.5% accurate, 0.5× speedup?

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

                1. Initial program 80.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. Add Preprocessing
                3. Step-by-step derivation
                  1. lift-*.f64N/A

                    \[\leadsto \color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
                  2. *-commutativeN/A

                    \[\leadsto \color{blue}{\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} \]
                  3. lift-*.f64N/A

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

                    \[\leadsto \color{blue}{\left(\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \]
                  5. lower-*.f64N/A

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

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

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

                    \[\leadsto \left(\left(\color{blue}{{\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right)} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                  3. lift-pow.f64N/A

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

                    \[\leadsto \left(\left({\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{\color{blue}{\left(-1 \cdot 2\right)}} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                  5. pow-powN/A

                    \[\leadsto \left(\left(\color{blue}{{\left({\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-1}\right)}^{2}} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                  6. inv-powN/A

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

                    \[\leadsto \left(\left({\left(\frac{1}{\color{blue}{\frac{2}{M} \cdot \frac{d}{D}}}\right)}^{2} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                  8. lift-/.f64N/A

                    \[\leadsto \left(\left({\left(\frac{1}{\color{blue}{\frac{2}{M}} \cdot \frac{d}{D}}\right)}^{2} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                  9. lift-/.f64N/A

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

                    \[\leadsto \left(\left({\left(\frac{1}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}}\right)}^{2} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                  11. clear-numN/A

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

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

                    \[\leadsto \left(\left(\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right)\right)} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                  14. lower-fma.f64N/A

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

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

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

                1. Initial program 0.0%

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{\left(\left({D}^{2} \cdot \frac{-1}{8}\right) \cdot \left(\frac{{M}^{2}}{d \cdot \ell} \cdot \sqrt{h}\right)\right)} \cdot {\ell}^{\frac{-1}{2}} \]
                  7. lower-*.f64N/A

                    \[\leadsto \color{blue}{\left(\left({D}^{2} \cdot \frac{-1}{8}\right) \cdot \left(\frac{{M}^{2}}{d \cdot \ell} \cdot \sqrt{h}\right)\right)} \cdot {\ell}^{\frac{-1}{2}} \]
                  8. lower-*.f64N/A

                    \[\leadsto \left(\color{blue}{\left({D}^{2} \cdot \frac{-1}{8}\right)} \cdot \left(\frac{{M}^{2}}{d \cdot \ell} \cdot \sqrt{h}\right)\right) \cdot {\ell}^{\frac{-1}{2}} \]
                  9. unpow2N/A

                    \[\leadsto \left(\left(\color{blue}{\left(D \cdot D\right)} \cdot \frac{-1}{8}\right) \cdot \left(\frac{{M}^{2}}{d \cdot \ell} \cdot \sqrt{h}\right)\right) \cdot {\ell}^{\frac{-1}{2}} \]
                  10. lower-*.f64N/A

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

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

                    \[\leadsto \left(\left(\left(D \cdot D\right) \cdot \frac{-1}{8}\right) \cdot \color{blue}{\frac{\sqrt{h} \cdot {M}^{2}}{d \cdot \ell}}\right) \cdot {\ell}^{\frac{-1}{2}} \]
                  13. times-fracN/A

                    \[\leadsto \left(\left(\left(D \cdot D\right) \cdot \frac{-1}{8}\right) \cdot \color{blue}{\left(\frac{\sqrt{h}}{d} \cdot \frac{{M}^{2}}{\ell}\right)}\right) \cdot {\ell}^{\frac{-1}{2}} \]
                  14. lower-*.f64N/A

                    \[\leadsto \left(\left(\left(D \cdot D\right) \cdot \frac{-1}{8}\right) \cdot \color{blue}{\left(\frac{\sqrt{h}}{d} \cdot \frac{{M}^{2}}{\ell}\right)}\right) \cdot {\ell}^{\frac{-1}{2}} \]
                  15. lower-/.f64N/A

                    \[\leadsto \left(\left(\left(D \cdot D\right) \cdot \frac{-1}{8}\right) \cdot \left(\color{blue}{\frac{\sqrt{h}}{d}} \cdot \frac{{M}^{2}}{\ell}\right)\right) \cdot {\ell}^{\frac{-1}{2}} \]
                  16. lower-sqrt.f64N/A

                    \[\leadsto \left(\left(\left(D \cdot D\right) \cdot \frac{-1}{8}\right) \cdot \left(\frac{\color{blue}{\sqrt{h}}}{d} \cdot \frac{{M}^{2}}{\ell}\right)\right) \cdot {\ell}^{\frac{-1}{2}} \]
                  17. lower-/.f64N/A

                    \[\leadsto \left(\left(\left(D \cdot D\right) \cdot \frac{-1}{8}\right) \cdot \left(\frac{\sqrt{h}}{d} \cdot \color{blue}{\frac{{M}^{2}}{\ell}}\right)\right) \cdot {\ell}^{\frac{-1}{2}} \]
                  18. unpow2N/A

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

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

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

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

              Alternative 7: 69.2% accurate, 0.5× speedup?

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

                1. Initial program 80.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. Add Preprocessing
                3. Step-by-step derivation
                  1. lift-*.f64N/A

                    \[\leadsto \color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
                  2. *-commutativeN/A

                    \[\leadsto \color{blue}{\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} \]
                  3. lift-*.f64N/A

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

                    \[\leadsto \color{blue}{\left(\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \]
                  5. lower-*.f64N/A

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

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

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

                    \[\leadsto \left(\left(\color{blue}{{\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right)} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                  3. lift-pow.f64N/A

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

                    \[\leadsto \left(\left({\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{\color{blue}{\left(-1 \cdot 2\right)}} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                  5. pow-powN/A

                    \[\leadsto \left(\left(\color{blue}{{\left({\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-1}\right)}^{2}} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                  6. inv-powN/A

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

                    \[\leadsto \left(\left({\left(\frac{1}{\color{blue}{\frac{2}{M} \cdot \frac{d}{D}}}\right)}^{2} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                  8. lift-/.f64N/A

                    \[\leadsto \left(\left({\left(\frac{1}{\color{blue}{\frac{2}{M}} \cdot \frac{d}{D}}\right)}^{2} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                  9. lift-/.f64N/A

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

                    \[\leadsto \left(\left({\left(\frac{1}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}}\right)}^{2} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right) + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                  11. clear-numN/A

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

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

                    \[\leadsto \left(\left(\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot \left(\frac{-1}{2} \cdot \frac{h}{\ell}\right)\right)} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                  14. lower-fma.f64N/A

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

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

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

                1. Initial program 0.0%

                  \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
                2. Add Preprocessing
                3. Step-by-step derivation
                  1. lift-*.f64N/A

                    \[\leadsto \color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
                  2. *-commutativeN/A

                    \[\leadsto \color{blue}{\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} \]
                  3. lift-*.f64N/A

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

                    \[\leadsto \color{blue}{\left(\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \]
                  5. lower-*.f64N/A

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

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

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

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

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

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

                    \[\leadsto \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                  6. lift-*.f64N/A

                    \[\leadsto \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                  7. lift-/.f64N/A

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

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

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

                    \[\leadsto \left(\left(\color{blue}{h \cdot \frac{\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                  11. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              Alternative 8: 77.9% accurate, 1.3× speedup?

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

                1. Initial program 65.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. Add Preprocessing
                3. Applied rewrites71.2%

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

                if -1.999999999999994e-310 < d < 2.70000000000000007e-151

                1. Initial program 42.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. Add Preprocessing
                3. Applied rewrites56.1%

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

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

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

                  if 2.70000000000000007e-151 < d < 1.82e-22

                  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. Add Preprocessing
                  3. Applied rewrites66.1%

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

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

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

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

                  if 1.82e-22 < d

                  1. Initial program 78.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. Add Preprocessing
                  3. Applied rewrites83.3%

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

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

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

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

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

                      \[\leadsto \left(\left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{d}\right) \cdot {\ell}^{\frac{-1}{2}} \]
                    6. lift-*.f64N/A

                      \[\leadsto \left(\left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{d}\right) \cdot {\ell}^{\frac{-1}{2}} \]
                    7. lift-/.f64N/A

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

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

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

                      \[\leadsto \left(\left(\left(\color{blue}{h \cdot \frac{\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{d}\right) \cdot {\ell}^{\frac{-1}{2}} \]
                    11. lift-/.f64N/A

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

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

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

                Alternative 9: 76.5% accurate, 1.4× speedup?

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

                  1. Initial program 65.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. Add Preprocessing
                  3. Applied rewrites71.2%

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

                  if -1.999999999999994e-310 < d < 2.70000000000000007e-151

                  1. Initial program 42.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. Add Preprocessing
                  3. Applied rewrites56.1%

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

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

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

                    if 2.70000000000000007e-151 < d < 4.3999999999999999e-36

                    1. Initial program 58.8%

                      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
                    2. Add Preprocessing
                    3. Applied rewrites62.4%

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

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

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

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

                    if 4.3999999999999999e-36 < d

                    1. Initial program 78.9%

                      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
                    2. Add Preprocessing
                    3. Step-by-step derivation
                      1. lift-*.f64N/A

                        \[\leadsto \color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
                      2. *-commutativeN/A

                        \[\leadsto \color{blue}{\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} \]
                      3. lift-*.f64N/A

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

                        \[\leadsto \color{blue}{\left(\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \]
                      5. lower-*.f64N/A

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

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

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

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

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

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

                        \[\leadsto \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                      6. lift-*.f64N/A

                        \[\leadsto \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                      7. lift-/.f64N/A

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

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

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

                        \[\leadsto \left(\left(\color{blue}{h \cdot \frac{\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                      11. lift-/.f64N/A

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

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

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

                  Alternative 10: 73.7% accurate, 1.4× speedup?

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

                    1. Initial program 65.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. Add Preprocessing
                    3. Applied rewrites70.9%

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

                    if -1.999999999999994e-310 < d < 2.70000000000000007e-151

                    1. Initial program 42.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. Add Preprocessing
                    3. Applied rewrites56.1%

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

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

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

                      if 2.70000000000000007e-151 < d < 4.3999999999999999e-36

                      1. Initial program 58.8%

                        \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
                      2. Add Preprocessing
                      3. Applied rewrites62.4%

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

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

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

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

                      if 4.3999999999999999e-36 < d

                      1. Initial program 78.9%

                        \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
                      2. Add Preprocessing
                      3. Step-by-step derivation
                        1. lift-*.f64N/A

                          \[\leadsto \color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
                        2. *-commutativeN/A

                          \[\leadsto \color{blue}{\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} \]
                        3. lift-*.f64N/A

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

                          \[\leadsto \color{blue}{\left(\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \]
                        5. lower-*.f64N/A

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

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

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

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

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

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

                          \[\leadsto \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                        6. lift-*.f64N/A

                          \[\leadsto \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                        7. lift-/.f64N/A

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

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

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

                          \[\leadsto \left(\left(\color{blue}{h \cdot \frac{\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                        11. lift-/.f64N/A

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

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

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

                    Alternative 11: 72.6% accurate, 1.4× speedup?

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

                      1. Initial program 65.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. Add Preprocessing
                      3. Step-by-step derivation
                        1. lift-*.f64N/A

                          \[\leadsto \color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
                        2. *-commutativeN/A

                          \[\leadsto \color{blue}{\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} \]
                        3. lift-*.f64N/A

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

                          \[\leadsto \color{blue}{\left(\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \]
                        5. lower-*.f64N/A

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

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

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

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

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

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

                          \[\leadsto \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                        6. lift-*.f64N/A

                          \[\leadsto \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                        7. lift-/.f64N/A

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

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

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

                          \[\leadsto \left(\left(\color{blue}{h \cdot \frac{\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                        11. lift-/.f64N/A

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

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

                          \[\leadsto \left(\mathsf{fma}\left(\frac{-1}{2} \cdot h, \frac{\frac{1}{4} \cdot {\color{blue}{\left(\frac{\frac{d}{D}}{M}\right)}}^{-2}}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                        2. lift-/.f64N/A

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

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

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

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

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

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

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

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

                      if -1.999999999999994e-310 < d < 2.70000000000000007e-151

                      1. Initial program 42.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. Add Preprocessing
                      3. Applied rewrites56.1%

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

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

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

                        if 2.70000000000000007e-151 < d < 4.3999999999999999e-36

                        1. Initial program 58.8%

                          \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
                        2. Add Preprocessing
                        3. Applied rewrites62.4%

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

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

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

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

                        if 4.3999999999999999e-36 < d

                        1. Initial program 78.9%

                          \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
                        2. Add Preprocessing
                        3. Step-by-step derivation
                          1. lift-*.f64N/A

                            \[\leadsto \color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
                          2. *-commutativeN/A

                            \[\leadsto \color{blue}{\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} \]
                          3. lift-*.f64N/A

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

                            \[\leadsto \color{blue}{\left(\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \]
                          5. lower-*.f64N/A

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

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

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

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

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

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

                            \[\leadsto \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                          6. lift-*.f64N/A

                            \[\leadsto \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                          7. lift-/.f64N/A

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

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

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

                            \[\leadsto \left(\left(\color{blue}{h \cdot \frac{\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                          11. lift-/.f64N/A

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

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

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

                      Alternative 12: 72.5% accurate, 1.4× speedup?

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

                        1. Initial program 70.4%

                          \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
                        2. Add Preprocessing
                        3. Step-by-step derivation
                          1. lift-*.f64N/A

                            \[\leadsto \color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
                          2. *-commutativeN/A

                            \[\leadsto \color{blue}{\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} \]
                          3. lift-*.f64N/A

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

                            \[\leadsto \color{blue}{\left(\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \]
                          5. lower-*.f64N/A

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

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

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

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

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

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

                            \[\leadsto \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                          6. lift-*.f64N/A

                            \[\leadsto \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                          7. lift-/.f64N/A

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

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

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

                            \[\leadsto \left(\left(\color{blue}{h \cdot \frac{\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                          11. lift-/.f64N/A

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

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

                            \[\leadsto \left(\mathsf{fma}\left(\frac{-1}{2} \cdot h, \frac{\frac{1}{4} \cdot {\color{blue}{\left(\frac{\frac{d}{D}}{M}\right)}}^{-2}}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                          2. lift-/.f64N/A

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

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

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

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

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

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

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

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

                        if -1.999999999999994e-310 < d < 2.70000000000000007e-151

                        1. Initial program 42.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. Add Preprocessing
                        3. Applied rewrites56.1%

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

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

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

                          if 2.70000000000000007e-151 < d < 4.3999999999999999e-36

                          1. Initial program 58.8%

                            \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
                          2. Add Preprocessing
                          3. Applied rewrites62.4%

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

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

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

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

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

                        Alternative 13: 52.9% accurate, 2.9× speedup?

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

                          1. Initial program 65.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. Add Preprocessing
                          3. Taylor expanded in d around inf

                            \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
                          4. Step-by-step derivation
                            1. *-commutativeN/A

                              \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                            2. lower-*.f64N/A

                              \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                            3. lower-sqrt.f64N/A

                              \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \cdot d \]
                            4. lower-/.f64N/A

                              \[\leadsto \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \cdot d \]
                            5. *-commutativeN/A

                              \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                            6. lower-*.f6436.3

                              \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                          5. Applied rewrites36.3%

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

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

                            if 4.9999999999999995e-94 < (*.f64 M D) < 5.9999999999999999e205

                            1. Initial program 72.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. Add Preprocessing
                            3. Step-by-step derivation
                              1. lift-*.f64N/A

                                \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}}\right) \]
                              2. *-commutativeN/A

                                \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{\frac{h}{\ell} \cdot \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)}\right) \]
                              3. lift-*.f64N/A

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

                                \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right) \]
                              5. lift-pow.f64N/A

                                \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right) \]
                              6. unpow2N/A

                                \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)}\right) \]
                              7. lift-/.f64N/A

                                \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \]
                              8. lift-/.f64N/A

                                \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot \color{blue}{\frac{M \cdot D}{2 \cdot d}}\right)\right) \]
                              9. clear-numN/A

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

                                \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \color{blue}{\frac{\left(M \cdot D\right) \cdot 1}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}}\right) \]
                              11. *-rgt-identityN/A

                                \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \frac{\color{blue}{M \cdot D}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}\right) \]
                              12. associate-*r/N/A

                                \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{\frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(M \cdot D\right)}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}}\right) \]
                              13. associate-*r/N/A

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

                                \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(M \cdot D\right)}{\color{blue}{\frac{2 \cdot d}{M \cdot D} \cdot \left(2 \cdot d\right)}}\right) \]
                              15. lower-/.f64N/A

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

                              \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{\frac{\left(\frac{h}{\ell} \cdot 0.5\right) \cdot \left(D \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D \cdot M}}}\right) \]
                            5. Step-by-step derivation
                              1. lift-/.f64N/A

                                \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(D \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D \cdot M}}\right) \]
                              2. lift-pow.f64N/A

                                \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(D \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D \cdot M}}\right) \]
                              3. metadata-evalN/A

                                \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\frac{1}{2}}}\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(D \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D \cdot M}}\right) \]
                              4. pow1/2N/A

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

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

                              \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}}\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot 0.5\right) \cdot \left(D \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D \cdot M}}\right) \]
                            7. Step-by-step derivation
                              1. lift-/.f64N/A

                                \[\leadsto \left({\left(\frac{d}{h}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(D \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D \cdot M}}\right) \]
                              2. lift-pow.f64N/A

                                \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(D \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D \cdot M}}\right) \]
                              3. metadata-evalN/A

                                \[\leadsto \left({\left(\frac{d}{h}\right)}^{\color{blue}{\frac{1}{2}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(D \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D \cdot M}}\right) \]
                              4. pow1/2N/A

                                \[\leadsto \left(\color{blue}{\sqrt{\frac{d}{h}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(D \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D \cdot M}}\right) \]
                              5. lift-sqrt.f6471.0

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

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

                            if 5.9999999999999999e205 < (*.f64 M D)

                            1. Initial program 59.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. Add Preprocessing
                            3. Step-by-step derivation
                              1. lift-*.f64N/A

                                \[\leadsto \color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
                              2. *-commutativeN/A

                                \[\leadsto \color{blue}{\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} \]
                              3. lift-*.f64N/A

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

                                \[\leadsto \color{blue}{\left(\left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \]
                              5. lower-*.f64N/A

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

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

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

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

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

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

                                \[\leadsto \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                              6. lift-*.f64N/A

                                \[\leadsto \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}\right)} \cdot \frac{h}{\ell} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                              7. lift-/.f64N/A

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

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

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

                                \[\leadsto \left(\left(\color{blue}{h \cdot \frac{\frac{-1}{2} \cdot {\left(\frac{2}{M} \cdot \frac{d}{D}\right)}^{-2}}{\ell}} + 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                              11. lift-/.f64N/A

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

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

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

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

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

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

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

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

                                \[\leadsto \left(\color{blue}{\frac{\left(\frac{-1}{8} \cdot \left({D}^{2} \cdot h\right)\right) \cdot {M}^{2}}{{d}^{2} \cdot \ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                              7. times-fracN/A

                                \[\leadsto \left(\color{blue}{\left(\frac{\frac{-1}{8} \cdot \left({D}^{2} \cdot h\right)}{{d}^{2}} \cdot \frac{{M}^{2}}{\ell}\right)} \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                              8. lower-*.f64N/A

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

                              \[\leadsto \left(\color{blue}{\left(\left(\left(\frac{\frac{D \cdot D}{d}}{d} \cdot h\right) \cdot -0.125\right) \cdot \frac{M \cdot M}{\ell}\right)} \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}} \]
                          7. Recombined 3 regimes into one program.
                          8. Add Preprocessing

                          Alternative 14: 57.9% accurate, 3.6× speedup?

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

                            1. Initial program 65.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. Add Preprocessing
                            3. Taylor expanded in d around inf

                              \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
                            4. Step-by-step derivation
                              1. *-commutativeN/A

                                \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                              2. lower-*.f64N/A

                                \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                              3. lower-sqrt.f64N/A

                                \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \cdot d \]
                              4. lower-/.f64N/A

                                \[\leadsto \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \cdot d \]
                              5. *-commutativeN/A

                                \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                              6. lower-*.f649.8

                                \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                            5. Applied rewrites9.8%

                              \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
                            6. Step-by-step derivation
                              1. Applied rewrites33.1%

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

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

                                if -4.999999999999985e-310 < l < 1.1999999999999999e129

                                1. Initial program 72.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. Add Preprocessing
                                3. Step-by-step derivation
                                  1. lift-*.f64N/A

                                    \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}}\right) \]
                                  2. *-commutativeN/A

                                    \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{\frac{h}{\ell} \cdot \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)}\right) \]
                                  3. lift-*.f64N/A

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

                                    \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right) \]
                                  5. lift-pow.f64N/A

                                    \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right) \]
                                  6. unpow2N/A

                                    \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)}\right) \]
                                  7. lift-/.f64N/A

                                    \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \]
                                  8. lift-/.f64N/A

                                    \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot \color{blue}{\frac{M \cdot D}{2 \cdot d}}\right)\right) \]
                                  9. clear-numN/A

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

                                    \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \color{blue}{\frac{\left(M \cdot D\right) \cdot 1}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}}\right) \]
                                  11. *-rgt-identityN/A

                                    \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \frac{\color{blue}{M \cdot D}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}\right) \]
                                  12. associate-*r/N/A

                                    \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{\frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(M \cdot D\right)}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}}\right) \]
                                  13. associate-*r/N/A

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

                                    \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(M \cdot D\right)}{\color{blue}{\frac{2 \cdot d}{M \cdot D} \cdot \left(2 \cdot d\right)}}\right) \]
                                  15. lower-/.f64N/A

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

                                  \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{\frac{\left(\frac{h}{\ell} \cdot 0.5\right) \cdot \left(D \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D \cdot M}}}\right) \]
                                5. Step-by-step derivation
                                  1. lift-/.f64N/A

                                    \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(D \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D \cdot M}}\right) \]
                                  2. lift-pow.f64N/A

                                    \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(D \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D \cdot M}}\right) \]
                                  3. metadata-evalN/A

                                    \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\frac{1}{2}}}\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(D \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D \cdot M}}\right) \]
                                  4. pow1/2N/A

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

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

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

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

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

                                if 1.1999999999999999e129 < l

                                1. Initial program 55.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. Add Preprocessing
                                3. Taylor expanded in d around inf

                                  \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
                                4. Step-by-step derivation
                                  1. *-commutativeN/A

                                    \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                                  2. lower-*.f64N/A

                                    \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                                  3. lower-sqrt.f64N/A

                                    \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \cdot d \]
                                  4. lower-/.f64N/A

                                    \[\leadsto \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \cdot d \]
                                  5. *-commutativeN/A

                                    \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                                  6. lower-*.f6458.3

                                    \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                                5. Applied rewrites58.3%

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

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

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

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

                                  Alternative 15: 50.2% accurate, 7.5× speedup?

                                  \[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{\frac{-d}{\sqrt{-\ell}}}{\sqrt{-h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
                                  D_m = (fabs.f64 D)
                                  NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
                                  (FPCore (d h l M D_m)
                                   :precision binary64
                                   (if (<= l -5e-310)
                                     (/ (/ (- d) (sqrt (- l))) (sqrt (- h)))
                                     (/ d (* (sqrt l) (sqrt h)))))
                                  D_m = fabs(D);
                                  assert(d < h && h < l && l < M && M < D_m);
                                  double code(double d, double h, double l, double M, double D_m) {
                                  	double tmp;
                                  	if (l <= -5e-310) {
                                  		tmp = (-d / sqrt(-l)) / sqrt(-h);
                                  	} else {
                                  		tmp = d / (sqrt(l) * sqrt(h));
                                  	}
                                  	return tmp;
                                  }
                                  
                                  D_m = abs(d)
                                  NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
                                  real(8) function code(d, h, l, m, d_m)
                                      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_m
                                      real(8) :: tmp
                                      if (l <= (-5d-310)) then
                                          tmp = (-d / sqrt(-l)) / sqrt(-h)
                                      else
                                          tmp = d / (sqrt(l) * sqrt(h))
                                      end if
                                      code = tmp
                                  end function
                                  
                                  D_m = Math.abs(D);
                                  assert d < h && h < l && l < M && M < D_m;
                                  public static double code(double d, double h, double l, double M, double D_m) {
                                  	double tmp;
                                  	if (l <= -5e-310) {
                                  		tmp = (-d / Math.sqrt(-l)) / Math.sqrt(-h);
                                  	} else {
                                  		tmp = d / (Math.sqrt(l) * Math.sqrt(h));
                                  	}
                                  	return tmp;
                                  }
                                  
                                  D_m = math.fabs(D)
                                  [d, h, l, M, D_m] = sort([d, h, l, M, D_m])
                                  def code(d, h, l, M, D_m):
                                  	tmp = 0
                                  	if l <= -5e-310:
                                  		tmp = (-d / math.sqrt(-l)) / math.sqrt(-h)
                                  	else:
                                  		tmp = d / (math.sqrt(l) * math.sqrt(h))
                                  	return tmp
                                  
                                  D_m = abs(D)
                                  d, h, l, M, D_m = sort([d, h, l, M, D_m])
                                  function code(d, h, l, M, D_m)
                                  	tmp = 0.0
                                  	if (l <= -5e-310)
                                  		tmp = Float64(Float64(Float64(-d) / sqrt(Float64(-l))) / sqrt(Float64(-h)));
                                  	else
                                  		tmp = Float64(d / Float64(sqrt(l) * sqrt(h)));
                                  	end
                                  	return tmp
                                  end
                                  
                                  D_m = abs(D);
                                  d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
                                  function tmp_2 = code(d, h, l, M, D_m)
                                  	tmp = 0.0;
                                  	if (l <= -5e-310)
                                  		tmp = (-d / sqrt(-l)) / sqrt(-h);
                                  	else
                                  		tmp = d / (sqrt(l) * sqrt(h));
                                  	end
                                  	tmp_2 = tmp;
                                  end
                                  
                                  D_m = N[Abs[D], $MachinePrecision]
                                  NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
                                  code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[l, -5e-310], N[(N[((-d) / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                  
                                  \begin{array}{l}
                                  D_m = \left|D\right|
                                  \\
                                  [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
                                  \\
                                  \begin{array}{l}
                                  \mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
                                  \;\;\;\;\frac{\frac{-d}{\sqrt{-\ell}}}{\sqrt{-h}}\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
                                  
                                  
                                  \end{array}
                                  \end{array}
                                  
                                  Derivation
                                  1. Split input into 2 regimes
                                  2. if l < -4.999999999999985e-310

                                    1. Initial program 65.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. Add Preprocessing
                                    3. Taylor expanded in d around inf

                                      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
                                    4. Step-by-step derivation
                                      1. *-commutativeN/A

                                        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                                      2. lower-*.f64N/A

                                        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                                      3. lower-sqrt.f64N/A

                                        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \cdot d \]
                                      4. lower-/.f64N/A

                                        \[\leadsto \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \cdot d \]
                                      5. *-commutativeN/A

                                        \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                                      6. lower-*.f649.8

                                        \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                                    5. Applied rewrites9.8%

                                      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
                                    6. Step-by-step derivation
                                      1. Applied rewrites33.1%

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

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

                                        if -4.999999999999985e-310 < l

                                        1. Initial program 67.1%

                                          \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
                                        2. Add Preprocessing
                                        3. Taylor expanded in d around inf

                                          \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
                                        4. Step-by-step derivation
                                          1. *-commutativeN/A

                                            \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                                          2. lower-*.f64N/A

                                            \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                                          3. lower-sqrt.f64N/A

                                            \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \cdot d \]
                                          4. lower-/.f64N/A

                                            \[\leadsto \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \cdot d \]
                                          5. *-commutativeN/A

                                            \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                                          6. lower-*.f6451.9

                                            \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                                        5. Applied rewrites51.9%

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

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

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

                                            \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{\frac{-d}{\sqrt{-\ell}}}{\sqrt{-h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
                                          5. Add Preprocessing

                                          Alternative 16: 46.8% accurate, 9.6× speedup?

                                          \[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 7.8 \cdot 10^{-259}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
                                          D_m = (fabs.f64 D)
                                          NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
                                          (FPCore (d h l M D_m)
                                           :precision binary64
                                           (if (<= l 7.8e-259) (/ (- d) (sqrt (* l h))) (/ d (* (sqrt l) (sqrt h)))))
                                          D_m = fabs(D);
                                          assert(d < h && h < l && l < M && M < D_m);
                                          double code(double d, double h, double l, double M, double D_m) {
                                          	double tmp;
                                          	if (l <= 7.8e-259) {
                                          		tmp = -d / sqrt((l * h));
                                          	} else {
                                          		tmp = d / (sqrt(l) * sqrt(h));
                                          	}
                                          	return tmp;
                                          }
                                          
                                          D_m = abs(d)
                                          NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
                                          real(8) function code(d, h, l, m, d_m)
                                              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_m
                                              real(8) :: tmp
                                              if (l <= 7.8d-259) then
                                                  tmp = -d / sqrt((l * h))
                                              else
                                                  tmp = d / (sqrt(l) * sqrt(h))
                                              end if
                                              code = tmp
                                          end function
                                          
                                          D_m = Math.abs(D);
                                          assert d < h && h < l && l < M && M < D_m;
                                          public static double code(double d, double h, double l, double M, double D_m) {
                                          	double tmp;
                                          	if (l <= 7.8e-259) {
                                          		tmp = -d / Math.sqrt((l * h));
                                          	} else {
                                          		tmp = d / (Math.sqrt(l) * Math.sqrt(h));
                                          	}
                                          	return tmp;
                                          }
                                          
                                          D_m = math.fabs(D)
                                          [d, h, l, M, D_m] = sort([d, h, l, M, D_m])
                                          def code(d, h, l, M, D_m):
                                          	tmp = 0
                                          	if l <= 7.8e-259:
                                          		tmp = -d / math.sqrt((l * h))
                                          	else:
                                          		tmp = d / (math.sqrt(l) * math.sqrt(h))
                                          	return tmp
                                          
                                          D_m = abs(D)
                                          d, h, l, M, D_m = sort([d, h, l, M, D_m])
                                          function code(d, h, l, M, D_m)
                                          	tmp = 0.0
                                          	if (l <= 7.8e-259)
                                          		tmp = Float64(Float64(-d) / sqrt(Float64(l * h)));
                                          	else
                                          		tmp = Float64(d / Float64(sqrt(l) * sqrt(h)));
                                          	end
                                          	return tmp
                                          end
                                          
                                          D_m = abs(D);
                                          d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
                                          function tmp_2 = code(d, h, l, M, D_m)
                                          	tmp = 0.0;
                                          	if (l <= 7.8e-259)
                                          		tmp = -d / sqrt((l * h));
                                          	else
                                          		tmp = d / (sqrt(l) * sqrt(h));
                                          	end
                                          	tmp_2 = tmp;
                                          end
                                          
                                          D_m = N[Abs[D], $MachinePrecision]
                                          NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
                                          code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[l, 7.8e-259], 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}
                                          D_m = \left|D\right|
                                          \\
                                          [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
                                          \\
                                          \begin{array}{l}
                                          \mathbf{if}\;\ell \leq 7.8 \cdot 10^{-259}:\\
                                          \;\;\;\;\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 l < 7.80000000000000031e-259

                                            1. Initial program 66.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. Add Preprocessing
                                            3. Taylor expanded in d around inf

                                              \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
                                            4. Step-by-step derivation
                                              1. *-commutativeN/A

                                                \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                                              2. lower-*.f64N/A

                                                \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                                              3. lower-sqrt.f64N/A

                                                \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \cdot d \]
                                              4. lower-/.f64N/A

                                                \[\leadsto \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \cdot d \]
                                              5. *-commutativeN/A

                                                \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                                              6. lower-*.f6411.3

                                                \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                                            5. Applied rewrites11.3%

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

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

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

                                                if 7.80000000000000031e-259 < l

                                                1. Initial program 66.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. Add Preprocessing
                                                3. Taylor expanded in d around inf

                                                  \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
                                                4. Step-by-step derivation
                                                  1. *-commutativeN/A

                                                    \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                                                  2. lower-*.f64N/A

                                                    \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                                                  3. lower-sqrt.f64N/A

                                                    \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \cdot d \]
                                                  4. lower-/.f64N/A

                                                    \[\leadsto \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \cdot d \]
                                                  5. *-commutativeN/A

                                                    \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                                                  6. lower-*.f6453.7

                                                    \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                                                5. Applied rewrites53.7%

                                                  \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
                                                6. Step-by-step derivation
                                                  1. Applied rewrites53.7%

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

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

                                                    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 7.8 \cdot 10^{-259}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
                                                  5. Add Preprocessing

                                                  Alternative 17: 42.6% accurate, 11.8× speedup?

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

                                                    1. Initial program 73.3%

                                                      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
                                                    2. Add Preprocessing
                                                    3. Taylor expanded in d around inf

                                                      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
                                                    4. Step-by-step derivation
                                                      1. *-commutativeN/A

                                                        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                                                      2. lower-*.f64N/A

                                                        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                                                      3. lower-sqrt.f64N/A

                                                        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \cdot d \]
                                                      4. lower-/.f64N/A

                                                        \[\leadsto \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \cdot d \]
                                                      5. *-commutativeN/A

                                                        \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                                                      6. lower-*.f647.4

                                                        \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                                                    5. Applied rewrites7.4%

                                                      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
                                                    6. Step-by-step derivation
                                                      1. Applied rewrites7.4%

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

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

                                                        if -3.39999999999999985e-171 < d

                                                        1. Initial program 61.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. Add Preprocessing
                                                        3. Taylor expanded in d around inf

                                                          \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
                                                        4. Step-by-step derivation
                                                          1. *-commutativeN/A

                                                            \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                                                          2. lower-*.f64N/A

                                                            \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                                                          3. lower-sqrt.f64N/A

                                                            \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \cdot d \]
                                                          4. lower-/.f64N/A

                                                            \[\leadsto \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \cdot d \]
                                                          5. *-commutativeN/A

                                                            \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                                                          6. lower-*.f6446.1

                                                            \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                                                        5. Applied rewrites46.1%

                                                          \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
                                                        6. Step-by-step derivation
                                                          1. Applied rewrites46.1%

                                                            \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell \cdot h}}} \]
                                                        7. Recombined 2 regimes into one program.
                                                        8. Final simplification46.4%

                                                          \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.4 \cdot 10^{-171}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\ \end{array} \]
                                                        9. Add Preprocessing

                                                        Alternative 18: 26.9% accurate, 15.3× speedup?

                                                        \[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \frac{d}{\sqrt{\ell \cdot h}} \end{array} \]
                                                        D_m = (fabs.f64 D)
                                                        NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
                                                        (FPCore (d h l M D_m) :precision binary64 (/ d (sqrt (* l h))))
                                                        D_m = fabs(D);
                                                        assert(d < h && h < l && l < M && M < D_m);
                                                        double code(double d, double h, double l, double M, double D_m) {
                                                        	return d / sqrt((l * h));
                                                        }
                                                        
                                                        D_m = abs(d)
                                                        NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
                                                        real(8) function code(d, h, l, m, d_m)
                                                            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_m
                                                            code = d / sqrt((l * h))
                                                        end function
                                                        
                                                        D_m = Math.abs(D);
                                                        assert d < h && h < l && l < M && M < D_m;
                                                        public static double code(double d, double h, double l, double M, double D_m) {
                                                        	return d / Math.sqrt((l * h));
                                                        }
                                                        
                                                        D_m = math.fabs(D)
                                                        [d, h, l, M, D_m] = sort([d, h, l, M, D_m])
                                                        def code(d, h, l, M, D_m):
                                                        	return d / math.sqrt((l * h))
                                                        
                                                        D_m = abs(D)
                                                        d, h, l, M, D_m = sort([d, h, l, M, D_m])
                                                        function code(d, h, l, M, D_m)
                                                        	return Float64(d / sqrt(Float64(l * h)))
                                                        end
                                                        
                                                        D_m = abs(D);
                                                        d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
                                                        function tmp = code(d, h, l, M, D_m)
                                                        	tmp = d / sqrt((l * h));
                                                        end
                                                        
                                                        D_m = N[Abs[D], $MachinePrecision]
                                                        NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
                                                        code[d_, h_, l_, M_, D$95$m_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
                                                        
                                                        \begin{array}{l}
                                                        D_m = \left|D\right|
                                                        \\
                                                        [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
                                                        \\
                                                        \frac{d}{\sqrt{\ell \cdot h}}
                                                        \end{array}
                                                        
                                                        Derivation
                                                        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. Add Preprocessing
                                                        3. Taylor expanded in d around inf

                                                          \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
                                                        4. Step-by-step derivation
                                                          1. *-commutativeN/A

                                                            \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                                                          2. lower-*.f64N/A

                                                            \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
                                                          3. lower-sqrt.f64N/A

                                                            \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \cdot d \]
                                                          4. lower-/.f64N/A

                                                            \[\leadsto \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \cdot d \]
                                                          5. *-commutativeN/A

                                                            \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                                                          6. lower-*.f6430.8

                                                            \[\leadsto \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \cdot d \]
                                                        5. Applied rewrites30.8%

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

                                                            \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell \cdot h}}} \]
                                                          2. Add Preprocessing

                                                          Reproduce

                                                          ?
                                                          herbie shell --seed 2024298 
                                                          (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)))))