Henrywood and Agarwal, Equation (12)

Percentage Accurate: 65.9% → 83.1%
Time: 23.3s
Alternatives: 18
Speedup: 1.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 18 alternatives:

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

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

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

\mathbf{elif}\;d \leq 2.2 \cdot 10^{-149}:\\
\;\;\;\;d \cdot \mathsf{fma}\left(-0.125, t\_2 \cdot \sqrt{\frac{h}{{\ell}^{3}}}, {\left(h \cdot \ell\right)}^{-0.5}\right)\\

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


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

    1. Initial program 62.1%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*47.2%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
      2. neg-mul-147.2%

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      4. distribute-lft-in47.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < d < 2.1999999999999998e-149

    1. Initial program 30.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. Simplified27.4%

      \[\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-2neg27.6%

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

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

      \[\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. Taylor expanded in d around inf 37.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.1999999999999998e-149 < d

    1. Initial program 74.5%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*49.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
      2. neg-mul-149.4%

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      4. distribute-lft-in49.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(h \cdot \left(-0.125 \cdot \color{blue}{\left(\left(D \cdot \frac{M}{d}\right) \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{1}{\ell}\right)\right)}\right) + 1\right)\right) \]
    13. Step-by-step derivation
      1. pow1/278.4%

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

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

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

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

      \[\leadsto \color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{h}\right)}^{0.5}\right)} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(h \cdot \left(-0.125 \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{1}{\ell}\right)\right)\right) + 1\right)\right) \]
    15. Step-by-step derivation
      1. unpow1/287.5%

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

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

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

Alternative 2: 81.3% accurate, 1.0× speedup?

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

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\frac{t\_0}{\sqrt{-h}} \cdot t\_2\\

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


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

    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.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 h around -inf 58.3%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*58.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
      2. neg-mul-158.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. sub-neg58.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      4. distribute-lft-in58.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(h \cdot \left(-0.125 \cdot \color{blue}{\left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}\right)}\right) + 1\right)\right) \]
    14. Applied egg-rr79.9%

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

    if -8.4999999999999993e97 < l < -5.00000000000023e-311

    1. Initial program 58.1%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*39.9%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
      2. neg-mul-139.9%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. sub-neg39.9%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      4. distribute-lft-in39.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.00000000000023e-311 < l

    1. Initial program 65.4%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*43.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
      2. neg-mul-143.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. sub-neg43.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      4. distribute-lft-in43.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    6. Simplified67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(h \cdot \left(-0.125 \cdot \color{blue}{\left(\left(D \cdot \frac{M}{d}\right) \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{1}{\ell}\right)\right)}\right) + 1\right)\right) \]
    13. Step-by-step derivation
      1. pow1/267.8%

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

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

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

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

      \[\leadsto \color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{h}\right)}^{0.5}\right)} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(h \cdot \left(-0.125 \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{1}{\ell}\right)\right)\right) + 1\right)\right) \]
    15. Step-by-step derivation
      1. unpow1/279.7%

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

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

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

Alternative 3: 77.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 64.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. Simplified64.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 h around -inf 49.1%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*49.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
      2. neg-mul-149.1%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    6. Simplified67.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3e-227 < h < -4.999999999999985e-310

    1. Initial program 47.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. Simplified47.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-2neg47.1%

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

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

      \[\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. Taylor expanded in d around inf 1.2%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt1.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| \]
      6. fabs-sqr1.2%

        \[\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-sqrt1.2%

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. 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}}} \]
    10. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 65.4%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*43.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
      2. neg-mul-143.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. sub-neg43.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      4. distribute-lft-in43.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    6. Simplified67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(h \cdot \left(-0.125 \cdot \color{blue}{\left(\left(D \cdot \frac{M}{d}\right) \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{1}{\ell}\right)\right)}\right) + 1\right)\right) \]
    13. Step-by-step derivation
      1. pow1/267.8%

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

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

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

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

      \[\leadsto \color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{h}\right)}^{0.5}\right)} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(h \cdot \left(-0.125 \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{1}{\ell}\right)\right)\right) + 1\right)\right) \]
    15. Step-by-step derivation
      1. unpow1/279.7%

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

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

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

Alternative 4: 77.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 64.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. Simplified64.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 h around -inf 49.1%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*49.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
      2. neg-mul-149.1%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    6. Simplified67.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3e-227 < h < -4.999999999999985e-310

    1. Initial program 47.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. Simplified47.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-2neg47.1%

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

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

      \[\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. Taylor expanded in d around inf 1.2%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt1.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| \]
      6. fabs-sqr1.2%

        \[\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-sqrt1.2%

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. 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}}} \]
    10. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 65.4%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*43.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
      2. neg-mul-143.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. sub-neg43.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      4. distribute-lft-in43.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    6. Simplified67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 75.6% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 64.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. Simplified64.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 h around -inf 49.1%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*49.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
      2. neg-mul-149.1%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    6. Simplified67.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3e-227 < h < -4.999999999999985e-310

    1. Initial program 47.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. Simplified47.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-2neg47.1%

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

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

      \[\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. Taylor expanded in d around inf 1.2%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt1.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| \]
      6. fabs-sqr1.2%

        \[\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-sqrt1.2%

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. 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}}} \]
    10. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 65.4%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*43.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
      2. neg-mul-143.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. sub-neg43.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      4. distribute-lft-in43.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    6. Simplified67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 73.1% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 71.8%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*53.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
      2. neg-mul-153.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. sub-neg53.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      4. distribute-lft-in53.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.0000000000000003e-203 < d < -5.50000000000000018e-303

    1. Initial program 18.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. Simplified18.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 h around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

    if -5.50000000000000018e-303 < d

    1. Initial program 64.9%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*42.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
      2. neg-mul-142.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. sub-neg42.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      4. distribute-lft-in42.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 68.4% accurate, 1.3× speedup?

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

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

\mathbf{elif}\;h \leq 8 \cdot 10^{-249}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if h < -3.2000000000000001e-227

    1. Initial program 64.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. Simplified64.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 h around -inf 49.1%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*49.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
      2. neg-mul-149.1%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    6. Simplified67.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.2000000000000001e-227 < h < -4.999999999999985e-310

    1. Initial program 47.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. Simplified47.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-2neg47.1%

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

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

      \[\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. Taylor expanded in d around inf 1.2%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt1.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| \]
      6. fabs-sqr1.2%

        \[\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-sqrt1.2%

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. 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}}} \]
    10. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h < 8.00000000000000043e-249

    1. Initial program 46.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. Simplified46.4%

      \[\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-2neg46.6%

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

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

      \[\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. Taylor expanded in d around inf 71.8%

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt71.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-sqr71.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-sqrt71.8%

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative71.8%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down83.6%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr83.6%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]

    if 8.00000000000000043e-249 < h

    1. Initial program 67.7%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*43.6%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
      2. neg-mul-143.6%

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      4. distribute-lft-in43.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(h \cdot \left(-0.125 \cdot \color{blue}{\left(\left(D \cdot \frac{M}{d}\right) \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{1}{\ell}\right)\right)}\right) + 1\right)\right) \]
    13. Step-by-step derivation
      1. clear-num70.4%

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

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

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

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

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

Alternative 8: 68.3% accurate, 1.3× speedup?

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

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

\mathbf{elif}\;h \leq 4.8 \cdot 10^{-250}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if h < -3.2000000000000001e-227

    1. Initial program 64.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. Simplified64.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 h around -inf 49.1%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*49.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
      2. neg-mul-149.1%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    6. Simplified67.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.2000000000000001e-227 < h < -4.999999999999985e-310

    1. Initial program 47.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. Simplified47.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-2neg47.1%

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

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

      \[\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. Taylor expanded in d around inf 1.2%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt1.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| \]
      6. fabs-sqr1.2%

        \[\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-sqrt1.2%

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. 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}}} \]
    10. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h < 4.7999999999999998e-250

    1. Initial program 46.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. Simplified46.4%

      \[\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-2neg46.6%

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

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

      \[\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. Taylor expanded in d around inf 71.8%

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt71.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-sqr71.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-sqrt71.8%

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative71.8%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down83.6%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr83.6%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]

    if 4.7999999999999998e-250 < h

    1. Initial program 67.7%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*43.6%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
      2. neg-mul-143.6%

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      4. distribute-lft-in43.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(h \cdot \left(-0.125 \cdot \color{blue}{\left(\left(D \cdot \frac{M}{d}\right) \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{1}{\ell}\right)\right)}\right) + 1\right)\right) \]
    13. Step-by-step derivation
      1. clear-num70.3%

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

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

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

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

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

Alternative 9: 56.4% accurate, 1.4× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 5.2e8

    1. Initial program 64.5%

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

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

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

    if 5.2e8 < D

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

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

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

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

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

        \[\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) \]
    7. Simplified54.0%

      \[\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) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification46.0%

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

Alternative 10: 69.2% accurate, 1.4× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} t_0 := D \cdot \frac{M\_m}{d}\\ \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + h \cdot \left(-0.125 \cdot \left(t\_0 \cdot \left(t\_0 \cdot \frac{1}{\ell}\right)\right)\right)\right)\right) \cdot \sqrt{\frac{d}{h}} \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (let* ((t_0 (* D (/ M_m d))))
   (*
    (* (sqrt (/ d l)) (+ 1.0 (* h (* -0.125 (* t_0 (* t_0 (/ 1.0 l)))))))
    (sqrt (/ d h)))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double t_0 = D * (M_m / d);
	return (sqrt((d / l)) * (1.0 + (h * (-0.125 * (t_0 * (t_0 * (1.0 / l))))))) * sqrt((d / h));
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    t_0 = d_1 * (m_m / d)
    code = (sqrt((d / l)) * (1.0d0 + (h * ((-0.125d0) * (t_0 * (t_0 * (1.0d0 / l))))))) * sqrt((d / h))
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double t_0 = D * (M_m / d);
	return (Math.sqrt((d / l)) * (1.0 + (h * (-0.125 * (t_0 * (t_0 * (1.0 / l))))))) * Math.sqrt((d / h));
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	t_0 = D * (M_m / d)
	return (math.sqrt((d / l)) * (1.0 + (h * (-0.125 * (t_0 * (t_0 * (1.0 / l))))))) * math.sqrt((d / h))
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	t_0 = Float64(D * Float64(M_m / d))
	return Float64(Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(h * Float64(-0.125 * Float64(t_0 * Float64(t_0 * Float64(1.0 / l))))))) * sqrt(Float64(d / h)))
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
	t_0 = D * (M_m / d);
	tmp = (sqrt((d / l)) * (1.0 + (h * (-0.125 * (t_0 * (t_0 * (1.0 / l))))))) * sqrt((d / h));
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(-0.125 * N[(t$95$0 * N[(t$95$0 * N[(1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := D \cdot \frac{M\_m}{d}\\
\left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + h \cdot \left(-0.125 \cdot \left(t\_0 \cdot \left(t\_0 \cdot \frac{1}{\ell}\right)\right)\right)\right)\right) \cdot \sqrt{\frac{d}{h}}
\end{array}
\end{array}
Derivation
  1. Initial program 63.8%

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

    \[\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 h around -inf 45.1%

    \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
  5. Step-by-step derivation
    1. associate-*r*45.1%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    2. neg-mul-145.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + h \cdot \left(-0.125 \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{1}{\ell}\right)\right)\right)\right)\right) \cdot \sqrt{\frac{d}{h}} \]
  14. Add Preprocessing

Alternative 11: 69.2% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} t_0 := D \cdot \frac{M\_m}{d}\\ \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + h \cdot \left(-0.125 \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)\right)\right)\right) \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (let* ((t_0 (* D (/ M_m d))))
   (*
    (sqrt (/ d h))
    (* (sqrt (/ d l)) (+ 1.0 (* h (* -0.125 (* t_0 (/ t_0 l)))))))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double t_0 = D * (M_m / d);
	return sqrt((d / h)) * (sqrt((d / l)) * (1.0 + (h * (-0.125 * (t_0 * (t_0 / l))))));
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    t_0 = d_1 * (m_m / d)
    code = sqrt((d / h)) * (sqrt((d / l)) * (1.0d0 + (h * ((-0.125d0) * (t_0 * (t_0 / l))))))
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double t_0 = D * (M_m / d);
	return Math.sqrt((d / h)) * (Math.sqrt((d / l)) * (1.0 + (h * (-0.125 * (t_0 * (t_0 / l))))));
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	t_0 = D * (M_m / d)
	return math.sqrt((d / h)) * (math.sqrt((d / l)) * (1.0 + (h * (-0.125 * (t_0 * (t_0 / l))))))
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	t_0 = Float64(D * Float64(M_m / d))
	return Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(h * Float64(-0.125 * Float64(t_0 * Float64(t_0 / l)))))))
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
	t_0 = D * (M_m / d);
	tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 + (h * (-0.125 * (t_0 * (t_0 / l))))));
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(-0.125 * N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := D \cdot \frac{M\_m}{d}\\
\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + h \cdot \left(-0.125 \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 63.8%

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

    \[\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 h around -inf 45.1%

    \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
  5. Step-by-step derivation
    1. associate-*r*45.1%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    2. neg-mul-145.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + h \cdot \left(-0.125 \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}\right)\right)\right)\right) \]
  14. Add Preprocessing

Alternative 12: 68.0% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + h \cdot \left(-0.125 \cdot \left(\left(D \cdot \frac{M\_m}{d}\right) \cdot \left(D \cdot \frac{\frac{M\_m}{d}}{\ell}\right)\right)\right)\right)\right) \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (*
  (sqrt (/ d h))
  (*
   (sqrt (/ d l))
   (+ 1.0 (* h (* -0.125 (* (* D (/ M_m d)) (* D (/ (/ M_m d) l)))))))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	return sqrt((d / h)) * (sqrt((d / l)) * (1.0 + (h * (-0.125 * ((D * (M_m / d)) * (D * ((M_m / d) / l)))))));
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_1
    code = sqrt((d / h)) * (sqrt((d / l)) * (1.0d0 + (h * ((-0.125d0) * ((d_1 * (m_m / d)) * (d_1 * ((m_m / d) / l)))))))
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	return Math.sqrt((d / h)) * (Math.sqrt((d / l)) * (1.0 + (h * (-0.125 * ((D * (M_m / d)) * (D * ((M_m / d) / l)))))));
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	return math.sqrt((d / h)) * (math.sqrt((d / l)) * (1.0 + (h * (-0.125 * ((D * (M_m / d)) * (D * ((M_m / d) / l)))))))
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	return Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(h * Float64(-0.125 * Float64(Float64(D * Float64(M_m / d)) * Float64(D * Float64(Float64(M_m / d) / l))))))))
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
	tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 + (h * (-0.125 * ((D * (M_m / d)) * (D * ((M_m / d) / l)))))));
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(-0.125 * N[(N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(D * N[(N[(M$95$m / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + h \cdot \left(-0.125 \cdot \left(\left(D \cdot \frac{M\_m}{d}\right) \cdot \left(D \cdot \frac{\frac{M\_m}{d}}{\ell}\right)\right)\right)\right)\right)
\end{array}
Derivation
  1. Initial program 63.8%

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

    \[\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 h around -inf 45.1%

    \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
  5. Step-by-step derivation
    1. associate-*r*45.1%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)}\right) \]
    2. neg-mul-145.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(h \cdot \left(-0.125 \cdot \color{blue}{\left(\left(D \cdot \frac{M}{d}\right) \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{1}{\ell}\right)\right)}\right) + 1\right)\right) \]
  13. Taylor expanded in D around 0 63.4%

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

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

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

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

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

    \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + h \cdot \left(-0.125 \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{d}}{\ell}\right)\right)\right)\right)\right) \]
  17. Add Preprocessing

Alternative 13: 47.6% accurate, 1.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


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

    1. Initial program 74.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. Simplified74.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. frac-2neg78.1%

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

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

      \[\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. Taylor expanded in d around inf 7.5%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square6.5%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt6.5%

        \[\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-sqr6.5%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt6.5%

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. 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}}} \]
    10. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

    if -8.50000000000000054e-161 < d < -1.000000000000002e-309

    1. Initial program 24.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. Simplified24.7%

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

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

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

      \[\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. Taylor expanded in d around inf 5.7%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square5.7%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt5.7%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr5.7%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt5.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < d

    1. Initial program 65.4%

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

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

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

      \[\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. Taylor expanded in d around inf 44.2%

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

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

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr44.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-square44.6%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt44.4%

        \[\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-sqr44.4%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt44.6%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr51.5%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification52.3%

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

Alternative 14: 45.9% accurate, 1.6× speedup?

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

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


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

    1. Initial program 60.2%

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

      \[\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-2neg62.2%

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square6.6%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt6.6%

        \[\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-sqr6.6%

        \[\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-sqrt6.6%

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. 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}}} \]
    10. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

    if 7.7999999999999999e-227 < d

    1. Initial program 68.1%

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

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

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

      \[\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. Taylor expanded in d around inf 48.4%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square48.9%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt48.7%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr48.7%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt48.9%

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

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

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down56.6%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr56.6%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification48.8%

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

Alternative 15: 44.9% accurate, 1.6× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{d \cdot {h}^{-0.5}}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 1.20000000000000001e-228

    1. Initial program 60.2%

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

      \[\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-2neg62.2%

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square6.6%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt6.6%

        \[\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-sqr6.6%

        \[\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-sqrt6.6%

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. 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}}} \]
    10. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

    if 1.20000000000000001e-228 < d

    1. Initial program 68.1%

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

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

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

      \[\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. Taylor expanded in d around inf 48.4%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square48.9%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt48.7%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr48.7%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt48.9%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      8. rem-square-sqrt48.7%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      9. fabs-sqr48.7%

        \[\leadsto d \cdot \color{blue}{\left|\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right|} \]
      10. rem-square-sqrt48.9%

        \[\leadsto d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.5}}\right| \]
      11. rem-sqrt-square48.4%

        \[\leadsto d \cdot \color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      12. pow-sqr48.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(2 \cdot -0.5\right)}}} \]
      13. metadata-eval48.4%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{-1}}} \]
      14. unpow-148.4%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    8. Simplified48.4%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
      2. associate-*r/53.6%

        \[\leadsto \color{blue}{\frac{d \cdot {h}^{-0.5}}{\sqrt{\ell}}} \]
    12. Simplified53.6%

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

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

Alternative 16: 42.2% accurate, 2.9× speedup?

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

\mathbf{else}:\\
\;\;\;\;d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 3.7999999999999999e-228

    1. Initial program 60.2%

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

      \[\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-2neg62.2%

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square6.6%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt6.6%

        \[\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-sqr6.6%

        \[\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-sqrt6.6%

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. 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}}} \]
    10. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

    if 3.7999999999999999e-228 < d

    1. Initial program 68.1%

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

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

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

      \[\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. Taylor expanded in d around inf 48.4%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square48.9%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt48.7%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr48.7%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt48.9%

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

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

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

Alternative 17: 42.1% accurate, 3.0× speedup?

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

    1. Initial program 60.2%

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

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

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

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right) \]
      6. metadata-eval41.9%

        \[\leadsto d \cdot \left(-\sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}}\right) \]
      7. pow-sqr41.9%

        \[\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-square41.9%

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

        \[\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-sqr41.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) \]
      11. rem-square-sqrt41.9%

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

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]

    if 1.99999999999999989e-227 < d

    1. Initial program 68.1%

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

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

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

      \[\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. Taylor expanded in d around inf 48.4%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square48.9%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt48.7%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr48.7%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt48.9%

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 18: 26.0% accurate, 3.1× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ d \cdot {\left(h \cdot \ell\right)}^{-0.5} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D) :precision binary64 (* d (pow (* h l) -0.5)))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	return d * pow((h * l), -0.5);
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_1
    code = d * ((h * l) ** (-0.5d0))
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	return d * Math.pow((h * l), -0.5);
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	return d * math.pow((h * l), -0.5)
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	return Float64(d * (Float64(h * l) ^ -0.5))
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
	tmp = d * ((h * l) ^ -0.5);
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
d \cdot {\left(h \cdot \ell\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 63.8%

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

    \[\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-2neg65.7%

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

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

    \[\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. Taylor expanded in d around inf 25.7%

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

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

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

      \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
    4. rem-sqrt-square25.6%

      \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
    5. rem-square-sqrt25.5%

      \[\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-sqr25.5%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
    7. rem-square-sqrt25.6%

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

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

Reproduce

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