Henrywood and Agarwal, Equation (12)

Percentage Accurate: 65.8% → 78.9%
Time: 30.8s
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: 65.8% accurate, 1.0× speedup?

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

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

Alternative 1: 78.9% accurate, 0.6× speedup?

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

\mathbf{elif}\;\ell \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\frac{1}{\frac{t_2}{t_1}} \cdot t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -2.4e-206

    1. Initial program 67.4%

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

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

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

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

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

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

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

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

    if -2.4e-206 < l < -1.000000000000002e-309

    1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < l

    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. Simplified68.3%

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

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

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

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

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

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

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

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

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

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

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+190}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}} \cdot \mathsf{fma}\left(h, {\left(M_m \cdot \frac{D_m}{d}\right)}^{2} \cdot \frac{0.125}{\ell}, 1\right)\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < -inf.0

    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. Simplified74.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < 2.0000000000000001e190

    1. Initial program 90.8%

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

    if 2.0000000000000001e190 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < +inf.0

    1. Initial program 64.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l))))

    1. Initial program 0.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. Simplified0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 72.7% accurate, 0.3× 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({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{D_m \cdot M_m}{d \cdot 2}\right)}^{2}\right)\right)\\ t_1 := \frac{M_m}{\frac{d}{D_m}}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;\frac{1}{\sqrt{\frac{\ell}{d}}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{-8 \cdot \left(\frac{1}{t_1} \cdot \frac{\ell}{t_1}\right)}\right)\right)\\ \mathbf{elif}\;t_0 \leq \infty:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{\sqrt{h} \cdot \left(-0.125 \cdot {\left(D_m \cdot M_m\right)}^{2}\right)}{{\ell}^{0.75}}}{{\ell}^{0.75}}}{d}\\ \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 h) 0.5) (pow (/ d l) 0.5))
          (- 1.0 (* (/ h l) (* 0.5 (pow (/ (* D_m M_m) (* d 2.0)) 2.0))))))
        (t_1 (/ M_m (/ d D_m))))
   (if (<= t_0 (- INFINITY))
     (*
      (/ 1.0 (sqrt (/ l d)))
      (* (sqrt (/ d h)) (+ 1.0 (/ h (* -8.0 (* (/ 1.0 t_1) (/ l t_1)))))))
     (if (<= t_0 INFINITY)
       t_0
       (/
        (/
         (/ (* (sqrt h) (* -0.125 (pow (* D_m M_m) 2.0))) (pow l 0.75))
         (pow l 0.75))
        d)))))
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 / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * pow(((D_m * M_m) / (d * 2.0)), 2.0))));
	double t_1 = M_m / (d / D_m);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = (1.0 / sqrt((l / d))) * (sqrt((d / h)) * (1.0 + (h / (-8.0 * ((1.0 / t_1) * (l / t_1))))));
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = t_0;
	} else {
		tmp = (((sqrt(h) * (-0.125 * pow((D_m * M_m), 2.0))) / pow(l, 0.75)) / pow(l, 0.75)) / d;
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = (Math.pow((d / h), 0.5) * Math.pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * Math.pow(((D_m * M_m) / (d * 2.0)), 2.0))));
	double t_1 = M_m / (d / D_m);
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = (1.0 / Math.sqrt((l / d))) * (Math.sqrt((d / h)) * (1.0 + (h / (-8.0 * ((1.0 / t_1) * (l / t_1))))));
	} else if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = t_0;
	} else {
		tmp = (((Math.sqrt(h) * (-0.125 * Math.pow((D_m * M_m), 2.0))) / Math.pow(l, 0.75)) / Math.pow(l, 0.75)) / d;
	}
	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 / h), 0.5) * math.pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * math.pow(((D_m * M_m) / (d * 2.0)), 2.0))))
	t_1 = M_m / (d / D_m)
	tmp = 0
	if t_0 <= -math.inf:
		tmp = (1.0 / math.sqrt((l / d))) * (math.sqrt((d / h)) * (1.0 + (h / (-8.0 * ((1.0 / t_1) * (l / t_1))))))
	elif t_0 <= math.inf:
		tmp = t_0
	else:
		tmp = (((math.sqrt(h) * (-0.125 * math.pow((D_m * M_m), 2.0))) / math.pow(l, 0.75)) / math.pow(l, 0.75)) / d
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.5 * (Float64(Float64(D_m * M_m) / Float64(d * 2.0)) ^ 2.0)))))
	t_1 = Float64(M_m / Float64(d / D_m))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(Float64(1.0 / sqrt(Float64(l / d))) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(h / Float64(-8.0 * Float64(Float64(1.0 / t_1) * Float64(l / t_1)))))));
	elseif (t_0 <= Inf)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64(Float64(sqrt(h) * Float64(-0.125 * (Float64(D_m * M_m) ^ 2.0))) / (l ^ 0.75)) / (l ^ 0.75)) / d);
	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 / h) ^ 0.5) * ((d / l) ^ 0.5)) * (1.0 - ((h / l) * (0.5 * (((D_m * M_m) / (d * 2.0)) ^ 2.0))));
	t_1 = M_m / (d / D_m);
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = (1.0 / sqrt((l / d))) * (sqrt((d / h)) * (1.0 + (h / (-8.0 * ((1.0 / t_1) * (l / t_1))))));
	elseif (t_0 <= Inf)
		tmp = t_0;
	else
		tmp = (((sqrt(h) * (-0.125 * ((D_m * M_m) ^ 2.0))) / (l ^ 0.75)) / (l ^ 0.75)) / d;
	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[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.5 * N[Power[N[(N[(D$95$m * M$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(M$95$m / N[(d / D$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(1.0 / N[Sqrt[N[(l / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h / N[(-8.0 * N[(N[(1.0 / t$95$1), $MachinePrecision] * N[(l / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], t$95$0, N[(N[(N[(N[(N[Sqrt[h], $MachinePrecision] * N[(-0.125 * N[Power[N[(D$95$m * M$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[l, 0.75], $MachinePrecision]), $MachinePrecision] / N[Power[l, 0.75], $MachinePrecision]), $MachinePrecision] / d), $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({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{D_m \cdot M_m}{d \cdot 2}\right)}^{2}\right)\right)\\
t_1 := \frac{M_m}{\frac{d}{D_m}}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\frac{1}{\sqrt{\frac{\ell}{d}}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{-8 \cdot \left(\frac{1}{t_1} \cdot \frac{\ell}{t_1}\right)}\right)\right)\\

\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < -inf.0

    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. Simplified74.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < +inf.0

    1. Initial program 84.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) \]

    if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l))))

    1. Initial program 0.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. Simplified0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 71.4% accurate, 0.3× 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({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{D_m \cdot M_m}{d \cdot 2}\right)}^{2}\right)\right)\\ t_1 := \frac{M_m}{\frac{d}{D_m}}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;\frac{1}{\sqrt{\frac{\ell}{d}}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{-8 \cdot \left(\frac{1}{t_1} \cdot \frac{\ell}{t_1}\right)}\right)\right)\\ \mathbf{elif}\;t_0 \leq \infty:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{h} \cdot \left(-0.125 \cdot {\left(D_m \cdot M_m\right)}^{2}\right)}{d \cdot {\ell}^{1.5}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0
         (*
          (* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
          (- 1.0 (* (/ h l) (* 0.5 (pow (/ (* D_m M_m) (* d 2.0)) 2.0))))))
        (t_1 (/ M_m (/ d D_m))))
   (if (<= t_0 (- INFINITY))
     (*
      (/ 1.0 (sqrt (/ l d)))
      (* (sqrt (/ d h)) (+ 1.0 (/ h (* -8.0 (* (/ 1.0 t_1) (/ l t_1)))))))
     (if (<= t_0 INFINITY)
       t_0
       (/ (* (sqrt h) (* -0.125 (pow (* D_m M_m) 2.0))) (* d (pow l 1.5)))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = (pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * pow(((D_m * M_m) / (d * 2.0)), 2.0))));
	double t_1 = M_m / (d / D_m);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = (1.0 / sqrt((l / d))) * (sqrt((d / h)) * (1.0 + (h / (-8.0 * ((1.0 / t_1) * (l / t_1))))));
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = t_0;
	} else {
		tmp = (sqrt(h) * (-0.125 * pow((D_m * M_m), 2.0))) / (d * pow(l, 1.5));
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = (Math.pow((d / h), 0.5) * Math.pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * Math.pow(((D_m * M_m) / (d * 2.0)), 2.0))));
	double t_1 = M_m / (d / D_m);
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = (1.0 / Math.sqrt((l / d))) * (Math.sqrt((d / h)) * (1.0 + (h / (-8.0 * ((1.0 / t_1) * (l / t_1))))));
	} else if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = t_0;
	} else {
		tmp = (Math.sqrt(h) * (-0.125 * Math.pow((D_m * M_m), 2.0))) / (d * Math.pow(l, 1.5));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = (math.pow((d / h), 0.5) * math.pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * math.pow(((D_m * M_m) / (d * 2.0)), 2.0))))
	t_1 = M_m / (d / D_m)
	tmp = 0
	if t_0 <= -math.inf:
		tmp = (1.0 / math.sqrt((l / d))) * (math.sqrt((d / h)) * (1.0 + (h / (-8.0 * ((1.0 / t_1) * (l / t_1))))))
	elif t_0 <= math.inf:
		tmp = t_0
	else:
		tmp = (math.sqrt(h) * (-0.125 * math.pow((D_m * M_m), 2.0))) / (d * math.pow(l, 1.5))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.5 * (Float64(Float64(D_m * M_m) / Float64(d * 2.0)) ^ 2.0)))))
	t_1 = Float64(M_m / Float64(d / D_m))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(Float64(1.0 / sqrt(Float64(l / d))) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(h / Float64(-8.0 * Float64(Float64(1.0 / t_1) * Float64(l / t_1)))))));
	elseif (t_0 <= Inf)
		tmp = t_0;
	else
		tmp = Float64(Float64(sqrt(h) * Float64(-0.125 * (Float64(D_m * M_m) ^ 2.0))) / Float64(d * (l ^ 1.5)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = (((d / h) ^ 0.5) * ((d / l) ^ 0.5)) * (1.0 - ((h / l) * (0.5 * (((D_m * M_m) / (d * 2.0)) ^ 2.0))));
	t_1 = M_m / (d / D_m);
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = (1.0 / sqrt((l / d))) * (sqrt((d / h)) * (1.0 + (h / (-8.0 * ((1.0 / t_1) * (l / t_1))))));
	elseif (t_0 <= Inf)
		tmp = t_0;
	else
		tmp = (sqrt(h) * (-0.125 * ((D_m * M_m) ^ 2.0))) / (d * (l ^ 1.5));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.5 * N[Power[N[(N[(D$95$m * M$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(M$95$m / N[(d / D$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(1.0 / N[Sqrt[N[(l / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h / N[(-8.0 * N[(N[(1.0 / t$95$1), $MachinePrecision] * N[(l / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], t$95$0, N[(N[(N[Sqrt[h], $MachinePrecision] * N[(-0.125 * N[Power[N[(D$95$m * M$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * N[Power[l, 1.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}
t_0 := \left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{D_m \cdot M_m}{d \cdot 2}\right)}^{2}\right)\right)\\
t_1 := \frac{M_m}{\frac{d}{D_m}}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\frac{1}{\sqrt{\frac{\ell}{d}}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{-8 \cdot \left(\frac{1}{t_1} \cdot \frac{\ell}{t_1}\right)}\right)\right)\\

\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < -inf.0

    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. Simplified74.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < +inf.0

    1. Initial program 84.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) \]

    if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l))))

    1. Initial program 0.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. Simplified0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 75.3% accurate, 0.8× speedup?

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

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

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


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

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

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

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

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

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

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

    if -8.0000000000000004e-114 < h < -1.000000000000002e-309

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

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

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

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

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

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

    if -1.000000000000002e-309 < h

    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. Simplified68.3%

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

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

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

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

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

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

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

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

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

Alternative 6: 77.1% accurate, 0.8× speedup?

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

\mathbf{elif}\;d \leq 1.36 \cdot 10^{-209}:\\
\;\;\;\;\frac{\frac{\frac{\sqrt{h} \cdot \left(-0.125 \cdot {\left(D_m \cdot M_m\right)}^{2}\right)}{{\ell}^{0.75}}}{{\ell}^{0.75}}}{d}\\

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


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

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

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

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

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

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

    if -1.999999999999994e-310 < d < 1.3599999999999999e-209

    1. Initial program 40.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. Simplified40.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}{\frac{d \cdot 2}{D}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Taylor expanded in d around 0 44.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3599999999999999e-209 < d

    1. Initial program 76.2%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 70.6% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -3.3e-307 or 8.19999999999999982e-220 < d

    1. Initial program 70.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. Simplified71.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.3e-307 < d < 8.19999999999999982e-220

    1. Initial program 42.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. Simplified42.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}{\frac{d \cdot 2}{D}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Taylor expanded in d around 0 47.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.3 \cdot 10^{-307} \lor \neg \left(d \leq 8.2 \cdot 10^{-220}\right):\\ \;\;\;\;\frac{1}{\sqrt{\frac{\ell}{d}}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{-8 \cdot \left(\frac{1}{\frac{M}{\frac{d}{D}}} \cdot \frac{\ell}{\frac{M}{\frac{d}{D}}}\right)}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{h} \cdot \left(-0.125 \cdot {\left(D \cdot M\right)}^{2}\right)}{d \cdot {\ell}^{1.5}}\\ \end{array} \]

Alternative 8: 69.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} t_0 := \frac{M_m}{\frac{d}{D_m}}\\ \mathbf{if}\;\ell \leq 4 \cdot 10^{+234}:\\ \;\;\;\;\frac{1}{\sqrt{\frac{\ell}{d}}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{-8 \cdot \left(\frac{1}{t_0} \cdot \frac{\ell}{t_0}\right)}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (/ M_m (/ d D_m))))
   (if (<= l 4e+234)
     (*
      (/ 1.0 (sqrt (/ l d)))
      (* (sqrt (/ d h)) (+ 1.0 (/ h (* -8.0 (* (/ 1.0 t_0) (/ l t_0)))))))
     (* d (/ (sqrt (/ 1.0 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 = M_m / (d / D_m);
	double tmp;
	if (l <= 4e+234) {
		tmp = (1.0 / sqrt((l / d))) * (sqrt((d / h)) * (1.0 + (h / (-8.0 * ((1.0 / t_0) * (l / t_0))))));
	} else {
		tmp = d * (sqrt((1.0 / 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 = m_m / (d / d_m)
    if (l <= 4d+234) then
        tmp = (1.0d0 / sqrt((l / d))) * (sqrt((d / h)) * (1.0d0 + (h / ((-8.0d0) * ((1.0d0 / t_0) * (l / t_0))))))
    else
        tmp = d * (sqrt((1.0d0 / 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 = M_m / (d / D_m);
	double tmp;
	if (l <= 4e+234) {
		tmp = (1.0 / Math.sqrt((l / d))) * (Math.sqrt((d / h)) * (1.0 + (h / (-8.0 * ((1.0 / t_0) * (l / t_0))))));
	} else {
		tmp = d * (Math.sqrt((1.0 / 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 = M_m / (d / D_m)
	tmp = 0
	if l <= 4e+234:
		tmp = (1.0 / math.sqrt((l / d))) * (math.sqrt((d / h)) * (1.0 + (h / (-8.0 * ((1.0 / t_0) * (l / t_0))))))
	else:
		tmp = d * (math.sqrt((1.0 / 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(M_m / Float64(d / D_m))
	tmp = 0.0
	if (l <= 4e+234)
		tmp = Float64(Float64(1.0 / sqrt(Float64(l / d))) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(h / Float64(-8.0 * Float64(Float64(1.0 / t_0) * Float64(l / t_0)))))));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / 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 = M_m / (d / D_m);
	tmp = 0.0;
	if (l <= 4e+234)
		tmp = (1.0 / sqrt((l / d))) * (sqrt((d / h)) * (1.0 + (h / (-8.0 * ((1.0 / t_0) * (l / t_0))))));
	else
		tmp = d * (sqrt((1.0 / 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[(M$95$m / N[(d / D$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, 4e+234], N[(N[(1.0 / N[Sqrt[N[(l / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h / N[(-8.0 * N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(l / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $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{M_m}{\frac{d}{D_m}}\\
\mathbf{if}\;\ell \leq 4 \cdot 10^{+234}:\\
\;\;\;\;\frac{1}{\sqrt{\frac{\ell}{d}}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{-8 \cdot \left(\frac{1}{t_0} \cdot \frac{\ell}{t_0}\right)}\right)\right)\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.00000000000000007e234 < l

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    5. Applied egg-rr68.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 4 \cdot 10^{+234}:\\ \;\;\;\;\frac{1}{\sqrt{\frac{\ell}{d}}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{-8 \cdot \left(\frac{1}{\frac{M}{\frac{d}{D}}} \cdot \frac{\ell}{\frac{M}{\frac{d}{D}}}\right)}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 9: 46.4% accurate, 1.5× speedup?

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

\mathbf{elif}\;M_m \leq 1.9 \cdot 10^{-57}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;M_m \leq 1.6 \cdot 10^{-16}:\\
\;\;\;\;t_1\\

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if M < 1.15e-75 or 1.8999999999999999e-57 < M < 1.60000000000000011e-16

    1. Initial program 74.2%

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

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

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

    if 1.15e-75 < M < 1.8999999999999999e-57 or 1.5499999999999999e132 < M

    1. Initial program 48.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. Simplified45.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}{\frac{d \cdot 2}{D}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Taylor expanded in d around 0 13.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.60000000000000011e-16 < M < 1.5499999999999999e132

    1. Initial program 61.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. 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}{\frac{d \cdot 2}{D}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Applied egg-rr63.8%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 1.15 \cdot 10^{-75}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;M \leq 1.9 \cdot 10^{-57}:\\ \;\;\;\;\frac{\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \left(-0.125 \cdot \left(D \cdot \left(M \cdot \left(D \cdot M\right)\right)\right)\right)}{d}\\ \mathbf{elif}\;M \leq 1.6 \cdot 10^{-16}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;M \leq 1.55 \cdot 10^{+132}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + h \cdot \left(\frac{0.125}{\ell} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \left(-0.125 \cdot \left(D \cdot \left(M \cdot \left(D \cdot M\right)\right)\right)\right)}{d}\\ \end{array} \]

Alternative 10: 45.1% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq 1.5 \cdot 10^{-280}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;d \leq 4.4 \cdot 10^{-226}:\\ \;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(-0.125 \cdot \left(\left(M_m \cdot \frac{D_m}{d}\right) \cdot \left(D_m \cdot M_m\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= d 1.5e-280)
   (* (sqrt (/ d h)) (sqrt (/ d l)))
   (if (<= d 4.4e-226)
     (* (sqrt (/ h (pow l 3.0))) (* -0.125 (* (* M_m (/ D_m d)) (* D_m M_m))))
     (/ (/ d (sqrt l)) (sqrt h)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= 1.5e-280) {
		tmp = sqrt((d / h)) * sqrt((d / l));
	} else if (d <= 4.4e-226) {
		tmp = sqrt((h / pow(l, 3.0))) * (-0.125 * ((M_m * (D_m / d)) * (D_m * M_m)));
	} else {
		tmp = (d / sqrt(l)) / sqrt(h);
	}
	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.5d-280) then
        tmp = sqrt((d / h)) * sqrt((d / l))
    else if (d <= 4.4d-226) then
        tmp = sqrt((h / (l ** 3.0d0))) * ((-0.125d0) * ((m_m * (d_m / d)) * (d_m * m_m)))
    else
        tmp = (d / sqrt(l)) / sqrt(h)
    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.5e-280) {
		tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
	} else if (d <= 4.4e-226) {
		tmp = Math.sqrt((h / Math.pow(l, 3.0))) * (-0.125 * ((M_m * (D_m / d)) * (D_m * M_m)));
	} else {
		tmp = (d / Math.sqrt(l)) / Math.sqrt(h);
	}
	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.5e-280:
		tmp = math.sqrt((d / h)) * math.sqrt((d / l))
	elif d <= 4.4e-226:
		tmp = math.sqrt((h / math.pow(l, 3.0))) * (-0.125 * ((M_m * (D_m / d)) * (D_m * M_m)))
	else:
		tmp = (d / math.sqrt(l)) / math.sqrt(h)
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (d <= 1.5e-280)
		tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)));
	elseif (d <= 4.4e-226)
		tmp = Float64(sqrt(Float64(h / (l ^ 3.0))) * Float64(-0.125 * Float64(Float64(M_m * Float64(D_m / d)) * Float64(D_m * M_m))));
	else
		tmp = Float64(Float64(d / sqrt(l)) / sqrt(h));
	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.5e-280)
		tmp = sqrt((d / h)) * sqrt((d / l));
	elseif (d <= 4.4e-226)
		tmp = sqrt((h / (l ^ 3.0))) * (-0.125 * ((M_m * (D_m / d)) * (D_m * M_m)));
	else
		tmp = (d / sqrt(l)) / sqrt(h);
	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.5e-280], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.4e-226], N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-0.125 * N[(N[(M$95$m * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 1.5 \cdot 10^{-280}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\

\mathbf{elif}\;d \leq 4.4 \cdot 10^{-226}:\\
\;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(-0.125 \cdot \left(\left(M_m \cdot \frac{D_m}{d}\right) \cdot \left(D_m \cdot M_m\right)\right)\right)\\

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


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

    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. Simplified66.3%

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

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

    if 1.49999999999999994e-280 < d < 4.4e-226

    1. Initial program 56.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.4e-226 < d

    1. Initial program 74.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. Simplified73.9%

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

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

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

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. un-div-inv48.2%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{d}{\sqrt{\ell}}}}{\sqrt{h}} \]
    9. Simplified62.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 1.5 \cdot 10^{-280}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;d \leq 4.4 \cdot 10^{-226}:\\ \;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(-0.125 \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot \left(D \cdot M\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\ \end{array} \]

Alternative 11: 48.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 -2 \cdot 10^{-310}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;d \leq 1.6 \cdot 10^{-99}:\\ \;\;\;\;\frac{\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \left(-0.125 \cdot \left(D_m \cdot \left(M_m \cdot \left(D_m \cdot M_m\right)\right)\right)\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\ \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 -2e-310)
   (* (sqrt (/ d h)) (sqrt (/ d l)))
   (if (<= d 1.6e-99)
     (/ (* (/ (sqrt h) (pow l 1.5)) (* -0.125 (* D_m (* M_m (* D_m M_m))))) d)
     (/ (/ d (sqrt l)) (sqrt h)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -2e-310) {
		tmp = sqrt((d / h)) * sqrt((d / l));
	} else if (d <= 1.6e-99) {
		tmp = ((sqrt(h) / pow(l, 1.5)) * (-0.125 * (D_m * (M_m * (D_m * M_m))))) / d;
	} else {
		tmp = (d / sqrt(l)) / sqrt(h);
	}
	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 <= (-2d-310)) then
        tmp = sqrt((d / h)) * sqrt((d / l))
    else if (d <= 1.6d-99) then
        tmp = ((sqrt(h) / (l ** 1.5d0)) * ((-0.125d0) * (d_m * (m_m * (d_m * m_m))))) / d
    else
        tmp = (d / sqrt(l)) / sqrt(h)
    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 <= -2e-310) {
		tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
	} else if (d <= 1.6e-99) {
		tmp = ((Math.sqrt(h) / Math.pow(l, 1.5)) * (-0.125 * (D_m * (M_m * (D_m * M_m))))) / d;
	} else {
		tmp = (d / Math.sqrt(l)) / Math.sqrt(h);
	}
	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 <= -2e-310:
		tmp = math.sqrt((d / h)) * math.sqrt((d / l))
	elif d <= 1.6e-99:
		tmp = ((math.sqrt(h) / math.pow(l, 1.5)) * (-0.125 * (D_m * (M_m * (D_m * M_m))))) / d
	else:
		tmp = (d / math.sqrt(l)) / math.sqrt(h)
	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 <= -2e-310)
		tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)));
	elseif (d <= 1.6e-99)
		tmp = Float64(Float64(Float64(sqrt(h) / (l ^ 1.5)) * Float64(-0.125 * Float64(D_m * Float64(M_m * Float64(D_m * M_m))))) / d);
	else
		tmp = Float64(Float64(d / sqrt(l)) / sqrt(h));
	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 <= -2e-310)
		tmp = sqrt((d / h)) * sqrt((d / l));
	elseif (d <= 1.6e-99)
		tmp = ((sqrt(h) / (l ^ 1.5)) * (-0.125 * (D_m * (M_m * (D_m * M_m))))) / d;
	else
		tmp = (d / sqrt(l)) / sqrt(h);
	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, -2e-310], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.6e-99], N[(N[(N[(N[Sqrt[h], $MachinePrecision] / N[Power[l, 1.5], $MachinePrecision]), $MachinePrecision] * N[(-0.125 * N[(D$95$m * N[(M$95$m * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $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 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\

\mathbf{elif}\;d \leq 1.6 \cdot 10^{-99}:\\
\;\;\;\;\frac{\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \left(-0.125 \cdot \left(D_m \cdot \left(M_m \cdot \left(D_m \cdot M_m\right)\right)\right)\right)}{d}\\

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


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

    1. Initial program 66.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. Simplified68.9%

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

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

    if -1.999999999999994e-310 < d < 1.6e-99

    1. Initial program 48.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. Simplified48.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.6e-99 < d

    1. Initial program 81.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. Simplified80.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}{\frac{d \cdot 2}{D}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Taylor expanded in d around inf 55.1%

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

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

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. un-div-inv55.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    5. Applied egg-rr55.0%

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

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

        \[\leadsto \frac{1 \cdot d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. times-frac69.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;d \leq 1.6 \cdot 10^{-99}:\\ \;\;\;\;\frac{\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \left(-0.125 \cdot \left(D \cdot \left(M \cdot \left(D \cdot M\right)\right)\right)\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\ \end{array} \]

Alternative 12: 38.3% accurate, 1.6× speedup?

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

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


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

    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. Simplified68.7%

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

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

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

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. un-div-inv6.7%

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      8. sqrt-div45.9%

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

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

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

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

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

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

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

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

    if 2.3000000000000001e-299 < l

    1. Initial program 70.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 2.3 \cdot 10^{-299}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 13: 44.8% accurate, 1.6× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 1.55000000000000007e-282

    1. Initial program 64.8%

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

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

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

    if 1.55000000000000007e-282 < d

    1. Initial program 72.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. Simplified71.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}{\frac{d \cdot 2}{D}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Taylor expanded in d around inf 46.4%

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

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

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    5. Applied egg-rr58.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 1.55 \cdot 10^{-282}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 14: 37.2% 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.05 \cdot 10^{-303}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\ \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.05e-303)
   (sqrt (/ (pow d 2.0) (* l h)))
   (/ (/ d (sqrt l)) (sqrt h))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (h <= 1.05e-303) {
		tmp = sqrt((pow(d, 2.0) / (l * h)));
	} else {
		tmp = (d / sqrt(l)) / sqrt(h);
	}
	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.05d-303) then
        tmp = sqrt(((d ** 2.0d0) / (l * h)))
    else
        tmp = (d / sqrt(l)) / sqrt(h)
    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.05e-303) {
		tmp = Math.sqrt((Math.pow(d, 2.0) / (l * h)));
	} else {
		tmp = (d / Math.sqrt(l)) / Math.sqrt(h);
	}
	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.05e-303:
		tmp = math.sqrt((math.pow(d, 2.0) / (l * h)))
	else:
		tmp = (d / math.sqrt(l)) / math.sqrt(h)
	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.05e-303)
		tmp = sqrt(Float64((d ^ 2.0) / Float64(l * h)));
	else
		tmp = Float64(Float64(d / sqrt(l)) / sqrt(h));
	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.05e-303)
		tmp = sqrt(((d ^ 2.0) / (l * h)));
	else
		tmp = (d / sqrt(l)) / sqrt(h);
	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.05e-303], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $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.05 \cdot 10^{-303}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\

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


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

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

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

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

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

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. un-div-inv6.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
      4. add-sqr-sqrt0.7%

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      6. frac-times0.7%

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

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

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

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

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

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

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

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

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

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

    if 1.05e-303 < h

    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. Simplified68.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}{\frac{d \cdot 2}{D}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Taylor expanded in d around inf 45.4%

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

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

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. un-div-inv45.3%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    5. Applied egg-rr45.3%

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\sqrt{h}} \cdot \frac{d}{\sqrt{\ell}}} \]
    7. Applied egg-rr57.1%

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

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

        \[\leadsto \frac{\color{blue}{\frac{d}{\sqrt{\ell}}}}{\sqrt{h}} \]
    9. Simplified57.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq 1.05 \cdot 10^{-303}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\ \end{array} \]

Alternative 15: 29.0% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq 6.2 \cdot 10^{-209}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= d 6.2e-209)
   (* d (sqrt (* (/ 1.0 h) (/ 1.0 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 (d <= 6.2e-209) {
		tmp = d * sqrt(((1.0 / h) * (1.0 / 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 (d <= 6.2d-209) then
        tmp = d * sqrt(((1.0d0 / h) * (1.0d0 / 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 (d <= 6.2e-209) {
		tmp = d * Math.sqrt(((1.0 / h) * (1.0 / 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 d <= 6.2e-209:
		tmp = d * math.sqrt(((1.0 / h) * (1.0 / 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 (d <= 6.2e-209)
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / h) * Float64(1.0 / l))));
	else
		tmp = Float64(Float64(d / sqrt(h)) / sqrt(l));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (d <= 6.2e-209)
		tmp = d * sqrt(((1.0 / h) * (1.0 / 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[d, 6.2e-209], N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] * N[(1.0 / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 6.2 \cdot 10^{-209}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 6.2e-209

    1. Initial program 62.8%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{h} \cdot \frac{1}{\ell}}} \]
    5. Applied egg-rr9.8%

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

    if 6.2e-209 < d

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

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

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

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

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

        \[\leadsto \log \left(e^{d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}}\right) \]
      4. un-div-inv14.6%

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}} \]
    7. Applied egg-rr62.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 6.2 \cdot 10^{-209}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 16: 29.2% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq 1.4 \cdot 10^{-208}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\ \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.4e-208)
   (* d (sqrt (* (/ 1.0 h) (/ 1.0 l))))
   (/ (/ d (sqrt l)) (sqrt h))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= 1.4e-208) {
		tmp = d * sqrt(((1.0 / h) * (1.0 / l)));
	} else {
		tmp = (d / sqrt(l)) / sqrt(h);
	}
	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.4d-208) then
        tmp = d * sqrt(((1.0d0 / h) * (1.0d0 / l)))
    else
        tmp = (d / sqrt(l)) / sqrt(h)
    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.4e-208) {
		tmp = d * Math.sqrt(((1.0 / h) * (1.0 / l)));
	} else {
		tmp = (d / Math.sqrt(l)) / Math.sqrt(h);
	}
	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.4e-208:
		tmp = d * math.sqrt(((1.0 / h) * (1.0 / l)))
	else:
		tmp = (d / math.sqrt(l)) / math.sqrt(h)
	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.4e-208)
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / h) * Float64(1.0 / l))));
	else
		tmp = Float64(Float64(d / sqrt(l)) / sqrt(h));
	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.4e-208)
		tmp = d * sqrt(((1.0 / h) * (1.0 / l)));
	else
		tmp = (d / sqrt(l)) / sqrt(h);
	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.4e-208], N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] * N[(1.0 / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $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.4 \cdot 10^{-208}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 1.40000000000000001e-208

    1. Initial program 62.8%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{h} \cdot \frac{1}{\ell}}} \]
    5. Applied egg-rr9.8%

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

    if 1.40000000000000001e-208 < d

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

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

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

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

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. un-div-inv48.1%

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

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

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

        \[\leadsto \frac{1 \cdot d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. times-frac62.7%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{h}} \cdot \frac{d}{\sqrt{\ell}}} \]
    7. Applied egg-rr62.7%

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

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
      2. *-lft-identity62.8%

        \[\leadsto \frac{\color{blue}{\frac{d}{\sqrt{\ell}}}}{\sqrt{h}} \]
    9. Simplified62.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 1.4 \cdot 10^{-208}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\ \end{array} \]

Alternative 17: 25.7% accurate, 3.1× speedup?

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

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

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  4. Final simplification24.6%

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

Alternative 18: 25.6% accurate, 3.2× speedup?

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  5. Applied egg-rr24.6%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  6. Final simplification24.6%

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

Alternative 19: 4.3% accurate, 332.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])\\ \\ 0 \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 0.0)
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return 0.0;
}
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 = 0.0d0
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 0.0;
}
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 0.0
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 0.0
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 = 0.0;
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_] := 0.0
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
0
\end{array}
Derivation
  1. Initial program 68.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. Simplified68.9%

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

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

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

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

      \[\leadsto \log \left(e^{d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}}\right) \]
    4. un-div-inv14.5%

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

    \[\leadsto \color{blue}{\log \left(e^{\frac{d}{\sqrt{h \cdot \ell}}}\right)} \]
  6. Taylor expanded in d around 0 6.1%

    \[\leadsto \log \color{blue}{1} \]
  7. Final simplification6.1%

    \[\leadsto 0 \]

Reproduce

?
herbie shell --seed 2023326 
(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)))))