Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.2% → 80.2%
Time: 1.8min
Alternatives: 19
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 19 alternatives:

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

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

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M\_m}{2} \cdot \frac{D\_m}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + h \cdot \frac{{\left(D\_m \cdot \frac{0.5 \cdot M\_m}{d}\right)}^{2} \cdot -0.5}{\ell}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= h -5e-310)
   (*
    (* (/ (sqrt (- d)) (sqrt (- h))) (sqrt (/ d l)))
    (- 1.0 (* 0.5 (* (pow (* (/ M_m 2.0) (/ D_m d)) 2.0) (/ h l)))))
   (*
    (+ 1.0 (* h (/ (* (pow (* D_m (/ (* 0.5 M_m) 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 (h <= -5e-310) {
		tmp = ((sqrt(-d) / sqrt(-h)) * sqrt((d / l))) * (1.0 - (0.5 * (pow(((M_m / 2.0) * (D_m / d)), 2.0) * (h / l))));
	} else {
		tmp = (1.0 + (h * ((pow((D_m * ((0.5 * M_m) / d)), 2.0) * -0.5) / l))) * (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 (h <= (-5d-310)) then
        tmp = ((sqrt(-d) / sqrt(-h)) * sqrt((d / l))) * (1.0d0 - (0.5d0 * ((((m_m / 2.0d0) * (d_m / d)) ** 2.0d0) * (h / l))))
    else
        tmp = (1.0d0 + (h * ((((d_m * ((0.5d0 * m_m) / d)) ** 2.0d0) * (-0.5d0)) / l))) * (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 (h <= -5e-310) {
		tmp = ((Math.sqrt(-d) / Math.sqrt(-h)) * Math.sqrt((d / l))) * (1.0 - (0.5 * (Math.pow(((M_m / 2.0) * (D_m / d)), 2.0) * (h / l))));
	} else {
		tmp = (1.0 + (h * ((Math.pow((D_m * ((0.5 * M_m) / d)), 2.0) * -0.5) / l))) * (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 h <= -5e-310:
		tmp = ((math.sqrt(-d) / math.sqrt(-h)) * math.sqrt((d / l))) * (1.0 - (0.5 * (math.pow(((M_m / 2.0) * (D_m / d)), 2.0) * (h / l))))
	else:
		tmp = (1.0 + (h * ((math.pow((D_m * ((0.5 * M_m) / d)), 2.0) * -0.5) / l))) * (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 (h <= -5e-310)
		tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * Float64((Float64(Float64(M_m / 2.0) * Float64(D_m / d)) ^ 2.0) * Float64(h / l)))));
	else
		tmp = Float64(Float64(1.0 + Float64(h * Float64(Float64((Float64(D_m * Float64(Float64(0.5 * M_m) / d)) ^ 2.0) * -0.5) / l))) * 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 (h <= -5e-310)
		tmp = ((sqrt(-d) / sqrt(-h)) * sqrt((d / l))) * (1.0 - (0.5 * ((((M_m / 2.0) * (D_m / d)) ^ 2.0) * (h / l))));
	else
		tmp = (1.0 + (h * ((((D_m * ((0.5 * M_m) / d)) ^ 2.0) * -0.5) / l))) * (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[h, -5e-310], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(h * N[(N[(N[Power[N[(D$95$m * N[(N[(0.5 * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M\_m}{2} \cdot \frac{D\_m}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\\

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


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

    1. Initial program 64.1%

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

        \[\leadsto \left(\sqrt{\color{blue}{\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) \]
      2. sqrt-div73.5%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{-d}}{\sqrt{-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) \]
    5. Applied egg-rr73.5%

      \[\leadsto \left(\color{blue}{\frac{\sqrt{-d}}{\sqrt{-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) \]

    if -4.999999999999985e-310 < h

    1. Initial program 69.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. Add Preprocessing
    3. Applied egg-rr72.4%

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

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

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

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

        \[\leadsto \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) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. associate-*r*86.1%

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

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

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

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

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

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

Alternative 2: 79.2% accurate, 0.8× speedup?

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

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


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

    1. Initial program 64.7%

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

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

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

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

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

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\frac{\ell}{h}}}\right) \]
    6. Step-by-step derivation
      1. associate-/r/65.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) \]
      2. associate-*r*65.6%

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

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

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

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

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

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

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

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

    if -5.79999999999999985e-292 < l

    1. Initial program 68.6%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Add Preprocessing
    3. Applied egg-rr71.8%

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

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

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

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

        \[\leadsto \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) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. associate-*r*85.4%

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

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

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

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

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

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

Alternative 3: 72.3% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \frac{D\_m}{d} \cdot \left(0.5 \cdot M\_m\right)\\ \mathbf{if}\;\ell \leq 5.6 \cdot 10^{-112}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h \cdot -0.5}{\frac{1}{t\_0} \cdot \frac{\ell}{t\_0}}\right)\right)\\ \mathbf{elif}\;\ell \leq 1.85 \cdot 10^{+116}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left({\left(0.5 \cdot \left(D\_m \cdot \frac{M\_m}{d}\right)\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)}{\sqrt{h \cdot \ell}}\\ \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 (* (/ D_m d) (* 0.5 M_m))))
   (if (<= l 5.6e-112)
     (*
      (sqrt (/ d l))
      (* (sqrt (/ d h)) (+ 1.0 (/ (* h -0.5) (* (/ 1.0 t_0) (/ l t_0))))))
     (if (<= l 1.85e+116)
       (*
        d
        (/
         (fma (pow (* 0.5 (* D_m (/ M_m d))) 2.0) (* (/ h l) -0.5) 1.0)
         (sqrt (* h l))))
       (* 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 = (D_m / d) * (0.5 * M_m);
	double tmp;
	if (l <= 5.6e-112) {
		tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + ((h * -0.5) / ((1.0 / t_0) * (l / t_0)))));
	} else if (l <= 1.85e+116) {
		tmp = d * (fma(pow((0.5 * (D_m * (M_m / d))), 2.0), ((h / l) * -0.5), 1.0) / sqrt((h * l)));
	} else {
		tmp = d * (pow(h, -0.5) * 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(D_m / d) * Float64(0.5 * M_m))
	tmp = 0.0
	if (l <= 5.6e-112)
		tmp = Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(Float64(h * -0.5) / Float64(Float64(1.0 / t_0) * Float64(l / t_0))))));
	elseif (l <= 1.85e+116)
		tmp = Float64(d * Float64(fma((Float64(0.5 * Float64(D_m * Float64(M_m / d))) ^ 2.0), Float64(Float64(h / l) * -0.5), 1.0) / sqrt(Float64(h * l))));
	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[(D$95$m / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, 5.6e-112], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(h * -0.5), $MachinePrecision] / N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(l / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.85e+116], N[(d * N[(N[(N[Power[N[(0.5 * N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] + 1.0), $MachinePrecision] / N[Sqrt[N[(h * l), $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{D\_m}{d} \cdot \left(0.5 \cdot M\_m\right)\\
\mathbf{if}\;\ell \leq 5.6 \cdot 10^{-112}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h \cdot -0.5}{\frac{1}{t\_0} \cdot \frac{\ell}{t\_0}}\right)\right)\\

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

\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.60000000000000046e-112

    1. Initial program 68.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. Simplified67.4%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \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-rr67.4%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\left(\left(1 + \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. associate--l+67.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.60000000000000046e-112 < l < 1.8500000000000001e116

    1. Initial program 69.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. Add Preprocessing
    3. Applied egg-rr76.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.8500000000000001e116 < l

    1. Initial program 57.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in d around inf 53.1%

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    5. Applied egg-rr45.2%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    6. Step-by-step derivation
      1. pow-pow53.0%

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

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{h} \cdot \frac{1}{\ell}\right)}}^{\left(1.5 \cdot 0.3333333333333333\right)} \]
      3. metadata-eval53.1%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 72.2% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \frac{D\_m}{d} \cdot \left(0.5 \cdot M\_m\right)\\ \mathbf{if}\;\ell \leq 4 \cdot 10^{-112}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h \cdot -0.5}{\frac{1}{t\_0} \cdot \frac{\ell}{t\_0}}\right)\right)\\ \mathbf{elif}\;\ell \leq 1.7 \cdot 10^{+116}:\\ \;\;\;\;\frac{d \cdot \mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(\left(M\_m \cdot D\_m\right) \cdot \frac{0.5}{d}\right)}^{2}, 1\right)}{\sqrt{h \cdot \ell}}\\ \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 (* (/ D_m d) (* 0.5 M_m))))
   (if (<= l 4e-112)
     (*
      (sqrt (/ d l))
      (* (sqrt (/ d h)) (+ 1.0 (/ (* h -0.5) (* (/ 1.0 t_0) (/ l t_0))))))
     (if (<= l 1.7e+116)
       (/
        (* d (fma (/ h l) (* -0.5 (pow (* (* M_m D_m) (/ 0.5 d)) 2.0)) 1.0))
        (sqrt (* h l)))
       (* 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 = (D_m / d) * (0.5 * M_m);
	double tmp;
	if (l <= 4e-112) {
		tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + ((h * -0.5) / ((1.0 / t_0) * (l / t_0)))));
	} else if (l <= 1.7e+116) {
		tmp = (d * fma((h / l), (-0.5 * pow(((M_m * D_m) * (0.5 / d)), 2.0)), 1.0)) / sqrt((h * l));
	} else {
		tmp = d * (pow(h, -0.5) * 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(D_m / d) * Float64(0.5 * M_m))
	tmp = 0.0
	if (l <= 4e-112)
		tmp = Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(Float64(h * -0.5) / Float64(Float64(1.0 / t_0) * Float64(l / t_0))))));
	elseif (l <= 1.7e+116)
		tmp = Float64(Float64(d * fma(Float64(h / l), Float64(-0.5 * (Float64(Float64(M_m * D_m) * Float64(0.5 / d)) ^ 2.0)), 1.0)) / sqrt(Float64(h * l)));
	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[(D$95$m / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, 4e-112], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(h * -0.5), $MachinePrecision] / N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(l / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.7e+116], N[(N[(d * N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(h * l), $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{D\_m}{d} \cdot \left(0.5 \cdot M\_m\right)\\
\mathbf{if}\;\ell \leq 4 \cdot 10^{-112}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h \cdot -0.5}{\frac{1}{t\_0} \cdot \frac{\ell}{t\_0}}\right)\right)\\

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

\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 < 3.9999999999999998e-112

    1. Initial program 68.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. Simplified67.4%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \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-rr67.4%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\left(\left(1 + \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. associate--l+67.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.9999999999999998e-112 < l < 1.70000000000000011e116

    1. Initial program 69.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. Add Preprocessing
    3. Applied egg-rr76.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.70000000000000011e116 < l

    1. Initial program 57.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in d around inf 53.1%

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    5. Applied egg-rr45.2%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    6. Step-by-step derivation
      1. pow-pow53.0%

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

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{h} \cdot \frac{1}{\ell}\right)}}^{\left(1.5 \cdot 0.3333333333333333\right)} \]
      3. metadata-eval53.1%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 75.5% accurate, 1.0× speedup?

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

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


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

    1. Initial program 68.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. Simplified67.4%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \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-rr67.4%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\left(\left(1 + \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. associate--l+67.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.49999999999999994e-112 < 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. Add Preprocessing
    3. Applied egg-rr75.3%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 76.5% accurate, 1.0× speedup?

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

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


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

    1. Initial program 64.7%

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

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \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-rr63.8%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\left(\left(1 + \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. associate--l+63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.79999999999999985e-292 < l

    1. Initial program 68.6%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Add Preprocessing
    3. Applied egg-rr71.8%

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

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

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

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

        \[\leadsto \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) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. associate-*r*85.4%

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

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

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

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

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

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

Alternative 7: 70.6% accurate, 1.4× speedup?

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

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


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

    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. Simplified67.4%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \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-rr67.4%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\left(\left(1 + \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. associate--l+67.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.01999999999999993e236 < l

    1. Initial program 50.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. Add Preprocessing
    3. Taylor expanded in d around inf 52.6%

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

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

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

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

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

        \[\leadsto d \cdot {\left({\left(\frac{1}{h \cdot \ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)}^{0.3333333333333333} \]
      6. pow-prod-up34.4%

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

        \[\leadsto d \cdot {\left({\color{blue}{\left(\frac{\frac{1}{h}}{\ell}\right)}}^{\left(1 + 0.5\right)}\right)}^{0.3333333333333333} \]
      8. metadata-eval34.4%

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    5. Applied egg-rr34.4%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    6. Step-by-step derivation
      1. pow-pow52.6%

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

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

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

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      5. inv-pow79.9%

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

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

        \[\leadsto d \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}} \]
    7. Applied egg-rr79.9%

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

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

Alternative 8: 60.8% accurate, 1.4× speedup?

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

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


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

    1. Initial program 69.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. Simplified69.1%

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2}}{\frac{\ell}{h}}\right) \]
      4. associate-/l*69.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 \frac{D}{2 \cdot d}\right)}}^{2}}{\frac{\ell}{h}}\right) \]
      5. *-un-lft-identity69.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.30000000000000007e46 < l

    1. Initial program 55.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. Add Preprocessing
    3. Taylor expanded in d around inf 49.8%

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

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

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

        \[\leadsto d \cdot {\left(\color{blue}{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{0.3333333333333333} \]
      4. pow141.9%

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

        \[\leadsto d \cdot {\left({\left(\frac{1}{h \cdot \ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)}^{0.3333333333333333} \]
      6. pow-prod-up41.9%

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

        \[\leadsto d \cdot {\left({\color{blue}{\left(\frac{\frac{1}{h}}{\ell}\right)}}^{\left(1 + 0.5\right)}\right)}^{0.3333333333333333} \]
      8. metadata-eval41.9%

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    5. Applied egg-rr41.9%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    6. Step-by-step derivation
      1. pow-pow50.8%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}} \]
      2. div-inv50.9%

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{h} \cdot \frac{1}{\ell}\right)}}^{\left(1.5 \cdot 0.3333333333333333\right)} \]
      3. metadata-eval50.9%

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

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

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

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

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

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

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

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

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

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

Alternative 9: 40.3% accurate, 1.5× speedup?

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

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

\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 < -1.4499999999999999e-139

    1. Initial program 73.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. Simplified72.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. clear-num72.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot e^{-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      10. unpow1/24.1%

        \[\leadsto d \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
      11. rec-exp4.1%

        \[\leadsto d \cdot \color{blue}{\frac{1}{e^{\log \left(\sqrt{h \cdot \ell}\right)}}} \]
      12. rem-exp-log4.1%

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

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      14. *-rgt-identity4.1%

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\sqrt{h \cdot \ell}} \cdot \frac{d}{\sqrt{h \cdot \ell}}}} \]
      3. frac-times31.3%

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

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{\sqrt{h \cdot \ell} \cdot \sqrt{h \cdot \ell}}} \]
      5. add-sqr-sqrt31.4%

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

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

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

    if -1.4499999999999999e-139 < d < -1.999999999999994e-310

    1. Initial program 41.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. Add Preprocessing
    3. Taylor expanded in d around inf 19.3%

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

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

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

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

        \[\leadsto d \cdot \sqrt{{\left({\color{blue}{\left(\frac{\frac{1}{h}}{\ell}\right)}}^{3}\right)}^{0.3333333333333333}} \]
    5. Applied egg-rr43.1%

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < d

    1. Initial program 69.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. Add Preprocessing
    3. Taylor expanded in d around inf 40.6%

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

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

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

        \[\leadsto d \cdot {\left(\color{blue}{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{0.3333333333333333} \]
      4. pow133.8%

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

        \[\leadsto d \cdot {\left({\left(\frac{1}{h \cdot \ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)}^{0.3333333333333333} \]
      6. pow-prod-up33.8%

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

        \[\leadsto d \cdot {\left({\color{blue}{\left(\frac{\frac{1}{h}}{\ell}\right)}}^{\left(1 + 0.5\right)}\right)}^{0.3333333333333333} \]
      8. metadata-eval33.8%

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    5. Applied egg-rr33.8%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    6. Step-by-step derivation
      1. pow-pow41.1%

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

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{h} \cdot \frac{1}{\ell}\right)}}^{\left(1.5 \cdot 0.3333333333333333\right)} \]
      3. metadata-eval41.1%

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

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

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

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

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

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

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

        \[\leadsto d \cdot \left({h}^{-0.5} \cdot \color{blue}{\sqrt{\frac{1}{\ell}}}\right) \]
    9. Simplified51.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 simplification43.2%

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

Alternative 10: 39.9% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 73.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. Simplified72.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. clear-num72.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot e^{-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      10. unpow1/24.1%

        \[\leadsto d \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
      11. rec-exp4.1%

        \[\leadsto d \cdot \color{blue}{\frac{1}{e^{\log \left(\sqrt{h \cdot \ell}\right)}}} \]
      12. rem-exp-log4.1%

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

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      14. *-rgt-identity4.1%

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\sqrt{h \cdot \ell}} \cdot \frac{d}{\sqrt{h \cdot \ell}}}} \]
      3. frac-times31.3%

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

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{\sqrt{h \cdot \ell} \cdot \sqrt{h \cdot \ell}}} \]
      5. add-sqr-sqrt31.4%

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

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

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

    if -7.19999999999999955e-135 < d < -1.999999999999994e-310

    1. Initial program 41.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. Add Preprocessing
    3. Taylor expanded in d around inf 19.3%

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

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

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

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

        \[\leadsto d \cdot \sqrt{{\left({\color{blue}{\left(\frac{\frac{1}{h}}{\ell}\right)}}^{3}\right)}^{0.3333333333333333}} \]
    5. Applied egg-rr43.1%

      \[\leadsto d \cdot \sqrt{\color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}} \]
    6. Step-by-step derivation
      1. unpow1/343.1%

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

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

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

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\ell \cdot h}}} \]
      5. metadata-eval14.0%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{\ell \cdot h}} \]
      6. *-commutative14.0%

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

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      8. sqrt-unprod14.0%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      9. *-commutative14.0%

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < d

    1. Initial program 69.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. Add Preprocessing
    3. Taylor expanded in d around inf 40.6%

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

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

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

        \[\leadsto d \cdot {\left(\color{blue}{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{0.3333333333333333} \]
      4. pow133.8%

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

        \[\leadsto d \cdot {\left({\left(\frac{1}{h \cdot \ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)}^{0.3333333333333333} \]
      6. pow-prod-up33.8%

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

        \[\leadsto d \cdot {\left({\color{blue}{\left(\frac{\frac{1}{h}}{\ell}\right)}}^{\left(1 + 0.5\right)}\right)}^{0.3333333333333333} \]
      8. metadata-eval33.8%

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    5. Applied egg-rr33.8%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    6. Step-by-step derivation
      1. pow-pow41.1%

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

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{h} \cdot \frac{1}{\ell}\right)}}^{\left(1.5 \cdot 0.3333333333333333\right)} \]
      3. metadata-eval41.1%

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

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

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

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

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

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

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

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

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

Alternative 11: 40.0% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 73.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. Simplified72.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. clear-num72.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot e^{-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      10. unpow1/24.1%

        \[\leadsto d \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
      11. rec-exp4.1%

        \[\leadsto d \cdot \color{blue}{\frac{1}{e^{\log \left(\sqrt{h \cdot \ell}\right)}}} \]
      12. rem-exp-log4.1%

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

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      14. *-rgt-identity4.1%

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\sqrt{h \cdot \ell}} \cdot \frac{d}{\sqrt{h \cdot \ell}}}} \]
      3. frac-times31.3%

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

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{\sqrt{h \cdot \ell} \cdot \sqrt{h \cdot \ell}}} \]
      5. add-sqr-sqrt31.4%

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

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

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

    if -1.62e-142 < d < -1.999999999999994e-310

    1. Initial program 41.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. Add Preprocessing
    3. Taylor expanded in d around inf 19.3%

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

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

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

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

        \[\leadsto d \cdot \sqrt{{\left({\color{blue}{\left(\frac{\frac{1}{h}}{\ell}\right)}}^{3}\right)}^{0.3333333333333333}} \]
    5. Applied egg-rr43.1%

      \[\leadsto d \cdot \sqrt{\color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}} \]
    6. Step-by-step derivation
      1. unpow1/343.1%

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

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

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

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\ell \cdot h}}} \]
      5. metadata-eval14.0%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{\ell \cdot h}} \]
      6. *-commutative14.0%

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

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      8. sqrt-unprod14.0%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      9. *-commutative14.0%

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < d

    1. Initial program 69.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. Add Preprocessing
    3. Taylor expanded in d around inf 40.6%

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

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

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

        \[\leadsto d \cdot {\left(\color{blue}{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{0.3333333333333333} \]
      4. pow133.8%

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

        \[\leadsto d \cdot {\left({\left(\frac{1}{h \cdot \ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)}^{0.3333333333333333} \]
      6. pow-prod-up33.8%

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

        \[\leadsto d \cdot {\left({\color{blue}{\left(\frac{\frac{1}{h}}{\ell}\right)}}^{\left(1 + 0.5\right)}\right)}^{0.3333333333333333} \]
      8. metadata-eval33.8%

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    5. Applied egg-rr33.8%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    6. Step-by-step derivation
      1. pow-pow41.1%

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

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

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

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      5. inv-pow51.0%

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

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

        \[\leadsto d \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}} \]
    7. Applied egg-rr51.0%

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

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

Alternative 12: 39.9% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 73.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. Simplified72.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. clear-num72.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot e^{-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      10. unpow1/24.1%

        \[\leadsto d \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
      11. rec-exp4.1%

        \[\leadsto d \cdot \color{blue}{\frac{1}{e^{\log \left(\sqrt{h \cdot \ell}\right)}}} \]
      12. rem-exp-log4.1%

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

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      14. *-rgt-identity4.1%

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\sqrt{h \cdot \ell}} \cdot \frac{d}{\sqrt{h \cdot \ell}}}} \]
      3. frac-times31.3%

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

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{\sqrt{h \cdot \ell} \cdot \sqrt{h \cdot \ell}}} \]
      5. add-sqr-sqrt31.4%

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

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

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

    if -5.5999999999999997e-139 < d < -1.999999999999994e-310

    1. Initial program 41.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. Add Preprocessing
    3. Taylor expanded in d around inf 19.3%

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

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

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

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

        \[\leadsto d \cdot \sqrt{{\left({\color{blue}{\left(\frac{\frac{1}{h}}{\ell}\right)}}^{3}\right)}^{0.3333333333333333}} \]
    5. Applied egg-rr43.1%

      \[\leadsto d \cdot \sqrt{\color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}} \]
    6. Step-by-step derivation
      1. unpow1/343.1%

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

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

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

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\ell \cdot h}}} \]
      5. metadata-eval14.0%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{\ell \cdot h}} \]
      6. *-commutative14.0%

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

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      8. sqrt-unprod14.0%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      9. *-commutative14.0%

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < d

    1. Initial program 69.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. Simplified69.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. clear-num69.6%

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2}}{\frac{\ell}{h}}\right) \]
      4. associate-/l*69.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 \frac{D}{2 \cdot d}\right)}}^{2}}{\frac{\ell}{h}}\right) \]
      5. *-un-lft-identity69.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot e^{-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      10. unpow1/238.8%

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

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

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

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      14. *-rgt-identity40.7%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    10. Simplified40.7%

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

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

        \[\leadsto d \cdot \frac{\color{blue}{\sqrt{1}}}{\sqrt{h \cdot \ell}} \]
      3. sqrt-div40.6%

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
      4. *-commutative40.6%

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

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

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

        \[\leadsto d \cdot {\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{\left(1.5 \cdot 0.3333333333333333\right)}} \]
      8. pow-pow33.8%

        \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
      9. *-commutative33.8%

        \[\leadsto \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333} \cdot d} \]
      10. pow-pow41.1%

        \[\leadsto \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}} \cdot d \]
      11. metadata-eval41.1%

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{1}{\ell \cdot h}}} \cdot d \]
      14. *-commutative40.6%

        \[\leadsto \sqrt{\frac{1}{\color{blue}{h \cdot \ell}}} \cdot d \]
      15. sqrt-div40.6%

        \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \cdot d \]
      16. metadata-eval40.6%

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\ell \cdot h\right)}^{-0.5} \cdot d} \]
    13. Step-by-step derivation
      1. unpow-prod-down51.0%

        \[\leadsto \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \cdot d \]
    14. Applied egg-rr51.0%

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

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

Alternative 13: 39.3% accurate, 1.5× speedup?

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

\mathbf{elif}\;d \leq 1.05 \cdot 10^{-213}:\\
\;\;\;\;\frac{d}{\sqrt[3]{{\left(h \cdot \ell\right)}^{1.5}}}\\

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


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

    1. Initial program 72.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. Simplified71.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. clear-num71.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot e^{-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      10. unpow1/24.1%

        \[\leadsto d \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
      11. rec-exp4.1%

        \[\leadsto d \cdot \color{blue}{\frac{1}{e^{\log \left(\sqrt{h \cdot \ell}\right)}}} \]
      12. rem-exp-log4.1%

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

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      14. *-rgt-identity4.1%

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\sqrt{h \cdot \ell}} \cdot \frac{d}{\sqrt{h \cdot \ell}}}} \]
      3. frac-times31.0%

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

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

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

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

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

    if -2.9499999999999999e-145 < d < 1.0499999999999999e-213

    1. Initial program 40.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. Simplified40.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. clear-num40.5%

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

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

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

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

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\frac{\ell}{h}}}\right) \]
    6. Step-by-step derivation
      1. associate-/r/40.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) \]
      2. associate-*r*40.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot e^{-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      10. unpow1/214.0%

        \[\leadsto d \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
      11. rec-exp14.0%

        \[\leadsto d \cdot \color{blue}{\frac{1}{e^{\log \left(\sqrt{h \cdot \ell}\right)}}} \]
      12. rem-exp-log14.3%

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

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      14. *-rgt-identity14.3%

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

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

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

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

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

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

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

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

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

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

    if 1.0499999999999999e-213 < d

    1. Initial program 76.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. Add Preprocessing
    3. Taylor expanded in d around inf 46.5%

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

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

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

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

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

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

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

        \[\leadsto d \cdot {\left({\color{blue}{\left(\frac{\frac{1}{h}}{\ell}\right)}}^{\left(1 + 0.5\right)}\right)}^{0.3333333333333333} \]
      8. metadata-eval38.3%

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    5. Applied egg-rr38.3%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    6. Step-by-step derivation
      1. pow-pow47.1%

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

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

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

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

        \[\leadsto d \cdot \frac{\sqrt{\color{blue}{{h}^{-1}}}}{\sqrt{\ell}} \]
      6. sqrt-pow159.3%

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

        \[\leadsto d \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}} \]
    7. Applied egg-rr59.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.95 \cdot 10^{-145}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\\ \mathbf{elif}\;d \leq 1.05 \cdot 10^{-213}:\\ \;\;\;\;\frac{d}{\sqrt[3]{{\left(h \cdot \ell\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 38.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}\;\ell \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\\ \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 -5e-311)
   (sqrt (/ (pow d 2.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 <= -5e-311) {
		tmp = sqrt((pow(d, 2.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 <= (-5d-311)) then
        tmp = sqrt(((d ** 2.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 <= -5e-311) {
		tmp = Math.sqrt((Math.pow(d, 2.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 <= -5e-311:
		tmp = math.sqrt((math.pow(d, 2.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 <= -5e-311)
		tmp = sqrt(Float64((d ^ 2.0) / Float64(h * 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 <= -5e-311)
		tmp = sqrt(((d ^ 2.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, -5e-311], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(h * l), $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 -5 \cdot 10^{-311}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\\

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


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

    1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot e^{-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      10. unpow1/27.0%

        \[\leadsto d \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
      11. rec-exp7.0%

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

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

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      14. *-rgt-identity7.0%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    10. Simplified7.0%

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

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

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

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

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{\sqrt{h \cdot \ell} \cdot \sqrt{h \cdot \ell}}} \]
      5. add-sqr-sqrt25.2%

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

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

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

    if -5.00000000000023e-311 < l

    1. Initial program 69.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. Add Preprocessing
    3. Taylor expanded in d around inf 40.6%

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

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

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. sqrt-unprod50.9%

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      5. associate-/r*48.9%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
    5. Applied egg-rr48.9%

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    7. Simplified50.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 38.0% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\\ \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-311)
   (sqrt (/ (pow d 2.0) (* h l)))
   (* 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-311) {
		tmp = sqrt((pow(d, 2.0) / (h * l)));
	} 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-311)) then
        tmp = sqrt(((d ** 2.0d0) / (h * l)))
    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-311) {
		tmp = Math.sqrt((Math.pow(d, 2.0) / (h * l)));
	} 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-311:
		tmp = math.sqrt((math.pow(d, 2.0) / (h * l)))
	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-311)
		tmp = sqrt(Float64((d ^ 2.0) / Float64(h * l)));
	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-311)
		tmp = sqrt(((d ^ 2.0) / (h * l)));
	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-311], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(h * l), $MachinePrecision]), $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^{-311}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\\

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


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

    1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{{\color{blue}{\left(\frac{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell} \cdot h\right)\right) \]
      4. *-commutative65.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{{\left(\frac{\color{blue}{D \cdot \left(M \cdot 0.5\right)}}{d}\right)}^{2}}{\ell} \cdot h\right)\right) \]
      5. associate-/l*65.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{{\color{blue}{\left(D \cdot \frac{M \cdot 0.5}{d}\right)}}^{2}}{\ell} \cdot h\right)\right) \]
    7. Simplified65.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{{\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2}}{\ell} \cdot h\right)}\right) \]
    8. Taylor expanded in d around inf 8.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. associate-/r*8.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. unpow1/28.6%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
      3. associate-/r*8.6%

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{h \cdot \ell}\right)}}^{0.5} \]
      4. rem-exp-log8.6%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      5. exp-neg8.6%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      6. exp-prod7.0%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      7. *-commutative7.0%

        \[\leadsto d \cdot e^{\color{blue}{0.5 \cdot \left(-\log \left(h \cdot \ell\right)\right)}} \]
      8. distribute-rgt-neg-out7.0%

        \[\leadsto d \cdot e^{\color{blue}{-0.5 \cdot \log \left(h \cdot \ell\right)}} \]
      9. log-pow7.0%

        \[\leadsto d \cdot e^{-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      10. unpow1/27.0%

        \[\leadsto d \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
      11. rec-exp7.0%

        \[\leadsto d \cdot \color{blue}{\frac{1}{e^{\log \left(\sqrt{h \cdot \ell}\right)}}} \]
      12. rem-exp-log7.0%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      13. associate-/l*7.0%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      14. *-rgt-identity7.0%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    10. Simplified7.0%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    11. Step-by-step derivation
      1. add-sqr-sqrt2.4%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\sqrt{h \cdot \ell}}} \cdot \sqrt{\frac{d}{\sqrt{h \cdot \ell}}}} \]
      2. sqrt-unprod25.5%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\sqrt{h \cdot \ell}} \cdot \frac{d}{\sqrt{h \cdot \ell}}}} \]
      3. frac-times25.1%

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot d}{\sqrt{h \cdot \ell} \cdot \sqrt{h \cdot \ell}}}} \]
      4. pow225.1%

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{\sqrt{h \cdot \ell} \cdot \sqrt{h \cdot \ell}}} \]
      5. add-sqr-sqrt25.2%

        \[\leadsto \sqrt{\frac{{d}^{2}}{\color{blue}{h \cdot \ell}}} \]
      6. *-commutative25.2%

        \[\leadsto \sqrt{\frac{{d}^{2}}{\color{blue}{\ell \cdot h}}} \]
    12. Applied egg-rr25.2%

      \[\leadsto \color{blue}{\sqrt{\frac{{d}^{2}}{\ell \cdot h}}} \]

    if -5.00000000000023e-311 < l

    1. Initial program 69.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. Add Preprocessing
    3. Taylor expanded in d around inf 40.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. add-cbrt-cube35.4%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}}} \]
      2. pow1/333.8%

        \[\leadsto d \cdot \color{blue}{{\left(\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{0.3333333333333333}} \]
      3. add-sqr-sqrt33.8%

        \[\leadsto d \cdot {\left(\color{blue}{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{0.3333333333333333} \]
      4. pow133.8%

        \[\leadsto d \cdot {\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{1}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{0.3333333333333333} \]
      5. pow1/233.8%

        \[\leadsto d \cdot {\left({\left(\frac{1}{h \cdot \ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)}^{0.3333333333333333} \]
      6. pow-prod-up33.8%

        \[\leadsto d \cdot {\color{blue}{\left({\left(\frac{1}{h \cdot \ell}\right)}^{\left(1 + 0.5\right)}\right)}}^{0.3333333333333333} \]
      7. associate-/r*33.8%

        \[\leadsto d \cdot {\left({\color{blue}{\left(\frac{\frac{1}{h}}{\ell}\right)}}^{\left(1 + 0.5\right)}\right)}^{0.3333333333333333} \]
      8. metadata-eval33.8%

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    5. Applied egg-rr33.8%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    6. Step-by-step derivation
      1. pow-pow41.1%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}} \]
      2. metadata-eval41.1%

        \[\leadsto d \cdot {\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{0.5}} \]
      3. pow1/241.1%

        \[\leadsto d \cdot \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}}} \]
      4. sqrt-div51.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      5. inv-pow51.0%

        \[\leadsto d \cdot \frac{\sqrt{\color{blue}{{h}^{-1}}}}{\sqrt{\ell}} \]
      6. sqrt-pow151.0%

        \[\leadsto d \cdot \frac{\color{blue}{{h}^{\left(\frac{-1}{2}\right)}}}{\sqrt{\ell}} \]
      7. metadata-eval51.0%

        \[\leadsto d \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}} \]
    7. Applied egg-rr51.0%

      \[\leadsto d \cdot \color{blue}{\frac{{h}^{-0.5}}{\sqrt{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification38.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 29.9% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;h \leq 1.35 \cdot 10^{-282}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \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 (<= h 1.35e-282)
   (* 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 (h <= 1.35e-282) {
		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 (h <= 1.35d-282) 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 (h <= 1.35e-282) {
		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 h <= 1.35e-282:
		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 (h <= 1.35e-282)
		tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * 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 (h <= 1.35e-282)
		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[h, 1.35e-282], N[(d * N[Sqrt[N[(1.0 / N[(h * l), $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}\;h \leq 1.35 \cdot 10^{-282}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if h < 1.34999999999999991e-282

    1. Initial program 64.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in d around inf 12.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]

    if 1.34999999999999991e-282 < h

    1. Initial program 69.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. Add Preprocessing
    3. Taylor expanded in d around inf 38.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. sqrt-div38.6%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval38.6%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. sqrt-unprod49.4%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      4. div-inv49.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      5. associate-/r*47.3%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
    5. Applied egg-rr47.3%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
    6. Step-by-step derivation
      1. associate-/l/49.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    7. Simplified49.4%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification30.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq 1.35 \cdot 10^{-282}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 26.2% 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}{h \cdot \ell}} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (* d (sqrt (/ 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(1.0 / Float64(h * l))))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d * sqrt((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[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
d \cdot \sqrt{\frac{1}{h \cdot \ell}}
\end{array}
Derivation
  1. Initial program 66.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. Add Preprocessing
  3. Taylor expanded in d around inf 25.0%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  4. Final simplification25.0%

    \[\leadsto d \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
  5. Add Preprocessing

Alternative 18: 26.4% 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 66.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. Add Preprocessing
  3. Taylor expanded in d around inf 25.0%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  4. Step-by-step derivation
    1. associate-/r*25.2%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
  5. Simplified25.2%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  6. Final simplification25.2%

    \[\leadsto d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}} \]
  7. Add Preprocessing

Alternative 19: 26.1% accurate, 3.2× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \frac{d}{\sqrt{h \cdot \ell}} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (/ d (sqrt (* h l))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d / sqrt((h * l));
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d / sqrt((h * l))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d / Math.sqrt((h * l));
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d / math.sqrt((h * l))
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d / sqrt(Float64(h * l)))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d / sqrt((h * l));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\frac{d}{\sqrt{h \cdot \ell}}
\end{array}
Derivation
  1. Initial program 66.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. Simplified66.5%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. clear-num66.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \color{blue}{\frac{1}{\frac{\ell}{h}}}\right)\right) \]
    2. un-div-inv67.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}}{\frac{\ell}{h}}}\right) \]
    3. frac-times67.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2}}{\frac{\ell}{h}}\right) \]
    4. associate-/l*67.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{2}}{\frac{\ell}{h}}\right) \]
    5. *-un-lft-identity67.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \frac{\color{blue}{1 \cdot D}}{2 \cdot d}\right)}^{2}}{\frac{\ell}{h}}\right) \]
    6. times-frac67.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \color{blue}{\left(\frac{1}{2} \cdot \frac{D}{d}\right)}\right)}^{2}}{\frac{\ell}{h}}\right) \]
    7. metadata-eval67.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(M \cdot \left(\color{blue}{0.5} \cdot \frac{D}{d}\right)\right)}^{2}}{\frac{\ell}{h}}\right) \]
  5. Applied egg-rr67.1%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\frac{\ell}{h}}}\right) \]
  6. Step-by-step derivation
    1. associate-/r/69.0%

      \[\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) \]
    2. associate-*r*69.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{{\color{blue}{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}}^{2}}{\ell} \cdot h\right)\right) \]
    3. associate-*r/69.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{{\color{blue}{\left(\frac{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell} \cdot h\right)\right) \]
    4. *-commutative69.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{{\left(\frac{\color{blue}{D \cdot \left(M \cdot 0.5\right)}}{d}\right)}^{2}}{\ell} \cdot h\right)\right) \]
    5. associate-/l*68.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{{\color{blue}{\left(D \cdot \frac{M \cdot 0.5}{d}\right)}}^{2}}{\ell} \cdot h\right)\right) \]
  7. Simplified68.7%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{{\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2}}{\ell} \cdot h\right)}\right) \]
  8. Taylor expanded in d around inf 25.0%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  9. Step-by-step derivation
    1. associate-/r*25.2%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    2. unpow1/225.2%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
    3. associate-/r*25.0%

      \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{h \cdot \ell}\right)}}^{0.5} \]
    4. rem-exp-log24.0%

      \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
    5. exp-neg24.0%

      \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
    6. exp-prod23.3%

      \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
    7. *-commutative23.3%

      \[\leadsto d \cdot e^{\color{blue}{0.5 \cdot \left(-\log \left(h \cdot \ell\right)\right)}} \]
    8. distribute-rgt-neg-out23.3%

      \[\leadsto d \cdot e^{\color{blue}{-0.5 \cdot \log \left(h \cdot \ell\right)}} \]
    9. log-pow23.3%

      \[\leadsto d \cdot e^{-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
    10. unpow1/223.3%

      \[\leadsto d \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
    11. rec-exp23.3%

      \[\leadsto d \cdot \color{blue}{\frac{1}{e^{\log \left(\sqrt{h \cdot \ell}\right)}}} \]
    12. rem-exp-log24.2%

      \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
    13. associate-/l*24.3%

      \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
    14. *-rgt-identity24.3%

      \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
  10. Simplified24.3%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  11. Final simplification24.3%

    \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
  12. Add Preprocessing

Reproduce

?
herbie shell --seed 2024044 
(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)))))