Henrywood and Agarwal, Equation (12)

Percentage Accurate: 65.7% → 78.4%
Time: 31.7s
Alternatives: 21
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 21 alternatives:

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

Initial Program: 65.7% 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: 78.4% accurate, 0.8× speedup?

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

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


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

    1. Initial program 67.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. Simplified66.8%

      \[\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. Add Preprocessing
    4. Applied egg-rr38.5%

      \[\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(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot -0.5\right)\right)} - 1\right)}\right)\right) \]
    5. Step-by-step derivation
      1. expm1-def38.5%

        \[\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(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot -0.5\right)\right)\right)}\right)\right) \]
      2. expm1-log1p66.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < 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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. expm1-log1p-u63.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({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
      2. expm1-udef63.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({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} - 1\right)}\right) \]
      3. *-commutative63.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{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}}\right)} - 1\right)\right) \]
      4. div-inv63.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{h}{\ell} \cdot {\left(\color{blue}{\left(M \cdot \frac{1}{2}\right)} \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
      5. associate-*l*63.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{h}{\ell} \cdot {\color{blue}{\left(M \cdot \left(\frac{1}{2} \cdot \frac{D}{d}\right)\right)}}^{2}\right)} - 1\right)\right) \]
      6. metadata-eval63.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{h}{\ell} \cdot {\left(M \cdot \left(\color{blue}{0.5} \cdot \frac{D}{d}\right)\right)}^{2}\right)} - 1\right)\right) \]
    5. Applied egg-rr63.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{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)} - 1\right)}\right) \]
    6. Step-by-step derivation
      1. expm1-def63.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{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)}\right) \]
      2. expm1-log1p63.8%

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

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

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

        \[\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) \]
      6. *-commutative68.1%

        \[\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) \]
      7. associate-*r*68.1%

        \[\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(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      8. associate-*r/68.0%

        \[\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{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      9. associate-*l/68.1%

        \[\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{M \cdot 0.5}{d} \cdot D\right)}}^{2}}{\ell}\right)\right) \]
      10. associate-*r/68.1%

        \[\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(M \cdot \frac{0.5}{d}\right)} \cdot D\right)}^{2}}{\ell}\right)\right) \]
      11. *-commutative68.1%

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

      \[\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(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}\right)}\right) \]
    8. Step-by-step derivation
      1. sqrt-div78.0%

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

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

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

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

Alternative 2: 74.3% accurate, 0.8× speedup?

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

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


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

    1. Initial program 67.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. Simplified66.8%

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

        \[\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({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
      2. expm1-udef66.4%

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

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

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

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

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

      \[\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{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)} - 1\right)}\right) \]
    6. Step-by-step derivation
      1. expm1-def66.4%

        \[\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{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)}\right) \]
      2. expm1-log1p66.8%

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

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

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

        \[\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) \]
      6. *-commutative70.6%

        \[\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) \]
      7. associate-*r*70.6%

        \[\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(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      8. associate-*r/71.3%

        \[\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{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      9. associate-*l/71.2%

        \[\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{M \cdot 0.5}{d} \cdot D\right)}}^{2}}{\ell}\right)\right) \]
      10. associate-*r/71.2%

        \[\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(M \cdot \frac{0.5}{d}\right)} \cdot D\right)}^{2}}{\ell}\right)\right) \]
      11. *-commutative71.2%

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

      \[\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(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}\right)}\right) \]
    8. Step-by-step derivation
      1. frac-2neg71.2%

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 63.8%

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

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

      \[\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(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot -0.5\right)\right)} - 1\right)}\right)\right) \]
    5. Step-by-step derivation
      1. expm1-def37.5%

        \[\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(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot -0.5\right)\right)\right)}\right)\right) \]
      2. expm1-log1p63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 76.1% accurate, 0.8× speedup?

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

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


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

    1. Initial program 67.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. Simplified66.8%

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

        \[\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({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
      2. expm1-udef66.4%

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

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

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

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

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

      \[\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{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)} - 1\right)}\right) \]
    6. Step-by-step derivation
      1. expm1-def66.4%

        \[\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{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)}\right) \]
      2. expm1-log1p66.8%

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

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

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

        \[\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) \]
      6. *-commutative70.6%

        \[\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) \]
      7. associate-*r*70.6%

        \[\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(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      8. associate-*r/71.3%

        \[\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{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      9. associate-*l/71.2%

        \[\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{M \cdot 0.5}{d} \cdot D\right)}}^{2}}{\ell}\right)\right) \]
      10. associate-*r/71.2%

        \[\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(M \cdot \frac{0.5}{d}\right)} \cdot D\right)}^{2}}{\ell}\right)\right) \]
      11. *-commutative71.2%

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

      \[\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(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}\right)}\right) \]
    8. Step-by-step derivation
      1. frac-2neg71.2%

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

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

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

    if -4.999999999999985e-310 < h

    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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. expm1-log1p-u63.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({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
      2. expm1-udef63.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({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} - 1\right)}\right) \]
      3. *-commutative63.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{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}}\right)} - 1\right)\right) \]
      4. div-inv63.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{h}{\ell} \cdot {\left(\color{blue}{\left(M \cdot \frac{1}{2}\right)} \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
      5. associate-*l*63.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{h}{\ell} \cdot {\color{blue}{\left(M \cdot \left(\frac{1}{2} \cdot \frac{D}{d}\right)\right)}}^{2}\right)} - 1\right)\right) \]
      6. metadata-eval63.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{h}{\ell} \cdot {\left(M \cdot \left(\color{blue}{0.5} \cdot \frac{D}{d}\right)\right)}^{2}\right)} - 1\right)\right) \]
    5. Applied egg-rr63.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{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)} - 1\right)}\right) \]
    6. Step-by-step derivation
      1. expm1-def63.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{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)}\right) \]
      2. expm1-log1p63.8%

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

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

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

        \[\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) \]
      6. *-commutative68.1%

        \[\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) \]
      7. associate-*r*68.1%

        \[\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(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      8. associate-*r/68.0%

        \[\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{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      9. associate-*l/68.1%

        \[\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{M \cdot 0.5}{d} \cdot D\right)}}^{2}}{\ell}\right)\right) \]
      10. associate-*r/68.1%

        \[\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(M \cdot \frac{0.5}{d}\right)} \cdot D\right)}^{2}}{\ell}\right)\right) \]
      11. *-commutative68.1%

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

      \[\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(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}\right)}\right) \]
    8. Step-by-step derivation
      1. sqrt-div78.0%

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

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

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

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

Alternative 4: 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 := 1 - 0.5 \cdot \left(h \cdot \frac{{\left(D_m \cdot \left(M_m \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}\right)\\ t_1 := \sqrt{\frac{d}{\ell}}\\ \mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;t_0 \cdot \left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t_1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t_1 \cdot \left(\sqrt{d} \cdot \frac{1}{\sqrt{h}}\right)\right) \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 (- 1.0 (* 0.5 (* h (/ (pow (* D_m (* M_m (/ 0.5 d))) 2.0) l)))))
        (t_1 (sqrt (/ d l))))
   (if (<= l -2e-310)
     (* t_0 (* (/ (sqrt (- d)) (sqrt (- h))) t_1))
     (* (* t_1 (* (sqrt d) (/ 1.0 (sqrt h)))) 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 = 1.0 - (0.5 * (h * (pow((D_m * (M_m * (0.5 / d))), 2.0) / l)));
	double t_1 = sqrt((d / l));
	double tmp;
	if (l <= -2e-310) {
		tmp = t_0 * ((sqrt(-d) / sqrt(-h)) * t_1);
	} else {
		tmp = (t_1 * (sqrt(d) * (1.0 / sqrt(h)))) * 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) :: t_1
    real(8) :: tmp
    t_0 = 1.0d0 - (0.5d0 * (h * (((d_m * (m_m * (0.5d0 / d))) ** 2.0d0) / l)))
    t_1 = sqrt((d / l))
    if (l <= (-2d-310)) then
        tmp = t_0 * ((sqrt(-d) / sqrt(-h)) * t_1)
    else
        tmp = (t_1 * (sqrt(d) * (1.0d0 / sqrt(h)))) * 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 = 1.0 - (0.5 * (h * (Math.pow((D_m * (M_m * (0.5 / d))), 2.0) / l)));
	double t_1 = Math.sqrt((d / l));
	double tmp;
	if (l <= -2e-310) {
		tmp = t_0 * ((Math.sqrt(-d) / Math.sqrt(-h)) * t_1);
	} else {
		tmp = (t_1 * (Math.sqrt(d) * (1.0 / Math.sqrt(h)))) * 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 = 1.0 - (0.5 * (h * (math.pow((D_m * (M_m * (0.5 / d))), 2.0) / l)))
	t_1 = math.sqrt((d / l))
	tmp = 0
	if l <= -2e-310:
		tmp = t_0 * ((math.sqrt(-d) / math.sqrt(-h)) * t_1)
	else:
		tmp = (t_1 * (math.sqrt(d) * (1.0 / math.sqrt(h)))) * 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(1.0 - Float64(0.5 * Float64(h * Float64((Float64(D_m * Float64(M_m * Float64(0.5 / d))) ^ 2.0) / l))))
	t_1 = sqrt(Float64(d / l))
	tmp = 0.0
	if (l <= -2e-310)
		tmp = Float64(t_0 * Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_1));
	else
		tmp = Float64(Float64(t_1 * Float64(sqrt(d) * Float64(1.0 / sqrt(h)))) * 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 = 1.0 - (0.5 * (h * (((D_m * (M_m * (0.5 / d))) ^ 2.0) / l)));
	t_1 = sqrt((d / l));
	tmp = 0.0;
	if (l <= -2e-310)
		tmp = t_0 * ((sqrt(-d) / sqrt(-h)) * t_1);
	else
		tmp = (t_1 * (sqrt(d) * (1.0 / sqrt(h)))) * 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[(1.0 - N[(0.5 * N[(h * N[(N[Power[N[(D$95$m * N[(M$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -2e-310], N[(t$95$0 * N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * N[(N[Sqrt[d], $MachinePrecision] * N[(1.0 / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 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 := 1 - 0.5 \cdot \left(h \cdot \frac{{\left(D_m \cdot \left(M_m \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\
\;\;\;\;t_0 \cdot \left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t_1\right)\\

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


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

    1. Initial program 67.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. Simplified66.8%

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

        \[\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({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
      2. expm1-udef66.4%

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

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

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

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

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

      \[\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{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)} - 1\right)}\right) \]
    6. Step-by-step derivation
      1. expm1-def66.4%

        \[\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{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)}\right) \]
      2. expm1-log1p66.8%

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

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

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

        \[\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) \]
      6. *-commutative70.6%

        \[\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) \]
      7. associate-*r*70.6%

        \[\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(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      8. associate-*r/71.3%

        \[\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{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      9. associate-*l/71.2%

        \[\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{M \cdot 0.5}{d} \cdot D\right)}}^{2}}{\ell}\right)\right) \]
      10. associate-*r/71.2%

        \[\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(M \cdot \frac{0.5}{d}\right)} \cdot D\right)}^{2}}{\ell}\right)\right) \]
      11. *-commutative71.2%

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

      \[\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(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}\right)}\right) \]
    8. Step-by-step derivation
      1. frac-2neg71.2%

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

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

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

    if -1.999999999999994e-310 < 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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. expm1-log1p-u63.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({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
      2. expm1-udef63.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({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} - 1\right)}\right) \]
      3. *-commutative63.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{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}}\right)} - 1\right)\right) \]
      4. div-inv63.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{h}{\ell} \cdot {\left(\color{blue}{\left(M \cdot \frac{1}{2}\right)} \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
      5. associate-*l*63.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{h}{\ell} \cdot {\color{blue}{\left(M \cdot \left(\frac{1}{2} \cdot \frac{D}{d}\right)\right)}}^{2}\right)} - 1\right)\right) \]
      6. metadata-eval63.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{h}{\ell} \cdot {\left(M \cdot \left(\color{blue}{0.5} \cdot \frac{D}{d}\right)\right)}^{2}\right)} - 1\right)\right) \]
    5. Applied egg-rr63.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{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)} - 1\right)}\right) \]
    6. Step-by-step derivation
      1. expm1-def63.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{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)}\right) \]
      2. expm1-log1p63.8%

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

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

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

        \[\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) \]
      6. *-commutative68.1%

        \[\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) \]
      7. associate-*r*68.1%

        \[\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(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      8. associate-*r/68.0%

        \[\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{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      9. associate-*l/68.1%

        \[\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{M \cdot 0.5}{d} \cdot D\right)}}^{2}}{\ell}\right)\right) \]
      10. associate-*r/68.1%

        \[\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(M \cdot \frac{0.5}{d}\right)} \cdot D\right)}^{2}}{\ell}\right)\right) \]
      11. *-commutative68.1%

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

      \[\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(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}\right)}\right) \]
    8. Step-by-step derivation
      1. sqrt-div78.0%

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

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

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

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

Alternative 5: 71.0% accurate, 0.8× speedup?

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

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


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

    1. Initial program 67.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. Simplified66.8%

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

        \[\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({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
      2. expm1-udef66.4%

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

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

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

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

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

      \[\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{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)} - 1\right)}\right) \]
    6. Step-by-step derivation
      1. expm1-def66.4%

        \[\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{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)}\right) \]
      2. expm1-log1p66.8%

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

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

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

        \[\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) \]
      6. *-commutative70.6%

        \[\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) \]
      7. associate-*r*70.6%

        \[\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(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      8. associate-*r/71.3%

        \[\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{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      9. associate-*l/71.2%

        \[\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{M \cdot 0.5}{d} \cdot D\right)}}^{2}}{\ell}\right)\right) \]
      10. associate-*r/71.2%

        \[\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(M \cdot \frac{0.5}{d}\right)} \cdot D\right)}^{2}}{\ell}\right)\right) \]
      11. *-commutative71.2%

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

      \[\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(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}\right)}\right) \]

    if 5.00000000000000014e-307 < 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}{\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. Add Preprocessing
    4. Applied egg-rr37.5%

      \[\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(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot -0.5\right)\right)} - 1\right)}\right)\right) \]
    5. Step-by-step derivation
      1. expm1-def37.5%

        \[\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(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot -0.5\right)\right)\right)}\right)\right) \]
      2. expm1-log1p63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 42.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} t_0 := -0.125 \cdot \frac{{\left(D_m \cdot M_m\right)}^{2}}{\frac{d}{\sqrt{\frac{h}{{\ell}^{3}}}}}\\ t_1 := \frac{\frac{1}{\ell}}{h}\\ \mathbf{if}\;d \leq -1.3 \cdot 10^{+148}:\\ \;\;\;\;\sqrt[3]{{t_1}^{1.5} \cdot {d}^{3}}\\ \mathbf{elif}\;d \leq -9 \cdot 10^{-29}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 2 \cdot 10^{-300}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{t_1}\right)}\\ \mathbf{elif}\;d \leq 6.2 \cdot 10^{-147}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 4.4 \cdot 10^{-51}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;d \leq 190000:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0
         (* -0.125 (/ (pow (* D_m M_m) 2.0) (/ d (sqrt (/ h (pow l 3.0)))))))
        (t_1 (/ (/ 1.0 l) h)))
   (if (<= d -1.3e+148)
     (cbrt (* (pow t_1 1.5) (pow d 3.0)))
     (if (<= d -9e-29)
       (sqrt (/ (pow d 2.0) (* l h)))
       (if (<= d 2e-300)
         (* d (sqrt (log (exp t_1))))
         (if (<= d 6.2e-147)
           t_0
           (if (<= d 4.4e-51)
             (/ d (* (sqrt h) (sqrt l)))
             (if (<= d 190000.0) t_0 (* d (/ (pow h -0.5) (sqrt l)))))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = -0.125 * (pow((D_m * M_m), 2.0) / (d / sqrt((h / pow(l, 3.0)))));
	double t_1 = (1.0 / l) / h;
	double tmp;
	if (d <= -1.3e+148) {
		tmp = cbrt((pow(t_1, 1.5) * pow(d, 3.0)));
	} else if (d <= -9e-29) {
		tmp = sqrt((pow(d, 2.0) / (l * h)));
	} else if (d <= 2e-300) {
		tmp = d * sqrt(log(exp(t_1)));
	} else if (d <= 6.2e-147) {
		tmp = t_0;
	} else if (d <= 4.4e-51) {
		tmp = d / (sqrt(h) * sqrt(l));
	} else if (d <= 190000.0) {
		tmp = t_0;
	} else {
		tmp = d * (pow(h, -0.5) / sqrt(l));
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = -0.125 * (Math.pow((D_m * M_m), 2.0) / (d / Math.sqrt((h / Math.pow(l, 3.0)))));
	double t_1 = (1.0 / l) / h;
	double tmp;
	if (d <= -1.3e+148) {
		tmp = Math.cbrt((Math.pow(t_1, 1.5) * Math.pow(d, 3.0)));
	} else if (d <= -9e-29) {
		tmp = Math.sqrt((Math.pow(d, 2.0) / (l * h)));
	} else if (d <= 2e-300) {
		tmp = d * Math.sqrt(Math.log(Math.exp(t_1)));
	} else if (d <= 6.2e-147) {
		tmp = t_0;
	} else if (d <= 4.4e-51) {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	} else if (d <= 190000.0) {
		tmp = t_0;
	} else {
		tmp = d * (Math.pow(h, -0.5) / Math.sqrt(l));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(-0.125 * Float64((Float64(D_m * M_m) ^ 2.0) / Float64(d / sqrt(Float64(h / (l ^ 3.0))))))
	t_1 = Float64(Float64(1.0 / l) / h)
	tmp = 0.0
	if (d <= -1.3e+148)
		tmp = cbrt(Float64((t_1 ^ 1.5) * (d ^ 3.0)));
	elseif (d <= -9e-29)
		tmp = sqrt(Float64((d ^ 2.0) / Float64(l * h)));
	elseif (d <= 2e-300)
		tmp = Float64(d * sqrt(log(exp(t_1))));
	elseif (d <= 6.2e-147)
		tmp = t_0;
	elseif (d <= 4.4e-51)
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	elseif (d <= 190000.0)
		tmp = t_0;
	else
		tmp = Float64(d * Float64((h ^ -0.5) / sqrt(l)));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(-0.125 * N[(N[Power[N[(D$95$m * M$95$m), $MachinePrecision], 2.0], $MachinePrecision] / N[(d / N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]}, If[LessEqual[d, -1.3e+148], N[Power[N[(N[Power[t$95$1, 1.5], $MachinePrecision] * N[Power[d, 3.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], If[LessEqual[d, -9e-29], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, 2e-300], N[(d * N[Sqrt[N[Log[N[Exp[t$95$1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.2e-147], t$95$0, If[LessEqual[d, 4.4e-51], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 190000.0], t$95$0, N[(d * N[(N[Power[h, -0.5], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := -0.125 \cdot \frac{{\left(D_m \cdot M_m\right)}^{2}}{\frac{d}{\sqrt{\frac{h}{{\ell}^{3}}}}}\\
t_1 := \frac{\frac{1}{\ell}}{h}\\
\mathbf{if}\;d \leq -1.3 \cdot 10^{+148}:\\
\;\;\;\;\sqrt[3]{{t_1}^{1.5} \cdot {d}^{3}}\\

\mathbf{elif}\;d \leq -9 \cdot 10^{-29}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\

\mathbf{elif}\;d \leq 2 \cdot 10^{-300}:\\
\;\;\;\;d \cdot \sqrt{\log \left(e^{t_1}\right)}\\

\mathbf{elif}\;d \leq 6.2 \cdot 10^{-147}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq 4.4 \cdot 10^{-51}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\

\mathbf{elif}\;d \leq 190000:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if d < -1.3e148

    1. Initial program 70.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified16.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Step-by-step derivation
      1. add-cbrt-cube31.9%

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

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

        \[\leadsto \color{blue}{\sqrt[3]{\left(\left(d \cdot d\right) \cdot d\right) \cdot \left(\left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)}} \]
      4. pow329.0%

        \[\leadsto \sqrt[3]{\color{blue}{{d}^{3}} \cdot \left(\left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)} \]
      5. add-sqr-sqrt29.0%

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

        \[\leadsto \sqrt[3]{{d}^{3} \cdot \left(\color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{1}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)} \]
      7. pow1/229.0%

        \[\leadsto \sqrt[3]{{d}^{3} \cdot \left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}}\right)} \]
      8. pow-prod-up29.0%

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

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

        \[\leadsto \sqrt[3]{{d}^{3} \cdot {\color{blue}{\left(\frac{\frac{1}{\ell}}{h}\right)}}^{\left(1 + 0.5\right)}} \]
      11. metadata-eval29.0%

        \[\leadsto \sqrt[3]{{d}^{3} \cdot {\left(\frac{\frac{1}{\ell}}{h}\right)}^{\color{blue}{1.5}}} \]
    12. Applied egg-rr29.0%

      \[\leadsto \color{blue}{\sqrt[3]{{d}^{3} \cdot {\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5}}} \]
    13. Step-by-step derivation
      1. *-commutative29.0%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5} \cdot {d}^{3}}} \]
    14. Simplified29.0%

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

    if -1.3e148 < d < -8.9999999999999996e-29

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified9.9%

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \left(d \cdot d\right)}} \]
      6. add-sqr-sqrt48.8%

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

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

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

        \[\leadsto \sqrt{\frac{\frac{1}{\ell}}{h} \cdot \color{blue}{{d}^{2}}} \]
    12. Applied egg-rr48.8%

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

        \[\leadsto \sqrt{\color{blue}{\frac{1}{\ell \cdot h}} \cdot {d}^{2}} \]
      2. associate-*l/48.9%

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot {d}^{2}}{\ell \cdot h}}} \]
      3. *-lft-identity48.9%

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

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

    if -8.9999999999999996e-29 < d < 2.00000000000000005e-300

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified18.3%

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

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

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

        \[\leadsto d \cdot \sqrt{\log \left(e^{\color{blue}{\frac{\frac{1}{\ell}}{h}}}\right)} \]
    12. Applied egg-rr31.6%

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

    if 2.00000000000000005e-300 < d < 6.2000000000000005e-147 or 4.4e-51 < d < 1.9e5

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.2000000000000005e-147 < d < 4.4e-51

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified61.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Step-by-step derivation
      1. expm1-log1p-u60.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)\right)} \]
      2. expm1-udef20.5%

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

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}}\right)} - 1 \]
      4. associate-*r/26.7%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{d \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}}}\right)} - 1 \]
      5. add-sqr-sqrt26.7%

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{{d}^{2}}} \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}}\right)} - 1 \]
      8. sqrt-prod26.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{h}}}}{\sqrt{\ell}}\right)} - 1 \]
      9. div-inv26.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{\frac{{d}^{2}}{h}}}}{\sqrt{\ell}}\right)} - 1 \]
      10. sqrt-div26.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h}}}}{\sqrt{\ell}}\right)} - 1 \]
      11. unpow226.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1 \]
      12. sqrt-prod26.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1 \]
      13. add-sqr-sqrt26.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{\color{blue}{d}}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1 \]
    12. Applied egg-rr26.7%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1} \]
    13. Step-by-step derivation
      1. expm1-def70.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\right)\right)} \]
      2. expm1-log1p71.3%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
      3. associate-/l/71.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    14. Simplified71.4%

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

    if 1.9e5 < d

    1. Initial program 71.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d} \]
      2. sqrt-div72.1%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \cdot d \]
      3. associate-*l/72.1%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{1}{h}} \cdot d}{\sqrt{\ell}}} \]
      4. inv-pow72.1%

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

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

        \[\leadsto \frac{{h}^{\color{blue}{-0.5}} \cdot d}{\sqrt{\ell}} \]
    12. Applied egg-rr72.1%

      \[\leadsto \color{blue}{\frac{{h}^{-0.5} \cdot d}{\sqrt{\ell}}} \]
    13. Step-by-step derivation
      1. associate-/l*68.8%

        \[\leadsto \color{blue}{\frac{{h}^{-0.5}}{\frac{\sqrt{\ell}}{d}}} \]
      2. associate-/r/72.1%

        \[\leadsto \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}} \cdot d} \]
    14. Simplified72.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.3 \cdot 10^{+148}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5} \cdot {d}^{3}}\\ \mathbf{elif}\;d \leq -9 \cdot 10^{-29}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 2 \cdot 10^{-300}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{\ell}}{h}}\right)}\\ \mathbf{elif}\;d \leq 6.2 \cdot 10^{-147}:\\ \;\;\;\;-0.125 \cdot \frac{{\left(D \cdot M\right)}^{2}}{\frac{d}{\sqrt{\frac{h}{{\ell}^{3}}}}}\\ \mathbf{elif}\;d \leq 4.4 \cdot 10^{-51}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;d \leq 190000:\\ \;\;\;\;-0.125 \cdot \frac{{\left(D \cdot M\right)}^{2}}{\frac{d}{\sqrt{\frac{h}{{\ell}^{3}}}}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 42.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{{\left(D_m \cdot M_m\right)}^{2}}{d} \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot -0.125\right)\\ t_1 := \frac{\frac{1}{\ell}}{h}\\ \mathbf{if}\;d \leq -8.8 \cdot 10^{+147}:\\ \;\;\;\;\sqrt[3]{{t_1}^{1.5} \cdot {d}^{3}}\\ \mathbf{elif}\;d \leq -4.7 \cdot 10^{-29}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{t_1}\right)}\\ \mathbf{elif}\;d \leq 1.1 \cdot 10^{-148}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.8 \cdot 10^{-49}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;d \leq 23000:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0
         (* (/ (pow (* D_m M_m) 2.0) d) (* (sqrt (/ h (pow l 3.0))) -0.125)))
        (t_1 (/ (/ 1.0 l) h)))
   (if (<= d -8.8e+147)
     (cbrt (* (pow t_1 1.5) (pow d 3.0)))
     (if (<= d -4.7e-29)
       (sqrt (/ (pow d 2.0) (* l h)))
       (if (<= d -5e-310)
         (* d (sqrt (log (exp t_1))))
         (if (<= d 1.1e-148)
           t_0
           (if (<= d 2.8e-49)
             (/ d (* (sqrt h) (sqrt l)))
             (if (<= d 23000.0) t_0 (* d (/ (pow h -0.5) (sqrt l)))))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = (pow((D_m * M_m), 2.0) / d) * (sqrt((h / pow(l, 3.0))) * -0.125);
	double t_1 = (1.0 / l) / h;
	double tmp;
	if (d <= -8.8e+147) {
		tmp = cbrt((pow(t_1, 1.5) * pow(d, 3.0)));
	} else if (d <= -4.7e-29) {
		tmp = sqrt((pow(d, 2.0) / (l * h)));
	} else if (d <= -5e-310) {
		tmp = d * sqrt(log(exp(t_1)));
	} else if (d <= 1.1e-148) {
		tmp = t_0;
	} else if (d <= 2.8e-49) {
		tmp = d / (sqrt(h) * sqrt(l));
	} else if (d <= 23000.0) {
		tmp = t_0;
	} else {
		tmp = d * (pow(h, -0.5) / sqrt(l));
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = (Math.pow((D_m * M_m), 2.0) / d) * (Math.sqrt((h / Math.pow(l, 3.0))) * -0.125);
	double t_1 = (1.0 / l) / h;
	double tmp;
	if (d <= -8.8e+147) {
		tmp = Math.cbrt((Math.pow(t_1, 1.5) * Math.pow(d, 3.0)));
	} else if (d <= -4.7e-29) {
		tmp = Math.sqrt((Math.pow(d, 2.0) / (l * h)));
	} else if (d <= -5e-310) {
		tmp = d * Math.sqrt(Math.log(Math.exp(t_1)));
	} else if (d <= 1.1e-148) {
		tmp = t_0;
	} else if (d <= 2.8e-49) {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	} else if (d <= 23000.0) {
		tmp = t_0;
	} else {
		tmp = d * (Math.pow(h, -0.5) / Math.sqrt(l));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(Float64((Float64(D_m * M_m) ^ 2.0) / d) * Float64(sqrt(Float64(h / (l ^ 3.0))) * -0.125))
	t_1 = Float64(Float64(1.0 / l) / h)
	tmp = 0.0
	if (d <= -8.8e+147)
		tmp = cbrt(Float64((t_1 ^ 1.5) * (d ^ 3.0)));
	elseif (d <= -4.7e-29)
		tmp = sqrt(Float64((d ^ 2.0) / Float64(l * h)));
	elseif (d <= -5e-310)
		tmp = Float64(d * sqrt(log(exp(t_1))));
	elseif (d <= 1.1e-148)
		tmp = t_0;
	elseif (d <= 2.8e-49)
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	elseif (d <= 23000.0)
		tmp = t_0;
	else
		tmp = Float64(d * Float64((h ^ -0.5) / sqrt(l)));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(D$95$m * M$95$m), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision] * N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]}, If[LessEqual[d, -8.8e+147], N[Power[N[(N[Power[t$95$1, 1.5], $MachinePrecision] * N[Power[d, 3.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], If[LessEqual[d, -4.7e-29], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -5e-310], N[(d * N[Sqrt[N[Log[N[Exp[t$95$1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.1e-148], t$95$0, If[LessEqual[d, 2.8e-49], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 23000.0], t$95$0, N[(d * N[(N[Power[h, -0.5], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{{\left(D_m \cdot M_m\right)}^{2}}{d} \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot -0.125\right)\\
t_1 := \frac{\frac{1}{\ell}}{h}\\
\mathbf{if}\;d \leq -8.8 \cdot 10^{+147}:\\
\;\;\;\;\sqrt[3]{{t_1}^{1.5} \cdot {d}^{3}}\\

\mathbf{elif}\;d \leq -4.7 \cdot 10^{-29}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\

\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \sqrt{\log \left(e^{t_1}\right)}\\

\mathbf{elif}\;d \leq 1.1 \cdot 10^{-148}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq 2.8 \cdot 10^{-49}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\

\mathbf{elif}\;d \leq 23000:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if d < -8.8000000000000007e147

    1. Initial program 70.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified16.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Step-by-step derivation
      1. add-cbrt-cube31.9%

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

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

        \[\leadsto \color{blue}{\sqrt[3]{\left(\left(d \cdot d\right) \cdot d\right) \cdot \left(\left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)}} \]
      4. pow329.0%

        \[\leadsto \sqrt[3]{\color{blue}{{d}^{3}} \cdot \left(\left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)} \]
      5. add-sqr-sqrt29.0%

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

        \[\leadsto \sqrt[3]{{d}^{3} \cdot \left(\color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{1}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)} \]
      7. pow1/229.0%

        \[\leadsto \sqrt[3]{{d}^{3} \cdot \left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}}\right)} \]
      8. pow-prod-up29.0%

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

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

        \[\leadsto \sqrt[3]{{d}^{3} \cdot {\color{blue}{\left(\frac{\frac{1}{\ell}}{h}\right)}}^{\left(1 + 0.5\right)}} \]
      11. metadata-eval29.0%

        \[\leadsto \sqrt[3]{{d}^{3} \cdot {\left(\frac{\frac{1}{\ell}}{h}\right)}^{\color{blue}{1.5}}} \]
    12. Applied egg-rr29.0%

      \[\leadsto \color{blue}{\sqrt[3]{{d}^{3} \cdot {\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5}}} \]
    13. Step-by-step derivation
      1. *-commutative29.0%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5} \cdot {d}^{3}}} \]
    14. Simplified29.0%

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

    if -8.8000000000000007e147 < d < -4.6999999999999998e-29

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified9.9%

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \left(d \cdot d\right)}} \]
      6. add-sqr-sqrt48.8%

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

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

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

        \[\leadsto \sqrt{\frac{\frac{1}{\ell}}{h} \cdot \color{blue}{{d}^{2}}} \]
    12. Applied egg-rr48.8%

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

        \[\leadsto \sqrt{\color{blue}{\frac{1}{\ell \cdot h}} \cdot {d}^{2}} \]
      2. associate-*l/48.9%

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot {d}^{2}}{\ell \cdot h}}} \]
      3. *-lft-identity48.9%

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

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

    if -4.6999999999999998e-29 < d < -4.999999999999985e-310

    1. Initial program 57.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. 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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/255.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified17.2%

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

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

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

        \[\leadsto d \cdot \sqrt{\log \left(e^{\color{blue}{\frac{\frac{1}{\ell}}{h}}}\right)} \]
    12. Applied egg-rr31.0%

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

    if -4.999999999999985e-310 < d < 1.10000000000000009e-148 or 2.79999999999999997e-49 < d < 23000

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.10000000000000009e-148 < d < 2.79999999999999997e-49

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified61.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Step-by-step derivation
      1. expm1-log1p-u60.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)\right)} \]
      2. expm1-udef20.5%

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

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}}\right)} - 1 \]
      4. associate-*r/26.7%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{d \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}}}\right)} - 1 \]
      5. add-sqr-sqrt26.7%

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{{d}^{2}}} \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}}\right)} - 1 \]
      8. sqrt-prod26.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{h}}}}{\sqrt{\ell}}\right)} - 1 \]
      9. div-inv26.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{\frac{{d}^{2}}{h}}}}{\sqrt{\ell}}\right)} - 1 \]
      10. sqrt-div26.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h}}}}{\sqrt{\ell}}\right)} - 1 \]
      11. unpow226.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1 \]
      12. sqrt-prod26.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1 \]
      13. add-sqr-sqrt26.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{\color{blue}{d}}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1 \]
    12. Applied egg-rr26.7%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1} \]
    13. Step-by-step derivation
      1. expm1-def70.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\right)\right)} \]
      2. expm1-log1p71.3%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
      3. associate-/l/71.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    14. Simplified71.4%

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

    if 23000 < d

    1. Initial program 71.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d} \]
      2. sqrt-div72.1%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \cdot d \]
      3. associate-*l/72.1%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{1}{h}} \cdot d}{\sqrt{\ell}}} \]
      4. inv-pow72.1%

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

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

        \[\leadsto \frac{{h}^{\color{blue}{-0.5}} \cdot d}{\sqrt{\ell}} \]
    12. Applied egg-rr72.1%

      \[\leadsto \color{blue}{\frac{{h}^{-0.5} \cdot d}{\sqrt{\ell}}} \]
    13. Step-by-step derivation
      1. associate-/l*68.8%

        \[\leadsto \color{blue}{\frac{{h}^{-0.5}}{\frac{\sqrt{\ell}}{d}}} \]
      2. associate-/r/72.1%

        \[\leadsto \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}} \cdot d} \]
    14. Simplified72.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -8.8 \cdot 10^{+147}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5} \cdot {d}^{3}}\\ \mathbf{elif}\;d \leq -4.7 \cdot 10^{-29}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{\ell}}{h}}\right)}\\ \mathbf{elif}\;d \leq 1.1 \cdot 10^{-148}:\\ \;\;\;\;\frac{{\left(D \cdot M\right)}^{2}}{d} \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot -0.125\right)\\ \mathbf{elif}\;d \leq 2.8 \cdot 10^{-49}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;d \leq 23000:\\ \;\;\;\;\frac{{\left(D \cdot M\right)}^{2}}{d} \cdot \left(\sqrt{\frac{h}{{\ell}^{3}}} \cdot -0.125\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 8.0000000000000003e206

    1. Initial program 68.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. Simplified68.3%

      \[\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. Add Preprocessing
    4. Applied egg-rr38.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(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot -0.5\right)\right)} - 1\right)}\right)\right) \]
    5. Step-by-step derivation
      1. expm1-def38.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(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot -0.5\right)\right)\right)}\right)\right) \]
      2. expm1-log1p68.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.0000000000000003e206 < l

    1. Initial program 37.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. Simplified37.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified47.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Step-by-step derivation
      1. expm1-log1p-u44.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)\right)} \]
      2. expm1-udef29.2%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)} - 1} \]
      3. sqrt-div33.0%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}}\right)} - 1 \]
      4. associate-*r/33.0%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{d \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}}}\right)} - 1 \]
      5. add-sqr-sqrt33.0%

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{{d}^{2}}} \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}}\right)} - 1 \]
      8. sqrt-prod7.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{h}}}}{\sqrt{\ell}}\right)} - 1 \]
      9. div-inv7.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{\frac{{d}^{2}}{h}}}}{\sqrt{\ell}}\right)} - 1 \]
      10. sqrt-div11.2%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h}}}}{\sqrt{\ell}}\right)} - 1 \]
      11. unpow211.2%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1 \]
      12. sqrt-prod33.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1 \]
      13. add-sqr-sqrt33.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{\color{blue}{d}}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1 \]
    12. Applied egg-rr33.0%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1} \]
    13. Step-by-step derivation
      1. expm1-def56.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\right)\right)} \]
      2. expm1-log1p59.0%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
      3. associate-/l/59.1%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    14. Simplified59.1%

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 1.3999999999999999e195

    1. Initial program 68.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. Simplified68.3%

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

        \[\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({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
      2. expm1-udef68.0%

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

        \[\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{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}}\right)} - 1\right)\right) \]
      4. div-inv68.0%

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

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

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

      \[\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{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)} - 1\right)}\right) \]
    6. Step-by-step derivation
      1. expm1-def68.0%

        \[\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{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)}\right) \]
      2. expm1-log1p68.3%

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

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

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

        \[\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) \]
      6. *-commutative72.7%

        \[\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) \]
      7. associate-*r*72.7%

        \[\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(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      8. associate-*r/73.1%

        \[\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{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      9. associate-*l/73.1%

        \[\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{M \cdot 0.5}{d} \cdot D\right)}}^{2}}{\ell}\right)\right) \]
      10. associate-*r/73.1%

        \[\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(M \cdot \frac{0.5}{d}\right)} \cdot D\right)}^{2}}{\ell}\right)\right) \]
      11. *-commutative73.1%

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

      \[\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(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}\right)}\right) \]

    if 1.3999999999999999e195 < l

    1. Initial program 37.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. Simplified37.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified47.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Step-by-step derivation
      1. expm1-log1p-u44.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)\right)} \]
      2. expm1-udef29.2%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)} - 1} \]
      3. sqrt-div33.0%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}}\right)} - 1 \]
      4. associate-*r/33.0%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{d \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}}}\right)} - 1 \]
      5. add-sqr-sqrt33.0%

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{{d}^{2}}} \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}}\right)} - 1 \]
      8. sqrt-prod7.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{h}}}}{\sqrt{\ell}}\right)} - 1 \]
      9. div-inv7.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{\frac{{d}^{2}}{h}}}}{\sqrt{\ell}}\right)} - 1 \]
      10. sqrt-div11.2%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h}}}}{\sqrt{\ell}}\right)} - 1 \]
      11. unpow211.2%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1 \]
      12. sqrt-prod33.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1 \]
      13. add-sqr-sqrt33.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{\color{blue}{d}}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1 \]
    12. Applied egg-rr33.0%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1} \]
    13. Step-by-step derivation
      1. expm1-def56.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\right)\right)} \]
      2. expm1-log1p59.0%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
      3. associate-/l/59.1%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    14. Simplified59.1%

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

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

Alternative 10: 39.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} t_0 := \frac{\frac{1}{\ell}}{h}\\ \mathbf{if}\;d \leq -1.3 \cdot 10^{+148}:\\ \;\;\;\;\sqrt[3]{{t_0}^{1.5} \cdot {d}^{3}}\\ \mathbf{elif}\;d \leq -8.5 \cdot 10^{-29}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{t_0}\right)}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot \sqrt{\frac{1}{\ell}}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (/ (/ 1.0 l) h)))
   (if (<= d -1.3e+148)
     (cbrt (* (pow t_0 1.5) (pow d 3.0)))
     (if (<= d -8.5e-29)
       (sqrt (/ (pow d 2.0) (* l h)))
       (if (<= d -5e-310)
         (* d (sqrt (log (exp t_0))))
         (* d (* (pow h -0.5) (sqrt (/ 1.0 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 = (1.0 / l) / h;
	double tmp;
	if (d <= -1.3e+148) {
		tmp = cbrt((pow(t_0, 1.5) * pow(d, 3.0)));
	} else if (d <= -8.5e-29) {
		tmp = sqrt((pow(d, 2.0) / (l * h)));
	} else if (d <= -5e-310) {
		tmp = d * sqrt(log(exp(t_0)));
	} else {
		tmp = d * (pow(h, -0.5) * sqrt((1.0 / l)));
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = (1.0 / l) / h;
	double tmp;
	if (d <= -1.3e+148) {
		tmp = Math.cbrt((Math.pow(t_0, 1.5) * Math.pow(d, 3.0)));
	} else if (d <= -8.5e-29) {
		tmp = Math.sqrt((Math.pow(d, 2.0) / (l * h)));
	} else if (d <= -5e-310) {
		tmp = d * Math.sqrt(Math.log(Math.exp(t_0)));
	} else {
		tmp = d * (Math.pow(h, -0.5) * Math.sqrt((1.0 / 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(1.0 / l) / h)
	tmp = 0.0
	if (d <= -1.3e+148)
		tmp = cbrt(Float64((t_0 ^ 1.5) * (d ^ 3.0)));
	elseif (d <= -8.5e-29)
		tmp = sqrt(Float64((d ^ 2.0) / Float64(l * h)));
	elseif (d <= -5e-310)
		tmp = Float64(d * sqrt(log(exp(t_0))));
	else
		tmp = Float64(d * Float64((h ^ -0.5) * sqrt(Float64(1.0 / 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[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]}, If[LessEqual[d, -1.3e+148], N[Power[N[(N[Power[t$95$0, 1.5], $MachinePrecision] * N[Power[d, 3.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], If[LessEqual[d, -8.5e-29], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -5e-310], N[(d * N[Sqrt[N[Log[N[Exp[t$95$0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[h, -0.5], $MachinePrecision] * N[Sqrt[N[(1.0 / 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{\frac{1}{\ell}}{h}\\
\mathbf{if}\;d \leq -1.3 \cdot 10^{+148}:\\
\;\;\;\;\sqrt[3]{{t_0}^{1.5} \cdot {d}^{3}}\\

\mathbf{elif}\;d \leq -8.5 \cdot 10^{-29}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\

\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \sqrt{\log \left(e^{t_0}\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.3e148

    1. Initial program 70.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified16.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Step-by-step derivation
      1. add-cbrt-cube31.9%

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

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

        \[\leadsto \color{blue}{\sqrt[3]{\left(\left(d \cdot d\right) \cdot d\right) \cdot \left(\left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)}} \]
      4. pow329.0%

        \[\leadsto \sqrt[3]{\color{blue}{{d}^{3}} \cdot \left(\left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)} \]
      5. add-sqr-sqrt29.0%

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

        \[\leadsto \sqrt[3]{{d}^{3} \cdot \left(\color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{1}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)} \]
      7. pow1/229.0%

        \[\leadsto \sqrt[3]{{d}^{3} \cdot \left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}}\right)} \]
      8. pow-prod-up29.0%

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

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

        \[\leadsto \sqrt[3]{{d}^{3} \cdot {\color{blue}{\left(\frac{\frac{1}{\ell}}{h}\right)}}^{\left(1 + 0.5\right)}} \]
      11. metadata-eval29.0%

        \[\leadsto \sqrt[3]{{d}^{3} \cdot {\left(\frac{\frac{1}{\ell}}{h}\right)}^{\color{blue}{1.5}}} \]
    12. Applied egg-rr29.0%

      \[\leadsto \color{blue}{\sqrt[3]{{d}^{3} \cdot {\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5}}} \]
    13. Step-by-step derivation
      1. *-commutative29.0%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5} \cdot {d}^{3}}} \]
    14. Simplified29.0%

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

    if -1.3e148 < d < -8.5000000000000001e-29

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified9.9%

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \left(d \cdot d\right)}} \]
      6. add-sqr-sqrt48.8%

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

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

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

        \[\leadsto \sqrt{\frac{\frac{1}{\ell}}{h} \cdot \color{blue}{{d}^{2}}} \]
    12. Applied egg-rr48.8%

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

        \[\leadsto \sqrt{\color{blue}{\frac{1}{\ell \cdot h}} \cdot {d}^{2}} \]
      2. associate-*l/48.9%

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot {d}^{2}}{\ell \cdot h}}} \]
      3. *-lft-identity48.9%

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

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

    if -8.5000000000000001e-29 < d < -4.999999999999985e-310

    1. Initial program 57.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. 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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/255.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified17.2%

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

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

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

        \[\leadsto d \cdot \sqrt{\log \left(e^{\color{blue}{\frac{\frac{1}{\ell}}{h}}}\right)} \]
    12. Applied egg-rr31.0%

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

    if -4.999999999999985e-310 < d

    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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/263.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Step-by-step derivation
      1. pow1/245.8%

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

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

        \[\leadsto d \cdot \color{blue}{\left({\left(\frac{1}{h}\right)}^{0.5} \cdot {\left(\frac{1}{\ell}\right)}^{0.5}\right)} \]
      4. pow1/252.1%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.3 \cdot 10^{+148}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5} \cdot {d}^{3}}\\ \mathbf{elif}\;d \leq -8.5 \cdot 10^{-29}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{\ell}}{h}}\right)}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot \sqrt{\frac{1}{\ell}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 40.6% accurate, 1.0× speedup?

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

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

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


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

    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. Simplified76.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified13.0%

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

        \[\leadsto \color{blue}{\sqrt{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \cdot \sqrt{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}}} \]
      2. sqrt-unprod39.8%

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}} \cdot \left(d \cdot d\right)} \]
      9. unpow232.1%

        \[\leadsto \sqrt{\frac{\frac{1}{\ell}}{h} \cdot \color{blue}{{d}^{2}}} \]
    12. Applied egg-rr32.1%

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

    if -4.8999999999999998e-29 < d < -4.999999999999985e-310

    1. Initial program 57.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. 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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/255.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified17.2%

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

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

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

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

        \[\leadsto d \cdot \log \left(e^{\frac{\color{blue}{1}}{\sqrt{\ell \cdot h}}}\right) \]
    12. Applied egg-rr31.0%

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

    if -4.999999999999985e-310 < d

    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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/263.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Step-by-step derivation
      1. pow1/245.8%

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

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

        \[\leadsto d \cdot \color{blue}{\left({\left(\frac{1}{h}\right)}^{0.5} \cdot {\left(\frac{1}{\ell}\right)}^{0.5}\right)} \]
      4. pow1/252.1%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.9 \cdot 10^{-29}:\\ \;\;\;\;\sqrt{\frac{\frac{1}{\ell}}{h} \cdot {d}^{2}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \log \left(e^{\frac{1}{\sqrt{\ell \cdot h}}}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot \sqrt{\frac{1}{\ell}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 40.5% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \frac{\frac{1}{\ell}}{h}\\ \mathbf{if}\;d \leq -2.25 \cdot 10^{-26}:\\ \;\;\;\;\sqrt{t_0 \cdot {d}^{2}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{t_0}\right)}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot \sqrt{\frac{1}{\ell}}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (/ (/ 1.0 l) h)))
   (if (<= d -2.25e-26)
     (sqrt (* t_0 (pow d 2.0)))
     (if (<= d -5e-310)
       (* d (sqrt (log (exp t_0))))
       (* d (* (pow h -0.5) (sqrt (/ 1.0 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 = (1.0 / l) / h;
	double tmp;
	if (d <= -2.25e-26) {
		tmp = sqrt((t_0 * pow(d, 2.0)));
	} else if (d <= -5e-310) {
		tmp = d * sqrt(log(exp(t_0)));
	} else {
		tmp = d * (pow(h, -0.5) * sqrt((1.0 / 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 = (1.0d0 / l) / h
    if (d <= (-2.25d-26)) then
        tmp = sqrt((t_0 * (d ** 2.0d0)))
    else if (d <= (-5d-310)) then
        tmp = d * sqrt(log(exp(t_0)))
    else
        tmp = d * ((h ** (-0.5d0)) * sqrt((1.0d0 / 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 = (1.0 / l) / h;
	double tmp;
	if (d <= -2.25e-26) {
		tmp = Math.sqrt((t_0 * Math.pow(d, 2.0)));
	} else if (d <= -5e-310) {
		tmp = d * Math.sqrt(Math.log(Math.exp(t_0)));
	} else {
		tmp = d * (Math.pow(h, -0.5) * Math.sqrt((1.0 / 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 = (1.0 / l) / h
	tmp = 0
	if d <= -2.25e-26:
		tmp = math.sqrt((t_0 * math.pow(d, 2.0)))
	elif d <= -5e-310:
		tmp = d * math.sqrt(math.log(math.exp(t_0)))
	else:
		tmp = d * (math.pow(h, -0.5) * math.sqrt((1.0 / 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(1.0 / l) / h)
	tmp = 0.0
	if (d <= -2.25e-26)
		tmp = sqrt(Float64(t_0 * (d ^ 2.0)));
	elseif (d <= -5e-310)
		tmp = Float64(d * sqrt(log(exp(t_0))));
	else
		tmp = Float64(d * Float64((h ^ -0.5) * sqrt(Float64(1.0 / 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 = (1.0 / l) / h;
	tmp = 0.0;
	if (d <= -2.25e-26)
		tmp = sqrt((t_0 * (d ^ 2.0)));
	elseif (d <= -5e-310)
		tmp = d * sqrt(log(exp(t_0)));
	else
		tmp = d * ((h ^ -0.5) * sqrt((1.0 / 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[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]}, If[LessEqual[d, -2.25e-26], N[Sqrt[N[(t$95$0 * N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -5e-310], N[(d * N[Sqrt[N[Log[N[Exp[t$95$0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[h, -0.5], $MachinePrecision] * N[Sqrt[N[(1.0 / 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{\frac{1}{\ell}}{h}\\
\mathbf{if}\;d \leq -2.25 \cdot 10^{-26}:\\
\;\;\;\;\sqrt{t_0 \cdot {d}^{2}}\\

\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \sqrt{\log \left(e^{t_0}\right)}\\

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


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

    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. Simplified76.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified13.0%

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

        \[\leadsto \color{blue}{\sqrt{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \cdot \sqrt{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}}} \]
      2. sqrt-unprod39.8%

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}} \cdot \left(d \cdot d\right)} \]
      9. unpow232.1%

        \[\leadsto \sqrt{\frac{\frac{1}{\ell}}{h} \cdot \color{blue}{{d}^{2}}} \]
    12. Applied egg-rr32.1%

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

    if -2.2499999999999999e-26 < d < -4.999999999999985e-310

    1. Initial program 57.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. 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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/255.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified17.2%

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

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

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

        \[\leadsto d \cdot \sqrt{\log \left(e^{\color{blue}{\frac{\frac{1}{\ell}}{h}}}\right)} \]
    12. Applied egg-rr31.0%

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

    if -4.999999999999985e-310 < d

    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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/263.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Step-by-step derivation
      1. pow1/245.8%

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

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

        \[\leadsto d \cdot \color{blue}{\left({\left(\frac{1}{h}\right)}^{0.5} \cdot {\left(\frac{1}{\ell}\right)}^{0.5}\right)} \]
      4. pow1/252.1%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.25 \cdot 10^{-26}:\\ \;\;\;\;\sqrt{\frac{\frac{1}{\ell}}{h} \cdot {d}^{2}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{\ell}}{h}}\right)}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot \sqrt{\frac{1}{\ell}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 38.4% accurate, 1.5× speedup?

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

\mathbf{elif}\;\ell \leq -2 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \sqrt[3]{{\left(\frac{1}{\ell \cdot h}\right)}^{1.5}}\\

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


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

    1. Initial program 66.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified11.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{\frac{1}{\ell}}{h} \cdot \color{blue}{{d}^{2}}} \]
    12. Applied egg-rr25.7%

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

        \[\leadsto \sqrt{\color{blue}{\frac{1}{\ell \cdot h}} \cdot {d}^{2}} \]
      2. associate-*l/26.1%

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot {d}^{2}}{\ell \cdot h}}} \]
      3. *-lft-identity26.1%

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

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

    if -7.79999999999999988e-184 < l < -1.999999999999994e-310

    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. Simplified76.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{{\left(\left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)}^{0.3333333333333333}} \]
      3. add-sqr-sqrt59.4%

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

        \[\leadsto d \cdot {\left(\color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{1}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)}^{0.3333333333333333} \]
      5. pow1/259.4%

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}}\right)}^{0.3333333333333333} \]
      6. pow-prod-up59.4%

        \[\leadsto d \cdot {\color{blue}{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{\left(1 + 0.5\right)}\right)}}^{0.3333333333333333} \]
      7. associate-/l/59.4%

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

        \[\leadsto d \cdot {\left({\color{blue}{\left(\frac{\frac{1}{\ell}}{h}\right)}}^{\left(1 + 0.5\right)}\right)}^{0.3333333333333333} \]
      9. metadata-eval59.4%

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{\ell}}{h}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    12. Applied egg-rr59.4%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    13. Step-by-step derivation
      1. unpow1/359.4%

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

        \[\leadsto d \cdot \sqrt[3]{{\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{1.5}} \]
    14. Simplified59.4%

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

    if -1.999999999999994e-310 < 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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/263.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d} \]
      2. sqrt-div52.1%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \cdot d \]
      3. associate-*l/52.1%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{1}{h}} \cdot d}{\sqrt{\ell}}} \]
      4. inv-pow52.1%

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

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

        \[\leadsto \frac{{h}^{\color{blue}{-0.5}} \cdot d}{\sqrt{\ell}} \]
    12. Applied egg-rr52.1%

      \[\leadsto \color{blue}{\frac{{h}^{-0.5} \cdot d}{\sqrt{\ell}}} \]
    13. Step-by-step derivation
      1. associate-/l*49.8%

        \[\leadsto \color{blue}{\frac{{h}^{-0.5}}{\frac{\sqrt{\ell}}{d}}} \]
      2. associate-/r/52.1%

        \[\leadsto \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}} \cdot d} \]
    14. Simplified52.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7.8 \cdot 10^{-184}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt[3]{{\left(\frac{1}{\ell \cdot h}\right)}^{1.5}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 38.4% accurate, 1.5× speedup?

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

\mathbf{elif}\;\ell \leq 5 \cdot 10^{-309}:\\
\;\;\;\;d \cdot \sqrt[3]{{\left(\frac{1}{\ell \cdot h}\right)}^{1.5}}\\

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


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

    1. Initial program 66.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified11.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{\frac{1}{\ell}}{h} \cdot \color{blue}{{d}^{2}}} \]
    12. Applied egg-rr25.7%

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

        \[\leadsto \sqrt{\color{blue}{\frac{1}{\ell \cdot h}} \cdot {d}^{2}} \]
      2. associate-*l/26.1%

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot {d}^{2}}{\ell \cdot h}}} \]
      3. *-lft-identity26.1%

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

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

    if -5.4000000000000002e-184 < l < 4.9999999999999995e-309

    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. Simplified76.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{{\left(\left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)}^{0.3333333333333333}} \]
      3. add-sqr-sqrt59.4%

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

        \[\leadsto d \cdot {\left(\color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{1}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)}^{0.3333333333333333} \]
      5. pow1/259.4%

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}}\right)}^{0.3333333333333333} \]
      6. pow-prod-up59.4%

        \[\leadsto d \cdot {\color{blue}{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{\left(1 + 0.5\right)}\right)}}^{0.3333333333333333} \]
      7. associate-/l/59.4%

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

        \[\leadsto d \cdot {\left({\color{blue}{\left(\frac{\frac{1}{\ell}}{h}\right)}}^{\left(1 + 0.5\right)}\right)}^{0.3333333333333333} \]
      9. metadata-eval59.4%

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{\ell}}{h}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    12. Applied egg-rr59.4%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    13. Step-by-step derivation
      1. unpow1/359.4%

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

        \[\leadsto d \cdot \sqrt[3]{{\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{1.5}} \]
    14. Simplified59.4%

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

    if 4.9999999999999995e-309 < 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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/263.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Step-by-step derivation
      1. pow1/245.8%

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

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

        \[\leadsto d \cdot \color{blue}{\left({\left(\frac{1}{h}\right)}^{0.5} \cdot {\left(\frac{1}{\ell}\right)}^{0.5}\right)} \]
      4. pow1/252.1%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5.4 \cdot 10^{-184}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;\ell \leq 5 \cdot 10^{-309}:\\ \;\;\;\;d \cdot \sqrt[3]{{\left(\frac{1}{\ell \cdot h}\right)}^{1.5}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({h}^{-0.5} \cdot \sqrt{\frac{1}{\ell}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 37.9% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Step-by-step derivation
      1. add-sqr-sqrt5.1%

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \left(d \cdot d\right)}} \]
      6. add-sqr-sqrt25.9%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}} \cdot \left(d \cdot d\right)} \]
      7. associate-/l/25.8%

        \[\leadsto \sqrt{\color{blue}{\frac{1}{\ell \cdot h}} \cdot \left(d \cdot d\right)} \]
      8. associate-/r*25.9%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}} \cdot \left(d \cdot d\right)} \]
      9. unpow225.9%

        \[\leadsto \sqrt{\frac{\frac{1}{\ell}}{h} \cdot \color{blue}{{d}^{2}}} \]
    12. Applied egg-rr25.9%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{\ell}}{h} \cdot {d}^{2}}} \]
    13. Step-by-step derivation
      1. associate-/r*25.8%

        \[\leadsto \sqrt{\color{blue}{\frac{1}{\ell \cdot h}} \cdot {d}^{2}} \]
      2. associate-*l/26.3%

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot {d}^{2}}{\ell \cdot h}}} \]
      3. *-lft-identity26.3%

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{\ell \cdot h}} \]
    14. Simplified26.3%

      \[\leadsto \color{blue}{\sqrt{\frac{{d}^{2}}{\ell \cdot h}}} \]

    if -5.00000000000000023e-231 < l < 1.1000000000000001e-308

    1. Initial program 70.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. Simplified70.0%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/270.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. metadata-eval70.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      3. div-inv70.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\color{blue}{\left(d \cdot \frac{1}{\ell}\right)}}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. unpow-prod-down0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left({d}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. metadata-eval0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left({d}^{\color{blue}{0.5}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      6. pow1/20.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\sqrt{d}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      7. metadata-eval0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{\color{blue}{0.5}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr0.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{0.5}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. unpow1/20.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot \color{blue}{\sqrt{\frac{1}{\ell}}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. Simplified0.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot \sqrt{\frac{1}{\ell}}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    8. Taylor expanded in d around inf 70.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. associate-/r*70.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified70.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Taylor expanded in d around 0 70.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    12. Step-by-step derivation
      1. *-commutative70.4%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. rem-exp-log70.4%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}} \]
      3. exp-neg70.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{e^{-\log \left(\ell \cdot h\right)}}} \]
      4. unpow1/270.4%

        \[\leadsto d \cdot \color{blue}{{\left(e^{-\log \left(\ell \cdot h\right)}\right)}^{0.5}} \]
      5. exp-prod70.4%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}} \]
      6. distribute-lft-neg-out70.4%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}} \]
      7. distribute-rgt-neg-in70.4%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}} \]
      8. metadata-eval70.4%

        \[\leadsto d \cdot e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}} \]
      9. exp-to-pow70.4%

        \[\leadsto d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
    13. Simplified70.4%

      \[\leadsto \color{blue}{d \cdot {\left(\ell \cdot h\right)}^{-0.5}} \]

    if 1.1000000000000001e-308 < 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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/263.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. metadata-eval63.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      3. div-inv63.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\color{blue}{\left(d \cdot \frac{1}{\ell}\right)}}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. unpow-prod-down67.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left({d}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. metadata-eval67.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left({d}^{\color{blue}{0.5}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      6. pow1/267.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\sqrt{d}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      7. metadata-eval67.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{\color{blue}{0.5}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr67.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{0.5}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. unpow1/267.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot \color{blue}{\sqrt{\frac{1}{\ell}}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. Simplified67.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot \sqrt{\frac{1}{\ell}}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    8. Taylor expanded in d around inf 45.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. associate-/r*45.8%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified45.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Step-by-step derivation
      1. *-commutative45.8%

        \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d} \]
      2. sqrt-div52.1%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \cdot d \]
      3. associate-*l/52.1%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{1}{h}} \cdot d}{\sqrt{\ell}}} \]
      4. inv-pow52.1%

        \[\leadsto \frac{\sqrt{\color{blue}{{h}^{-1}}} \cdot d}{\sqrt{\ell}} \]
      5. sqrt-pow152.1%

        \[\leadsto \frac{\color{blue}{{h}^{\left(\frac{-1}{2}\right)}} \cdot d}{\sqrt{\ell}} \]
      6. metadata-eval52.1%

        \[\leadsto \frac{{h}^{\color{blue}{-0.5}} \cdot d}{\sqrt{\ell}} \]
    12. Applied egg-rr52.1%

      \[\leadsto \color{blue}{\frac{{h}^{-0.5} \cdot d}{\sqrt{\ell}}} \]
    13. Step-by-step derivation
      1. associate-/l*49.8%

        \[\leadsto \color{blue}{\frac{{h}^{-0.5}}{\frac{\sqrt{\ell}}{d}}} \]
      2. associate-/r/52.1%

        \[\leadsto \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}} \cdot d} \]
    14. Simplified52.1%

      \[\leadsto \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}} \cdot d} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification40.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-231}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{-308}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 36.8% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -9.6 \cdot 10^{-231}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;\ell \leq 4.3 \cdot 10^{-297}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{h}}}{\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.6e-231)
   (sqrt (/ (pow d 2.0) (* l h)))
   (if (<= l 4.3e-297)
     (* d (sqrt (/ (/ 1.0 h) l)))
     (/ (/ 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.6e-231) {
		tmp = sqrt((pow(d, 2.0) / (l * h)));
	} else if (l <= 4.3e-297) {
		tmp = d * sqrt(((1.0 / h) / l));
	} else {
		tmp = (d / sqrt(h)) / sqrt(l);
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= (-9.6d-231)) then
        tmp = sqrt(((d ** 2.0d0) / (l * h)))
    else if (l <= 4.3d-297) then
        tmp = d * sqrt(((1.0d0 / h) / l))
    else
        tmp = (d / sqrt(h)) / sqrt(l)
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -9.6e-231) {
		tmp = Math.sqrt((Math.pow(d, 2.0) / (l * h)));
	} else if (l <= 4.3e-297) {
		tmp = d * Math.sqrt(((1.0 / h) / l));
	} else {
		tmp = (d / Math.sqrt(h)) / Math.sqrt(l);
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= -9.6e-231:
		tmp = math.sqrt((math.pow(d, 2.0) / (l * h)))
	elif l <= 4.3e-297:
		tmp = d * math.sqrt(((1.0 / h) / l))
	else:
		tmp = (d / math.sqrt(h)) / math.sqrt(l)
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -9.6e-231)
		tmp = sqrt(Float64((d ^ 2.0) / Float64(l * h)));
	elseif (l <= 4.3e-297)
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / h) / l)));
	else
		tmp = Float64(Float64(d / 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.6e-231)
		tmp = sqrt(((d ^ 2.0) / (l * h)));
	elseif (l <= 4.3e-297)
		tmp = d * sqrt(((1.0 / h) / l));
	else
		tmp = (d / sqrt(h)) / sqrt(l);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -9.6e-231], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, 4.3e-297], N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $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.6 \cdot 10^{-231}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\

\mathbf{elif}\;\ell \leq 4.3 \cdot 10^{-297}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -9.59999999999999967e-231

    1. Initial program 67.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified66.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/266.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. metadata-eval66.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      3. div-inv66.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\color{blue}{\left(d \cdot \frac{1}{\ell}\right)}}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. unpow-prod-down0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left({d}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. metadata-eval0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left({d}^{\color{blue}{0.5}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      6. pow1/20.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\sqrt{d}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      7. metadata-eval0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{\color{blue}{0.5}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr0.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{0.5}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. unpow1/20.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot \color{blue}{\sqrt{\frac{1}{\ell}}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. Simplified0.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot \sqrt{\frac{1}{\ell}}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    8. Taylor expanded in d around inf 10.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. associate-/r*10.5%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified10.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Step-by-step derivation
      1. add-sqr-sqrt5.1%

        \[\leadsto \color{blue}{\sqrt{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \cdot \sqrt{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}}} \]
      2. sqrt-unprod32.7%

        \[\leadsto \color{blue}{\sqrt{\left(d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \left(d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)}} \]
      3. *-commutative32.7%

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\right)} \cdot \left(d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)} \]
      4. *-commutative32.7%

        \[\leadsto \sqrt{\left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\right) \cdot \color{blue}{\left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\right)}} \]
      5. swap-sqr25.8%

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \left(d \cdot d\right)}} \]
      6. add-sqr-sqrt25.9%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}} \cdot \left(d \cdot d\right)} \]
      7. associate-/l/25.8%

        \[\leadsto \sqrt{\color{blue}{\frac{1}{\ell \cdot h}} \cdot \left(d \cdot d\right)} \]
      8. associate-/r*25.9%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}} \cdot \left(d \cdot d\right)} \]
      9. unpow225.9%

        \[\leadsto \sqrt{\frac{\frac{1}{\ell}}{h} \cdot \color{blue}{{d}^{2}}} \]
    12. Applied egg-rr25.9%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{\ell}}{h} \cdot {d}^{2}}} \]
    13. Step-by-step derivation
      1. associate-/r*25.8%

        \[\leadsto \sqrt{\color{blue}{\frac{1}{\ell \cdot h}} \cdot {d}^{2}} \]
      2. associate-*l/26.3%

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot {d}^{2}}{\ell \cdot h}}} \]
      3. *-lft-identity26.3%

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{\ell \cdot h}} \]
    14. Simplified26.3%

      \[\leadsto \color{blue}{\sqrt{\frac{{d}^{2}}{\ell \cdot h}}} \]

    if -9.59999999999999967e-231 < l < 4.3000000000000003e-297

    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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/263.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. metadata-eval63.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      3. div-inv63.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\color{blue}{\left(d \cdot \frac{1}{\ell}\right)}}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. unpow-prod-down0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left({d}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. metadata-eval0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left({d}^{\color{blue}{0.5}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      6. pow1/20.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\sqrt{d}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      7. metadata-eval0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{\color{blue}{0.5}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr0.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{0.5}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. unpow1/20.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot \color{blue}{\sqrt{\frac{1}{\ell}}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. Simplified0.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot \sqrt{\frac{1}{\ell}}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    8. Taylor expanded in d around inf 72.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. associate-/r*73.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified73.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]

    if 4.3000000000000003e-297 < l

    1. Initial program 64.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. Simplified64.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/264.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. metadata-eval64.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      3. div-inv64.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\color{blue}{\left(d \cdot \frac{1}{\ell}\right)}}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. unpow-prod-down68.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left({d}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. metadata-eval68.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left({d}^{\color{blue}{0.5}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      6. pow1/268.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\sqrt{d}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      7. metadata-eval68.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{\color{blue}{0.5}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr68.3%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{0.5}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. unpow1/268.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot \color{blue}{\sqrt{\frac{1}{\ell}}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. Simplified68.3%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot \sqrt{\frac{1}{\ell}}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    8. Taylor expanded in d around inf 45.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. associate-/r*45.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified45.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Step-by-step derivation
      1. sqrt-div51.7%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      2. associate-*r/51.7%

        \[\leadsto \color{blue}{\frac{d \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      3. add-sqr-sqrt51.6%

        \[\leadsto \frac{\color{blue}{\left(\sqrt{d} \cdot \sqrt{d}\right)} \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}} \]
      4. sqrt-prod36.0%

        \[\leadsto \frac{\color{blue}{\sqrt{d \cdot d}} \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}} \]
      5. unpow236.0%

        \[\leadsto \frac{\sqrt{\color{blue}{{d}^{2}}} \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}} \]
      6. sqrt-prod34.5%

        \[\leadsto \frac{\color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{h}}}}{\sqrt{\ell}} \]
      7. div-inv34.5%

        \[\leadsto \frac{\sqrt{\color{blue}{\frac{{d}^{2}}{h}}}}{\sqrt{\ell}} \]
      8. sqrt-div36.0%

        \[\leadsto \frac{\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h}}}}{\sqrt{\ell}} \]
      9. unpow236.0%

        \[\leadsto \frac{\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h}}}{\sqrt{\ell}} \]
      10. sqrt-prod51.6%

        \[\leadsto \frac{\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h}}}{\sqrt{\ell}} \]
      11. add-sqr-sqrt51.7%

        \[\leadsto \frac{\frac{\color{blue}{d}}{\sqrt{h}}}{\sqrt{\ell}} \]
    12. Applied egg-rr51.7%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification40.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9.6 \cdot 10^{-231}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;\ell \leq 4.3 \cdot 10^{-297}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 30.3% 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 8 \cdot 10^{-245}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= d 8e-245) (* d (sqrt (/ 1.0 (* l h)))) (/ d (* (sqrt h) (sqrt l)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= 8e-245) {
		tmp = d * sqrt((1.0 / (l * h)));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (d <= 8d-245) then
        tmp = d * sqrt((1.0d0 / (l * h)))
    else
        tmp = d / (sqrt(h) * sqrt(l))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= 8e-245) {
		tmp = d * Math.sqrt((1.0 / (l * h)));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if d <= 8e-245:
		tmp = d * math.sqrt((1.0 / (l * h)))
	else:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (d <= 8e-245)
		tmp = Float64(d * sqrt(Float64(1.0 / Float64(l * h))));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (d <= 8e-245)
		tmp = d * sqrt((1.0 / (l * h)));
	else
		tmp = d / (sqrt(h) * sqrt(l));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, 8e-245], N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 8 \cdot 10^{-245}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 7.9999999999999994e-245

    1. Initial program 64.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.8%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/263.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. metadata-eval63.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      3. div-inv63.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\color{blue}{\left(d \cdot \frac{1}{\ell}\right)}}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. unpow-prod-down4.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left({d}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. metadata-eval4.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left({d}^{\color{blue}{0.5}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      6. pow1/24.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\sqrt{d}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      7. metadata-eval4.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{\color{blue}{0.5}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr4.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{0.5}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. unpow1/24.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot \color{blue}{\sqrt{\frac{1}{\ell}}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. Simplified4.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot \sqrt{\frac{1}{\ell}}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    8. Taylor expanded in d around inf 16.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. *-commutative16.2%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    10. Simplified16.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]

    if 7.9999999999999994e-245 < d

    1. Initial program 67.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified67.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/267.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. metadata-eval67.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      3. div-inv67.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\color{blue}{\left(d \cdot \frac{1}{\ell}\right)}}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. unpow-prod-down71.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left({d}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. metadata-eval71.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left({d}^{\color{blue}{0.5}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      6. pow1/271.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\sqrt{d}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      7. metadata-eval71.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{\color{blue}{0.5}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr71.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{0.5}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. unpow1/271.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot \color{blue}{\sqrt{\frac{1}{\ell}}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. Simplified71.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot \sqrt{\frac{1}{\ell}}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    8. Taylor expanded in d around inf 48.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. associate-/r*48.8%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified48.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Step-by-step derivation
      1. expm1-log1p-u46.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)\right)} \]
      2. expm1-udef36.1%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)} - 1} \]
      3. sqrt-div40.1%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}}\right)} - 1 \]
      4. associate-*r/40.1%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{d \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}}}\right)} - 1 \]
      5. add-sqr-sqrt40.1%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\left(\sqrt{d} \cdot \sqrt{d}\right)} \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}}\right)} - 1 \]
      6. sqrt-prod27.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{d \cdot d}} \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}}\right)} - 1 \]
      7. unpow227.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{{d}^{2}}} \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}}\right)} - 1 \]
      8. sqrt-prod26.2%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{h}}}}{\sqrt{\ell}}\right)} - 1 \]
      9. div-inv26.2%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{\frac{{d}^{2}}{h}}}}{\sqrt{\ell}}\right)} - 1 \]
      10. sqrt-div27.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h}}}}{\sqrt{\ell}}\right)} - 1 \]
      11. unpow227.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1 \]
      12. sqrt-prod40.1%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1 \]
      13. add-sqr-sqrt40.1%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{\color{blue}{d}}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1 \]
    12. Applied egg-rr40.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\right)} - 1} \]
    13. Step-by-step derivation
      1. expm1-def53.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\right)\right)} \]
      2. expm1-log1p56.0%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
      3. associate-/l/56.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    14. Simplified56.0%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification32.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 8 \cdot 10^{-245}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 29.1% 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 5 \cdot 10^{-176}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= d 5e-176) (* d (sqrt (/ 1.0 (* l h)))) (/ (/ d (sqrt h)) (sqrt l))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= 5e-176) {
		tmp = d * sqrt((1.0 / (l * h)));
	} else {
		tmp = (d / sqrt(h)) / sqrt(l);
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (d <= 5d-176) then
        tmp = d * sqrt((1.0d0 / (l * h)))
    else
        tmp = (d / sqrt(h)) / sqrt(l)
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= 5e-176) {
		tmp = d * Math.sqrt((1.0 / (l * h)));
	} else {
		tmp = (d / Math.sqrt(h)) / Math.sqrt(l);
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if d <= 5e-176:
		tmp = d * math.sqrt((1.0 / (l * h)))
	else:
		tmp = (d / math.sqrt(h)) / math.sqrt(l)
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (d <= 5e-176)
		tmp = Float64(d * sqrt(Float64(1.0 / Float64(l * h))));
	else
		tmp = Float64(Float64(d / 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 (d <= 5e-176)
		tmp = d * sqrt((1.0 / (l * h)));
	else
		tmp = (d / sqrt(h)) / sqrt(l);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, 5e-176], N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 5 \cdot 10^{-176}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 5e-176

    1. Initial program 62.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified61.5%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/261.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. metadata-eval61.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      3. div-inv61.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\color{blue}{\left(d \cdot \frac{1}{\ell}\right)}}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. unpow-prod-down6.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left({d}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. metadata-eval6.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left({d}^{\color{blue}{0.5}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      6. pow1/26.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\sqrt{d}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      7. metadata-eval6.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{\color{blue}{0.5}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr6.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{0.5}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. unpow1/26.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot \color{blue}{\sqrt{\frac{1}{\ell}}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. Simplified6.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot \sqrt{\frac{1}{\ell}}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    8. Taylor expanded in d around inf 16.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. *-commutative16.6%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    10. Simplified16.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]

    if 5e-176 < d

    1. Initial program 71.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. Simplified71.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. pow1/271.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. metadata-eval71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      3. div-inv71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\color{blue}{\left(d \cdot \frac{1}{\ell}\right)}}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. unpow-prod-down73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left({d}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. metadata-eval73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left({d}^{\color{blue}{0.5}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      6. pow1/273.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\sqrt{d}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      7. metadata-eval73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{\color{blue}{0.5}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr73.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{0.5}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. unpow1/273.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot \color{blue}{\sqrt{\frac{1}{\ell}}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. Simplified73.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot \sqrt{\frac{1}{\ell}}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    8. Taylor expanded in d around inf 50.7%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. associate-/r*51.2%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified51.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    11. Step-by-step derivation
      1. sqrt-div59.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      2. associate-*r/59.0%

        \[\leadsto \color{blue}{\frac{d \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      3. add-sqr-sqrt58.9%

        \[\leadsto \frac{\color{blue}{\left(\sqrt{d} \cdot \sqrt{d}\right)} \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}} \]
      4. sqrt-prod43.2%

        \[\leadsto \frac{\color{blue}{\sqrt{d \cdot d}} \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}} \]
      5. unpow243.2%

        \[\leadsto \frac{\sqrt{\color{blue}{{d}^{2}}} \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}} \]
      6. sqrt-prod41.3%

        \[\leadsto \frac{\color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{h}}}}{\sqrt{\ell}} \]
      7. div-inv41.3%

        \[\leadsto \frac{\sqrt{\color{blue}{\frac{{d}^{2}}{h}}}}{\sqrt{\ell}} \]
      8. sqrt-div43.2%

        \[\leadsto \frac{\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h}}}}{\sqrt{\ell}} \]
      9. unpow243.2%

        \[\leadsto \frac{\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h}}}{\sqrt{\ell}} \]
      10. sqrt-prod58.9%

        \[\leadsto \frac{\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h}}}{\sqrt{\ell}} \]
      11. add-sqr-sqrt59.0%

        \[\leadsto \frac{\frac{\color{blue}{d}}{\sqrt{h}}}{\sqrt{\ell}} \]
    12. Applied egg-rr59.0%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification32.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 5 \cdot 10^{-176}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 26.6% 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 \sqrt{\frac{1}{\ell \cdot h}} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (* d (sqrt (/ 1.0 (* l h)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d * sqrt((1.0 / (l * h)));
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d * sqrt((1.0d0 / (l * h)))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d * Math.sqrt((1.0 / (l * h)));
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d * math.sqrt((1.0 / (l * h)))
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d * sqrt(Float64(1.0 / Float64(l * h))))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d * sqrt((1.0 / (l * h)));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
d \cdot \sqrt{\frac{1}{\ell \cdot h}}
\end{array}
Derivation
  1. Initial program 65.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. Simplified65.4%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. pow1/265.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    2. metadata-eval65.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    3. div-inv65.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\color{blue}{\left(d \cdot \frac{1}{\ell}\right)}}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    4. unpow-prod-down32.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left({d}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. metadata-eval32.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left({d}^{\color{blue}{0.5}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. pow1/232.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\sqrt{d}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. metadata-eval32.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{\color{blue}{0.5}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
  5. Applied egg-rr32.0%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{0.5}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
  6. Step-by-step derivation
    1. unpow1/232.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot \color{blue}{\sqrt{\frac{1}{\ell}}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
  7. Simplified32.0%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot \sqrt{\frac{1}{\ell}}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
  8. Taylor expanded in d around inf 29.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  9. Step-by-step derivation
    1. *-commutative29.4%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
  10. Simplified29.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
  11. Final simplification29.4%

    \[\leadsto d \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
  12. Add Preprocessing

Alternative 20: 26.8% 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 \sqrt{\frac{\frac{1}{h}}{\ell}} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (* d (sqrt (/ (/ 1.0 h) l))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d * sqrt(((1.0 / h) / l));
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d * sqrt(((1.0d0 / h) / l))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d * Math.sqrt(((1.0 / h) / l));
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d * math.sqrt(((1.0 / h) / l))
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d * sqrt(Float64(Float64(1.0 / h) / l)))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d * sqrt(((1.0 / h) / l));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}
\end{array}
Derivation
  1. Initial program 65.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. Simplified65.4%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. pow1/265.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    2. metadata-eval65.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    3. div-inv65.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\color{blue}{\left(d \cdot \frac{1}{\ell}\right)}}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    4. unpow-prod-down32.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left({d}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. metadata-eval32.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left({d}^{\color{blue}{0.5}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. pow1/232.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\sqrt{d}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. metadata-eval32.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{\color{blue}{0.5}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
  5. Applied egg-rr32.0%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{0.5}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
  6. Step-by-step derivation
    1. unpow1/232.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot \color{blue}{\sqrt{\frac{1}{\ell}}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
  7. Simplified32.0%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot \sqrt{\frac{1}{\ell}}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
  8. Taylor expanded in d around inf 29.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  9. Step-by-step derivation
    1. associate-/r*29.5%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
  10. Simplified29.5%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  11. Final simplification29.5%

    \[\leadsto d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}} \]
  12. Add Preprocessing

Alternative 21: 26.6% accurate, 3.1× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ d \cdot {\left(\ell \cdot h\right)}^{-0.5} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (* d (pow (* l h) -0.5)))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d * pow((l * h), -0.5);
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d * ((l * h) ** (-0.5d0))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d * Math.pow((l * h), -0.5);
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d * math.pow((l * h), -0.5)
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d * (Float64(l * h) ^ -0.5))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d * ((l * h) ^ -0.5);
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
d \cdot {\left(\ell \cdot h\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 65.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. Simplified65.4%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. pow1/265.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    2. metadata-eval65.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    3. div-inv65.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\color{blue}{\left(d \cdot \frac{1}{\ell}\right)}}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    4. unpow-prod-down32.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left({d}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. metadata-eval32.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left({d}^{\color{blue}{0.5}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. pow1/232.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\sqrt{d}} \cdot {\left(\frac{1}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. metadata-eval32.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{\color{blue}{0.5}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
  5. Applied egg-rr32.0%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{\ell}\right)}^{0.5}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
  6. Step-by-step derivation
    1. unpow1/232.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot \color{blue}{\sqrt{\frac{1}{\ell}}}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
  7. Simplified32.0%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot \sqrt{\frac{1}{\ell}}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
  8. Taylor expanded in d around inf 29.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  9. Step-by-step derivation
    1. associate-/r*29.5%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
  10. Simplified29.5%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  11. Taylor expanded in d around 0 29.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  12. Step-by-step derivation
    1. *-commutative29.4%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    2. rem-exp-log28.2%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}} \]
    3. exp-neg28.2%

      \[\leadsto d \cdot \sqrt{\color{blue}{e^{-\log \left(\ell \cdot h\right)}}} \]
    4. unpow1/228.2%

      \[\leadsto d \cdot \color{blue}{{\left(e^{-\log \left(\ell \cdot h\right)}\right)}^{0.5}} \]
    5. exp-prod27.9%

      \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}} \]
    6. distribute-lft-neg-out27.9%

      \[\leadsto d \cdot e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}} \]
    7. distribute-rgt-neg-in27.9%

      \[\leadsto d \cdot e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}} \]
    8. metadata-eval27.9%

      \[\leadsto d \cdot e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}} \]
    9. exp-to-pow29.0%

      \[\leadsto d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
  13. Simplified29.0%

    \[\leadsto \color{blue}{d \cdot {\left(\ell \cdot h\right)}^{-0.5}} \]
  14. Final simplification29.0%

    \[\leadsto d \cdot {\left(\ell \cdot h\right)}^{-0.5} \]
  15. Add Preprocessing

Reproduce

?
herbie shell --seed 2024011 
(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)))))