Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.7% → 82.0%
Time: 28.2s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 66.7% accurate, 1.0× speedup?

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

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

Alternative 1: 82.0% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{-d}\\ t_1 := D\_m \cdot \left(0.5 \cdot \frac{M\_m}{d}\right)\\ t_2 := 1 + h \cdot \left(\frac{t\_1}{\ell} \cdot \frac{t\_1}{-2}\right)\\ t_3 := t\_2 \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{if}\;\ell \leq -2.1 \cdot 10^{+150}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{t\_0}{\sqrt{-\ell}} \cdot t\_2\right)\\ \mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\ \;\;\;\;\frac{t\_0}{\sqrt{-h}} \cdot t\_3\\ \mathbf{else}:\\ \;\;\;\;t\_3 \cdot \left(\sqrt{d} \cdot \sqrt{\frac{1}{h}}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (- d)))
        (t_1 (* D_m (* 0.5 (/ M_m d))))
        (t_2 (+ 1.0 (* h (* (/ t_1 l) (/ t_1 -2.0)))))
        (t_3 (* t_2 (sqrt (/ d l)))))
   (if (<= l -2.1e+150)
     (* (sqrt (/ d h)) (* (/ t_0 (sqrt (- l))) t_2))
     (if (<= l -1e-310)
       (* (/ t_0 (sqrt (- h))) t_3)
       (* t_3 (* (sqrt d) (sqrt (/ 1.0 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 t_0 = sqrt(-d);
	double t_1 = D_m * (0.5 * (M_m / d));
	double t_2 = 1.0 + (h * ((t_1 / l) * (t_1 / -2.0)));
	double t_3 = t_2 * sqrt((d / l));
	double tmp;
	if (l <= -2.1e+150) {
		tmp = sqrt((d / h)) * ((t_0 / sqrt(-l)) * t_2);
	} else if (l <= -1e-310) {
		tmp = (t_0 / sqrt(-h)) * t_3;
	} else {
		tmp = t_3 * (sqrt(d) * sqrt((1.0 / 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) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = sqrt(-d)
    t_1 = d_m * (0.5d0 * (m_m / d))
    t_2 = 1.0d0 + (h * ((t_1 / l) * (t_1 / (-2.0d0))))
    t_3 = t_2 * sqrt((d / l))
    if (l <= (-2.1d+150)) then
        tmp = sqrt((d / h)) * ((t_0 / sqrt(-l)) * t_2)
    else if (l <= (-1d-310)) then
        tmp = (t_0 / sqrt(-h)) * t_3
    else
        tmp = t_3 * (sqrt(d) * sqrt((1.0d0 / 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 t_0 = Math.sqrt(-d);
	double t_1 = D_m * (0.5 * (M_m / d));
	double t_2 = 1.0 + (h * ((t_1 / l) * (t_1 / -2.0)));
	double t_3 = t_2 * Math.sqrt((d / l));
	double tmp;
	if (l <= -2.1e+150) {
		tmp = Math.sqrt((d / h)) * ((t_0 / Math.sqrt(-l)) * t_2);
	} else if (l <= -1e-310) {
		tmp = (t_0 / Math.sqrt(-h)) * t_3;
	} else {
		tmp = t_3 * (Math.sqrt(d) * Math.sqrt((1.0 / 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):
	t_0 = math.sqrt(-d)
	t_1 = D_m * (0.5 * (M_m / d))
	t_2 = 1.0 + (h * ((t_1 / l) * (t_1 / -2.0)))
	t_3 = t_2 * math.sqrt((d / l))
	tmp = 0
	if l <= -2.1e+150:
		tmp = math.sqrt((d / h)) * ((t_0 / math.sqrt(-l)) * t_2)
	elif l <= -1e-310:
		tmp = (t_0 / math.sqrt(-h)) * t_3
	else:
		tmp = t_3 * (math.sqrt(d) * math.sqrt((1.0 / 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)
	t_0 = sqrt(Float64(-d))
	t_1 = Float64(D_m * Float64(0.5 * Float64(M_m / d)))
	t_2 = Float64(1.0 + Float64(h * Float64(Float64(t_1 / l) * Float64(t_1 / -2.0))))
	t_3 = Float64(t_2 * sqrt(Float64(d / l)))
	tmp = 0.0
	if (l <= -2.1e+150)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(t_0 / sqrt(Float64(-l))) * t_2));
	elseif (l <= -1e-310)
		tmp = Float64(Float64(t_0 / sqrt(Float64(-h))) * t_3);
	else
		tmp = Float64(t_3 * Float64(sqrt(d) * sqrt(Float64(1.0 / 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)
	t_0 = sqrt(-d);
	t_1 = D_m * (0.5 * (M_m / d));
	t_2 = 1.0 + (h * ((t_1 / l) * (t_1 / -2.0)));
	t_3 = t_2 * sqrt((d / l));
	tmp = 0.0;
	if (l <= -2.1e+150)
		tmp = sqrt((d / h)) * ((t_0 / sqrt(-l)) * t_2);
	elseif (l <= -1e-310)
		tmp = (t_0 / sqrt(-h)) * t_3;
	else
		tmp = t_3 * (sqrt(d) * sqrt((1.0 / 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_] := Block[{t$95$0 = N[Sqrt[(-d)], $MachinePrecision]}, Block[{t$95$1 = N[(D$95$m * N[(0.5 * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 + N[(h * N[(N[(t$95$1 / l), $MachinePrecision] * N[(t$95$1 / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.1e+150], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(t$95$0 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1e-310], N[(N[(t$95$0 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision], N[(t$95$3 * N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[N[(1.0 / 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])\\
\\
\begin{array}{l}
t_0 := \sqrt{-d}\\
t_1 := D\_m \cdot \left(0.5 \cdot \frac{M\_m}{d}\right)\\
t_2 := 1 + h \cdot \left(\frac{t\_1}{\ell} \cdot \frac{t\_1}{-2}\right)\\
t_3 := t\_2 \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;\ell \leq -2.1 \cdot 10^{+150}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{t\_0}{\sqrt{-\ell}} \cdot t\_2\right)\\

\mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\frac{t\_0}{\sqrt{-h}} \cdot t\_3\\

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


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

    1. Initial program 60.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. Simplified63.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.09999999999999998e150 < l < -9.999999999999969e-311

    1. Initial program 73.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.999999999999969e-311 < l

    1. Initial program 63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 79.8% accurate, 1.0× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 79.7% accurate, 1.0× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 73.8% accurate, 1.0× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 75.4% accurate, 1.0× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 70.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.6999999999999999e125 < l

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-sqr-sqrt69.1%

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

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

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

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

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


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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. *-rgt-identity44.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. pow1/244.5%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}}} \]
    9. Taylor expanded in d around -inf 49.3%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    10. Step-by-step derivation
      1. associate-*r*49.3%

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

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

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

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

    if 1.7999999999999999e-270 < d

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. *-commutative43.1%

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

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

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

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

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

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

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

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

Alternative 8: 43.5% accurate, 2.8× speedup?

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

\mathbf{elif}\;h \leq 1.9 \cdot 10^{+164}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

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


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

    1. Initial program 70.0%

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. *-rgt-identity45.6%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. pow1/245.6%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}}} \]
    9. Taylor expanded in d around -inf 50.5%

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

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

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

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

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

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

    if -6.000000000000001e-309 < h < 1.90000000000000011e164

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. *-rgt-identity43.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. pow1/243.1%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}}} \]
    9. Taylor expanded in d around 0 49.3%

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

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

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

    if 1.90000000000000011e164 < h

    1. Initial program 46.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. Simplified46.1%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. *-rgt-identity35.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -6 \cdot 10^{-309}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{elif}\;h \leq 1.9 \cdot 10^{+164}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 43.5% accurate, 2.8× speedup?

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

\mathbf{elif}\;h \leq 7.5 \cdot 10^{+155}:\\
\;\;\;\;d \cdot t\_0\\

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


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

    1. Initial program 70.0%

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. *-rgt-identity45.6%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. pow1/245.6%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}}} \]
    9. Taylor expanded in d around -inf 50.5%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    10. Step-by-step derivation
      1. associate-*r*50.5%

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

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

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

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

    if -6.000000000000001e-309 < h < 7.4999999999999999e155

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. *-rgt-identity43.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. pow1/243.1%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}}} \]
    9. Taylor expanded in d around 0 49.3%

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

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

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

    if 7.4999999999999999e155 < h

    1. Initial program 46.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. Simplified46.1%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. *-rgt-identity35.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -6 \cdot 10^{-309}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;h \leq 7.5 \cdot 10^{+155}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 36.9% accurate, 3.0× speedup?

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

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


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

    1. Initial program 81.2%

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. *-rgt-identity53.4%

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

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

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

    if -4.2000000000000002e-94 < d

    1. Initial program 58.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. Simplified58.1%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Taylor expanded in d around 0 35.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.2 \cdot 10^{-94}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 37.1% accurate, 3.0× speedup?

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

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


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

    1. Initial program 81.2%

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. *-rgt-identity53.4%

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

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

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

    if -2.1000000000000001e-94 < d

    1. Initial program 58.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. Simplified58.1%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. *-rgt-identity37.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. pow1/237.8%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot \frac{d}{\ell}}{h}}} \]
    9. Taylor expanded in d around 0 35.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.1 \cdot 10^{-94}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 32.2% accurate, 3.1× speedup?

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

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

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

    \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
  5. Step-by-step derivation
    1. *-rgt-identity43.9%

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

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

    \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
  7. Final simplification34.8%

    \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \]
  8. Add Preprocessing

Reproduce

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