Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.6% → 82.0%
Time: 33.8s
Alternatives: 21
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 21 alternatives:

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

Initial Program: 66.6% accurate, 1.0× speedup?

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

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

Alternative 1: 82.0% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 75.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.80000000000000022e-189 < d < 2.95e-270

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{\left|{\left(\frac{h}{\ell}\right)}^{1.5}\right|}}{d}\right)}{h} \]
      11. metadata-eval83.0%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|{\left(\frac{h}{\ell}\right)}^{\color{blue}{\left(2 \cdot 0.75\right)}}\right|}{d}\right)}{h} \]
      12. pow-sqr83.1%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|\color{blue}{{\left(\frac{h}{\ell}\right)}^{0.75} \cdot {\left(\frac{h}{\ell}\right)}^{0.75}}\right|}{d}\right)}{h} \]
      13. fabs-sqr83.1%

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{{\left(\frac{h}{\ell}\right)}^{\left(2 \cdot 0.75\right)}}}{d}\right)}{h} \]
      15. metadata-eval83.0%

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

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

    if 2.95e-270 < d

    1. Initial program 70.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. Simplified70.9%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 78.3% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 77.9%

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

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

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

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

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

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

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

    if -1.6500000000000001e-158 < d < 1.25999999999999995e-272

    1. Initial program 28.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. Simplified28.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{\left|{\left(\frac{h}{\ell}\right)}^{1.5}\right|}}{d}\right)}{h} \]
      11. metadata-eval79.2%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|{\left(\frac{h}{\ell}\right)}^{\color{blue}{\left(2 \cdot 0.75\right)}}\right|}{d}\right)}{h} \]
      12. pow-sqr79.3%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|\color{blue}{{\left(\frac{h}{\ell}\right)}^{0.75} \cdot {\left(\frac{h}{\ell}\right)}^{0.75}}\right|}{d}\right)}{h} \]
      13. fabs-sqr79.3%

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{{\left(\frac{h}{\ell}\right)}^{\left(2 \cdot 0.75\right)}}}{d}\right)}{h} \]
      15. metadata-eval79.2%

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

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

    if 1.25999999999999995e-272 < d

    1. Initial program 70.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. Simplified70.9%

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 78.2% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 77.9%

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

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

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

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

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

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

    if -1.68e-161 < d < 5.39999999999999985e-272

    1. Initial program 28.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. Simplified28.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{\left|{\left(\frac{h}{\ell}\right)}^{1.5}\right|}}{d}\right)}{h} \]
      11. metadata-eval79.2%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|{\left(\frac{h}{\ell}\right)}^{\color{blue}{\left(2 \cdot 0.75\right)}}\right|}{d}\right)}{h} \]
      12. pow-sqr79.3%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|\color{blue}{{\left(\frac{h}{\ell}\right)}^{0.75} \cdot {\left(\frac{h}{\ell}\right)}^{0.75}}\right|}{d}\right)}{h} \]
      13. fabs-sqr79.3%

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{{\left(\frac{h}{\ell}\right)}^{\left(2 \cdot 0.75\right)}}}{d}\right)}{h} \]
      15. metadata-eval79.2%

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

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

    if 5.39999999999999985e-272 < d

    1. Initial program 70.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. Simplified70.9%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 78.1% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 77.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified77.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. associate-*l/80.1%

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

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

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

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

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

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

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

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

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

    if -1.9e-168 < d < 5.4999999999999999e-272

    1. Initial program 28.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. Simplified28.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{\left|{\left(\frac{h}{\ell}\right)}^{1.5}\right|}}{d}\right)}{h} \]
      11. metadata-eval79.2%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|{\left(\frac{h}{\ell}\right)}^{\color{blue}{\left(2 \cdot 0.75\right)}}\right|}{d}\right)}{h} \]
      12. pow-sqr79.3%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|\color{blue}{{\left(\frac{h}{\ell}\right)}^{0.75} \cdot {\left(\frac{h}{\ell}\right)}^{0.75}}\right|}{d}\right)}{h} \]
      13. fabs-sqr79.3%

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{{\left(\frac{h}{\ell}\right)}^{\left(2 \cdot 0.75\right)}}}{d}\right)}{h} \]
      15. metadata-eval79.2%

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

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

    if 5.4999999999999999e-272 < d

    1. Initial program 70.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. Simplified70.9%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 69.6% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;d \leq 2.6 \cdot 10^{+90}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -7.19999999999999969e-165 or 9.5000000000000005e-146 < d < 2.5999999999999998e90

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.19999999999999969e-165 < d < 9.5000000000000005e-146

    1. Initial program 35.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. Simplified35.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. add-sqr-sqrt35.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{\left|{\left(\frac{h}{\ell}\right)}^{1.5}\right|}}{d}\right)}{h} \]
      11. metadata-eval72.6%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|{\left(\frac{h}{\ell}\right)}^{\color{blue}{\left(2 \cdot 0.75\right)}}\right|}{d}\right)}{h} \]
      12. pow-sqr72.6%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|\color{blue}{{\left(\frac{h}{\ell}\right)}^{0.75} \cdot {\left(\frac{h}{\ell}\right)}^{0.75}}\right|}{d}\right)}{h} \]
      13. fabs-sqr72.6%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{{\left(\frac{h}{\ell}\right)}^{0.75} \cdot {\left(\frac{h}{\ell}\right)}^{0.75}}}{d}\right)}{h} \]
      14. pow-sqr72.6%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{{\left(\frac{h}{\ell}\right)}^{\left(2 \cdot 0.75\right)}}}{d}\right)}{h} \]
      15. metadata-eval72.6%

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

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

    if 2.5999999999999998e90 < 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. Simplified70.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. Taylor expanded in d around inf 78.7%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*80.8%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified80.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity80.8%

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
    10. Simplified87.7%

      \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification80.0%

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

Alternative 6: 63.5% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;d \leq 1.95 \cdot 10^{+23}:\\
\;\;\;\;\frac{t\_1 \cdot \frac{-0.125}{\frac{d}{t\_0}} + d \cdot \sqrt{\frac{h}{\ell}}}{h}\\

\mathbf{elif}\;d \leq 6.6 \cdot 10^{+87}:\\
\;\;\;\;t\_2\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.66000000000000009e-158 or 1.95e23 < d < 6.6000000000000003e87

    1. Initial program 80.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.66000000000000009e-158 < d < 2.0499999999999999e-168

    1. Initial program 37.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{\left|{\left(\frac{h}{\ell}\right)}^{1.5}\right|}}{d}\right)}{h} \]
      11. metadata-eval74.6%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|{\left(\frac{h}{\ell}\right)}^{\color{blue}{\left(2 \cdot 0.75\right)}}\right|}{d}\right)}{h} \]
      12. pow-sqr74.6%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|\color{blue}{{\left(\frac{h}{\ell}\right)}^{0.75} \cdot {\left(\frac{h}{\ell}\right)}^{0.75}}\right|}{d}\right)}{h} \]
      13. fabs-sqr74.6%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{{\left(\frac{h}{\ell}\right)}^{0.75} \cdot {\left(\frac{h}{\ell}\right)}^{0.75}}}{d}\right)}{h} \]
      14. pow-sqr74.6%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{{\left(\frac{h}{\ell}\right)}^{\left(2 \cdot 0.75\right)}}}{d}\right)}{h} \]
      15. metadata-eval74.6%

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

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

    if 2.0499999999999999e-168 < d < 1.95e23

    1. Initial program 78.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.6000000000000003e87 < 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. Simplified70.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. Taylor expanded in d around inf 78.7%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*80.8%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified80.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity80.8%

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
    10. Simplified87.7%

      \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification72.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.66 \cdot 10^{-158}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right)\right)\\ \mathbf{elif}\;d \leq 2.05 \cdot 10^{-168}:\\ \;\;\;\;\frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{{\left(\frac{h}{\ell}\right)}^{1.5}}{d}\right)}{h}\\ \mathbf{elif}\;d \leq 1.95 \cdot 10^{+23}:\\ \;\;\;\;\frac{{\left(\frac{h}{\ell}\right)}^{1.5} \cdot \frac{-0.125}{\frac{d}{{\left(D \cdot M\right)}^{2}}} + d \cdot \sqrt{\frac{h}{\ell}}}{h}\\ \mathbf{elif}\;d \leq 6.6 \cdot 10^{+87}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 76.2% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 77.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified77.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. associate-*l/80.1%

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

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

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

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

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

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

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

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

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

    if -5.40000000000000029e-163 < d < 1.6000000000000001e-269

    1. Initial program 28.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. Simplified28.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{\left|{\left(\frac{h}{\ell}\right)}^{1.5}\right|}}{d}\right)}{h} \]
      11. metadata-eval79.2%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|{\left(\frac{h}{\ell}\right)}^{\color{blue}{\left(2 \cdot 0.75\right)}}\right|}{d}\right)}{h} \]
      12. pow-sqr79.3%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|\color{blue}{{\left(\frac{h}{\ell}\right)}^{0.75} \cdot {\left(\frac{h}{\ell}\right)}^{0.75}}\right|}{d}\right)}{h} \]
      13. fabs-sqr79.3%

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{{\left(\frac{h}{\ell}\right)}^{\left(2 \cdot 0.75\right)}}}{d}\right)}{h} \]
      15. metadata-eval79.2%

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

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

    if 1.6000000000000001e-269 < d

    1. Initial program 70.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. Simplified70.9%

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

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

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

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

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

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

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

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

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

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

Alternative 8: 76.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 77.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified77.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. associate-*l/80.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.10000000000000002e-160 < d < 1.65e-269

    1. Initial program 28.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. Simplified28.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{\left|{\left(\frac{h}{\ell}\right)}^{1.5}\right|}}{d}\right)}{h} \]
      11. metadata-eval79.2%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|{\left(\frac{h}{\ell}\right)}^{\color{blue}{\left(2 \cdot 0.75\right)}}\right|}{d}\right)}{h} \]
      12. pow-sqr79.3%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|\color{blue}{{\left(\frac{h}{\ell}\right)}^{0.75} \cdot {\left(\frac{h}{\ell}\right)}^{0.75}}\right|}{d}\right)}{h} \]
      13. fabs-sqr79.3%

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{{\left(\frac{h}{\ell}\right)}^{\left(2 \cdot 0.75\right)}}}{d}\right)}{h} \]
      15. metadata-eval79.2%

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

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

    if 1.65e-269 < d

    1. Initial program 70.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. Simplified70.9%

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

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

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

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

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

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

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

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

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

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

Alternative 9: 75.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 77.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.99999999999999977e-159 < d < 1.7999999999999999e-270

    1. Initial program 28.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. Simplified28.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{\left|{\left(\frac{h}{\ell}\right)}^{1.5}\right|}}{d}\right)}{h} \]
      11. metadata-eval79.2%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|{\left(\frac{h}{\ell}\right)}^{\color{blue}{\left(2 \cdot 0.75\right)}}\right|}{d}\right)}{h} \]
      12. pow-sqr79.3%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|\color{blue}{{\left(\frac{h}{\ell}\right)}^{0.75} \cdot {\left(\frac{h}{\ell}\right)}^{0.75}}\right|}{d}\right)}{h} \]
      13. fabs-sqr79.3%

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{{\left(\frac{h}{\ell}\right)}^{\left(2 \cdot 0.75\right)}}}{d}\right)}{h} \]
      15. metadata-eval79.2%

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

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

    if 1.7999999999999999e-270 < d

    1. Initial program 70.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. Simplified70.9%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 60.1% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;d \leq 6 \cdot 10^{+16} \lor \neg \left(d \leq 10^{+92}\right):\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.75e-164 or 6e16 < d < 1e92

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.75e-164 < d < 3.79999999999999989e-164

    1. Initial program 36.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{\left|{\left(\frac{h}{\ell}\right)}^{1.5}\right|}}{d}\right)}{h} \]
      11. metadata-eval75.0%

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

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

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{{\left(\frac{h}{\ell}\right)}^{\left(2 \cdot 0.75\right)}}}{d}\right)}{h} \]
      15. metadata-eval75.0%

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

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

    if 3.79999999999999989e-164 < d < 6e16 or 1e92 < d

    1. Initial program 73.0%

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*63.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified63.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity63.4%

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
    10. Simplified77.6%

      \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification71.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.75 \cdot 10^{-164}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right)\right)\\ \mathbf{elif}\;d \leq 3.8 \cdot 10^{-164}:\\ \;\;\;\;\frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{{\left(\frac{h}{\ell}\right)}^{1.5}}{d}\right)}{h}\\ \mathbf{elif}\;d \leq 6 \cdot 10^{+16} \lor \neg \left(d \leq 10^{+92}\right):\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 56.5% accurate, 1.4× speedup?

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

\mathbf{elif}\;d \leq -1.3 \cdot 10^{-39}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\

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

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\


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

    1. Initial program 76.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. Simplified78.7%

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

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

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

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

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

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

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

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

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

    if -4.64999999999999999e126 < d < -1.3e-39

    1. Initial program 89.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. Simplified89.6%

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

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

    if -1.3e-39 < d < 6.19999999999999949e-163

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{\left|{\left(\frac{h}{\ell}\right)}^{1.5}\right|}}{d}\right)}{h} \]
      11. metadata-eval63.9%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|{\left(\frac{h}{\ell}\right)}^{\color{blue}{\left(2 \cdot 0.75\right)}}\right|}{d}\right)}{h} \]
      12. pow-sqr63.8%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\left|\color{blue}{{\left(\frac{h}{\ell}\right)}^{0.75} \cdot {\left(\frac{h}{\ell}\right)}^{0.75}}\right|}{d}\right)}{h} \]
      13. fabs-sqr63.8%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{{\left(\frac{h}{\ell}\right)}^{0.75} \cdot {\left(\frac{h}{\ell}\right)}^{0.75}}}{d}\right)}{h} \]
      14. pow-sqr63.9%

        \[\leadsto \frac{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\color{blue}{{\left(\frac{h}{\ell}\right)}^{\left(2 \cdot 0.75\right)}}}{d}\right)}{h} \]
      15. metadata-eval63.9%

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

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

    if 6.19999999999999949e-163 < d

    1. Initial program 77.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. Simplified77.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. Taylor expanded in d around inf 59.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*60.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified60.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity60.1%

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

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

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

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

        \[\leadsto d \cdot \left(1 \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}}\right) \]
    8. Applied egg-rr72.0%

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

        \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
    10. Simplified72.0%

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

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

Alternative 12: 46.7% accurate, 1.5× speedup?

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

\mathbf{elif}\;d \leq -2.45 \cdot 10^{-78}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\

\mathbf{elif}\;d \leq 8.5 \cdot 10^{-306}:\\
\;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\


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

    1. Initial program 76.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. Simplified78.7%

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

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

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

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

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

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

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

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

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

    if -9.39999999999999944e125 < d < -2.45000000000000015e-78

    1. Initial program 88.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. Simplified88.6%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]

    if -2.45000000000000015e-78 < d < 8.5000000000000002e-306

    1. Initial program 46.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. Simplified42.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 15.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative15.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified15.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. Step-by-step derivation
      1. add-log-exp26.4%

        \[\leadsto d \cdot \color{blue}{\log \left(e^{\sqrt{\frac{1}{\ell \cdot h}}}\right)} \]
      2. pow1/226.4%

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(\frac{1}{\ell \cdot h}\right)}^{0.5}}}\right) \]
      3. inv-pow26.4%

        \[\leadsto d \cdot \log \left(e^{{\color{blue}{\left({\left(\ell \cdot h\right)}^{-1}\right)}}^{0.5}}\right) \]
      4. pow-pow26.4%

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(\ell \cdot h\right)}^{\left(-1 \cdot 0.5\right)}}}\right) \]
      5. metadata-eval26.4%

        \[\leadsto d \cdot \log \left(e^{{\left(\ell \cdot h\right)}^{\color{blue}{-0.5}}}\right) \]
    8. Applied egg-rr26.4%

      \[\leadsto d \cdot \color{blue}{\log \left(e^{{\left(\ell \cdot h\right)}^{-0.5}}\right)} \]
    9. Step-by-step derivation
      1. rem-log-exp14.2%

        \[\leadsto d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
      2. sqr-pow14.2%

        \[\leadsto d \cdot \color{blue}{\left({\left(\ell \cdot h\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(\ell \cdot h\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      3. pow-prod-down21.4%

        \[\leadsto d \cdot \color{blue}{{\left(\left(\ell \cdot h\right) \cdot \left(\ell \cdot h\right)\right)}^{\left(\frac{-0.5}{2}\right)}} \]
      4. pow221.4%

        \[\leadsto d \cdot {\color{blue}{\left({\left(\ell \cdot h\right)}^{2}\right)}}^{\left(\frac{-0.5}{2}\right)} \]
      5. *-commutative21.4%

        \[\leadsto d \cdot {\left({\color{blue}{\left(h \cdot \ell\right)}}^{2}\right)}^{\left(\frac{-0.5}{2}\right)} \]
      6. metadata-eval21.4%

        \[\leadsto d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{\color{blue}{-0.25}} \]
    10. Applied egg-rr21.4%

      \[\leadsto d \cdot \color{blue}{{\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}} \]

    if 8.5000000000000002e-306 < d

    1. Initial program 68.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified68.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 50.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*50.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified50.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity50.9%

        \[\leadsto d \cdot \color{blue}{\left(1 \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)} \]
      2. sqrt-div60.7%

        \[\leadsto d \cdot \left(1 \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}}\right) \]
      3. inv-pow60.7%

        \[\leadsto d \cdot \left(1 \cdot \frac{\sqrt{\color{blue}{{h}^{-1}}}}{\sqrt{\ell}}\right) \]
      4. sqrt-pow160.8%

        \[\leadsto d \cdot \left(1 \cdot \frac{\color{blue}{{h}^{\left(\frac{-1}{2}\right)}}}{\sqrt{\ell}}\right) \]
      5. metadata-eval60.8%

        \[\leadsto d \cdot \left(1 \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}}\right) \]
    8. Applied egg-rr60.8%

      \[\leadsto d \cdot \color{blue}{\left(1 \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\right)} \]
    9. Step-by-step derivation
      1. *-lft-identity60.8%

        \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
    10. Simplified60.8%

      \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification53.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9.4 \cdot 10^{+125}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \mathbf{elif}\;d \leq -2.45 \cdot 10^{-78}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{-306}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 45.9% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -1.85 \cdot 10^{+62}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;d \leq -8.4 \cdot 10^{-76}:\\ \;\;\;\;\frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{-306}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= d -1.85e+62)
   (/ (- d) (sqrt (* h l)))
   (if (<= d -8.4e-76)
     (/ (* d (sqrt (/ h l))) h)
     (if (<= d 8.5e-306)
       (* d (pow (pow (* h l) 2.0) -0.25))
       (* d (/ (pow h -0.5) (sqrt l)))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -1.85e+62) {
		tmp = -d / sqrt((h * l));
	} else if (d <= -8.4e-76) {
		tmp = (d * sqrt((h / l))) / h;
	} else if (d <= 8.5e-306) {
		tmp = d * pow(pow((h * l), 2.0), -0.25);
	} else {
		tmp = d * (pow(h, -0.5) / sqrt(l));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (d <= (-1.85d+62)) then
        tmp = -d / sqrt((h * l))
    else if (d <= (-8.4d-76)) then
        tmp = (d * sqrt((h / l))) / h
    else if (d <= 8.5d-306) then
        tmp = d * (((h * l) ** 2.0d0) ** (-0.25d0))
    else
        tmp = d * ((h ** (-0.5d0)) / sqrt(l))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -1.85e+62) {
		tmp = -d / Math.sqrt((h * l));
	} else if (d <= -8.4e-76) {
		tmp = (d * Math.sqrt((h / l))) / h;
	} else if (d <= 8.5e-306) {
		tmp = d * Math.pow(Math.pow((h * l), 2.0), -0.25);
	} else {
		tmp = d * (Math.pow(h, -0.5) / Math.sqrt(l));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if d <= -1.85e+62:
		tmp = -d / math.sqrt((h * l))
	elif d <= -8.4e-76:
		tmp = (d * math.sqrt((h / l))) / h
	elif d <= 8.5e-306:
		tmp = d * math.pow(math.pow((h * l), 2.0), -0.25)
	else:
		tmp = d * (math.pow(h, -0.5) / math.sqrt(l))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (d <= -1.85e+62)
		tmp = Float64(Float64(-d) / sqrt(Float64(h * l)));
	elseif (d <= -8.4e-76)
		tmp = Float64(Float64(d * sqrt(Float64(h / l))) / h);
	elseif (d <= 8.5e-306)
		tmp = Float64(d * ((Float64(h * l) ^ 2.0) ^ -0.25));
	else
		tmp = Float64(d * Float64((h ^ -0.5) / sqrt(l)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (d <= -1.85e+62)
		tmp = -d / sqrt((h * l));
	elseif (d <= -8.4e-76)
		tmp = (d * sqrt((h / l))) / h;
	elseif (d <= 8.5e-306)
		tmp = d * (((h * l) ^ 2.0) ^ -0.25);
	else
		tmp = d * ((h ^ -0.5) / sqrt(l));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, -1.85e+62], N[((-d) / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -8.4e-76], N[(N[(d * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[d, 8.5e-306], N[(d * N[Power[N[Power[N[(h * l), $MachinePrecision], 2.0], $MachinePrecision], -0.25], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[h, -0.5], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.85 \cdot 10^{+62}:\\
\;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\

\mathbf{elif}\;d \leq -8.4 \cdot 10^{-76}:\\
\;\;\;\;\frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\

\mathbf{elif}\;d \leq 8.5 \cdot 10^{-306}:\\
\;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.85000000000000007e62

    1. Initial program 78.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. Simplified80.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 5.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*5.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified5.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. 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}}} \]
    8. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. unpow20.0%

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt68.6%

        \[\leadsto \left(\color{blue}{-1} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. associate-*r*68.6%

        \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. mul-1-neg68.6%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. *-commutative68.6%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      7. rem-exp-log65.0%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}} \]
      8. *-commutative65.0%

        \[\leadsto -d \cdot \sqrt{\frac{1}{e^{\log \color{blue}{\left(h \cdot \ell\right)}}}} \]
      9. exp-neg65.0%

        \[\leadsto -d \cdot \sqrt{\color{blue}{e^{-\log \left(h \cdot \ell\right)}}} \]
      10. unpow1/265.0%

        \[\leadsto -d \cdot \color{blue}{{\left(e^{-\log \left(h \cdot \ell\right)}\right)}^{0.5}} \]
      11. exp-prod65.0%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      12. distribute-lft-neg-out65.0%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      13. exp-neg65.0%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      14. associate-*r/65.0%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      15. *-rgt-identity65.0%

        \[\leadsto -\frac{\color{blue}{d}}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      16. *-commutative65.0%

        \[\leadsto -\frac{d}{e^{\log \color{blue}{\left(\ell \cdot h\right)} \cdot 0.5}} \]
      17. exp-to-pow68.6%

        \[\leadsto -\frac{d}{\color{blue}{{\left(\ell \cdot h\right)}^{0.5}}} \]
      18. unpow1/268.6%

        \[\leadsto -\frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \]
      19. *-commutative68.6%

        \[\leadsto -\frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    9. Simplified68.6%

      \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]

    if -1.85000000000000007e62 < d < -8.39999999999999969e-76

    1. Initial program 89.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. Simplified89.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt89.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow289.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod89.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow189.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval89.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. frac-times89.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*89.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. pow189.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative89.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr89.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/89.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. *-commutative89.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. associate-*r/86.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. associate-*l*86.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    7. Simplified86.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Taylor expanded in h around 0 16.5%

      \[\leadsto \color{blue}{\frac{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}\right) + d \cdot \sqrt{\frac{h}{\ell}}}{h}} \]
    9. Step-by-step derivation
      1. associate-*r*16.5%

        \[\leadsto \frac{\color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{d}\right) \cdot \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}} + d \cdot \sqrt{\frac{h}{\ell}}}{h} \]
      2. fma-define16.5%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}}{h} \]
      3. unpow216.5%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
      4. unpow216.5%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
      5. swap-sqr16.7%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{\color{blue}{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
      6. unpow216.7%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{\color{blue}{{\left(D \cdot M\right)}^{2}}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
      7. cube-div52.3%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}, \sqrt{\color{blue}{{\left(\frac{h}{\ell}\right)}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
    10. Simplified52.3%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-0.125 \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}, \sqrt{{\left(\frac{h}{\ell}\right)}^{3}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h}} \]
    11. Taylor expanded in D around 0 47.2%

      \[\leadsto \frac{\color{blue}{d \cdot \sqrt{\frac{h}{\ell}}}}{h} \]

    if -8.39999999999999969e-76 < d < 8.5000000000000002e-306

    1. Initial program 46.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. Simplified42.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 15.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative15.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified15.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. Step-by-step derivation
      1. add-log-exp26.4%

        \[\leadsto d \cdot \color{blue}{\log \left(e^{\sqrt{\frac{1}{\ell \cdot h}}}\right)} \]
      2. pow1/226.4%

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(\frac{1}{\ell \cdot h}\right)}^{0.5}}}\right) \]
      3. inv-pow26.4%

        \[\leadsto d \cdot \log \left(e^{{\color{blue}{\left({\left(\ell \cdot h\right)}^{-1}\right)}}^{0.5}}\right) \]
      4. pow-pow26.4%

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(\ell \cdot h\right)}^{\left(-1 \cdot 0.5\right)}}}\right) \]
      5. metadata-eval26.4%

        \[\leadsto d \cdot \log \left(e^{{\left(\ell \cdot h\right)}^{\color{blue}{-0.5}}}\right) \]
    8. Applied egg-rr26.4%

      \[\leadsto d \cdot \color{blue}{\log \left(e^{{\left(\ell \cdot h\right)}^{-0.5}}\right)} \]
    9. Step-by-step derivation
      1. rem-log-exp14.2%

        \[\leadsto d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
      2. sqr-pow14.2%

        \[\leadsto d \cdot \color{blue}{\left({\left(\ell \cdot h\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(\ell \cdot h\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      3. pow-prod-down21.4%

        \[\leadsto d \cdot \color{blue}{{\left(\left(\ell \cdot h\right) \cdot \left(\ell \cdot h\right)\right)}^{\left(\frac{-0.5}{2}\right)}} \]
      4. pow221.4%

        \[\leadsto d \cdot {\color{blue}{\left({\left(\ell \cdot h\right)}^{2}\right)}}^{\left(\frac{-0.5}{2}\right)} \]
      5. *-commutative21.4%

        \[\leadsto d \cdot {\left({\color{blue}{\left(h \cdot \ell\right)}}^{2}\right)}^{\left(\frac{-0.5}{2}\right)} \]
      6. metadata-eval21.4%

        \[\leadsto d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{\color{blue}{-0.25}} \]
    10. Applied egg-rr21.4%

      \[\leadsto d \cdot \color{blue}{{\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}} \]

    if 8.5000000000000002e-306 < d

    1. Initial program 68.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified68.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 50.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*50.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified50.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity50.9%

        \[\leadsto d \cdot \color{blue}{\left(1 \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)} \]
      2. sqrt-div60.7%

        \[\leadsto d \cdot \left(1 \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}}\right) \]
      3. inv-pow60.7%

        \[\leadsto d \cdot \left(1 \cdot \frac{\sqrt{\color{blue}{{h}^{-1}}}}{\sqrt{\ell}}\right) \]
      4. sqrt-pow160.8%

        \[\leadsto d \cdot \left(1 \cdot \frac{\color{blue}{{h}^{\left(\frac{-1}{2}\right)}}}{\sqrt{\ell}}\right) \]
      5. metadata-eval60.8%

        \[\leadsto d \cdot \left(1 \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}}\right) \]
    8. Applied egg-rr60.8%

      \[\leadsto d \cdot \color{blue}{\left(1 \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\right)} \]
    9. Step-by-step derivation
      1. *-lft-identity60.8%

        \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
    10. Simplified60.8%

      \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification52.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.85 \cdot 10^{+62}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;d \leq -8.4 \cdot 10^{-76}:\\ \;\;\;\;\frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{-306}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 45.4% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -1.5 \cdot 10^{+62}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;d \leq -2.45 \cdot 10^{-78}:\\ \;\;\;\;\frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{-306}:\\ \;\;\;\;d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= d -1.5e+62)
   (/ (- d) (sqrt (* h l)))
   (if (<= d -2.45e-78)
     (/ (* d (sqrt (/ h l))) h)
     (if (<= d 8.5e-306)
       (* d (cbrt (pow (* h l) -1.5)))
       (* d (/ (pow h -0.5) (sqrt l)))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -1.5e+62) {
		tmp = -d / sqrt((h * l));
	} else if (d <= -2.45e-78) {
		tmp = (d * sqrt((h / l))) / h;
	} else if (d <= 8.5e-306) {
		tmp = d * cbrt(pow((h * l), -1.5));
	} else {
		tmp = d * (pow(h, -0.5) / sqrt(l));
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -1.5e+62) {
		tmp = -d / Math.sqrt((h * l));
	} else if (d <= -2.45e-78) {
		tmp = (d * Math.sqrt((h / l))) / h;
	} else if (d <= 8.5e-306) {
		tmp = d * Math.cbrt(Math.pow((h * l), -1.5));
	} else {
		tmp = d * (Math.pow(h, -0.5) / Math.sqrt(l));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (d <= -1.5e+62)
		tmp = Float64(Float64(-d) / sqrt(Float64(h * l)));
	elseif (d <= -2.45e-78)
		tmp = Float64(Float64(d * sqrt(Float64(h / l))) / h);
	elseif (d <= 8.5e-306)
		tmp = Float64(d * cbrt((Float64(h * l) ^ -1.5)));
	else
		tmp = Float64(d * Float64((h ^ -0.5) / sqrt(l)));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, -1.5e+62], N[((-d) / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.45e-78], N[(N[(d * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[d, 8.5e-306], N[(d * N[Power[N[Power[N[(h * l), $MachinePrecision], -1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[h, -0.5], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.5 \cdot 10^{+62}:\\
\;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\

\mathbf{elif}\;d \leq -2.45 \cdot 10^{-78}:\\
\;\;\;\;\frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\

\mathbf{elif}\;d \leq 8.5 \cdot 10^{-306}:\\
\;\;\;\;d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.5e62

    1. Initial program 78.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. Simplified80.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 5.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*5.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified5.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. 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}}} \]
    8. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. unpow20.0%

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt68.6%

        \[\leadsto \left(\color{blue}{-1} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. associate-*r*68.6%

        \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. mul-1-neg68.6%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. *-commutative68.6%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      7. rem-exp-log65.0%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}} \]
      8. *-commutative65.0%

        \[\leadsto -d \cdot \sqrt{\frac{1}{e^{\log \color{blue}{\left(h \cdot \ell\right)}}}} \]
      9. exp-neg65.0%

        \[\leadsto -d \cdot \sqrt{\color{blue}{e^{-\log \left(h \cdot \ell\right)}}} \]
      10. unpow1/265.0%

        \[\leadsto -d \cdot \color{blue}{{\left(e^{-\log \left(h \cdot \ell\right)}\right)}^{0.5}} \]
      11. exp-prod65.0%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      12. distribute-lft-neg-out65.0%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      13. exp-neg65.0%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      14. associate-*r/65.0%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      15. *-rgt-identity65.0%

        \[\leadsto -\frac{\color{blue}{d}}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      16. *-commutative65.0%

        \[\leadsto -\frac{d}{e^{\log \color{blue}{\left(\ell \cdot h\right)} \cdot 0.5}} \]
      17. exp-to-pow68.6%

        \[\leadsto -\frac{d}{\color{blue}{{\left(\ell \cdot h\right)}^{0.5}}} \]
      18. unpow1/268.6%

        \[\leadsto -\frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \]
      19. *-commutative68.6%

        \[\leadsto -\frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    9. Simplified68.6%

      \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]

    if -1.5e62 < d < -2.45000000000000015e-78

    1. Initial program 89.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. Simplified89.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt89.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow289.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod89.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow189.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval89.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. frac-times89.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*89.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. pow189.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative89.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr89.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/89.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. *-commutative89.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. associate-*r/86.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. associate-*l*86.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    7. Simplified86.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Taylor expanded in h around 0 16.5%

      \[\leadsto \color{blue}{\frac{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}\right) + d \cdot \sqrt{\frac{h}{\ell}}}{h}} \]
    9. Step-by-step derivation
      1. associate-*r*16.5%

        \[\leadsto \frac{\color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{d}\right) \cdot \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}} + d \cdot \sqrt{\frac{h}{\ell}}}{h} \]
      2. fma-define16.5%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}}{h} \]
      3. unpow216.5%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
      4. unpow216.5%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
      5. swap-sqr16.7%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{\color{blue}{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
      6. unpow216.7%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{\color{blue}{{\left(D \cdot M\right)}^{2}}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
      7. cube-div52.3%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}, \sqrt{\color{blue}{{\left(\frac{h}{\ell}\right)}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
    10. Simplified52.3%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-0.125 \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}, \sqrt{{\left(\frac{h}{\ell}\right)}^{3}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h}} \]
    11. Taylor expanded in D around 0 47.2%

      \[\leadsto \frac{\color{blue}{d \cdot \sqrt{\frac{h}{\ell}}}}{h} \]

    if -2.45000000000000015e-78 < d < 8.5000000000000002e-306

    1. Initial program 46.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. Simplified42.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 15.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative15.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified15.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. Step-by-step derivation
      1. add-cbrt-cube21.3%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}}} \]
      2. pow1/321.3%

        \[\leadsto d \cdot \color{blue}{{\left(\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)}^{0.3333333333333333}} \]
      3. add-sqr-sqrt21.3%

        \[\leadsto d \cdot {\left(\color{blue}{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)}^{0.3333333333333333} \]
      4. pow121.3%

        \[\leadsto d \cdot {\left(\color{blue}{{\left(\frac{1}{\ell \cdot h}\right)}^{1}} \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)}^{0.3333333333333333} \]
      5. pow1/221.3%

        \[\leadsto d \cdot {\left({\left(\frac{1}{\ell \cdot h}\right)}^{1} \cdot \color{blue}{{\left(\frac{1}{\ell \cdot h}\right)}^{0.5}}\right)}^{0.3333333333333333} \]
      6. pow-prod-up21.3%

        \[\leadsto d \cdot {\color{blue}{\left({\left(\frac{1}{\ell \cdot h}\right)}^{\left(1 + 0.5\right)}\right)}}^{0.3333333333333333} \]
      7. associate-/r*21.3%

        \[\leadsto d \cdot {\left({\color{blue}{\left(\frac{\frac{1}{\ell}}{h}\right)}}^{\left(1 + 0.5\right)}\right)}^{0.3333333333333333} \]
      8. metadata-eval21.3%

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{\ell}}{h}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    8. Applied egg-rr21.3%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    9. Step-by-step derivation
      1. unpow1/321.3%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{{\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5}}} \]
    10. Simplified21.3%

      \[\leadsto d \cdot \color{blue}{\sqrt[3]{{\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5}}} \]
    11. Step-by-step derivation
      1. *-un-lft-identity21.3%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{1 \cdot {\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5}}} \]
      2. div-inv21.3%

        \[\leadsto d \cdot \sqrt[3]{1 \cdot {\color{blue}{\left(\frac{1}{\ell} \cdot \frac{1}{h}\right)}}^{1.5}} \]
      3. inv-pow21.3%

        \[\leadsto d \cdot \sqrt[3]{1 \cdot {\left(\color{blue}{{\ell}^{-1}} \cdot \frac{1}{h}\right)}^{1.5}} \]
      4. inv-pow21.3%

        \[\leadsto d \cdot \sqrt[3]{1 \cdot {\left({\ell}^{-1} \cdot \color{blue}{{h}^{-1}}\right)}^{1.5}} \]
      5. pow-prod-down21.3%

        \[\leadsto d \cdot \sqrt[3]{1 \cdot {\color{blue}{\left({\left(\ell \cdot h\right)}^{-1}\right)}}^{1.5}} \]
      6. inv-pow21.3%

        \[\leadsto d \cdot \sqrt[3]{1 \cdot {\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{1.5}} \]
    12. Applied egg-rr21.3%

      \[\leadsto d \cdot \sqrt[3]{\color{blue}{1 \cdot {\left(\frac{1}{\ell \cdot h}\right)}^{1.5}}} \]
    13. Step-by-step derivation
      1. *-lft-identity21.3%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{{\left(\frac{1}{\ell \cdot h}\right)}^{1.5}}} \]
      2. rem-exp-log21.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{1.5}} \]
      3. *-commutative21.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(\frac{1}{e^{\log \color{blue}{\left(h \cdot \ell\right)}}}\right)}^{1.5}} \]
      4. exp-neg21.3%

        \[\leadsto d \cdot \sqrt[3]{{\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{1.5}} \]
      5. exp-prod21.3%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 1.5}}} \]
      6. distribute-lft-neg-out21.3%

        \[\leadsto d \cdot \sqrt[3]{e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 1.5}}} \]
      7. distribute-rgt-neg-in21.3%

        \[\leadsto d \cdot \sqrt[3]{e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-1.5\right)}}} \]
      8. *-commutative21.3%

        \[\leadsto d \cdot \sqrt[3]{e^{\log \color{blue}{\left(\ell \cdot h\right)} \cdot \left(-1.5\right)}} \]
      9. exp-to-pow21.3%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{{\left(\ell \cdot h\right)}^{\left(-1.5\right)}}} \]
      10. *-commutative21.3%

        \[\leadsto d \cdot \sqrt[3]{{\color{blue}{\left(h \cdot \ell\right)}}^{\left(-1.5\right)}} \]
      11. metadata-eval21.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{\color{blue}{-1.5}}} \]
    14. Simplified21.3%

      \[\leadsto d \cdot \sqrt[3]{\color{blue}{{\left(h \cdot \ell\right)}^{-1.5}}} \]

    if 8.5000000000000002e-306 < d

    1. Initial program 68.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified68.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 50.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*50.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified50.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity50.9%

        \[\leadsto d \cdot \color{blue}{\left(1 \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)} \]
      2. sqrt-div60.7%

        \[\leadsto d \cdot \left(1 \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}}\right) \]
      3. inv-pow60.7%

        \[\leadsto d \cdot \left(1 \cdot \frac{\sqrt{\color{blue}{{h}^{-1}}}}{\sqrt{\ell}}\right) \]
      4. sqrt-pow160.8%

        \[\leadsto d \cdot \left(1 \cdot \frac{\color{blue}{{h}^{\left(\frac{-1}{2}\right)}}}{\sqrt{\ell}}\right) \]
      5. metadata-eval60.8%

        \[\leadsto d \cdot \left(1 \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}}\right) \]
    8. Applied egg-rr60.8%

      \[\leadsto d \cdot \color{blue}{\left(1 \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\right)} \]
    9. Step-by-step derivation
      1. *-lft-identity60.8%

        \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
    10. Simplified60.8%

      \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification52.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.5 \cdot 10^{+62}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;d \leq -2.45 \cdot 10^{-78}:\\ \;\;\;\;\frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{-306}:\\ \;\;\;\;d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 41.2% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\ \mathbf{if}\;d \leq -1.12 \cdot 10^{+61}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;d \leq -3.1 \cdot 10^{-78}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 2 \cdot 10^{-147}:\\ \;\;\;\;d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}\\ \mathbf{elif}\;d \leq 5.8 \cdot 10^{+16}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (/ (* d (sqrt (/ h l))) h)))
   (if (<= d -1.12e+61)
     (/ (- d) (sqrt (* h l)))
     (if (<= d -3.1e-78)
       t_0
       (if (<= d 2e-147)
         (* d (cbrt (pow (* h l) -1.5)))
         (if (<= d 5.8e+16) t_0 (* d (sqrt (/ (/ 1.0 h) l)))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = (d * sqrt((h / l))) / h;
	double tmp;
	if (d <= -1.12e+61) {
		tmp = -d / sqrt((h * l));
	} else if (d <= -3.1e-78) {
		tmp = t_0;
	} else if (d <= 2e-147) {
		tmp = d * cbrt(pow((h * l), -1.5));
	} else if (d <= 5.8e+16) {
		tmp = t_0;
	} else {
		tmp = d * sqrt(((1.0 / h) / l));
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = (d * Math.sqrt((h / l))) / h;
	double tmp;
	if (d <= -1.12e+61) {
		tmp = -d / Math.sqrt((h * l));
	} else if (d <= -3.1e-78) {
		tmp = t_0;
	} else if (d <= 2e-147) {
		tmp = d * Math.cbrt(Math.pow((h * l), -1.5));
	} else if (d <= 5.8e+16) {
		tmp = t_0;
	} else {
		tmp = d * Math.sqrt(((1.0 / h) / l));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(Float64(d * sqrt(Float64(h / l))) / h)
	tmp = 0.0
	if (d <= -1.12e+61)
		tmp = Float64(Float64(-d) / sqrt(Float64(h * l)));
	elseif (d <= -3.1e-78)
		tmp = t_0;
	elseif (d <= 2e-147)
		tmp = Float64(d * cbrt((Float64(h * l) ^ -1.5)));
	elseif (d <= 5.8e+16)
		tmp = t_0;
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / h) / l)));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(d * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]}, If[LessEqual[d, -1.12e+61], N[((-d) / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -3.1e-78], t$95$0, If[LessEqual[d, 2e-147], N[(d * N[Power[N[Power[N[(h * l), $MachinePrecision], -1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.8e+16], t$95$0, N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\mathbf{if}\;d \leq -1.12 \cdot 10^{+61}:\\
\;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\

\mathbf{elif}\;d \leq -3.1 \cdot 10^{-78}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 2 \cdot 10^{-147}:\\
\;\;\;\;d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}\\

\mathbf{elif}\;d \leq 5.8 \cdot 10^{+16}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.12e61

    1. Initial program 78.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. Simplified80.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 5.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*5.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified5.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. 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}}} \]
    8. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. unpow20.0%

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt68.6%

        \[\leadsto \left(\color{blue}{-1} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. associate-*r*68.6%

        \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. mul-1-neg68.6%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. *-commutative68.6%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      7. rem-exp-log65.0%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}} \]
      8. *-commutative65.0%

        \[\leadsto -d \cdot \sqrt{\frac{1}{e^{\log \color{blue}{\left(h \cdot \ell\right)}}}} \]
      9. exp-neg65.0%

        \[\leadsto -d \cdot \sqrt{\color{blue}{e^{-\log \left(h \cdot \ell\right)}}} \]
      10. unpow1/265.0%

        \[\leadsto -d \cdot \color{blue}{{\left(e^{-\log \left(h \cdot \ell\right)}\right)}^{0.5}} \]
      11. exp-prod65.0%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      12. distribute-lft-neg-out65.0%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      13. exp-neg65.0%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      14. associate-*r/65.0%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      15. *-rgt-identity65.0%

        \[\leadsto -\frac{\color{blue}{d}}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      16. *-commutative65.0%

        \[\leadsto -\frac{d}{e^{\log \color{blue}{\left(\ell \cdot h\right)} \cdot 0.5}} \]
      17. exp-to-pow68.6%

        \[\leadsto -\frac{d}{\color{blue}{{\left(\ell \cdot h\right)}^{0.5}}} \]
      18. unpow1/268.6%

        \[\leadsto -\frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \]
      19. *-commutative68.6%

        \[\leadsto -\frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    9. Simplified68.6%

      \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]

    if -1.12e61 < d < -3.10000000000000018e-78 or 1.9999999999999999e-147 < d < 5.8e16

    1. Initial program 87.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. Simplified86.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt86.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow286.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod86.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow186.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval86.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. frac-times87.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*86.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. pow186.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative86.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr86.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/87.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. *-commutative87.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. associate-*r/86.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. associate-*l*86.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    7. Simplified86.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Taylor expanded in h around 0 24.0%

      \[\leadsto \color{blue}{\frac{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}\right) + d \cdot \sqrt{\frac{h}{\ell}}}{h}} \]
    9. Step-by-step derivation
      1. associate-*r*24.0%

        \[\leadsto \frac{\color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{d}\right) \cdot \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}} + d \cdot \sqrt{\frac{h}{\ell}}}{h} \]
      2. fma-define24.0%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}}{h} \]
      3. unpow224.0%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
      4. unpow224.0%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
      5. swap-sqr25.9%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{\color{blue}{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
      6. unpow225.9%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{\color{blue}{{\left(D \cdot M\right)}^{2}}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
      7. cube-div61.5%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}, \sqrt{\color{blue}{{\left(\frac{h}{\ell}\right)}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
    10. Simplified61.5%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-0.125 \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}, \sqrt{{\left(\frac{h}{\ell}\right)}^{3}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h}} \]
    11. Taylor expanded in D around 0 52.1%

      \[\leadsto \frac{\color{blue}{d \cdot \sqrt{\frac{h}{\ell}}}}{h} \]

    if -3.10000000000000018e-78 < d < 1.9999999999999999e-147

    1. Initial program 43.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. Simplified41.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 19.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative19.0%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified19.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. Step-by-step derivation
      1. add-cbrt-cube22.4%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}}} \]
      2. pow1/322.1%

        \[\leadsto d \cdot \color{blue}{{\left(\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)}^{0.3333333333333333}} \]
      3. add-sqr-sqrt22.1%

        \[\leadsto d \cdot {\left(\color{blue}{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)}^{0.3333333333333333} \]
      4. pow122.1%

        \[\leadsto d \cdot {\left(\color{blue}{{\left(\frac{1}{\ell \cdot h}\right)}^{1}} \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)}^{0.3333333333333333} \]
      5. pow1/222.1%

        \[\leadsto d \cdot {\left({\left(\frac{1}{\ell \cdot h}\right)}^{1} \cdot \color{blue}{{\left(\frac{1}{\ell \cdot h}\right)}^{0.5}}\right)}^{0.3333333333333333} \]
      6. pow-prod-up22.1%

        \[\leadsto d \cdot {\color{blue}{\left({\left(\frac{1}{\ell \cdot h}\right)}^{\left(1 + 0.5\right)}\right)}}^{0.3333333333333333} \]
      7. associate-/r*22.1%

        \[\leadsto d \cdot {\left({\color{blue}{\left(\frac{\frac{1}{\ell}}{h}\right)}}^{\left(1 + 0.5\right)}\right)}^{0.3333333333333333} \]
      8. metadata-eval22.1%

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{\ell}}{h}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    8. Applied egg-rr22.1%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    9. Step-by-step derivation
      1. unpow1/322.5%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{{\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5}}} \]
    10. Simplified22.5%

      \[\leadsto d \cdot \color{blue}{\sqrt[3]{{\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5}}} \]
    11. Step-by-step derivation
      1. *-un-lft-identity22.5%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{1 \cdot {\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5}}} \]
      2. div-inv22.4%

        \[\leadsto d \cdot \sqrt[3]{1 \cdot {\color{blue}{\left(\frac{1}{\ell} \cdot \frac{1}{h}\right)}}^{1.5}} \]
      3. inv-pow22.4%

        \[\leadsto d \cdot \sqrt[3]{1 \cdot {\left(\color{blue}{{\ell}^{-1}} \cdot \frac{1}{h}\right)}^{1.5}} \]
      4. inv-pow22.4%

        \[\leadsto d \cdot \sqrt[3]{1 \cdot {\left({\ell}^{-1} \cdot \color{blue}{{h}^{-1}}\right)}^{1.5}} \]
      5. pow-prod-down22.5%

        \[\leadsto d \cdot \sqrt[3]{1 \cdot {\color{blue}{\left({\left(\ell \cdot h\right)}^{-1}\right)}}^{1.5}} \]
      6. inv-pow22.5%

        \[\leadsto d \cdot \sqrt[3]{1 \cdot {\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{1.5}} \]
    12. Applied egg-rr22.5%

      \[\leadsto d \cdot \sqrt[3]{\color{blue}{1 \cdot {\left(\frac{1}{\ell \cdot h}\right)}^{1.5}}} \]
    13. Step-by-step derivation
      1. *-lft-identity22.5%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{{\left(\frac{1}{\ell \cdot h}\right)}^{1.5}}} \]
      2. rem-exp-log22.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{1.5}} \]
      3. *-commutative22.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(\frac{1}{e^{\log \color{blue}{\left(h \cdot \ell\right)}}}\right)}^{1.5}} \]
      4. exp-neg22.3%

        \[\leadsto d \cdot \sqrt[3]{{\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{1.5}} \]
      5. exp-prod22.1%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 1.5}}} \]
      6. distribute-lft-neg-out22.1%

        \[\leadsto d \cdot \sqrt[3]{e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 1.5}}} \]
      7. distribute-rgt-neg-in22.1%

        \[\leadsto d \cdot \sqrt[3]{e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-1.5\right)}}} \]
      8. *-commutative22.1%

        \[\leadsto d \cdot \sqrt[3]{e^{\log \color{blue}{\left(\ell \cdot h\right)} \cdot \left(-1.5\right)}} \]
      9. exp-to-pow22.4%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{{\left(\ell \cdot h\right)}^{\left(-1.5\right)}}} \]
      10. *-commutative22.4%

        \[\leadsto d \cdot \sqrt[3]{{\color{blue}{\left(h \cdot \ell\right)}}^{\left(-1.5\right)}} \]
      11. metadata-eval22.4%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{\color{blue}{-1.5}}} \]
    14. Simplified22.4%

      \[\leadsto d \cdot \sqrt[3]{\color{blue}{{\left(h \cdot \ell\right)}^{-1.5}}} \]

    if 5.8e16 < d

    1. Initial program 75.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified77.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 69.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*71.5%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified71.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification50.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.12 \cdot 10^{+61}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;d \leq -3.1 \cdot 10^{-78}:\\ \;\;\;\;\frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\ \mathbf{elif}\;d \leq 2 \cdot 10^{-147}:\\ \;\;\;\;d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}\\ \mathbf{elif}\;d \leq 5.8 \cdot 10^{+16}:\\ \;\;\;\;\frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 40.8% accurate, 2.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\ \mathbf{if}\;d \leq -3.2 \cdot 10^{+61}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;d \leq -8.4 \cdot 10^{-76}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 5.3 \cdot 10^{-73}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \mathbf{elif}\;d \leq 5.2 \cdot 10^{+16}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (/ (* d (sqrt (/ h l))) h)))
   (if (<= d -3.2e+61)
     (/ (- d) (sqrt (* h l)))
     (if (<= d -8.4e-76)
       t_0
       (if (<= d 5.3e-73)
         (* d (sqrt (/ 1.0 (* h l))))
         (if (<= d 5.2e+16) t_0 (* d (sqrt (/ (/ 1.0 h) l)))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = (d * sqrt((h / l))) / h;
	double tmp;
	if (d <= -3.2e+61) {
		tmp = -d / sqrt((h * l));
	} else if (d <= -8.4e-76) {
		tmp = t_0;
	} else if (d <= 5.3e-73) {
		tmp = d * sqrt((1.0 / (h * l)));
	} else if (d <= 5.2e+16) {
		tmp = t_0;
	} else {
		tmp = d * sqrt(((1.0 / h) / l));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (d * sqrt((h / l))) / h
    if (d <= (-3.2d+61)) then
        tmp = -d / sqrt((h * l))
    else if (d <= (-8.4d-76)) then
        tmp = t_0
    else if (d <= 5.3d-73) then
        tmp = d * sqrt((1.0d0 / (h * l)))
    else if (d <= 5.2d+16) then
        tmp = t_0
    else
        tmp = d * sqrt(((1.0d0 / h) / l))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = (d * Math.sqrt((h / l))) / h;
	double tmp;
	if (d <= -3.2e+61) {
		tmp = -d / Math.sqrt((h * l));
	} else if (d <= -8.4e-76) {
		tmp = t_0;
	} else if (d <= 5.3e-73) {
		tmp = d * Math.sqrt((1.0 / (h * l)));
	} else if (d <= 5.2e+16) {
		tmp = t_0;
	} else {
		tmp = d * Math.sqrt(((1.0 / h) / l));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = (d * math.sqrt((h / l))) / h
	tmp = 0
	if d <= -3.2e+61:
		tmp = -d / math.sqrt((h * l))
	elif d <= -8.4e-76:
		tmp = t_0
	elif d <= 5.3e-73:
		tmp = d * math.sqrt((1.0 / (h * l)))
	elif d <= 5.2e+16:
		tmp = t_0
	else:
		tmp = d * math.sqrt(((1.0 / h) / l))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(Float64(d * sqrt(Float64(h / l))) / h)
	tmp = 0.0
	if (d <= -3.2e+61)
		tmp = Float64(Float64(-d) / sqrt(Float64(h * l)));
	elseif (d <= -8.4e-76)
		tmp = t_0;
	elseif (d <= 5.3e-73)
		tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * l))));
	elseif (d <= 5.2e+16)
		tmp = t_0;
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / h) / l)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = (d * sqrt((h / l))) / h;
	tmp = 0.0;
	if (d <= -3.2e+61)
		tmp = -d / sqrt((h * l));
	elseif (d <= -8.4e-76)
		tmp = t_0;
	elseif (d <= 5.3e-73)
		tmp = d * sqrt((1.0 / (h * l)));
	elseif (d <= 5.2e+16)
		tmp = t_0;
	else
		tmp = d * sqrt(((1.0 / h) / l));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(d * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]}, If[LessEqual[d, -3.2e+61], N[((-d) / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -8.4e-76], t$95$0, If[LessEqual[d, 5.3e-73], N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.2e+16], t$95$0, N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\mathbf{if}\;d \leq -3.2 \cdot 10^{+61}:\\
\;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\

\mathbf{elif}\;d \leq -8.4 \cdot 10^{-76}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 5.3 \cdot 10^{-73}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\

\mathbf{elif}\;d \leq 5.2 \cdot 10^{+16}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -3.1999999999999998e61

    1. Initial program 78.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. Simplified80.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 5.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*5.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified5.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. 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}}} \]
    8. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. unpow20.0%

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt68.6%

        \[\leadsto \left(\color{blue}{-1} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. associate-*r*68.6%

        \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. mul-1-neg68.6%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. *-commutative68.6%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      7. rem-exp-log65.0%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}} \]
      8. *-commutative65.0%

        \[\leadsto -d \cdot \sqrt{\frac{1}{e^{\log \color{blue}{\left(h \cdot \ell\right)}}}} \]
      9. exp-neg65.0%

        \[\leadsto -d \cdot \sqrt{\color{blue}{e^{-\log \left(h \cdot \ell\right)}}} \]
      10. unpow1/265.0%

        \[\leadsto -d \cdot \color{blue}{{\left(e^{-\log \left(h \cdot \ell\right)}\right)}^{0.5}} \]
      11. exp-prod65.0%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      12. distribute-lft-neg-out65.0%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      13. exp-neg65.0%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      14. associate-*r/65.0%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      15. *-rgt-identity65.0%

        \[\leadsto -\frac{\color{blue}{d}}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      16. *-commutative65.0%

        \[\leadsto -\frac{d}{e^{\log \color{blue}{\left(\ell \cdot h\right)} \cdot 0.5}} \]
      17. exp-to-pow68.6%

        \[\leadsto -\frac{d}{\color{blue}{{\left(\ell \cdot h\right)}^{0.5}}} \]
      18. unpow1/268.6%

        \[\leadsto -\frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \]
      19. *-commutative68.6%

        \[\leadsto -\frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    9. Simplified68.6%

      \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]

    if -3.1999999999999998e61 < d < -8.39999999999999969e-76 or 5.29999999999999972e-73 < d < 5.2e16

    1. Initial program 89.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. Simplified89.5%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt89.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow289.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod89.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow189.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval89.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. frac-times89.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*89.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. pow189.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative89.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr89.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/89.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. *-commutative89.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. associate-*r/87.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. associate-*l*87.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    7. Simplified87.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Taylor expanded in h around 0 20.3%

      \[\leadsto \color{blue}{\frac{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}\right) + d \cdot \sqrt{\frac{h}{\ell}}}{h}} \]
    9. Step-by-step derivation
      1. associate-*r*20.3%

        \[\leadsto \frac{\color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{d}\right) \cdot \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}} + d \cdot \sqrt{\frac{h}{\ell}}}{h} \]
      2. fma-define20.3%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}}{h} \]
      3. unpow220.3%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
      4. unpow220.3%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
      5. swap-sqr22.5%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{\color{blue}{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
      6. unpow222.5%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{\color{blue}{{\left(D \cdot M\right)}^{2}}}{d}, \sqrt{\frac{{h}^{3}}{{\ell}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
      7. cube-div60.5%

        \[\leadsto \frac{\mathsf{fma}\left(-0.125 \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}, \sqrt{\color{blue}{{\left(\frac{h}{\ell}\right)}^{3}}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
    10. Simplified60.5%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-0.125 \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}, \sqrt{{\left(\frac{h}{\ell}\right)}^{3}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h}} \]
    11. Taylor expanded in D around 0 53.4%

      \[\leadsto \frac{\color{blue}{d \cdot \sqrt{\frac{h}{\ell}}}}{h} \]

    if -8.39999999999999969e-76 < d < 5.29999999999999972e-73

    1. Initial program 46.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. Simplified43.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 22.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative22.6%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified22.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]

    if 5.2e16 < d

    1. Initial program 75.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified77.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 69.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*71.5%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified71.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification49.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.2 \cdot 10^{+61}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;d \leq -8.4 \cdot 10^{-76}:\\ \;\;\;\;\frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\ \mathbf{elif}\;d \leq 5.3 \cdot 10^{-73}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \mathbf{elif}\;d \leq 5.2 \cdot 10^{+16}:\\ \;\;\;\;\frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 42.1% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -7.2 \cdot 10^{-137}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= d -7.2e-137) (/ (- d) (sqrt (* h l))) (* d (sqrt (/ (/ 1.0 h) l)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -7.2e-137) {
		tmp = -d / sqrt((h * l));
	} else {
		tmp = d * sqrt(((1.0 / h) / l));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (d <= (-7.2d-137)) then
        tmp = -d / sqrt((h * l))
    else
        tmp = d * sqrt(((1.0d0 / h) / l))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -7.2e-137) {
		tmp = -d / Math.sqrt((h * l));
	} else {
		tmp = d * Math.sqrt(((1.0 / h) / l));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if d <= -7.2e-137:
		tmp = -d / math.sqrt((h * l))
	else:
		tmp = d * math.sqrt(((1.0 / h) / l))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (d <= -7.2e-137)
		tmp = Float64(Float64(-d) / sqrt(Float64(h * l)));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / h) / l)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (d <= -7.2e-137)
		tmp = -d / sqrt((h * l));
	else
		tmp = d * sqrt(((1.0 / h) / l));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, -7.2e-137], N[((-d) / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.2 \cdot 10^{-137}:\\
\;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -7.20000000000000013e-137

    1. Initial program 79.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. Simplified78.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. Taylor expanded in d around inf 8.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*8.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified8.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. 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}}} \]
    8. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. unpow20.0%

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt47.0%

        \[\leadsto \left(\color{blue}{-1} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. associate-*r*47.0%

        \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. mul-1-neg47.0%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. *-commutative47.0%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      7. rem-exp-log44.5%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}} \]
      8. *-commutative44.5%

        \[\leadsto -d \cdot \sqrt{\frac{1}{e^{\log \color{blue}{\left(h \cdot \ell\right)}}}} \]
      9. exp-neg44.5%

        \[\leadsto -d \cdot \sqrt{\color{blue}{e^{-\log \left(h \cdot \ell\right)}}} \]
      10. unpow1/244.5%

        \[\leadsto -d \cdot \color{blue}{{\left(e^{-\log \left(h \cdot \ell\right)}\right)}^{0.5}} \]
      11. exp-prod44.9%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      12. distribute-lft-neg-out44.9%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      13. exp-neg44.9%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      14. associate-*r/44.9%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      15. *-rgt-identity44.9%

        \[\leadsto -\frac{\color{blue}{d}}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      16. *-commutative44.9%

        \[\leadsto -\frac{d}{e^{\log \color{blue}{\left(\ell \cdot h\right)} \cdot 0.5}} \]
      17. exp-to-pow47.4%

        \[\leadsto -\frac{d}{\color{blue}{{\left(\ell \cdot h\right)}^{0.5}}} \]
      18. unpow1/247.4%

        \[\leadsto -\frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \]
      19. *-commutative47.4%

        \[\leadsto -\frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    9. Simplified47.4%

      \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]

    if -7.20000000000000013e-137 < d

    1. Initial program 61.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. Simplified61.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 41.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*42.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified42.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification44.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.2 \cdot 10^{-137}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 42.0% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -9.5 \cdot 10^{-137}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= d -9.5e-137) (/ (- d) (sqrt (* h l))) (* d (sqrt (/ 1.0 (* h l))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -9.5e-137) {
		tmp = -d / sqrt((h * l));
	} else {
		tmp = d * sqrt((1.0 / (h * l)));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (d <= (-9.5d-137)) then
        tmp = -d / sqrt((h * l))
    else
        tmp = d * sqrt((1.0d0 / (h * l)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -9.5e-137) {
		tmp = -d / Math.sqrt((h * l));
	} else {
		tmp = d * Math.sqrt((1.0 / (h * l)));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if d <= -9.5e-137:
		tmp = -d / math.sqrt((h * l))
	else:
		tmp = d * math.sqrt((1.0 / (h * l)))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (d <= -9.5e-137)
		tmp = Float64(Float64(-d) / sqrt(Float64(h * l)));
	else
		tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * l))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (d <= -9.5e-137)
		tmp = -d / sqrt((h * l));
	else
		tmp = d * sqrt((1.0 / (h * l)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, -9.5e-137], N[((-d) / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9.5 \cdot 10^{-137}:\\
\;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -9.5000000000000007e-137

    1. Initial program 79.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. Simplified78.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. Taylor expanded in d around inf 8.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*8.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified8.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. 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}}} \]
    8. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. unpow20.0%

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt47.0%

        \[\leadsto \left(\color{blue}{-1} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. associate-*r*47.0%

        \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. mul-1-neg47.0%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. *-commutative47.0%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      7. rem-exp-log44.5%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}} \]
      8. *-commutative44.5%

        \[\leadsto -d \cdot \sqrt{\frac{1}{e^{\log \color{blue}{\left(h \cdot \ell\right)}}}} \]
      9. exp-neg44.5%

        \[\leadsto -d \cdot \sqrt{\color{blue}{e^{-\log \left(h \cdot \ell\right)}}} \]
      10. unpow1/244.5%

        \[\leadsto -d \cdot \color{blue}{{\left(e^{-\log \left(h \cdot \ell\right)}\right)}^{0.5}} \]
      11. exp-prod44.9%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      12. distribute-lft-neg-out44.9%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      13. exp-neg44.9%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      14. associate-*r/44.9%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      15. *-rgt-identity44.9%

        \[\leadsto -\frac{\color{blue}{d}}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      16. *-commutative44.9%

        \[\leadsto -\frac{d}{e^{\log \color{blue}{\left(\ell \cdot h\right)} \cdot 0.5}} \]
      17. exp-to-pow47.4%

        \[\leadsto -\frac{d}{\color{blue}{{\left(\ell \cdot h\right)}^{0.5}}} \]
      18. unpow1/247.4%

        \[\leadsto -\frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \]
      19. *-commutative47.4%

        \[\leadsto -\frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    9. Simplified47.4%

      \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]

    if -9.5000000000000007e-137 < d

    1. Initial program 61.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. Simplified61.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 41.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative41.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified41.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification44.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9.5 \cdot 10^{-137}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 42.0% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -9 \cdot 10^{-136}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= d -9e-136) (/ (- d) (sqrt (* h l))) (* d (pow (* h l) -0.5))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -9e-136) {
		tmp = -d / sqrt((h * l));
	} else {
		tmp = d * pow((h * l), -0.5);
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (d <= (-9d-136)) then
        tmp = -d / sqrt((h * l))
    else
        tmp = d * ((h * l) ** (-0.5d0))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -9e-136) {
		tmp = -d / Math.sqrt((h * l));
	} else {
		tmp = d * Math.pow((h * l), -0.5);
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if d <= -9e-136:
		tmp = -d / math.sqrt((h * l))
	else:
		tmp = d * math.pow((h * l), -0.5)
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (d <= -9e-136)
		tmp = Float64(Float64(-d) / sqrt(Float64(h * l)));
	else
		tmp = Float64(d * (Float64(h * l) ^ -0.5));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (d <= -9e-136)
		tmp = -d / sqrt((h * l));
	else
		tmp = d * ((h * l) ^ -0.5);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, -9e-136], N[((-d) / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9 \cdot 10^{-136}:\\
\;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -8.99999999999999944e-136

    1. Initial program 79.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. Simplified78.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. Taylor expanded in d around inf 8.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*8.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified8.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. 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}}} \]
    8. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. unpow20.0%

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt47.0%

        \[\leadsto \left(\color{blue}{-1} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. associate-*r*47.0%

        \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. mul-1-neg47.0%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. *-commutative47.0%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      7. rem-exp-log44.5%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}} \]
      8. *-commutative44.5%

        \[\leadsto -d \cdot \sqrt{\frac{1}{e^{\log \color{blue}{\left(h \cdot \ell\right)}}}} \]
      9. exp-neg44.5%

        \[\leadsto -d \cdot \sqrt{\color{blue}{e^{-\log \left(h \cdot \ell\right)}}} \]
      10. unpow1/244.5%

        \[\leadsto -d \cdot \color{blue}{{\left(e^{-\log \left(h \cdot \ell\right)}\right)}^{0.5}} \]
      11. exp-prod44.9%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      12. distribute-lft-neg-out44.9%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      13. exp-neg44.9%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      14. associate-*r/44.9%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      15. *-rgt-identity44.9%

        \[\leadsto -\frac{\color{blue}{d}}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      16. *-commutative44.9%

        \[\leadsto -\frac{d}{e^{\log \color{blue}{\left(\ell \cdot h\right)} \cdot 0.5}} \]
      17. exp-to-pow47.4%

        \[\leadsto -\frac{d}{\color{blue}{{\left(\ell \cdot h\right)}^{0.5}}} \]
      18. unpow1/247.4%

        \[\leadsto -\frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \]
      19. *-commutative47.4%

        \[\leadsto -\frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    9. Simplified47.4%

      \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]

    if -8.99999999999999944e-136 < d

    1. Initial program 61.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. Simplified61.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 41.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative41.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified41.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. Taylor expanded in l around 0 41.9%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. *-commutative41.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. unpow-141.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(\ell \cdot h\right)}^{-1}}} \]
      3. metadata-eval41.9%

        \[\leadsto d \cdot \sqrt{{\left(\ell \cdot h\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      4. pow-sqr41.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(\ell \cdot h\right)}^{-0.5} \cdot {\left(\ell \cdot h\right)}^{-0.5}}} \]
      5. rem-sqrt-square41.8%

        \[\leadsto d \cdot \color{blue}{\left|{\left(\ell \cdot h\right)}^{-0.5}\right|} \]
      6. rem-square-sqrt41.6%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(\ell \cdot h\right)}^{-0.5}} \cdot \sqrt{{\left(\ell \cdot h\right)}^{-0.5}}}\right| \]
      7. fabs-sqr41.6%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(\ell \cdot h\right)}^{-0.5}} \cdot \sqrt{{\left(\ell \cdot h\right)}^{-0.5}}\right)} \]
      8. rem-square-sqrt41.8%

        \[\leadsto d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
    9. Simplified41.8%

      \[\leadsto d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification44.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9 \cdot 10^{-136}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 42.0% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{h \cdot \ell}\\ \mathbf{if}\;d \leq -1.35 \cdot 10^{-136}:\\ \;\;\;\;\frac{-d}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{t\_0}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (* h l)))) (if (<= d -1.35e-136) (/ (- d) t_0) (/ d t_0))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt((h * l));
	double tmp;
	if (d <= -1.35e-136) {
		tmp = -d / t_0;
	} else {
		tmp = d / t_0;
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((h * l))
    if (d <= (-1.35d-136)) then
        tmp = -d / t_0
    else
        tmp = d / t_0
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = Math.sqrt((h * l));
	double tmp;
	if (d <= -1.35e-136) {
		tmp = -d / t_0;
	} else {
		tmp = d / t_0;
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = math.sqrt((h * l))
	tmp = 0
	if d <= -1.35e-136:
		tmp = -d / t_0
	else:
		tmp = d / t_0
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = sqrt(Float64(h * l))
	tmp = 0.0
	if (d <= -1.35e-136)
		tmp = Float64(Float64(-d) / t_0);
	else
		tmp = Float64(d / t_0);
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = sqrt((h * l));
	tmp = 0.0;
	if (d <= -1.35e-136)
		tmp = -d / t_0;
	else
		tmp = d / t_0;
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -1.35e-136], N[((-d) / t$95$0), $MachinePrecision], N[(d / t$95$0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;d \leq -1.35 \cdot 10^{-136}:\\
\;\;\;\;\frac{-d}{t\_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.3499999999999999e-136

    1. Initial program 79.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. Simplified78.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. Taylor expanded in d around inf 8.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*8.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified8.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. 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}}} \]
    8. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. unpow20.0%

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. rem-square-sqrt47.0%

        \[\leadsto \left(\color{blue}{-1} \cdot d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      4. associate-*r*47.0%

        \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. mul-1-neg47.0%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      6. *-commutative47.0%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      7. rem-exp-log44.5%

        \[\leadsto -d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}} \]
      8. *-commutative44.5%

        \[\leadsto -d \cdot \sqrt{\frac{1}{e^{\log \color{blue}{\left(h \cdot \ell\right)}}}} \]
      9. exp-neg44.5%

        \[\leadsto -d \cdot \sqrt{\color{blue}{e^{-\log \left(h \cdot \ell\right)}}} \]
      10. unpow1/244.5%

        \[\leadsto -d \cdot \color{blue}{{\left(e^{-\log \left(h \cdot \ell\right)}\right)}^{0.5}} \]
      11. exp-prod44.9%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      12. distribute-lft-neg-out44.9%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      13. exp-neg44.9%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      14. associate-*r/44.9%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      15. *-rgt-identity44.9%

        \[\leadsto -\frac{\color{blue}{d}}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      16. *-commutative44.9%

        \[\leadsto -\frac{d}{e^{\log \color{blue}{\left(\ell \cdot h\right)} \cdot 0.5}} \]
      17. exp-to-pow47.4%

        \[\leadsto -\frac{d}{\color{blue}{{\left(\ell \cdot h\right)}^{0.5}}} \]
      18. unpow1/247.4%

        \[\leadsto -\frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \]
      19. *-commutative47.4%

        \[\leadsto -\frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    9. Simplified47.4%

      \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]

    if -1.3499999999999999e-136 < d

    1. Initial program 61.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. Simplified61.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 41.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*42.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified42.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. Taylor expanded in d around 0 41.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. *-commutative41.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. rem-exp-log39.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}} \]
      3. *-commutative39.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{e^{\log \color{blue}{\left(h \cdot \ell\right)}}}} \]
      4. exp-neg39.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{e^{-\log \left(h \cdot \ell\right)}}} \]
      5. unpow1/239.9%

        \[\leadsto d \cdot \color{blue}{{\left(e^{-\log \left(h \cdot \ell\right)}\right)}^{0.5}} \]
      6. exp-prod39.7%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      7. distribute-lft-neg-out39.7%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      8. exp-neg39.7%

        \[\leadsto d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      9. associate-*r/39.7%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      10. *-rgt-identity39.7%

        \[\leadsto \frac{\color{blue}{d}}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      11. *-commutative39.7%

        \[\leadsto \frac{d}{e^{\log \color{blue}{\left(\ell \cdot h\right)} \cdot 0.5}} \]
      12. exp-to-pow41.8%

        \[\leadsto \frac{d}{\color{blue}{{\left(\ell \cdot h\right)}^{0.5}}} \]
      13. unpow1/241.8%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \]
      14. *-commutative41.8%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    9. Simplified41.8%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification44.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.35 \cdot 10^{-136}:\\ \;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 21: 26.6% accurate, 3.2× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \frac{d}{\sqrt{h \cdot \ell}} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (/ d (sqrt (* h l))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d / sqrt((h * l));
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d / sqrt((h * l))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d / Math.sqrt((h * l));
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d / math.sqrt((h * l))
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d / sqrt(Float64(h * l)))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d / sqrt((h * l));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\frac{d}{\sqrt{h \cdot \ell}}
\end{array}
Derivation
  1. Initial program 68.5%

    \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  2. Simplified68.1%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in d around inf 28.0%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  5. Step-by-step derivation
    1. associate-/r*28.4%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
  6. Simplified28.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  7. Taylor expanded in d around 0 28.0%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  8. Step-by-step derivation
    1. *-commutative28.0%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    2. rem-exp-log26.8%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}} \]
    3. *-commutative26.8%

      \[\leadsto d \cdot \sqrt{\frac{1}{e^{\log \color{blue}{\left(h \cdot \ell\right)}}}} \]
    4. exp-neg26.8%

      \[\leadsto d \cdot \sqrt{\color{blue}{e^{-\log \left(h \cdot \ell\right)}}} \]
    5. unpow1/226.8%

      \[\leadsto d \cdot \color{blue}{{\left(e^{-\log \left(h \cdot \ell\right)}\right)}^{0.5}} \]
    6. exp-prod26.7%

      \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
    7. distribute-lft-neg-out26.7%

      \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
    8. exp-neg26.7%

      \[\leadsto d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
    9. associate-*r/26.7%

      \[\leadsto \color{blue}{\frac{d \cdot 1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
    10. *-rgt-identity26.7%

      \[\leadsto \frac{\color{blue}{d}}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}} \]
    11. *-commutative26.7%

      \[\leadsto \frac{d}{e^{\log \color{blue}{\left(\ell \cdot h\right)} \cdot 0.5}} \]
    12. exp-to-pow27.9%

      \[\leadsto \frac{d}{\color{blue}{{\left(\ell \cdot h\right)}^{0.5}}} \]
    13. unpow1/227.9%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \]
    14. *-commutative27.9%

      \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
  9. Simplified27.9%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  10. Add Preprocessing

Reproduce

?
herbie shell --seed 2024085 
(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)))))