Henrywood and Agarwal, Equation (12)

Percentage Accurate: 67.4% → 79.7%
Time: 29.2s
Alternatives: 18
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 18 alternatives:

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

Initial Program: 67.4% 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: 79.7% accurate, 0.6× speedup?

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

\mathbf{elif}\;d \leq 1.8 \cdot 10^{-157}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(t_0, {\left(M_m \cdot \left(0.5 \cdot \frac{D_m}{d}\right)\right)}^{2}, 1\right)}{\sqrt{h \cdot \ell}}\\

\mathbf{elif}\;d \leq 1.35 \cdot 10^{+143}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\left(0.5 \cdot D_m\right) \cdot \sqrt{h}}{\frac{d}{M_m} \cdot \sqrt{\ell}}\right)}^{2}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(1 + t_0 \cdot {\left(0.5 \cdot \frac{D_m \cdot M_m}{d}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


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

    1. Initial program 70.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. 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{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. frac-2neg70.9%

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

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

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

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

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

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

    if -1.999999999999994e-310 < d < 1.8e-157

    1. Initial program 21.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. Simplified21.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.8e-157 < d < 1.3500000000000001e143

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

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. add-sqr-sqrt80.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{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow280.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{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod80.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{D}{2} \cdot \frac{M}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. frac-times80.2%

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. add-sqr-sqrt84.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)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      10. div-inv84.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3500000000000001e143 < d

    1. Initial program 68.6%

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

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

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

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

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

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

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

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

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

Alternative 2: 77.2% accurate, 0.6× speedup?

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

\mathbf{elif}\;d \leq 7.6 \cdot 10^{-128}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(t_1, {\left(M_m \cdot \left(0.5 \cdot \frac{D_m}{d}\right)\right)}^{2}, 1\right)}{\sqrt{h \cdot \ell}}\\

\mathbf{elif}\;d \leq 1.45 \cdot 10^{+145}:\\
\;\;\;\;\left(t_0 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(t_2 \cdot \frac{\sqrt{h}}{\sqrt{\ell}}\right)}^{2}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(1 + t_1 \cdot {\left(0.5 \cdot \frac{D_m \cdot M_m}{d}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


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

    1. Initial program 70.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. 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{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. associate-*r/72.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < d < 7.6000000000000005e-128

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.6000000000000005e-128 < d < 1.45e145

    1. Initial program 79.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. 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{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. add-sqr-sqrt79.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{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow279.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{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod79.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{D}{2} \cdot \frac{M}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. frac-times79.4%

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

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

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

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

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

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

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

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

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

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

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

    if 1.45e145 < d

    1. Initial program 68.6%

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

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

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

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

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

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

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

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

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

Alternative 3: 76.6% accurate, 0.6× speedup?

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

\mathbf{elif}\;d \leq 2.2 \cdot 10^{-161}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(t_1, {\left(M_m \cdot \left(0.5 \cdot \frac{D_m}{d}\right)\right)}^{2}, 1\right)}{\sqrt{h \cdot \ell}}\\

\mathbf{elif}\;d \leq 1.05 \cdot 10^{+144}:\\
\;\;\;\;\left(t_0 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\left(0.5 \cdot D_m\right) \cdot \sqrt{h}}{\frac{d}{M_m} \cdot \sqrt{\ell}}\right)}^{2}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(1 + t_1 \cdot {\left(0.5 \cdot \frac{D_m \cdot M_m}{d}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


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

    1. Initial program 70.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. 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{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. associate-*r/72.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < d < 2.20000000000000002e-161

    1. Initial program 21.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. Simplified21.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.20000000000000002e-161 < d < 1.04999999999999998e144

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

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. add-sqr-sqrt80.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{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow280.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{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod80.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{D}{2} \cdot \frac{M}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. frac-times80.2%

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. add-sqr-sqrt84.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)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      10. div-inv84.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.04999999999999998e144 < d

    1. Initial program 68.6%

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

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

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

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

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

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

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

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

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

Alternative 4: 76.7% accurate, 0.8× speedup?

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

\mathbf{elif}\;d \leq 2 \cdot 10^{-206}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(t_0, {\left(M_m \cdot \left(0.5 \cdot \frac{D_m}{d}\right)\right)}^{2}, 1\right)}{\sqrt{h \cdot \ell}}\\

\mathbf{else}:\\
\;\;\;\;\left(1 + t_0 \cdot {\left(0.5 \cdot \frac{D_m \cdot M_m}{d}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


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

    1. Initial program 70.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. 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{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. frac-2neg70.9%

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

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

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

    if -1.999999999999994e-310 < d < 2.00000000000000006e-206

    1. Initial program 14.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. Simplified14.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000006e-206 < d

    1. Initial program 73.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. Simplified73.2%

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

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

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

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

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

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

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

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

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

\mathbf{elif}\;d \leq 2.5 \cdot 10^{-206}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(t_0, {\left(M_m \cdot \left(0.5 \cdot \frac{D_m}{d}\right)\right)}^{2}, 1\right)}{\sqrt{h \cdot \ell}}\\

\mathbf{else}:\\
\;\;\;\;\left(1 + t_0 \cdot {\left(0.5 \cdot \frac{D_m \cdot M_m}{d}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


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

    1. Initial program 70.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. 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{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. associate-*r/72.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < d < 2.5e-206

    1. Initial program 14.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. Simplified14.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.5e-206 < d

    1. Initial program 73.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. Simplified73.2%

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

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

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

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

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

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

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

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

Alternative 6: 75.4% accurate, 1.0× speedup?

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

\mathbf{elif}\;\ell \leq 4.3 \cdot 10^{-302}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{0.5 \cdot D_m}{\frac{d}{M_m}}\right)}^{2}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(0.5 \cdot \frac{D_m \cdot M_m}{d}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


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

    1. Initial program 52.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. Simplified55.8%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    6. Step-by-step derivation
      1. mul-1-neg58.0%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in58.0%

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

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
      4. unpow1/258.0%

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

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

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

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

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

        \[\leadsto d \cdot \left(-e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \]
      10. distribute-rgt-neg-in54.8%

        \[\leadsto d \cdot \left(-e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}}\right) \]
      11. metadata-eval54.8%

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

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

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    8. Taylor expanded in l around -inf 73.0%

      \[\leadsto d \cdot \left(-\color{blue}{e^{-0.5 \cdot \left(\log \left(-1 \cdot h\right) + -1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}}\right) \]
    9. Step-by-step derivation
      1. distribute-lft-in73.0%

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

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

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

        \[\leadsto d \cdot \left(-\color{blue}{{\left(-1 \cdot h\right)}^{-0.5}} \cdot e^{-0.5 \cdot \left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}\right) \]
      5. mul-1-neg73.2%

        \[\leadsto d \cdot \left(-{\color{blue}{\left(-h\right)}}^{-0.5} \cdot e^{-0.5 \cdot \left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}\right) \]
      6. *-commutative73.2%

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right) \cdot -0.5}}\right) \]
      7. *-commutative73.2%

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(\log \left(\frac{-1}{\ell}\right) \cdot -1\right)} \cdot -0.5}\right) \]
      8. associate-*l*73.2%

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

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

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

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

    if -9.4000000000000004e144 < l < 4.3000000000000002e-302

    1. Initial program 76.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. Simplified74.6%

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

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

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

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

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

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

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

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

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

    if 4.3000000000000002e-302 < l

    1. Initial program 63.8%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9.4 \cdot 10^{+144}:\\ \;\;\;\;d \cdot \left({\left(-h\right)}^{-0.5} \cdot \left(-{\left(\frac{-1}{\ell}\right)}^{0.5}\right)\right)\\ \mathbf{elif}\;\ell \leq 4.3 \cdot 10^{-302}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{0.5 \cdot D}{\frac{d}{M}}\right)}^{2}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(0.5 \cdot \frac{D \cdot M}{d}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

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

\mathbf{elif}\;\ell \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{-0.5 \cdot \left({t_0}^{2} \cdot 0.25\right)}{\frac{\ell}{h}}\right)\right)\\

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


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

    1. Initial program 52.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. Simplified55.8%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    6. Step-by-step derivation
      1. mul-1-neg58.0%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in58.0%

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

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
      4. unpow1/258.0%

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

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

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

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

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

        \[\leadsto d \cdot \left(-e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \]
      10. distribute-rgt-neg-in54.8%

        \[\leadsto d \cdot \left(-e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}}\right) \]
      11. metadata-eval54.8%

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

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

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    8. Taylor expanded in l around -inf 73.0%

      \[\leadsto d \cdot \left(-\color{blue}{e^{-0.5 \cdot \left(\log \left(-1 \cdot h\right) + -1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}}\right) \]
    9. Step-by-step derivation
      1. distribute-lft-in73.0%

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

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

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

        \[\leadsto d \cdot \left(-\color{blue}{{\left(-1 \cdot h\right)}^{-0.5}} \cdot e^{-0.5 \cdot \left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}\right) \]
      5. mul-1-neg73.2%

        \[\leadsto d \cdot \left(-{\color{blue}{\left(-h\right)}}^{-0.5} \cdot e^{-0.5 \cdot \left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}\right) \]
      6. *-commutative73.2%

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right) \cdot -0.5}}\right) \]
      7. *-commutative73.2%

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(\log \left(\frac{-1}{\ell}\right) \cdot -1\right)} \cdot -0.5}\right) \]
      8. associate-*l*73.2%

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

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

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

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

    if -4.29999999999999998e145 < l < -1.000000000000002e-309

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < l

    1. Initial program 63.6%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.3 \cdot 10^{+145}:\\ \;\;\;\;d \cdot \left({\left(-h\right)}^{-0.5} \cdot \left(-{\left(\frac{-1}{\ell}\right)}^{0.5}\right)\right)\\ \mathbf{elif}\;\ell \leq -1 \cdot 10^{-309}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{-0.5 \cdot \left({\left(\frac{D \cdot M}{d}\right)}^{2} \cdot 0.25\right)}{\frac{\ell}{h}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(0.5 \cdot \frac{D \cdot M}{d}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 8: 76.4% accurate, 1.0× speedup?

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

\mathbf{elif}\;\ell \leq 4.7 \cdot 10^{-290}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{D_m}{d} \cdot \left(0.5 \cdot M_m\right)\right)}^{2}}{\ell}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(0.5 \cdot \frac{D_m \cdot M_m}{d}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


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

    1. Initial program 52.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. Simplified55.8%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    6. Step-by-step derivation
      1. mul-1-neg58.0%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in58.0%

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

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
      4. unpow1/258.0%

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

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

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

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

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

        \[\leadsto d \cdot \left(-e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \]
      10. distribute-rgt-neg-in54.8%

        \[\leadsto d \cdot \left(-e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}}\right) \]
      11. metadata-eval54.8%

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

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

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    8. Taylor expanded in l around -inf 73.0%

      \[\leadsto d \cdot \left(-\color{blue}{e^{-0.5 \cdot \left(\log \left(-1 \cdot h\right) + -1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}}\right) \]
    9. Step-by-step derivation
      1. distribute-lft-in73.0%

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

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

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

        \[\leadsto d \cdot \left(-\color{blue}{{\left(-1 \cdot h\right)}^{-0.5}} \cdot e^{-0.5 \cdot \left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}\right) \]
      5. mul-1-neg73.2%

        \[\leadsto d \cdot \left(-{\color{blue}{\left(-h\right)}}^{-0.5} \cdot e^{-0.5 \cdot \left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}\right) \]
      6. *-commutative73.2%

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right) \cdot -0.5}}\right) \]
      7. *-commutative73.2%

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(\log \left(\frac{-1}{\ell}\right) \cdot -1\right)} \cdot -0.5}\right) \]
      8. associate-*l*73.2%

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

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

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

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

    if -2.3500000000000001e144 < l < 4.7000000000000001e-290

    1. Initial program 76.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. Simplified75.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.7000000000000001e-290 < l

    1. Initial program 63.8%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.35 \cdot 10^{+144}:\\ \;\;\;\;d \cdot \left({\left(-h\right)}^{-0.5} \cdot \left(-{\left(\frac{-1}{\ell}\right)}^{0.5}\right)\right)\\ \mathbf{elif}\;\ell \leq 4.7 \cdot 10^{-290}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{D}{d} \cdot \left(0.5 \cdot M\right)\right)}^{2}}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(0.5 \cdot \frac{D \cdot M}{d}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 9: 71.9% accurate, 1.0× speedup?

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

\mathbf{elif}\;\ell \leq 2.4 \cdot 10^{-208}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.125 \cdot {\left(D_m \cdot \frac{M_m}{d}\right)}^{2}\right)\right)\right)\\

\mathbf{elif}\;\ell \leq 1.5 \cdot 10^{+122}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(M_m \cdot \left(0.5 \cdot \frac{D_m}{d}\right)\right)}^{2}, 1\right)}{\sqrt{h \cdot \ell}}\\

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


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

    1. Initial program 52.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. Simplified55.8%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    6. Step-by-step derivation
      1. mul-1-neg58.0%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in58.0%

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

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
      4. unpow1/258.0%

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

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

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

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

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

        \[\leadsto d \cdot \left(-e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \]
      10. distribute-rgt-neg-in54.8%

        \[\leadsto d \cdot \left(-e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}}\right) \]
      11. metadata-eval54.8%

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

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

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    8. Taylor expanded in l around -inf 73.0%

      \[\leadsto d \cdot \left(-\color{blue}{e^{-0.5 \cdot \left(\log \left(-1 \cdot h\right) + -1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}}\right) \]
    9. Step-by-step derivation
      1. distribute-lft-in73.0%

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

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

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

        \[\leadsto d \cdot \left(-\color{blue}{{\left(-1 \cdot h\right)}^{-0.5}} \cdot e^{-0.5 \cdot \left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}\right) \]
      5. mul-1-neg73.2%

        \[\leadsto d \cdot \left(-{\color{blue}{\left(-h\right)}}^{-0.5} \cdot e^{-0.5 \cdot \left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}\right) \]
      6. *-commutative73.2%

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right) \cdot -0.5}}\right) \]
      7. *-commutative73.2%

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(\log \left(\frac{-1}{\ell}\right) \cdot -1\right)} \cdot -0.5}\right) \]
      8. associate-*l*73.2%

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

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

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

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

    if -2.4000000000000002e146 < l < 2.3999999999999999e-208

    1. Initial program 76.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. Simplified75.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot \left(-0.5 \cdot \left({\left(\frac{D \cdot M}{d}\right)}^{2} \cdot \color{blue}{0.25}\right)\right)\right)} - 1\right)\right)\right) \]
    6. Applied egg-rr36.9%

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

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

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

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

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

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

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

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

    if 2.3999999999999999e-208 < l < 1.49999999999999993e122

    1. Initial program 73.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. Simplified73.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.49999999999999993e122 < l

    1. Initial program 44.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. Simplified44.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in41.0%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval41.0%

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    9. Applied egg-rr58.4%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification76.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.4 \cdot 10^{+146}:\\ \;\;\;\;d \cdot \left({\left(-h\right)}^{-0.5} \cdot \left(-{\left(\frac{-1}{\ell}\right)}^{0.5}\right)\right)\\ \mathbf{elif}\;\ell \leq 2.4 \cdot 10^{-208}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 1.5 \cdot 10^{+122}:\\ \;\;\;\;\frac{d \cdot \mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}, 1\right)}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]

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

\mathbf{elif}\;\ell \leq 4.3 \cdot 10^{-302}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.125 \cdot {\left(D_m \cdot \frac{M_m}{d}\right)}^{2}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(0.5 \cdot \frac{D_m \cdot M_m}{d}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


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

    1. Initial program 52.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. Simplified55.8%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    6. Step-by-step derivation
      1. mul-1-neg58.0%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in58.0%

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

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
      4. unpow1/258.0%

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

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

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

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

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

        \[\leadsto d \cdot \left(-e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \]
      10. distribute-rgt-neg-in54.8%

        \[\leadsto d \cdot \left(-e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}}\right) \]
      11. metadata-eval54.8%

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

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

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    8. Taylor expanded in l around -inf 73.0%

      \[\leadsto d \cdot \left(-\color{blue}{e^{-0.5 \cdot \left(\log \left(-1 \cdot h\right) + -1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}}\right) \]
    9. Step-by-step derivation
      1. distribute-lft-in73.0%

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

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

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

        \[\leadsto d \cdot \left(-\color{blue}{{\left(-1 \cdot h\right)}^{-0.5}} \cdot e^{-0.5 \cdot \left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}\right) \]
      5. mul-1-neg73.2%

        \[\leadsto d \cdot \left(-{\color{blue}{\left(-h\right)}}^{-0.5} \cdot e^{-0.5 \cdot \left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}\right) \]
      6. *-commutative73.2%

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right) \cdot -0.5}}\right) \]
      7. *-commutative73.2%

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(\log \left(\frac{-1}{\ell}\right) \cdot -1\right)} \cdot -0.5}\right) \]
      8. associate-*l*73.2%

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

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

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

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

    if -5.60000000000000013e144 < l < 4.3000000000000002e-302

    1. Initial program 76.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. Simplified74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot \left(-0.5 \cdot \left({\left(\frac{D \cdot M}{d}\right)}^{2} \cdot 0.25\right)\right)\right)} - 1\right)}\right)\right) \]
    7. Step-by-step derivation
      1. expm1-def39.4%

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

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

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

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

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

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

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

    if 4.3000000000000002e-302 < l

    1. Initial program 63.8%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5.6 \cdot 10^{+144}:\\ \;\;\;\;d \cdot \left({\left(-h\right)}^{-0.5} \cdot \left(-{\left(\frac{-1}{\ell}\right)}^{0.5}\right)\right)\\ \mathbf{elif}\;\ell \leq 4.3 \cdot 10^{-302}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(0.5 \cdot \frac{D \cdot M}{d}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 11: 61.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 -4.6 \cdot 10^{-138}:\\ \;\;\;\;d \cdot \left({\left(-h\right)}^{-0.5} \cdot \left(-{\left(\frac{-1}{\ell}\right)}^{0.5}\right)\right)\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{-305}:\\ \;\;\;\;d \cdot \log \left(e^{{\left(h \cdot \ell\right)}^{-0.5}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d \cdot \mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(M_m \cdot \left(0.5 \cdot \frac{D_m}{d}\right)\right)}^{2}, 1\right)}{\sqrt{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 -4.6e-138)
   (* d (* (pow (- h) -0.5) (- (pow (/ -1.0 l) 0.5))))
   (if (<= d 2.5e-305)
     (* d (log (exp (pow (* h l) -0.5))))
     (/
      (* d (fma (* (/ h l) -0.5) (pow (* M_m (* 0.5 (/ D_m d))) 2.0) 1.0))
      (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) {
	double tmp;
	if (d <= -4.6e-138) {
		tmp = d * (pow(-h, -0.5) * -pow((-1.0 / l), 0.5));
	} else if (d <= 2.5e-305) {
		tmp = d * log(exp(pow((h * l), -0.5)));
	} else {
		tmp = (d * fma(((h / l) * -0.5), pow((M_m * (0.5 * (D_m / d))), 2.0), 1.0)) / sqrt((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 <= -4.6e-138)
		tmp = Float64(d * Float64((Float64(-h) ^ -0.5) * Float64(-(Float64(-1.0 / l) ^ 0.5))));
	elseif (d <= 2.5e-305)
		tmp = Float64(d * log(exp((Float64(h * l) ^ -0.5))));
	else
		tmp = Float64(Float64(d * fma(Float64(Float64(h / l) * -0.5), (Float64(M_m * Float64(0.5 * Float64(D_m / d))) ^ 2.0), 1.0)) / sqrt(Float64(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_] := If[LessEqual[d, -4.6e-138], N[(d * N[(N[Power[(-h), -0.5], $MachinePrecision] * (-N[Power[N[(-1.0 / l), $MachinePrecision], 0.5], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.5e-305], N[(d * N[Log[N[Exp[N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(d * N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(M$95$m * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / 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])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.6 \cdot 10^{-138}:\\
\;\;\;\;d \cdot \left({\left(-h\right)}^{-0.5} \cdot \left(-{\left(\frac{-1}{\ell}\right)}^{0.5}\right)\right)\\

\mathbf{elif}\;d \leq 2.5 \cdot 10^{-305}:\\
\;\;\;\;d \cdot \log \left(e^{{\left(h \cdot \ell\right)}^{-0.5}}\right)\\

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


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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    6. Step-by-step derivation
      1. mul-1-neg52.0%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in52.0%

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

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
      4. unpow1/252.3%

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

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

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

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

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

        \[\leadsto d \cdot \left(-e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \]
      10. distribute-rgt-neg-in50.9%

        \[\leadsto d \cdot \left(-e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}}\right) \]
      11. metadata-eval50.9%

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

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

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    8. Taylor expanded in l around -inf 62.2%

      \[\leadsto d \cdot \left(-\color{blue}{e^{-0.5 \cdot \left(\log \left(-1 \cdot h\right) + -1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}}\right) \]
    9. Step-by-step derivation
      1. distribute-lft-in62.2%

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

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

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

        \[\leadsto d \cdot \left(-\color{blue}{{\left(-1 \cdot h\right)}^{-0.5}} \cdot e^{-0.5 \cdot \left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}\right) \]
      5. mul-1-neg62.7%

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

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

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(\log \left(\frac{-1}{\ell}\right) \cdot -1\right)} \cdot -0.5}\right) \]
      8. associate-*l*62.7%

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

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

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot \color{blue}{{\left(\frac{-1}{\ell}\right)}^{0.5}}\right) \]
    10. Simplified66.7%

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

    if -4.5999999999999998e-138 < d < 2.49999999999999993e-305

    1. Initial program 50.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. Simplified50.4%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. add-log-exp44.5%

        \[\leadsto d \cdot \color{blue}{\log \left(e^{\sqrt{\frac{1}{h \cdot \ell}}}\right)} \]
      2. pow1/244.5%

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

        \[\leadsto d \cdot \log \left(e^{{\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}}\right) \]
      4. pow-pow44.5%

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}}\right) \]
      5. metadata-eval44.5%

        \[\leadsto d \cdot \log \left(e^{{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}}\right) \]
    5. Applied egg-rr44.5%

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

    if 2.49999999999999993e-305 < d

    1. Initial program 64.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. Simplified64.1%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.6 \cdot 10^{-138}:\\ \;\;\;\;d \cdot \left({\left(-h\right)}^{-0.5} \cdot \left(-{\left(\frac{-1}{\ell}\right)}^{0.5}\right)\right)\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{-305}:\\ \;\;\;\;d \cdot \log \left(e^{{\left(h \cdot \ell\right)}^{-0.5}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d \cdot \mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}, 1\right)}{\sqrt{h \cdot \ell}}\\ \end{array} \]

Alternative 12: 60.6% accurate, 1.1× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -4.6 \cdot 10^{-138}:\\ \;\;\;\;d \cdot \left({\left(-h\right)}^{-0.5} \cdot \left(-{\left(\frac{-1}{\ell}\right)}^{0.5}\right)\right)\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{-305}:\\ \;\;\;\;d \cdot \log \left(e^{{\left(h \cdot \ell\right)}^{-0.5}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(M_m \cdot \left(0.5 \cdot \frac{D_m}{d}\right)\right)}^{2}\right) \cdot \frac{d}{\sqrt{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 -4.6e-138)
   (* d (* (pow (- h) -0.5) (- (pow (/ -1.0 l) 0.5))))
   (if (<= d 2.5e-305)
     (* d (log (exp (pow (* h l) -0.5))))
     (*
      (+ 1.0 (* (* (/ h l) -0.5) (pow (* M_m (* 0.5 (/ D_m d))) 2.0)))
      (/ 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) {
	double tmp;
	if (d <= -4.6e-138) {
		tmp = d * (pow(-h, -0.5) * -pow((-1.0 / l), 0.5));
	} else if (d <= 2.5e-305) {
		tmp = d * log(exp(pow((h * l), -0.5)));
	} else {
		tmp = (1.0 + (((h / l) * -0.5) * pow((M_m * (0.5 * (D_m / d))), 2.0))) * (d / sqrt((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 <= (-4.6d-138)) then
        tmp = d * ((-h ** (-0.5d0)) * -(((-1.0d0) / l) ** 0.5d0))
    else if (d <= 2.5d-305) then
        tmp = d * log(exp(((h * l) ** (-0.5d0))))
    else
        tmp = (1.0d0 + (((h / l) * (-0.5d0)) * ((m_m * (0.5d0 * (d_m / d))) ** 2.0d0))) * (d / sqrt((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 <= -4.6e-138) {
		tmp = d * (Math.pow(-h, -0.5) * -Math.pow((-1.0 / l), 0.5));
	} else if (d <= 2.5e-305) {
		tmp = d * Math.log(Math.exp(Math.pow((h * l), -0.5)));
	} else {
		tmp = (1.0 + (((h / l) * -0.5) * Math.pow((M_m * (0.5 * (D_m / d))), 2.0))) * (d / Math.sqrt((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 <= -4.6e-138:
		tmp = d * (math.pow(-h, -0.5) * -math.pow((-1.0 / l), 0.5))
	elif d <= 2.5e-305:
		tmp = d * math.log(math.exp(math.pow((h * l), -0.5)))
	else:
		tmp = (1.0 + (((h / l) * -0.5) * math.pow((M_m * (0.5 * (D_m / d))), 2.0))) * (d / math.sqrt((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 <= -4.6e-138)
		tmp = Float64(d * Float64((Float64(-h) ^ -0.5) * Float64(-(Float64(-1.0 / l) ^ 0.5))));
	elseif (d <= 2.5e-305)
		tmp = Float64(d * log(exp((Float64(h * l) ^ -0.5))));
	else
		tmp = Float64(Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(M_m * Float64(0.5 * Float64(D_m / d))) ^ 2.0))) * Float64(d / sqrt(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 <= -4.6e-138)
		tmp = d * ((-h ^ -0.5) * -((-1.0 / l) ^ 0.5));
	elseif (d <= 2.5e-305)
		tmp = d * log(exp(((h * l) ^ -0.5)));
	else
		tmp = (1.0 + (((h / l) * -0.5) * ((M_m * (0.5 * (D_m / d))) ^ 2.0))) * (d / sqrt((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, -4.6e-138], N[(d * N[(N[Power[(-h), -0.5], $MachinePrecision] * (-N[Power[N[(-1.0 / l), $MachinePrecision], 0.5], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.5e-305], N[(d * N[Log[N[Exp[N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(M$95$m * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[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 -4.6 \cdot 10^{-138}:\\
\;\;\;\;d \cdot \left({\left(-h\right)}^{-0.5} \cdot \left(-{\left(\frac{-1}{\ell}\right)}^{0.5}\right)\right)\\

\mathbf{elif}\;d \leq 2.5 \cdot 10^{-305}:\\
\;\;\;\;d \cdot \log \left(e^{{\left(h \cdot \ell\right)}^{-0.5}}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(M_m \cdot \left(0.5 \cdot \frac{D_m}{d}\right)\right)}^{2}\right) \cdot \frac{d}{\sqrt{h \cdot \ell}}\\


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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    6. Step-by-step derivation
      1. mul-1-neg52.0%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in52.0%

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

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
      4. unpow1/252.3%

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

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

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

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

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

        \[\leadsto d \cdot \left(-e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \]
      10. distribute-rgt-neg-in50.9%

        \[\leadsto d \cdot \left(-e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}}\right) \]
      11. metadata-eval50.9%

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

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

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    8. Taylor expanded in l around -inf 62.2%

      \[\leadsto d \cdot \left(-\color{blue}{e^{-0.5 \cdot \left(\log \left(-1 \cdot h\right) + -1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}}\right) \]
    9. Step-by-step derivation
      1. distribute-lft-in62.2%

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

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

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

        \[\leadsto d \cdot \left(-\color{blue}{{\left(-1 \cdot h\right)}^{-0.5}} \cdot e^{-0.5 \cdot \left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}\right) \]
      5. mul-1-neg62.7%

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

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

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(\log \left(\frac{-1}{\ell}\right) \cdot -1\right)} \cdot -0.5}\right) \]
      8. associate-*l*62.7%

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

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

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot \color{blue}{{\left(\frac{-1}{\ell}\right)}^{0.5}}\right) \]
    10. Simplified66.7%

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

    if -4.5999999999999998e-138 < d < 2.49999999999999993e-305

    1. Initial program 50.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. Simplified50.4%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. add-log-exp44.5%

        \[\leadsto d \cdot \color{blue}{\log \left(e^{\sqrt{\frac{1}{h \cdot \ell}}}\right)} \]
      2. pow1/244.5%

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

        \[\leadsto d \cdot \log \left(e^{{\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}}\right) \]
      4. pow-pow44.5%

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}}\right) \]
      5. metadata-eval44.5%

        \[\leadsto d \cdot \log \left(e^{{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}}\right) \]
    5. Applied egg-rr44.5%

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

    if 2.49999999999999993e-305 < d

    1. Initial program 64.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. Simplified64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.6 \cdot 10^{-138}:\\ \;\;\;\;d \cdot \left({\left(-h\right)}^{-0.5} \cdot \left(-{\left(\frac{-1}{\ell}\right)}^{0.5}\right)\right)\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{-305}:\\ \;\;\;\;d \cdot \log \left(e^{{\left(h \cdot \ell\right)}^{-0.5}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right) \cdot \frac{d}{\sqrt{h \cdot \ell}}\\ \end{array} \]

Alternative 13: 59.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} \mathbf{if}\;d \leq -7.2 \cdot 10^{-138}:\\ \;\;\;\;d \cdot \left({\left(-h\right)}^{-0.5} \cdot \left(-{\left(\frac{-1}{\ell}\right)}^{0.5}\right)\right)\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{-305}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(M_m \cdot \left(0.5 \cdot \frac{D_m}{d}\right)\right)}^{2}\right) \cdot \frac{d}{\sqrt{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 -7.2e-138)
   (* d (* (pow (- h) -0.5) (- (pow (/ -1.0 l) 0.5))))
   (if (<= d 2.5e-305)
     (* d (pow (pow (* h l) 2.0) -0.25))
     (*
      (+ 1.0 (* (* (/ h l) -0.5) (pow (* M_m (* 0.5 (/ D_m d))) 2.0)))
      (/ 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) {
	double tmp;
	if (d <= -7.2e-138) {
		tmp = d * (pow(-h, -0.5) * -pow((-1.0 / l), 0.5));
	} else if (d <= 2.5e-305) {
		tmp = d * pow(pow((h * l), 2.0), -0.25);
	} else {
		tmp = (1.0 + (((h / l) * -0.5) * pow((M_m * (0.5 * (D_m / d))), 2.0))) * (d / sqrt((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-138)) then
        tmp = d * ((-h ** (-0.5d0)) * -(((-1.0d0) / l) ** 0.5d0))
    else if (d <= 2.5d-305) then
        tmp = d * (((h * l) ** 2.0d0) ** (-0.25d0))
    else
        tmp = (1.0d0 + (((h / l) * (-0.5d0)) * ((m_m * (0.5d0 * (d_m / d))) ** 2.0d0))) * (d / sqrt((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-138) {
		tmp = d * (Math.pow(-h, -0.5) * -Math.pow((-1.0 / l), 0.5));
	} else if (d <= 2.5e-305) {
		tmp = d * Math.pow(Math.pow((h * l), 2.0), -0.25);
	} else {
		tmp = (1.0 + (((h / l) * -0.5) * Math.pow((M_m * (0.5 * (D_m / d))), 2.0))) * (d / Math.sqrt((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-138:
		tmp = d * (math.pow(-h, -0.5) * -math.pow((-1.0 / l), 0.5))
	elif d <= 2.5e-305:
		tmp = d * math.pow(math.pow((h * l), 2.0), -0.25)
	else:
		tmp = (1.0 + (((h / l) * -0.5) * math.pow((M_m * (0.5 * (D_m / d))), 2.0))) * (d / math.sqrt((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-138)
		tmp = Float64(d * Float64((Float64(-h) ^ -0.5) * Float64(-(Float64(-1.0 / l) ^ 0.5))));
	elseif (d <= 2.5e-305)
		tmp = Float64(d * ((Float64(h * l) ^ 2.0) ^ -0.25));
	else
		tmp = Float64(Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(M_m * Float64(0.5 * Float64(D_m / d))) ^ 2.0))) * Float64(d / sqrt(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 <= -7.2e-138)
		tmp = d * ((-h ^ -0.5) * -((-1.0 / l) ^ 0.5));
	elseif (d <= 2.5e-305)
		tmp = d * (((h * l) ^ 2.0) ^ -0.25);
	else
		tmp = (1.0 + (((h / l) * -0.5) * ((M_m * (0.5 * (D_m / d))) ^ 2.0))) * (d / sqrt((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-138], N[(d * N[(N[Power[(-h), -0.5], $MachinePrecision] * (-N[Power[N[(-1.0 / l), $MachinePrecision], 0.5], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.5e-305], N[(d * N[Power[N[Power[N[(h * l), $MachinePrecision], 2.0], $MachinePrecision], -0.25], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(M$95$m * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[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 -7.2 \cdot 10^{-138}:\\
\;\;\;\;d \cdot \left({\left(-h\right)}^{-0.5} \cdot \left(-{\left(\frac{-1}{\ell}\right)}^{0.5}\right)\right)\\

\mathbf{elif}\;d \leq 2.5 \cdot 10^{-305}:\\
\;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\

\mathbf{else}:\\
\;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(M_m \cdot \left(0.5 \cdot \frac{D_m}{d}\right)\right)}^{2}\right) \cdot \frac{d}{\sqrt{h \cdot \ell}}\\


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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    6. Step-by-step derivation
      1. mul-1-neg52.0%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in52.0%

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

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
      4. unpow1/252.3%

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

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

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

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

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

        \[\leadsto d \cdot \left(-e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \]
      10. distribute-rgt-neg-in50.9%

        \[\leadsto d \cdot \left(-e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}}\right) \]
      11. metadata-eval50.9%

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

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

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    8. Taylor expanded in l around -inf 62.2%

      \[\leadsto d \cdot \left(-\color{blue}{e^{-0.5 \cdot \left(\log \left(-1 \cdot h\right) + -1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}}\right) \]
    9. Step-by-step derivation
      1. distribute-lft-in62.2%

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

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

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

        \[\leadsto d \cdot \left(-\color{blue}{{\left(-1 \cdot h\right)}^{-0.5}} \cdot e^{-0.5 \cdot \left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}\right) \]
      5. mul-1-neg62.7%

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

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

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(\log \left(\frac{-1}{\ell}\right) \cdot -1\right)} \cdot -0.5}\right) \]
      8. associate-*l*62.7%

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

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

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot \color{blue}{{\left(\frac{-1}{\ell}\right)}^{0.5}}\right) \]
    10. Simplified66.7%

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

    if -7.20000000000000036e-138 < d < 2.49999999999999993e-305

    1. Initial program 50.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. Simplified50.4%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. add-log-exp44.5%

        \[\leadsto d \cdot \color{blue}{\log \left(e^{\sqrt{\frac{1}{h \cdot \ell}}}\right)} \]
      2. pow1/244.5%

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

        \[\leadsto d \cdot \log \left(e^{{\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}}\right) \]
      4. pow-pow44.5%

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}}\right) \]
      5. metadata-eval44.5%

        \[\leadsto d \cdot \log \left(e^{{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}}\right) \]
    5. Applied egg-rr44.5%

      \[\leadsto d \cdot \color{blue}{\log \left(e^{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
    6. Step-by-step derivation
      1. rem-log-exp20.3%

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

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

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

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

        \[\leadsto d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{\color{blue}{-0.25}} \]
    7. Applied egg-rr34.3%

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

    if 2.49999999999999993e-305 < d

    1. Initial program 64.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. Simplified64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.2 \cdot 10^{-138}:\\ \;\;\;\;d \cdot \left({\left(-h\right)}^{-0.5} \cdot \left(-{\left(\frac{-1}{\ell}\right)}^{0.5}\right)\right)\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{-305}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right) \cdot \frac{d}{\sqrt{h \cdot \ell}}\\ \end{array} \]

Alternative 14: 50.6% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -6.5 \cdot 10^{-138}:\\ \;\;\;\;d \cdot \left({\left(-h\right)}^{-0.5} \cdot \left(-{\left(\frac{-1}{\ell}\right)}^{0.5}\right)\right)\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\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 -6.5e-138)
   (* d (* (pow (- h) -0.5) (- (pow (/ -1.0 l) 0.5))))
   (if (<= d -2e-310)
     (* d (pow (pow (* h l) 2.0) -0.25))
     (* d (* (pow l -0.5) (pow h -0.5))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -6.5e-138) {
		tmp = d * (pow(-h, -0.5) * -pow((-1.0 / l), 0.5));
	} else if (d <= -2e-310) {
		tmp = d * pow(pow((h * l), 2.0), -0.25);
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -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 <= (-6.5d-138)) then
        tmp = d * ((-h ** (-0.5d0)) * -(((-1.0d0) / l) ** 0.5d0))
    else if (d <= (-2d-310)) then
        tmp = d * (((h * l) ** 2.0d0) ** (-0.25d0))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-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 <= -6.5e-138) {
		tmp = d * (Math.pow(-h, -0.5) * -Math.pow((-1.0 / l), 0.5));
	} else if (d <= -2e-310) {
		tmp = d * Math.pow(Math.pow((h * l), 2.0), -0.25);
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -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 <= -6.5e-138:
		tmp = d * (math.pow(-h, -0.5) * -math.pow((-1.0 / l), 0.5))
	elif d <= -2e-310:
		tmp = d * math.pow(math.pow((h * l), 2.0), -0.25)
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -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 <= -6.5e-138)
		tmp = Float64(d * Float64((Float64(-h) ^ -0.5) * Float64(-(Float64(-1.0 / l) ^ 0.5))));
	elseif (d <= -2e-310)
		tmp = Float64(d * ((Float64(h * l) ^ 2.0) ^ -0.25));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -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 <= -6.5e-138)
		tmp = d * ((-h ^ -0.5) * -((-1.0 / l) ^ 0.5));
	elseif (d <= -2e-310)
		tmp = d * (((h * l) ^ 2.0) ^ -0.25);
	else
		tmp = d * ((l ^ -0.5) * (h ^ -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, -6.5e-138], N[(d * N[(N[Power[(-h), -0.5], $MachinePrecision] * (-N[Power[N[(-1.0 / l), $MachinePrecision], 0.5], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2e-310], N[(d * N[Power[N[Power[N[(h * l), $MachinePrecision], 2.0], $MachinePrecision], -0.25], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_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 -6.5 \cdot 10^{-138}:\\
\;\;\;\;d \cdot \left({\left(-h\right)}^{-0.5} \cdot \left(-{\left(\frac{-1}{\ell}\right)}^{0.5}\right)\right)\\

\mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\

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


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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    6. Step-by-step derivation
      1. mul-1-neg52.0%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in52.0%

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

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
      4. unpow1/252.3%

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

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

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

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

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

        \[\leadsto d \cdot \left(-e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \]
      10. distribute-rgt-neg-in50.9%

        \[\leadsto d \cdot \left(-e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}}\right) \]
      11. metadata-eval50.9%

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

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

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    8. Taylor expanded in l around -inf 62.2%

      \[\leadsto d \cdot \left(-\color{blue}{e^{-0.5 \cdot \left(\log \left(-1 \cdot h\right) + -1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}}\right) \]
    9. Step-by-step derivation
      1. distribute-lft-in62.2%

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

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

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

        \[\leadsto d \cdot \left(-\color{blue}{{\left(-1 \cdot h\right)}^{-0.5}} \cdot e^{-0.5 \cdot \left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}\right) \]
      5. mul-1-neg62.7%

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

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

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(\log \left(\frac{-1}{\ell}\right) \cdot -1\right)} \cdot -0.5}\right) \]
      8. associate-*l*62.7%

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

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

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot \color{blue}{{\left(\frac{-1}{\ell}\right)}^{0.5}}\right) \]
    10. Simplified66.7%

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

    if -6.4999999999999999e-138 < d < -1.999999999999994e-310

    1. Initial program 52.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. Simplified52.3%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. add-log-exp46.2%

        \[\leadsto d \cdot \color{blue}{\log \left(e^{\sqrt{\frac{1}{h \cdot \ell}}}\right)} \]
      2. pow1/246.2%

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

        \[\leadsto d \cdot \log \left(e^{{\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}}\right) \]
      4. pow-pow46.2%

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

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

      \[\leadsto d \cdot \color{blue}{\log \left(e^{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
    6. Step-by-step derivation
      1. rem-log-exp21.0%

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

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

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

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

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

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

    if -1.999999999999994e-310 < d

    1. Initial program 63.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in39.8%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval39.8%

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    9. Applied egg-rr50.3%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification55.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.5 \cdot 10^{-138}:\\ \;\;\;\;d \cdot \left({\left(-h\right)}^{-0.5} \cdot \left(-{\left(\frac{-1}{\ell}\right)}^{0.5}\right)\right)\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]

Alternative 15: 47.0% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -4.8 \cdot 10^{-138}:\\ \;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\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.8e-138)
   (* d (- (pow (* h l) -0.5)))
   (if (<= d -2e-310)
     (* d (pow (pow (* h l) 2.0) -0.25))
     (* d (* (pow l -0.5) (pow h -0.5))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -4.8e-138) {
		tmp = d * -pow((h * l), -0.5);
	} else if (d <= -2e-310) {
		tmp = d * pow(pow((h * l), 2.0), -0.25);
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -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.8d-138)) then
        tmp = d * -((h * l) ** (-0.5d0))
    else if (d <= (-2d-310)) then
        tmp = d * (((h * l) ** 2.0d0) ** (-0.25d0))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-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.8e-138) {
		tmp = d * -Math.pow((h * l), -0.5);
	} else if (d <= -2e-310) {
		tmp = d * Math.pow(Math.pow((h * l), 2.0), -0.25);
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -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.8e-138:
		tmp = d * -math.pow((h * l), -0.5)
	elif d <= -2e-310:
		tmp = d * math.pow(math.pow((h * l), 2.0), -0.25)
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -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.8e-138)
		tmp = Float64(d * Float64(-(Float64(h * l) ^ -0.5)));
	elseif (d <= -2e-310)
		tmp = Float64(d * ((Float64(h * l) ^ 2.0) ^ -0.25));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -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.8e-138)
		tmp = d * -((h * l) ^ -0.5);
	elseif (d <= -2e-310)
		tmp = d * (((h * l) ^ 2.0) ^ -0.25);
	else
		tmp = d * ((l ^ -0.5) * (h ^ -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.8e-138], N[(d * (-N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision])), $MachinePrecision], If[LessEqual[d, -2e-310], N[(d * N[Power[N[Power[N[(h * l), $MachinePrecision], 2.0], $MachinePrecision], -0.25], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_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.8 \cdot 10^{-138}:\\
\;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\

\mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\

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


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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    6. Step-by-step derivation
      1. mul-1-neg52.0%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in52.0%

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

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
      4. unpow1/252.3%

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

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

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

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

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

        \[\leadsto d \cdot \left(-e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \]
      10. distribute-rgt-neg-in50.9%

        \[\leadsto d \cdot \left(-e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}}\right) \]
      11. metadata-eval50.9%

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

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

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

    if -4.7999999999999998e-138 < d < -1.999999999999994e-310

    1. Initial program 52.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. Simplified52.3%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. add-log-exp46.2%

        \[\leadsto d \cdot \color{blue}{\log \left(e^{\sqrt{\frac{1}{h \cdot \ell}}}\right)} \]
      2. pow1/246.2%

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

        \[\leadsto d \cdot \log \left(e^{{\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}}\right) \]
      4. pow-pow46.2%

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

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

      \[\leadsto d \cdot \color{blue}{\log \left(e^{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
    6. Step-by-step derivation
      1. rem-log-exp21.0%

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

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

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

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

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

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

    if -1.999999999999994e-310 < d

    1. Initial program 63.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in39.8%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval39.8%

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    9. Applied egg-rr50.3%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification50.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.8 \cdot 10^{-138}:\\ \;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]

Alternative 16: 46.9% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq 2.9 \cdot 10^{-305}:\\ \;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\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 2.9e-305)
   (* d (- (pow (* h l) -0.5)))
   (* d (* (pow l -0.5) (pow h -0.5)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= 2.9e-305) {
		tmp = d * -pow((h * l), -0.5);
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -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 <= 2.9d-305) then
        tmp = d * -((h * l) ** (-0.5d0))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-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 <= 2.9e-305) {
		tmp = d * -Math.pow((h * l), -0.5);
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -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 <= 2.9e-305:
		tmp = d * -math.pow((h * l), -0.5)
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -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 <= 2.9e-305)
		tmp = Float64(d * Float64(-(Float64(h * l) ^ -0.5)));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -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 <= 2.9e-305)
		tmp = d * -((h * l) ^ -0.5);
	else
		tmp = d * ((l ^ -0.5) * (h ^ -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, 2.9e-305], N[(d * (-N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision])), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_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 2.9 \cdot 10^{-305}:\\
\;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 2.89999999999999988e-305

    1. Initial program 70.3%

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

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

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

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

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

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

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in45.2%

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

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
      4. unpow1/245.4%

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

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

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

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

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

        \[\leadsto d \cdot \left(-e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \]
      10. distribute-rgt-neg-in44.1%

        \[\leadsto d \cdot \left(-e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}}\right) \]
      11. metadata-eval44.1%

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

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

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

    if 2.89999999999999988e-305 < d

    1. Initial program 64.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. Simplified64.1%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in40.1%

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    9. Applied egg-rr50.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 2.9 \cdot 10^{-305}:\\ \;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]

Alternative 17: 42.8% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{if}\;d \leq -5.7 \cdot 10^{-208}:\\ \;\;\;\;d \cdot \left(-t_0\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot t_0\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (pow (* h l) -0.5)))
   (if (<= d -5.7e-208) (* d (- t_0)) (* d t_0))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = pow((h * l), -0.5);
	double tmp;
	if (d <= -5.7e-208) {
		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 = (h * l) ** (-0.5d0)
    if (d <= (-5.7d-208)) then
        tmp = d * -t_0
    else
        tmp = d * t_0
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = Math.pow((h * l), -0.5);
	double tmp;
	if (d <= -5.7e-208) {
		tmp = d * -t_0;
	} else {
		tmp = d * t_0;
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = math.pow((h * l), -0.5)
	tmp = 0
	if d <= -5.7e-208:
		tmp = d * -t_0
	else:
		tmp = d * t_0
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(h * l) ^ -0.5
	tmp = 0.0
	if (d <= -5.7e-208)
		tmp = Float64(d * Float64(-t_0));
	else
		tmp = Float64(d * t_0);
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = (h * l) ^ -0.5;
	tmp = 0.0;
	if (d <= -5.7e-208)
		tmp = d * -t_0;
	else
		tmp = d * t_0;
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]}, If[LessEqual[d, -5.7e-208], N[(d * (-t$95$0)), $MachinePrecision], N[(d * t$95$0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := {\left(h \cdot \ell\right)}^{-0.5}\\
\mathbf{if}\;d \leq -5.7 \cdot 10^{-208}:\\
\;\;\;\;d \cdot \left(-t_0\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.7000000000000004e-208

    1. Initial program 73.3%

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    6. Step-by-step derivation
      1. mul-1-neg49.8%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in49.8%

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

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
      4. unpow1/250.1%

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

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

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

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

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

        \[\leadsto d \cdot \left(-e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \]
      10. distribute-rgt-neg-in48.6%

        \[\leadsto d \cdot \left(-e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}}\right) \]
      11. metadata-eval48.6%

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

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

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

    if -5.7000000000000004e-208 < d

    1. Initial program 62.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. Simplified62.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in38.1%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5.7 \cdot 10^{-208}:\\ \;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \end{array} \]

Alternative 18: 26.7% accurate, 3.1× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ d \cdot {\left(h \cdot \ell\right)}^{-0.5} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (* d (pow (* 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) {
	return d * pow((h * l), -0.5);
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d * ((h * l) ** (-0.5d0))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d * Math.pow((h * l), -0.5);
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d * math.pow((h * l), -0.5)
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d * (Float64(h * l) ^ -0.5))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d * ((h * l) ^ -0.5);
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d * N[Power[N[(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])\\
\\
d \cdot {\left(h \cdot \ell\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 67.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. Simplified67.4%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
    8. distribute-rgt-neg-in24.6%

      \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
    9. metadata-eval24.6%

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

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

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

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

Reproduce

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