Henrywood and Agarwal, Equation (12)

Percentage Accurate: 65.5% → 83.0%
Time: 23.5s
Alternatives: 21
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 21 alternatives:

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

Initial Program: 65.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: 83.0% accurate, 0.6× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

    if -7.5999999999999995e-70 < l < -4.999999999999985e-310

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 80.7% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -2.00000000000000017e218

    1. Initial program 42.7%

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

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

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

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

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

    if -2.00000000000000017e218 < l < -4.999999999999985e-310

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 80.5% accurate, 0.8× speedup?

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

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


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

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 77.0% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 77.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.70000000000000013e-108 < d < -9.999999999999969e-311

    1. Initial program 49.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. Simplified46.8%

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

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

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

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

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

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

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

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

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

    if -9.999999999999969e-311 < d

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 76.7% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 77.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.6000000000000001e-108 < d < -9.999999999999969e-311

    1. Initial program 49.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. Simplified46.8%

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

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

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

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

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

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

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

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

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

    if -9.999999999999969e-311 < d

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 76.4% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 77.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.5000000000000005e-108 < d < -9.999999999999969e-311

    1. Initial program 49.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. Simplified46.8%

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

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

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

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

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

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

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

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

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

    if -9.999999999999969e-311 < d

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 75.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 77.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.00000000000000032e-108 < d < -9.999999999999969e-311

    1. Initial program 49.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. Simplified46.8%

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

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

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

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

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

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

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

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

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

    if -9.999999999999969e-311 < d

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

Alternative 8: 72.6% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 68.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.7e-274 < l < 3.3e134

    1. Initial program 71.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.3e134 < l

    1. Initial program 57.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 67.1% accurate, 1.4× speedup?

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

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

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

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


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

    1. Initial program 51.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. Simplified49.1%

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

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

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

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

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

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

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

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

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

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

    if -4.24999999999999998e40 < l < -4.999999999999985e-310

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l < 7.49999999999999992e133

    1. Initial program 72.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. Simplified71.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.49999999999999992e133 < l

    1. Initial program 57.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 62.4% accurate, 1.4× speedup?

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

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

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

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


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

    1. Initial program 63.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. Simplified62.6%

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

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

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

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

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

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

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

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

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

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

    if -1.05e-177 < l < -4.999999999999985e-310

    1. Initial program 85.7%

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      6. sqrt-div15.0%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}} \]
      7. sqrt-pow135.2%

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

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{h \cdot \ell}} \]
      9. pow135.2%

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

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

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

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

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.5\right)}} \]
      4. *-commutative35.2%

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

        \[\leadsto d \cdot {\left(\ell \cdot h\right)}^{\color{blue}{-0.5}} \]
    8. Applied egg-rr35.2%

      \[\leadsto \color{blue}{d \cdot {\left(\ell \cdot h\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. expm1-log1p-u35.2%

        \[\leadsto d \cdot {\color{blue}{\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\ell \cdot h\right)\right)\right)}}^{-0.5} \]
      2. expm1-undefine62.7%

        \[\leadsto d \cdot {\color{blue}{\left(e^{\mathsf{log1p}\left(\ell \cdot h\right)} - 1\right)}}^{-0.5} \]
    10. Applied egg-rr62.7%

      \[\leadsto d \cdot {\color{blue}{\left(e^{\mathsf{log1p}\left(\ell \cdot h\right)} - 1\right)}}^{-0.5} \]
    11. Step-by-step derivation
      1. sub-neg62.7%

        \[\leadsto d \cdot {\color{blue}{\left(e^{\mathsf{log1p}\left(\ell \cdot h\right)} + \left(-1\right)\right)}}^{-0.5} \]
      2. metadata-eval62.7%

        \[\leadsto d \cdot {\left(e^{\mathsf{log1p}\left(\ell \cdot h\right)} + \color{blue}{-1}\right)}^{-0.5} \]
      3. +-commutative62.7%

        \[\leadsto d \cdot {\color{blue}{\left(-1 + e^{\mathsf{log1p}\left(\ell \cdot h\right)}\right)}}^{-0.5} \]
      4. log1p-undefine62.7%

        \[\leadsto d \cdot {\left(-1 + e^{\color{blue}{\log \left(1 + \ell \cdot h\right)}}\right)}^{-0.5} \]
      5. rem-exp-log62.7%

        \[\leadsto d \cdot {\left(-1 + \color{blue}{\left(1 + \ell \cdot h\right)}\right)}^{-0.5} \]
      6. +-commutative62.7%

        \[\leadsto d \cdot {\left(-1 + \color{blue}{\left(\ell \cdot h + 1\right)}\right)}^{-0.5} \]
      7. *-commutative62.7%

        \[\leadsto d \cdot {\left(-1 + \left(\color{blue}{h \cdot \ell} + 1\right)\right)}^{-0.5} \]
      8. fma-define62.7%

        \[\leadsto d \cdot {\left(-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}\right)}^{-0.5} \]
    12. Simplified62.7%

      \[\leadsto d \cdot {\color{blue}{\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}}^{-0.5} \]

    if -4.999999999999985e-310 < l < 6.5e134

    1. Initial program 72.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. Simplified71.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.5e134 < l

    1. Initial program 57.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 60.1% accurate, 1.4× speedup?

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

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

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

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


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

    1. Initial program 63.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. Simplified62.6%

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

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

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

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

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

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

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

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

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

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

    if -2.49999999999999988e-178 < l < -4.999999999999985e-310

    1. Initial program 85.7%

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      6. sqrt-div15.0%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}} \]
      7. sqrt-pow135.2%

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

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{h \cdot \ell}} \]
      9. pow135.2%

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

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

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

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

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.5\right)}} \]
      4. *-commutative35.2%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{\left(-0.5\right)} \]
      5. metadata-eval35.2%

        \[\leadsto d \cdot {\left(\ell \cdot h\right)}^{\color{blue}{-0.5}} \]
    8. Applied egg-rr35.2%

      \[\leadsto \color{blue}{d \cdot {\left(\ell \cdot h\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. expm1-log1p-u35.2%

        \[\leadsto d \cdot {\color{blue}{\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\ell \cdot h\right)\right)\right)}}^{-0.5} \]
      2. expm1-undefine62.7%

        \[\leadsto d \cdot {\color{blue}{\left(e^{\mathsf{log1p}\left(\ell \cdot h\right)} - 1\right)}}^{-0.5} \]
    10. Applied egg-rr62.7%

      \[\leadsto d \cdot {\color{blue}{\left(e^{\mathsf{log1p}\left(\ell \cdot h\right)} - 1\right)}}^{-0.5} \]
    11. Step-by-step derivation
      1. sub-neg62.7%

        \[\leadsto d \cdot {\color{blue}{\left(e^{\mathsf{log1p}\left(\ell \cdot h\right)} + \left(-1\right)\right)}}^{-0.5} \]
      2. metadata-eval62.7%

        \[\leadsto d \cdot {\left(e^{\mathsf{log1p}\left(\ell \cdot h\right)} + \color{blue}{-1}\right)}^{-0.5} \]
      3. +-commutative62.7%

        \[\leadsto d \cdot {\color{blue}{\left(-1 + e^{\mathsf{log1p}\left(\ell \cdot h\right)}\right)}}^{-0.5} \]
      4. log1p-undefine62.7%

        \[\leadsto d \cdot {\left(-1 + e^{\color{blue}{\log \left(1 + \ell \cdot h\right)}}\right)}^{-0.5} \]
      5. rem-exp-log62.7%

        \[\leadsto d \cdot {\left(-1 + \color{blue}{\left(1 + \ell \cdot h\right)}\right)}^{-0.5} \]
      6. +-commutative62.7%

        \[\leadsto d \cdot {\left(-1 + \color{blue}{\left(\ell \cdot h + 1\right)}\right)}^{-0.5} \]
      7. *-commutative62.7%

        \[\leadsto d \cdot {\left(-1 + \left(\color{blue}{h \cdot \ell} + 1\right)\right)}^{-0.5} \]
      8. fma-define62.7%

        \[\leadsto d \cdot {\left(-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}\right)}^{-0.5} \]
    12. Simplified62.7%

      \[\leadsto d \cdot {\color{blue}{\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}}^{-0.5} \]

    if -4.999999999999985e-310 < l < 1.09999999999999997e130

    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. Simplified72.2%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow172.2%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\right)}^{1}} \]
      2. associate-*r*72.2%

        \[\leadsto {\color{blue}{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}}^{1} \]
      3. sqrt-div80.6%

        \[\leadsto {\left(\left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      4. sqrt-div84.9%

        \[\leadsto {\left(\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      5. frac-times84.8%

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      6. add-sqr-sqrt85.0%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      7. unpow-prod-down83.9%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{{0.5}^{2} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      8. metadata-eval83.9%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{0.25} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      9. clear-num83.9%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(M \cdot \color{blue}{\frac{1}{\frac{d}{D}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      10. un-div-inv83.9%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\color{blue}{\left(\frac{M}{\frac{d}{D}}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
    5. Applied egg-rr83.9%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow183.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \]
      2. associate-*l/85.1%

        \[\leadsto \color{blue}{\frac{d \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. associate-/l*83.9%

        \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      4. fma-define83.9%

        \[\leadsto d \cdot \frac{\color{blue}{\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot \left(-0.5 \cdot \frac{h}{\ell}\right) + 1}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. associate-*r*83.9%

        \[\leadsto d \cdot \frac{\color{blue}{\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5\right) \cdot \frac{h}{\ell}} + 1}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. fma-define83.9%

        \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5, \frac{h}{\ell}, 1\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      7. *-commutative83.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot 0.25\right)} \cdot -0.5, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      8. associate-*l*83.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{{\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \left(0.25 \cdot -0.5\right)}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      9. metadata-eval83.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \color{blue}{-0.125}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      10. *-commutative83.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{-0.125 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      11. associate-/r/83.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M}{d} \cdot D\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      12. associate-*l/83.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      13. associate-/l*83.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(M \cdot \frac{D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. Simplified83.9%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Step-by-step derivation
      1. associate-*r/85.1%

        \[\leadsto \color{blue}{\frac{d \cdot \mathsf{fma}\left(-0.125 \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      2. associate-*r/86.1%

        \[\leadsto \frac{d \cdot \mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      3. sqrt-unprod83.9%

        \[\leadsto \frac{d \cdot \mathsf{fma}\left(-0.125 \cdot {\left(\frac{M \cdot D}{d}\right)}^{2}, \frac{h}{\ell}, 1\right)}{\color{blue}{\sqrt{h \cdot \ell}}} \]
    9. Applied egg-rr83.9%

      \[\leadsto \color{blue}{\frac{d \cdot \mathsf{fma}\left(-0.125 \cdot {\left(\frac{M \cdot D}{d}\right)}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h \cdot \ell}}} \]
    10. Step-by-step derivation
      1. fma-undefine83.9%

        \[\leadsto \frac{d \cdot \color{blue}{\left(\left(-0.125 \cdot {\left(\frac{M \cdot D}{d}\right)}^{2}\right) \cdot \frac{h}{\ell} + 1\right)}}{\sqrt{h \cdot \ell}} \]
      2. associate-/l*82.8%

        \[\leadsto \frac{d \cdot \left(\left(-0.125 \cdot {\color{blue}{\left(M \cdot \frac{D}{d}\right)}}^{2}\right) \cdot \frac{h}{\ell} + 1\right)}{\sqrt{h \cdot \ell}} \]
    11. Applied egg-rr82.8%

      \[\leadsto \frac{d \cdot \color{blue}{\left(\left(-0.125 \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right) \cdot \frac{h}{\ell} + 1\right)}}{\sqrt{h \cdot \ell}} \]

    if 1.09999999999999997e130 < l

    1. Initial program 56.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. Simplified58.1%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow158.1%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\right)}^{1}} \]
      2. associate-*r*58.1%

        \[\leadsto {\color{blue}{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}}^{1} \]
      3. sqrt-div62.3%

        \[\leadsto {\left(\left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      4. sqrt-div71.8%

        \[\leadsto {\left(\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      5. frac-times71.8%

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      6. add-sqr-sqrt72.0%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      7. unpow-prod-down72.0%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{{0.5}^{2} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      8. metadata-eval72.0%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{0.25} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      9. clear-num72.0%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(M \cdot \color{blue}{\frac{1}{\frac{d}{D}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      10. un-div-inv72.0%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\color{blue}{\left(\frac{M}{\frac{d}{D}}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
    5. Applied egg-rr72.0%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow172.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \]
      2. associate-*l/75.5%

        \[\leadsto \color{blue}{\frac{d \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. associate-/l*77.6%

        \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      4. fma-define77.6%

        \[\leadsto d \cdot \frac{\color{blue}{\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot \left(-0.5 \cdot \frac{h}{\ell}\right) + 1}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. associate-*r*77.6%

        \[\leadsto d \cdot \frac{\color{blue}{\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5\right) \cdot \frac{h}{\ell}} + 1}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. fma-define77.6%

        \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5, \frac{h}{\ell}, 1\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      7. *-commutative77.6%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot 0.25\right)} \cdot -0.5, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      8. associate-*l*77.6%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{{\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \left(0.25 \cdot -0.5\right)}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      9. metadata-eval77.6%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \color{blue}{-0.125}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      10. *-commutative77.6%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{-0.125 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      11. associate-/r/77.5%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M}{d} \cdot D\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      12. associate-*l/73.3%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      13. associate-/l*77.5%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(M \cdot \frac{D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. Simplified77.5%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Taylor expanded in M around 0 67.1%

      \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h} \cdot \sqrt{\ell}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification64.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.5 \cdot 10^{-178}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot {\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}^{-0.5}\\ \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+130}:\\ \;\;\;\;\frac{d \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.125 \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right)\right)}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{1}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 72.7% accurate, 1.4× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(-1 + 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M\_m}{2} \cdot \frac{D\_m}{d}\right)}^{2}\right)\right)\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{+134}:\\ \;\;\;\;\frac{d \cdot \left(1 - h \cdot \left(0.125 \cdot \frac{{\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}}{\ell}\right)\right)}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{1}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l -5e-310)
   (*
    (* d (sqrt (/ 1.0 (* l h))))
    (+ -1.0 (* 0.5 (* (/ h l) (pow (* (/ M_m 2.0) (/ D_m d)) 2.0)))))
   (if (<= l 6e+134)
     (/
      (* d (- 1.0 (* h (* 0.125 (/ (pow (* D_m (/ M_m d)) 2.0) l)))))
      (sqrt (* l h)))
     (* d (/ 1.0 (* (sqrt h) (sqrt l)))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -5e-310) {
		tmp = (d * sqrt((1.0 / (l * h)))) * (-1.0 + (0.5 * ((h / l) * pow(((M_m / 2.0) * (D_m / d)), 2.0))));
	} else if (l <= 6e+134) {
		tmp = (d * (1.0 - (h * (0.125 * (pow((D_m * (M_m / d)), 2.0) / l))))) / sqrt((l * h));
	} else {
		tmp = d * (1.0 / (sqrt(h) * sqrt(l)));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= (-5d-310)) then
        tmp = (d * sqrt((1.0d0 / (l * h)))) * ((-1.0d0) + (0.5d0 * ((h / l) * (((m_m / 2.0d0) * (d_m / d)) ** 2.0d0))))
    else if (l <= 6d+134) then
        tmp = (d * (1.0d0 - (h * (0.125d0 * (((d_m * (m_m / d)) ** 2.0d0) / l))))) / sqrt((l * h))
    else
        tmp = d * (1.0d0 / (sqrt(h) * sqrt(l)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -5e-310) {
		tmp = (d * Math.sqrt((1.0 / (l * h)))) * (-1.0 + (0.5 * ((h / l) * Math.pow(((M_m / 2.0) * (D_m / d)), 2.0))));
	} else if (l <= 6e+134) {
		tmp = (d * (1.0 - (h * (0.125 * (Math.pow((D_m * (M_m / d)), 2.0) / l))))) / Math.sqrt((l * h));
	} else {
		tmp = d * (1.0 / (Math.sqrt(h) * Math.sqrt(l)));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= -5e-310:
		tmp = (d * math.sqrt((1.0 / (l * h)))) * (-1.0 + (0.5 * ((h / l) * math.pow(((M_m / 2.0) * (D_m / d)), 2.0))))
	elif l <= 6e+134:
		tmp = (d * (1.0 - (h * (0.125 * (math.pow((D_m * (M_m / d)), 2.0) / l))))) / math.sqrt((l * h))
	else:
		tmp = d * (1.0 / (math.sqrt(h) * math.sqrt(l)))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -5e-310)
		tmp = Float64(Float64(d * sqrt(Float64(1.0 / Float64(l * h)))) * Float64(-1.0 + Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(M_m / 2.0) * Float64(D_m / d)) ^ 2.0)))));
	elseif (l <= 6e+134)
		tmp = Float64(Float64(d * Float64(1.0 - Float64(h * Float64(0.125 * Float64((Float64(D_m * Float64(M_m / d)) ^ 2.0) / l))))) / sqrt(Float64(l * h)));
	else
		tmp = Float64(d * Float64(1.0 / Float64(sqrt(h) * sqrt(l))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= -5e-310)
		tmp = (d * sqrt((1.0 / (l * h)))) * (-1.0 + (0.5 * ((h / l) * (((M_m / 2.0) * (D_m / d)) ^ 2.0))));
	elseif (l <= 6e+134)
		tmp = (d * (1.0 - (h * (0.125 * (((D_m * (M_m / d)) ^ 2.0) / l))))) / sqrt((l * h));
	else
		tmp = d * (1.0 / (sqrt(h) * sqrt(l)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -5e-310], N[(N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-1.0 + N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6e+134], N[(N[(d * N[(1.0 - N[(h * N[(0.125 * N[(N[Power[N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(1.0 / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(-1 + 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M\_m}{2} \cdot \frac{D\_m}{d}\right)}^{2}\right)\right)\\

\mathbf{elif}\;\ell \leq 6 \cdot 10^{+134}:\\
\;\;\;\;\frac{d \cdot \left(1 - h \cdot \left(0.125 \cdot \frac{{\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}}{\ell}\right)\right)}{\sqrt{\ell \cdot h}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{1}{\sqrt{h} \cdot \sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -4.999999999999985e-310

    1. Initial program 67.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified66.5%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. sqrt-unprod54.2%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. pow1/254.2%

        \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      3. frac-times36.5%

        \[\leadsto {\color{blue}{\left(\frac{d \cdot d}{h \cdot \ell}\right)}}^{0.5} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. pow236.5%

        \[\leadsto {\left(\frac{\color{blue}{{d}^{2}}}{h \cdot \ell}\right)}^{0.5} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr36.5%

      \[\leadsto \color{blue}{{\left(\frac{{d}^{2}}{h \cdot \ell}\right)}^{0.5}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. unpow1/236.5%

        \[\leadsto \color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. Simplified36.5%

      \[\leadsto \color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}}} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    8. Taylor expanded in d around -inf 68.3%

      \[\leadsto \color{blue}{\left(-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]

    if -4.999999999999985e-310 < l < 5.99999999999999993e134

    1. Initial program 72.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. Simplified71.4%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow171.4%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\right)}^{1}} \]
      2. associate-*r*71.4%

        \[\leadsto {\color{blue}{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}}^{1} \]
      3. sqrt-div79.7%

        \[\leadsto {\left(\left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      4. sqrt-div83.9%

        \[\leadsto {\left(\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      5. frac-times83.9%

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      6. add-sqr-sqrt84.0%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      7. unpow-prod-down82.9%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{{0.5}^{2} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      8. metadata-eval82.9%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{0.25} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      9. clear-num82.9%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(M \cdot \color{blue}{\frac{1}{\frac{d}{D}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      10. un-div-inv82.9%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\color{blue}{\left(\frac{M}{\frac{d}{D}}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
    5. Applied egg-rr82.9%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow182.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \]
      2. associate-*l/84.1%

        \[\leadsto \color{blue}{\frac{d \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. associate-/l*82.9%

        \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      4. fma-define82.9%

        \[\leadsto d \cdot \frac{\color{blue}{\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot \left(-0.5 \cdot \frac{h}{\ell}\right) + 1}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. associate-*r*82.9%

        \[\leadsto d \cdot \frac{\color{blue}{\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5\right) \cdot \frac{h}{\ell}} + 1}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. fma-define82.9%

        \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5, \frac{h}{\ell}, 1\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      7. *-commutative82.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot 0.25\right)} \cdot -0.5, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      8. associate-*l*82.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{{\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \left(0.25 \cdot -0.5\right)}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      9. metadata-eval82.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \color{blue}{-0.125}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      10. *-commutative82.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{-0.125 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      11. associate-/r/83.0%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M}{d} \cdot D\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      12. associate-*l/82.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      13. associate-/l*82.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(M \cdot \frac{D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. Simplified82.9%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Step-by-step derivation
      1. associate-*r/84.1%

        \[\leadsto \color{blue}{\frac{d \cdot \mathsf{fma}\left(-0.125 \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      2. associate-*r/85.1%

        \[\leadsto \frac{d \cdot \mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      3. sqrt-unprod82.9%

        \[\leadsto \frac{d \cdot \mathsf{fma}\left(-0.125 \cdot {\left(\frac{M \cdot D}{d}\right)}^{2}, \frac{h}{\ell}, 1\right)}{\color{blue}{\sqrt{h \cdot \ell}}} \]
    9. Applied egg-rr82.9%

      \[\leadsto \color{blue}{\frac{d \cdot \mathsf{fma}\left(-0.125 \cdot {\left(\frac{M \cdot D}{d}\right)}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h \cdot \ell}}} \]
    10. Taylor expanded in h around -inf 59.4%

      \[\leadsto \frac{d \cdot \color{blue}{\left(-1 \cdot \left(h \cdot \left(0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} - \frac{1}{h}\right)\right)\right)}}{\sqrt{h \cdot \ell}} \]
    11. Step-by-step derivation
      1. associate-*r*59.4%

        \[\leadsto \frac{d \cdot \color{blue}{\left(\left(-1 \cdot h\right) \cdot \left(0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} - \frac{1}{h}\right)\right)}}{\sqrt{h \cdot \ell}} \]
      2. neg-mul-159.4%

        \[\leadsto \frac{d \cdot \left(\color{blue}{\left(-h\right)} \cdot \left(0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} - \frac{1}{h}\right)\right)}{\sqrt{h \cdot \ell}} \]
      3. sub-neg59.4%

        \[\leadsto \frac{d \cdot \left(\left(-h\right) \cdot \color{blue}{\left(0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} + \left(-\frac{1}{h}\right)\right)}\right)}{\sqrt{h \cdot \ell}} \]
      4. distribute-lft-in59.4%

        \[\leadsto \frac{d \cdot \color{blue}{\left(\left(-h\right) \cdot \left(0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) + \left(-h\right) \cdot \left(-\frac{1}{h}\right)\right)}}{\sqrt{h \cdot \ell}} \]
    12. Simplified86.5%

      \[\leadsto \frac{d \cdot \color{blue}{\left(\left(-h\right) \cdot \left(0.125 \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}\right) + 1\right)}}{\sqrt{h \cdot \ell}} \]

    if 5.99999999999999993e134 < l

    1. Initial program 57.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified59.4%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow159.4%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\right)}^{1}} \]
      2. associate-*r*59.4%

        \[\leadsto {\color{blue}{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}}^{1} \]
      3. sqrt-div63.7%

        \[\leadsto {\left(\left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      4. sqrt-div73.4%

        \[\leadsto {\left(\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      5. frac-times73.4%

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      6. add-sqr-sqrt73.6%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      7. unpow-prod-down73.6%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{{0.5}^{2} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      8. metadata-eval73.6%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{0.25} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      9. clear-num73.6%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(M \cdot \color{blue}{\frac{1}{\frac{d}{D}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      10. un-div-inv73.7%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\color{blue}{\left(\frac{M}{\frac{d}{D}}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
    5. Applied egg-rr73.7%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow173.7%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \]
      2. associate-*l/77.2%

        \[\leadsto \color{blue}{\frac{d \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. associate-/l*79.3%

        \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      4. fma-define79.3%

        \[\leadsto d \cdot \frac{\color{blue}{\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot \left(-0.5 \cdot \frac{h}{\ell}\right) + 1}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. associate-*r*79.3%

        \[\leadsto d \cdot \frac{\color{blue}{\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5\right) \cdot \frac{h}{\ell}} + 1}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. fma-define79.3%

        \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5, \frac{h}{\ell}, 1\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      7. *-commutative79.3%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot 0.25\right)} \cdot -0.5, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      8. associate-*l*79.3%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{{\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \left(0.25 \cdot -0.5\right)}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      9. metadata-eval79.3%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \color{blue}{-0.125}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      10. *-commutative79.3%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{-0.125 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      11. associate-/r/79.3%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M}{d} \cdot D\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      12. associate-*l/74.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      13. associate-/l*79.3%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(M \cdot \frac{D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. Simplified79.3%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Taylor expanded in M around 0 68.6%

      \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h} \cdot \sqrt{\ell}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification74.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(-1 + 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right)\right)\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{+134}:\\ \;\;\;\;\frac{d \cdot \left(1 - h \cdot \left(0.125 \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}\right)\right)}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{1}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 48.7% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -9 \cdot 10^{-178}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot {\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l -9e-178)
   (* d (- (sqrt (/ (/ 1.0 l) h))))
   (if (<= l -5e-310)
     (* d (pow (+ -1.0 (fma h l 1.0)) -0.5))
     (/ d (* (sqrt h) (sqrt l))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -9e-178) {
		tmp = d * -sqrt(((1.0 / l) / h));
	} else if (l <= -5e-310) {
		tmp = d * pow((-1.0 + fma(h, l, 1.0)), -0.5);
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -9e-178)
		tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / l) / h))));
	elseif (l <= -5e-310)
		tmp = Float64(d * (Float64(-1.0 + fma(h, l, 1.0)) ^ -0.5));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -9e-178], N[(d * (-N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[l, -5e-310], N[(d * N[Power[N[(-1.0 + N[(h * l + 1.0), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -9 \cdot 10^{-178}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot {\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}^{-0.5}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -8.99999999999999957e-178

    1. Initial program 63.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. Simplified62.6%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 6.7%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    6. Step-by-step derivation
      1. associate-*l*0.0%

        \[\leadsto \color{blue}{d \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt46.5%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. mul-1-neg46.5%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. *-commutative46.5%

        \[\leadsto d \cdot \left(-\sqrt{\frac{1}{\color{blue}{\ell \cdot h}}}\right) \]
      6. associate-/r*47.8%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}}\right) \]
    7. Simplified47.8%

      \[\leadsto \color{blue}{d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)} \]

    if -8.99999999999999957e-178 < l < -4.999999999999985e-310

    1. Initial program 85.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified85.7%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 39.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. pow139.9%

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. metadata-eval39.9%

        \[\leadsto {d}^{\color{blue}{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. sqrt-pow114.9%

        \[\leadsto \color{blue}{\sqrt{{d}^{2}}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. sqrt-prod14.9%

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{h \cdot \ell}}} \]
      5. div-inv14.9%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      6. sqrt-div15.0%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}} \]
      7. sqrt-pow135.2%

        \[\leadsto \frac{\color{blue}{{d}^{\left(\frac{2}{2}\right)}}}{\sqrt{h \cdot \ell}} \]
      8. metadata-eval35.2%

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{h \cdot \ell}} \]
      9. pow135.2%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    6. Applied egg-rr35.2%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. div-inv35.2%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. pow1/235.2%

        \[\leadsto d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      3. pow-flip35.2%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.5\right)}} \]
      4. *-commutative35.2%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{\left(-0.5\right)} \]
      5. metadata-eval35.2%

        \[\leadsto d \cdot {\left(\ell \cdot h\right)}^{\color{blue}{-0.5}} \]
    8. Applied egg-rr35.2%

      \[\leadsto \color{blue}{d \cdot {\left(\ell \cdot h\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. expm1-log1p-u35.2%

        \[\leadsto d \cdot {\color{blue}{\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\ell \cdot h\right)\right)\right)}}^{-0.5} \]
      2. expm1-undefine62.7%

        \[\leadsto d \cdot {\color{blue}{\left(e^{\mathsf{log1p}\left(\ell \cdot h\right)} - 1\right)}}^{-0.5} \]
    10. Applied egg-rr62.7%

      \[\leadsto d \cdot {\color{blue}{\left(e^{\mathsf{log1p}\left(\ell \cdot h\right)} - 1\right)}}^{-0.5} \]
    11. Step-by-step derivation
      1. sub-neg62.7%

        \[\leadsto d \cdot {\color{blue}{\left(e^{\mathsf{log1p}\left(\ell \cdot h\right)} + \left(-1\right)\right)}}^{-0.5} \]
      2. metadata-eval62.7%

        \[\leadsto d \cdot {\left(e^{\mathsf{log1p}\left(\ell \cdot h\right)} + \color{blue}{-1}\right)}^{-0.5} \]
      3. +-commutative62.7%

        \[\leadsto d \cdot {\color{blue}{\left(-1 + e^{\mathsf{log1p}\left(\ell \cdot h\right)}\right)}}^{-0.5} \]
      4. log1p-undefine62.7%

        \[\leadsto d \cdot {\left(-1 + e^{\color{blue}{\log \left(1 + \ell \cdot h\right)}}\right)}^{-0.5} \]
      5. rem-exp-log62.7%

        \[\leadsto d \cdot {\left(-1 + \color{blue}{\left(1 + \ell \cdot h\right)}\right)}^{-0.5} \]
      6. +-commutative62.7%

        \[\leadsto d \cdot {\left(-1 + \color{blue}{\left(\ell \cdot h + 1\right)}\right)}^{-0.5} \]
      7. *-commutative62.7%

        \[\leadsto d \cdot {\left(-1 + \left(\color{blue}{h \cdot \ell} + 1\right)\right)}^{-0.5} \]
      8. fma-define62.7%

        \[\leadsto d \cdot {\left(-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}\right)}^{-0.5} \]
    12. Simplified62.7%

      \[\leadsto d \cdot {\color{blue}{\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}}^{-0.5} \]

    if -4.999999999999985e-310 < l

    1. Initial program 67.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified67.4%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 37.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. pow137.9%

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. metadata-eval37.9%

        \[\leadsto {d}^{\color{blue}{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. sqrt-pow128.6%

        \[\leadsto \color{blue}{\sqrt{{d}^{2}}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. sqrt-prod20.8%

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{h \cdot \ell}}} \]
      5. div-inv20.8%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      6. sqrt-div28.5%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}} \]
      7. sqrt-pow137.8%

        \[\leadsto \frac{\color{blue}{{d}^{\left(\frac{2}{2}\right)}}}{\sqrt{h \cdot \ell}} \]
      8. metadata-eval37.8%

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{h \cdot \ell}} \]
      9. pow137.8%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    6. Applied egg-rr37.8%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. sqrt-prod46.2%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Applied egg-rr46.2%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    9. Step-by-step derivation
      1. *-commutative46.2%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    10. Simplified46.2%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification48.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9 \cdot 10^{-178}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot {\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 47.1% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -6 \cdot 10^{-187}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l -6e-187)
   (* d (- (sqrt (/ (/ 1.0 l) h))))
   (if (<= l -5e-310)
     (/ d (cbrt (pow (* l h) 1.5)))
     (/ d (* (sqrt h) (sqrt l))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -6e-187) {
		tmp = d * -sqrt(((1.0 / l) / h));
	} else if (l <= -5e-310) {
		tmp = d / cbrt(pow((l * h), 1.5));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -6e-187) {
		tmp = d * -Math.sqrt(((1.0 / l) / h));
	} else if (l <= -5e-310) {
		tmp = d / Math.cbrt(Math.pow((l * h), 1.5));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -6e-187)
		tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / l) / h))));
	elseif (l <= -5e-310)
		tmp = Float64(d / cbrt((Float64(l * h) ^ 1.5)));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -6e-187], N[(d * (-N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[l, -5e-310], N[(d / N[Power[N[Power[N[(l * h), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6 \cdot 10^{-187}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -6.00000000000000008e-187

    1. Initial program 64.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.7%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 6.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    6. Step-by-step derivation
      1. associate-*l*0.0%

        \[\leadsto \color{blue}{d \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt46.2%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. mul-1-neg46.2%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. *-commutative46.2%

        \[\leadsto d \cdot \left(-\sqrt{\frac{1}{\color{blue}{\ell \cdot h}}}\right) \]
      6. associate-/r*47.5%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}}\right) \]
    7. Simplified47.5%

      \[\leadsto \color{blue}{d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)} \]

    if -6.00000000000000008e-187 < l < -4.999999999999985e-310

    1. Initial program 83.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. Simplified83.3%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 46.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. pow146.2%

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. metadata-eval46.2%

        \[\leadsto {d}^{\color{blue}{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. sqrt-pow111.7%

        \[\leadsto \color{blue}{\sqrt{{d}^{2}}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. sqrt-prod11.7%

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{h \cdot \ell}}} \]
      5. div-inv11.7%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      6. sqrt-div11.8%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}} \]
      7. sqrt-pow140.8%

        \[\leadsto \frac{\color{blue}{{d}^{\left(\frac{2}{2}\right)}}}{\sqrt{h \cdot \ell}} \]
      8. metadata-eval40.8%

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{h \cdot \ell}} \]
      9. pow140.8%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    6. Applied egg-rr40.8%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. add-cbrt-cube51.2%

        \[\leadsto \frac{d}{\color{blue}{\sqrt[3]{\left(\sqrt{h \cdot \ell} \cdot \sqrt{h \cdot \ell}\right) \cdot \sqrt{h \cdot \ell}}}} \]
      2. add-sqr-sqrt51.2%

        \[\leadsto \frac{d}{\sqrt[3]{\color{blue}{\left(h \cdot \ell\right)} \cdot \sqrt{h \cdot \ell}}} \]
      3. pow151.2%

        \[\leadsto \frac{d}{\sqrt[3]{\color{blue}{{\left(h \cdot \ell\right)}^{1}} \cdot \sqrt{h \cdot \ell}}} \]
      4. pow1/251.2%

        \[\leadsto \frac{d}{\sqrt[3]{{\left(h \cdot \ell\right)}^{1} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{0.5}}}} \]
      5. pow-prod-up51.2%

        \[\leadsto \frac{d}{\sqrt[3]{\color{blue}{{\left(h \cdot \ell\right)}^{\left(1 + 0.5\right)}}}} \]
      6. *-commutative51.2%

        \[\leadsto \frac{d}{\sqrt[3]{{\color{blue}{\left(\ell \cdot h\right)}}^{\left(1 + 0.5\right)}}} \]
      7. metadata-eval51.2%

        \[\leadsto \frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{\color{blue}{1.5}}}} \]
    8. Applied egg-rr51.2%

      \[\leadsto \frac{d}{\color{blue}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}} \]

    if -4.999999999999985e-310 < l

    1. Initial program 67.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified67.4%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 37.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. pow137.9%

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. metadata-eval37.9%

        \[\leadsto {d}^{\color{blue}{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. sqrt-pow128.6%

        \[\leadsto \color{blue}{\sqrt{{d}^{2}}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. sqrt-prod20.8%

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{h \cdot \ell}}} \]
      5. div-inv20.8%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      6. sqrt-div28.5%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}} \]
      7. sqrt-pow137.8%

        \[\leadsto \frac{\color{blue}{{d}^{\left(\frac{2}{2}\right)}}}{\sqrt{h \cdot \ell}} \]
      8. metadata-eval37.8%

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{h \cdot \ell}} \]
      9. pow137.8%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    6. Applied egg-rr37.8%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. sqrt-prod46.2%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Applied egg-rr46.2%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    9. Step-by-step derivation
      1. *-commutative46.2%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    10. Simplified46.2%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification47.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -6 \cdot 10^{-187}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 46.7% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.12 \cdot 10^{-243}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l 1.12e-243)
   (* d (- (sqrt (/ (/ 1.0 l) h))))
   (/ d (* (sqrt h) (sqrt l)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 1.12e-243) {
		tmp = d * -sqrt(((1.0 / l) / h));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= 1.12d-243) then
        tmp = d * -sqrt(((1.0d0 / l) / h))
    else
        tmp = d / (sqrt(h) * sqrt(l))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 1.12e-243) {
		tmp = d * -Math.sqrt(((1.0 / l) / h));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= 1.12e-243:
		tmp = d * -math.sqrt(((1.0 / l) / h))
	else:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= 1.12e-243)
		tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / l) / h))));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= 1.12e-243)
		tmp = d * -sqrt(((1.0 / l) / h));
	else
		tmp = d / (sqrt(h) * sqrt(l));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, 1.12e-243], N[(d * (-N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.12 \cdot 10^{-243}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 1.12000000000000005e-243

    1. Initial program 68.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. Simplified67.4%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 11.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    6. Step-by-step derivation
      1. associate-*l*0.0%

        \[\leadsto \color{blue}{d \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt41.8%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. mul-1-neg41.8%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. *-commutative41.8%

        \[\leadsto d \cdot \left(-\sqrt{\frac{1}{\color{blue}{\ell \cdot h}}}\right) \]
      6. associate-/r*42.8%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}}\right) \]
    7. Simplified42.8%

      \[\leadsto \color{blue}{d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)} \]

    if 1.12000000000000005e-243 < l

    1. Initial program 66.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified66.3%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 41.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. pow141.1%

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. metadata-eval41.1%

        \[\leadsto {d}^{\color{blue}{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. sqrt-pow130.8%

        \[\leadsto \color{blue}{\sqrt{{d}^{2}}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. sqrt-prod23.0%

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{h \cdot \ell}}} \]
      5. div-inv23.0%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      6. sqrt-div30.8%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}} \]
      7. sqrt-pow141.0%

        \[\leadsto \frac{\color{blue}{{d}^{\left(\frac{2}{2}\right)}}}{\sqrt{h \cdot \ell}} \]
      8. metadata-eval41.0%

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{h \cdot \ell}} \]
      9. pow141.0%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    6. Applied egg-rr41.0%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. sqrt-prod48.8%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Applied egg-rr48.8%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    9. Step-by-step derivation
      1. *-commutative48.8%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    10. Simplified48.8%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification45.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 1.12 \cdot 10^{-243}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 42.7% accurate, 2.9× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1.45 \cdot 10^{-188}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{\ell} \cdot \frac{1}{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l -1.45e-188)
   (* d (- (sqrt (/ (/ 1.0 l) h))))
   (* d (sqrt (* (/ 1.0 l) (/ 1.0 h))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -1.45e-188) {
		tmp = d * -sqrt(((1.0 / l) / h));
	} else {
		tmp = d * sqrt(((1.0 / l) * (1.0 / h)));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= (-1.45d-188)) then
        tmp = d * -sqrt(((1.0d0 / l) / h))
    else
        tmp = d * sqrt(((1.0d0 / l) * (1.0d0 / h)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -1.45e-188) {
		tmp = d * -Math.sqrt(((1.0 / l) / h));
	} else {
		tmp = d * Math.sqrt(((1.0 / l) * (1.0 / h)));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= -1.45e-188:
		tmp = d * -math.sqrt(((1.0 / l) / h))
	else:
		tmp = d * math.sqrt(((1.0 / l) * (1.0 / h)))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -1.45e-188)
		tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / l) / h))));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / l) * Float64(1.0 / h))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= -1.45e-188)
		tmp = d * -sqrt(((1.0 / l) / h));
	else
		tmp = d * sqrt(((1.0 / l) * (1.0 / h)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -1.45e-188], N[(d * (-N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] * N[(1.0 / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.45 \cdot 10^{-188}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{\ell} \cdot \frac{1}{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -1.4500000000000001e-188

    1. Initial program 64.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.7%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 6.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    6. Step-by-step derivation
      1. associate-*l*0.0%

        \[\leadsto \color{blue}{d \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt46.2%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. mul-1-neg46.2%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. *-commutative46.2%

        \[\leadsto d \cdot \left(-\sqrt{\frac{1}{\color{blue}{\ell \cdot h}}}\right) \]
      6. associate-/r*47.5%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}}\right) \]
    7. Simplified47.5%

      \[\leadsto \color{blue}{d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)} \]

    if -1.4500000000000001e-188 < l

    1. Initial program 69.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified69.3%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 38.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. inv-pow38.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. *-commutative38.9%

        \[\leadsto d \cdot \sqrt{{\color{blue}{\left(\ell \cdot h\right)}}^{-1}} \]
      3. unpow-prod-down39.7%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\ell}^{-1} \cdot {h}^{-1}}} \]
      4. inv-pow39.7%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{\ell}} \cdot {h}^{-1}} \]
      5. inv-pow39.7%

        \[\leadsto d \cdot \sqrt{\frac{1}{\ell} \cdot \color{blue}{\frac{1}{h}}} \]
    6. Applied egg-rr39.7%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{\ell} \cdot \frac{1}{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 17: 42.7% accurate, 2.9× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{if}\;\ell \leq -2.4 \cdot 10^{-188}:\\ \;\;\;\;d \cdot \left(-t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot t\_0\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (/ (/ 1.0 l) h))))
   (if (<= l -2.4e-188) (* d (- t_0)) (* d t_0))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt(((1.0 / l) / h));
	double tmp;
	if (l <= -2.4e-188) {
		tmp = d * -t_0;
	} else {
		tmp = d * t_0;
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt(((1.0d0 / l) / h))
    if (l <= (-2.4d-188)) then
        tmp = d * -t_0
    else
        tmp = d * t_0
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = Math.sqrt(((1.0 / l) / h));
	double tmp;
	if (l <= -2.4e-188) {
		tmp = d * -t_0;
	} else {
		tmp = d * t_0;
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = math.sqrt(((1.0 / l) / h))
	tmp = 0
	if l <= -2.4e-188:
		tmp = d * -t_0
	else:
		tmp = d * t_0
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = sqrt(Float64(Float64(1.0 / l) / h))
	tmp = 0.0
	if (l <= -2.4e-188)
		tmp = Float64(d * Float64(-t_0));
	else
		tmp = Float64(d * t_0);
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = sqrt(((1.0 / l) / h));
	tmp = 0.0;
	if (l <= -2.4e-188)
		tmp = d * -t_0;
	else
		tmp = d * t_0;
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -2.4e-188], N[(d * (-t$95$0)), $MachinePrecision], N[(d * t$95$0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{\frac{1}{\ell}}{h}}\\
\mathbf{if}\;\ell \leq -2.4 \cdot 10^{-188}:\\
\;\;\;\;d \cdot \left(-t\_0\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.4e-188

    1. Initial program 64.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.7%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 6.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    6. Step-by-step derivation
      1. associate-*l*0.0%

        \[\leadsto \color{blue}{d \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt46.2%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. mul-1-neg46.2%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. *-commutative46.2%

        \[\leadsto d \cdot \left(-\sqrt{\frac{1}{\color{blue}{\ell \cdot h}}}\right) \]
      6. associate-/r*47.5%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}}\right) \]
    7. Simplified47.5%

      \[\leadsto \color{blue}{d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)} \]

    if -2.4e-188 < l

    1. Initial program 69.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified69.3%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow169.3%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\right)}^{1}} \]
      2. associate-*r*69.3%

        \[\leadsto {\color{blue}{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}}^{1} \]
      3. sqrt-div65.3%

        \[\leadsto {\left(\left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      4. sqrt-div70.6%

        \[\leadsto {\left(\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      5. frac-times70.6%

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      6. add-sqr-sqrt70.7%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      7. unpow-prod-down70.1%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{{0.5}^{2} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      8. metadata-eval70.1%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{0.25} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      9. clear-num70.1%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(M \cdot \color{blue}{\frac{1}{\frac{d}{D}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      10. un-div-inv70.1%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\color{blue}{\left(\frac{M}{\frac{d}{D}}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
    5. Applied egg-rr70.1%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow170.1%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \]
      2. associate-*l/71.8%

        \[\leadsto \color{blue}{\frac{d \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. associate-/l*71.8%

        \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      4. fma-define71.8%

        \[\leadsto d \cdot \frac{\color{blue}{\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot \left(-0.5 \cdot \frac{h}{\ell}\right) + 1}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. associate-*r*71.8%

        \[\leadsto d \cdot \frac{\color{blue}{\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5\right) \cdot \frac{h}{\ell}} + 1}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. fma-define71.8%

        \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5, \frac{h}{\ell}, 1\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      7. *-commutative71.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot 0.25\right)} \cdot -0.5, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      8. associate-*l*71.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{{\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \left(0.25 \cdot -0.5\right)}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      9. metadata-eval71.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \color{blue}{-0.125}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      10. *-commutative71.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{-0.125 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      11. associate-/r/71.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M}{d} \cdot D\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      12. associate-*l/70.4%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      13. associate-/l*71.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(M \cdot \frac{D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. Simplified71.8%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Taylor expanded in M around 0 38.9%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. *-commutative38.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*39.7%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    10. Simplified39.7%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{\frac{1}{\ell}}{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 18: 42.6% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2.4 \cdot 10^{-187}:\\ \;\;\;\;d \cdot \left(-{\left(\ell \cdot h\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l -2.4e-187)
   (* d (- (pow (* l h) -0.5)))
   (* d (sqrt (/ (/ 1.0 l) h)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -2.4e-187) {
		tmp = d * -pow((l * h), -0.5);
	} else {
		tmp = d * sqrt(((1.0 / l) / h));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= (-2.4d-187)) then
        tmp = d * -((l * h) ** (-0.5d0))
    else
        tmp = d * sqrt(((1.0d0 / l) / h))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -2.4e-187) {
		tmp = d * -Math.pow((l * h), -0.5);
	} else {
		tmp = d * Math.sqrt(((1.0 / l) / h));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= -2.4e-187:
		tmp = d * -math.pow((l * h), -0.5)
	else:
		tmp = d * math.sqrt(((1.0 / l) / h))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -2.4e-187)
		tmp = Float64(d * Float64(-(Float64(l * h) ^ -0.5)));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / l) / h)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= -2.4e-187)
		tmp = d * -((l * h) ^ -0.5);
	else
		tmp = d * sqrt(((1.0 / l) / h));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -2.4e-187], N[(d * (-N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision])), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.4 \cdot 10^{-187}:\\
\;\;\;\;d \cdot \left(-{\left(\ell \cdot h\right)}^{-0.5}\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.40000000000000013e-187

    1. Initial program 64.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.7%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 6.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    6. Step-by-step derivation
      1. associate-*l*0.0%

        \[\leadsto \color{blue}{d \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt46.2%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. mul-1-neg46.2%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. unpow-146.2%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right) \]
      6. metadata-eval46.2%

        \[\leadsto d \cdot \left(-\sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}}\right) \]
      7. pow-sqr46.2%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}}\right) \]
      8. rem-sqrt-square46.5%

        \[\leadsto d \cdot \left(-\color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|}\right) \]
      9. rem-square-sqrt46.2%

        \[\leadsto d \cdot \left(-\left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right|\right) \]
      10. fabs-sqr46.2%

        \[\leadsto d \cdot \left(-\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right) \]
      11. rem-square-sqrt46.5%

        \[\leadsto d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{-0.5}}\right) \]
    7. Simplified46.5%

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]

    if -2.40000000000000013e-187 < l

    1. Initial program 69.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified69.3%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow169.3%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\right)}^{1}} \]
      2. associate-*r*69.3%

        \[\leadsto {\color{blue}{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}}^{1} \]
      3. sqrt-div65.3%

        \[\leadsto {\left(\left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      4. sqrt-div70.6%

        \[\leadsto {\left(\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      5. frac-times70.6%

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      6. add-sqr-sqrt70.7%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      7. unpow-prod-down70.1%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{{0.5}^{2} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      8. metadata-eval70.1%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{0.25} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      9. clear-num70.1%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(M \cdot \color{blue}{\frac{1}{\frac{d}{D}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      10. un-div-inv70.1%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\color{blue}{\left(\frac{M}{\frac{d}{D}}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
    5. Applied egg-rr70.1%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow170.1%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \]
      2. associate-*l/71.8%

        \[\leadsto \color{blue}{\frac{d \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. associate-/l*71.8%

        \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      4. fma-define71.8%

        \[\leadsto d \cdot \frac{\color{blue}{\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot \left(-0.5 \cdot \frac{h}{\ell}\right) + 1}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. associate-*r*71.8%

        \[\leadsto d \cdot \frac{\color{blue}{\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5\right) \cdot \frac{h}{\ell}} + 1}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. fma-define71.8%

        \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5, \frac{h}{\ell}, 1\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      7. *-commutative71.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot 0.25\right)} \cdot -0.5, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      8. associate-*l*71.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{{\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \left(0.25 \cdot -0.5\right)}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      9. metadata-eval71.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \color{blue}{-0.125}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      10. *-commutative71.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{-0.125 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      11. associate-/r/71.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M}{d} \cdot D\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      12. associate-*l/70.4%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      13. associate-/l*71.8%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(M \cdot \frac{D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. Simplified71.8%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Taylor expanded in M around 0 38.9%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. *-commutative38.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*39.7%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    10. Simplified39.7%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{\frac{1}{\ell}}{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification42.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.4 \cdot 10^{-187}:\\ \;\;\;\;d \cdot \left(-{\left(\ell \cdot h\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 42.7% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{if}\;\ell \leq -2.5 \cdot 10^{-209}:\\ \;\;\;\;d \cdot \left(-t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot t\_0\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (pow (* l h) -0.5)))
   (if (<= l -2.5e-209) (* d (- t_0)) (* d t_0))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = pow((l * h), -0.5);
	double tmp;
	if (l <= -2.5e-209) {
		tmp = d * -t_0;
	} else {
		tmp = d * t_0;
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (l * h) ** (-0.5d0)
    if (l <= (-2.5d-209)) then
        tmp = d * -t_0
    else
        tmp = d * t_0
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = Math.pow((l * h), -0.5);
	double tmp;
	if (l <= -2.5e-209) {
		tmp = d * -t_0;
	} else {
		tmp = d * t_0;
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = math.pow((l * h), -0.5)
	tmp = 0
	if l <= -2.5e-209:
		tmp = d * -t_0
	else:
		tmp = d * t_0
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(l * h) ^ -0.5
	tmp = 0.0
	if (l <= -2.5e-209)
		tmp = Float64(d * Float64(-t_0));
	else
		tmp = Float64(d * t_0);
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = (l * h) ^ -0.5;
	tmp = 0.0;
	if (l <= -2.5e-209)
		tmp = d * -t_0;
	else
		tmp = d * t_0;
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]}, If[LessEqual[l, -2.5e-209], N[(d * (-t$95$0)), $MachinePrecision], N[(d * t$95$0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;\ell \leq -2.5 \cdot 10^{-209}:\\
\;\;\;\;d \cdot \left(-t\_0\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.5000000000000002e-209

    1. Initial program 65.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. Simplified64.6%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 7.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    6. Step-by-step derivation
      1. associate-*l*0.0%

        \[\leadsto \color{blue}{d \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt45.8%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. mul-1-neg45.8%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. unpow-145.8%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right) \]
      6. metadata-eval45.8%

        \[\leadsto d \cdot \left(-\sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}}\right) \]
      7. pow-sqr45.8%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}}\right) \]
      8. rem-sqrt-square46.1%

        \[\leadsto d \cdot \left(-\color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|}\right) \]
      9. rem-square-sqrt45.9%

        \[\leadsto d \cdot \left(-\left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right|\right) \]
      10. fabs-sqr45.9%

        \[\leadsto d \cdot \left(-\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right) \]
      11. rem-square-sqrt46.1%

        \[\leadsto d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{-0.5}}\right) \]
    7. Simplified46.1%

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]

    if -2.5000000000000002e-209 < l

    1. Initial program 68.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. Simplified68.7%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow168.7%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\right)}^{1}} \]
      2. associate-*r*68.7%

        \[\leadsto {\color{blue}{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}}^{1} \]
      3. sqrt-div66.6%

        \[\leadsto {\left(\left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      4. sqrt-div72.0%

        \[\leadsto {\left(\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      5. frac-times72.0%

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      6. add-sqr-sqrt72.2%

        \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      7. unpow-prod-down71.5%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{{0.5}^{2} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      8. metadata-eval71.5%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{0.25} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      9. clear-num71.5%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(M \cdot \color{blue}{\frac{1}{\frac{d}{D}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
      10. un-div-inv71.5%

        \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\color{blue}{\left(\frac{M}{\frac{d}{D}}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
    5. Applied egg-rr71.5%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1}} \]
    6. Step-by-step derivation
      1. unpow171.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \]
      2. associate-*l/73.3%

        \[\leadsto \color{blue}{\frac{d \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. associate-/l*73.3%

        \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      4. fma-define73.3%

        \[\leadsto d \cdot \frac{\color{blue}{\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot \left(-0.5 \cdot \frac{h}{\ell}\right) + 1}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. associate-*r*73.3%

        \[\leadsto d \cdot \frac{\color{blue}{\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5\right) \cdot \frac{h}{\ell}} + 1}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. fma-define73.3%

        \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5, \frac{h}{\ell}, 1\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      7. *-commutative73.3%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot 0.25\right)} \cdot -0.5, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      8. associate-*l*73.3%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{{\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \left(0.25 \cdot -0.5\right)}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      9. metadata-eval73.3%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \color{blue}{-0.125}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      10. *-commutative73.3%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{-0.125 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      11. associate-/r/73.3%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M}{d} \cdot D\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      12. associate-*l/71.9%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      13. associate-/l*73.2%

        \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(M \cdot \frac{D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. Simplified73.2%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Taylor expanded in M around 0 39.0%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. unpow-139.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. metadata-eval39.0%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr39.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square39.0%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt38.8%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr38.8%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt39.0%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Simplified39.0%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification42.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.5 \cdot 10^{-209}:\\ \;\;\;\;d \cdot \left(-{\left(\ell \cdot h\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 26.0% accurate, 3.1× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ d \cdot {\left(\ell \cdot h\right)}^{-0.5} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (* d (pow (* l h) -0.5)))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d * pow((l * h), -0.5);
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d * ((l * h) ** (-0.5d0))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d * Math.pow((l * h), -0.5);
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d * math.pow((l * h), -0.5)
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d * (Float64(l * h) ^ -0.5))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d * ((l * h) ^ -0.5);
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
d \cdot {\left(\ell \cdot h\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 67.3%

    \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  2. Simplified66.9%

    \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. pow166.9%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)\right)}^{1}} \]
    2. associate-*r*66.9%

      \[\leadsto {\color{blue}{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}}^{1} \]
    3. sqrt-div37.7%

      \[\leadsto {\left(\left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
    4. sqrt-div40.8%

      \[\leadsto {\left(\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}}\right) \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
    5. frac-times40.8%

      \[\leadsto {\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
    6. add-sqr-sqrt40.9%

      \[\leadsto {\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
    7. unpow-prod-down40.5%

      \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{{0.5}^{2} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
    8. metadata-eval40.5%

      \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(\color{blue}{0.25} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
    9. clear-num40.5%

      \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(M \cdot \color{blue}{\frac{1}{\frac{d}{D}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
    10. un-div-inv40.5%

      \[\leadsto {\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\color{blue}{\left(\frac{M}{\frac{d}{D}}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1} \]
  5. Applied egg-rr40.5%

    \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)}^{1}} \]
  6. Step-by-step derivation
    1. unpow140.5%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \]
    2. associate-*l/41.5%

      \[\leadsto \color{blue}{\frac{d \cdot \mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    3. associate-/l*41.5%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    4. fma-define41.5%

      \[\leadsto d \cdot \frac{\color{blue}{\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot \left(-0.5 \cdot \frac{h}{\ell}\right) + 1}}{\sqrt{h} \cdot \sqrt{\ell}} \]
    5. associate-*r*41.5%

      \[\leadsto d \cdot \frac{\color{blue}{\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5\right) \cdot \frac{h}{\ell}} + 1}{\sqrt{h} \cdot \sqrt{\ell}} \]
    6. fma-define41.5%

      \[\leadsto d \cdot \frac{\color{blue}{\mathsf{fma}\left(\left(0.25 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}\right) \cdot -0.5, \frac{h}{\ell}, 1\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. *-commutative41.5%

      \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot 0.25\right)} \cdot -0.5, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    8. associate-*l*41.5%

      \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{{\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \left(0.25 \cdot -0.5\right)}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    9. metadata-eval41.5%

      \[\leadsto d \cdot \frac{\mathsf{fma}\left({\left(\frac{M}{\frac{d}{D}}\right)}^{2} \cdot \color{blue}{-0.125}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    10. *-commutative41.5%

      \[\leadsto d \cdot \frac{\mathsf{fma}\left(\color{blue}{-0.125 \cdot {\left(\frac{M}{\frac{d}{D}}\right)}^{2}}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    11. associate-/r/41.5%

      \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M}{d} \cdot D\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    12. associate-*l/40.7%

      \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
    13. associate-/l*41.5%

      \[\leadsto d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\color{blue}{\left(M \cdot \frac{D}{d}\right)}}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
  7. Simplified41.5%

    \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.125 \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}, \frac{h}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}} \]
  8. Taylor expanded in M around 0 25.2%

    \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
  9. Step-by-step derivation
    1. unpow-125.2%

      \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
    2. metadata-eval25.2%

      \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
    3. pow-sqr25.2%

      \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
    4. rem-sqrt-square24.9%

      \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
    5. rem-square-sqrt24.8%

      \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
    6. fabs-sqr24.8%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
    7. rem-square-sqrt24.9%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  10. Simplified24.9%

    \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  11. Final simplification24.9%

    \[\leadsto d \cdot {\left(\ell \cdot h\right)}^{-0.5} \]
  12. Add Preprocessing

Alternative 21: 26.0% accurate, 3.2× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \frac{d}{\sqrt{\ell \cdot h}} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (/ d (sqrt (* l h))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d / sqrt((l * h));
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d / sqrt((l * h))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d / Math.sqrt((l * h));
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d / math.sqrt((l * h))
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d / sqrt(Float64(l * h)))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d / sqrt((l * h));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Derivation
  1. Initial program 67.3%

    \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  2. Simplified66.9%

    \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in d around inf 25.2%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  5. Step-by-step derivation
    1. pow125.2%

      \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
    2. metadata-eval25.2%

      \[\leadsto {d}^{\color{blue}{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
    3. sqrt-pow126.1%

      \[\leadsto \color{blue}{\sqrt{{d}^{2}}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
    4. sqrt-prod20.7%

      \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{h \cdot \ell}}} \]
    5. div-inv20.7%

      \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
    6. sqrt-div26.1%

      \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}} \]
    7. sqrt-pow124.8%

      \[\leadsto \frac{\color{blue}{{d}^{\left(\frac{2}{2}\right)}}}{\sqrt{h \cdot \ell}} \]
    8. metadata-eval24.8%

      \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{h \cdot \ell}} \]
    9. pow124.8%

      \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
  6. Applied egg-rr24.8%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  7. Final simplification24.8%

    \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
  8. Add Preprocessing

Reproduce

?
herbie shell --seed 2024163 
(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)))))