Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.1% → 82.7%
Time: 29.1s
Alternatives: 23
Speedup: 1.5×

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 23 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.1% 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.7% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 71.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.999999999999988e-310 < d < 1.69999999999999998e-46

    1. Initial program 43.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.69999999999999998e-46 < d

    1. Initial program 76.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 78.0% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 72.5%

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

      \[\leadsto \color{blue}{\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. frac-2neg72.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\color{blue}{\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) \]
      2. sqrt-div75.7%

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

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

    if -1.35e-305 < d < 1.1e-54

    1. Initial program 42.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.1e-54 < d

    1. Initial program 76.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 80.8% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 72.5%

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

      \[\leadsto \color{blue}{\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. frac-2neg72.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\color{blue}{\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) \]
      2. sqrt-div75.7%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\frac{\sqrt{-d}}{\sqrt{-\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) \]
    6. Step-by-step derivation
      1. *-commutative73.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.35e-305 < d < 1.40000000000000002e-48

    1. Initial program 42.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.40000000000000002e-48 < d

    1. Initial program 76.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 77.2% accurate, 0.8× speedup?

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

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

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


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

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div74.6%

        \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval74.6%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr74.6%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Step-by-step derivation
      1. *-commutative74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.80000000000000021e-296 < d < 1.79999999999999989e-56

    1. Initial program 41.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. Simplified39.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.79999999999999989e-56 < d

    1. Initial program 76.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 76.2% accurate, 0.8× speedup?

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

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


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

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div74.6%

        \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval74.6%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr74.6%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Step-by-step derivation
      1. *-commutative74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.80000000000000021e-296 < d

    1. Initial program 61.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. Simplified60.8%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 72.3% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 52.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. Simplified54.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.05e77 < l < -4.999999999999985e-310

    1. Initial program 81.9%

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

    if -4.999999999999985e-310 < l

    1. Initial program 62.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 70.6%

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div71.4%

        \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval71.4%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr71.4%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Step-by-step derivation
      1. *-commutative71.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.79999999999999988e-240 < l

    1. Initial program 62.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 69.6% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 52.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. Simplified54.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.99999999999999963e74 < l < 4.5000000000000001e-240

    1. Initial program 78.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.5000000000000001e-240 < l

    1. Initial program 62.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 69.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 52.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. Simplified54.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.4999999999999998e73 < l < 1.19999999999999996e-239

    1. Initial program 78.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.19999999999999996e-239 < l

    1. Initial program 62.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 74.3% accurate, 1.0× speedup?

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

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


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

    1. Initial program 70.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.79999999999999988e-240 < l

    1. Initial program 62.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 59.0% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2.2 \cdot 10^{-78}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{elif}\;\ell \leq -6.4 \cdot 10^{-301}:\\ \;\;\;\;d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(h \cdot \ell + -1\right)\right)\right) \cdot 0.3333333333333333}\\ \mathbf{elif}\;\ell \leq 2.9 \cdot 10^{+104}:\\ \;\;\;\;\left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(D_m \cdot \frac{M_m}{d \cdot 2}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l -2.2e-78)
   (* (- d) (pow (* h l) -0.5))
   (if (<= l -6.4e-301)
     (* d (exp (* (* 1.5 (- (log1p (+ (* h l) -1.0)))) 0.3333333333333333)))
     (if (<= l 2.9e+104)
       (*
        (+ 1.0 (* (* -0.5 (/ h l)) (pow (* D_m (/ M_m (* d 2.0))) 2.0)))
        (/ d (sqrt (* h l))))
       (* d (* (pow l -0.5) (pow h -0.5)))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -2.2e-78) {
		tmp = -d * pow((h * l), -0.5);
	} else if (l <= -6.4e-301) {
		tmp = d * exp(((1.5 * -log1p(((h * l) + -1.0))) * 0.3333333333333333));
	} else if (l <= 2.9e+104) {
		tmp = (1.0 + ((-0.5 * (h / l)) * pow((D_m * (M_m / (d * 2.0))), 2.0))) * (d / sqrt((h * l)));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -2.2e-78) {
		tmp = -d * Math.pow((h * l), -0.5);
	} else if (l <= -6.4e-301) {
		tmp = d * Math.exp(((1.5 * -Math.log1p(((h * l) + -1.0))) * 0.3333333333333333));
	} else if (l <= 2.9e+104) {
		tmp = (1.0 + ((-0.5 * (h / l)) * Math.pow((D_m * (M_m / (d * 2.0))), 2.0))) * (d / Math.sqrt((h * l)));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= -2.2e-78:
		tmp = -d * math.pow((h * l), -0.5)
	elif l <= -6.4e-301:
		tmp = d * math.exp(((1.5 * -math.log1p(((h * l) + -1.0))) * 0.3333333333333333))
	elif l <= 2.9e+104:
		tmp = (1.0 + ((-0.5 * (h / l)) * math.pow((D_m * (M_m / (d * 2.0))), 2.0))) * (d / math.sqrt((h * l)))
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -2.2e-78)
		tmp = Float64(Float64(-d) * (Float64(h * l) ^ -0.5));
	elseif (l <= -6.4e-301)
		tmp = Float64(d * exp(Float64(Float64(1.5 * Float64(-log1p(Float64(Float64(h * l) + -1.0)))) * 0.3333333333333333)));
	elseif (l <= 2.9e+104)
		tmp = Float64(Float64(1.0 + Float64(Float64(-0.5 * Float64(h / l)) * (Float64(D_m * Float64(M_m / Float64(d * 2.0))) ^ 2.0))) * Float64(d / sqrt(Float64(h * l))));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -2.2e-78], N[((-d) * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -6.4e-301], N[(d * N[Exp[N[(N[(1.5 * (-N[Log[1 + N[(N[(h * l), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.9e+104], N[(N[(1.0 + N[(N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(D$95$m * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.2 \cdot 10^{-78}:\\
\;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\

\mathbf{elif}\;\ell \leq -6.4 \cdot 10^{-301}:\\
\;\;\;\;d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(h \cdot \ell + -1\right)\right)\right) \cdot 0.3333333333333333}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -2.1999999999999999e-78

    1. Initial program 68.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      3. distribute-rgt-neg-in54.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.1999999999999999e-78 < l < -6.3999999999999998e-301

    1. Initial program 76.1%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto d \cdot \color{blue}{\sqrt[3]{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}}} \]
    7. Step-by-step derivation
      1. pow1/326.0%

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

        \[\leadsto d \cdot {\color{blue}{\left(e^{\log \left(\frac{\frac{1}{h}}{\ell}\right) \cdot 1.5}\right)}}^{0.3333333333333333} \]
      3. pow-exp19.5%

        \[\leadsto d \cdot \color{blue}{e^{\left(\log \left(\frac{\frac{1}{h}}{\ell}\right) \cdot 1.5\right) \cdot 0.3333333333333333}} \]
      4. rem-log-exp26.0%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(e^{\log \left(\frac{\frac{1}{h}}{\ell}\right) \cdot 1.5}\right)} \cdot 0.3333333333333333} \]
      5. pow-to-exp26.0%

        \[\leadsto d \cdot e^{\log \color{blue}{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)} \cdot 0.3333333333333333} \]
      6. log-pow19.5%

        \[\leadsto d \cdot e^{\color{blue}{\left(1.5 \cdot \log \left(\frac{\frac{1}{h}}{\ell}\right)\right)} \cdot 0.3333333333333333} \]
      7. associate-/l/19.5%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \log \color{blue}{\left(\frac{1}{\ell \cdot h}\right)}\right) \cdot 0.3333333333333333} \]
      8. log-rec17.4%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \color{blue}{\left(-\log \left(\ell \cdot h\right)\right)}\right) \cdot 0.3333333333333333} \]
    8. Applied egg-rr17.4%

      \[\leadsto d \cdot \color{blue}{e^{\left(1.5 \cdot \left(-\log \left(\ell \cdot h\right)\right)\right) \cdot 0.3333333333333333}} \]
    9. Step-by-step derivation
      1. log1p-expm1-u45.3%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(\ell \cdot h\right)\right)\right)}\right)\right) \cdot 0.3333333333333333} \]
      2. expm1-udef45.3%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(\color{blue}{e^{\log \left(\ell \cdot h\right)} - 1}\right)\right)\right) \cdot 0.3333333333333333} \]
      3. add-exp-log45.3%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(\color{blue}{\ell \cdot h} - 1\right)\right)\right) \cdot 0.3333333333333333} \]
      4. *-commutative45.3%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(\color{blue}{h \cdot \ell} - 1\right)\right)\right) \cdot 0.3333333333333333} \]
    10. Applied egg-rr45.3%

      \[\leadsto d \cdot e^{\left(1.5 \cdot \left(-\color{blue}{\mathsf{log1p}\left(h \cdot \ell - 1\right)}\right)\right) \cdot 0.3333333333333333} \]

    if -6.3999999999999998e-301 < l < 2.8999999999999998e104

    1. Initial program 72.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.8999999999999998e104 < l

    1. Initial program 43.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. Simplified43.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot {\left(\ell \cdot h\right)}^{-0.5}} \]
    11. Step-by-step derivation
      1. unpow-prod-down48.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.2 \cdot 10^{-78}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{elif}\;\ell \leq -6.4 \cdot 10^{-301}:\\ \;\;\;\;d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(h \cdot \ell + -1\right)\right)\right) \cdot 0.3333333333333333}\\ \mathbf{elif}\;\ell \leq 2.9 \cdot 10^{+104}:\\ \;\;\;\;\left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 59.5% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -5.1 \cdot 10^{-77}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{elif}\;\ell \leq -6.4 \cdot 10^{-301}:\\ \;\;\;\;d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(h \cdot \ell + -1\right)\right)\right) \cdot 0.3333333333333333}\\ \mathbf{elif}\;\ell \leq 1.8 \cdot 10^{+104}:\\ \;\;\;\;\frac{d \cdot \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(0.5 \cdot \left(D_m \cdot \frac{M_m}{d}\right)\right)}^{2}\right)}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l -5.1e-77)
   (* (- d) (pow (* h l) -0.5))
   (if (<= l -6.4e-301)
     (* d (exp (* (* 1.5 (- (log1p (+ (* h l) -1.0)))) 0.3333333333333333)))
     (if (<= l 1.8e+104)
       (/
        (* d (+ 1.0 (* (* -0.5 (/ h l)) (pow (* 0.5 (* D_m (/ M_m d))) 2.0))))
        (sqrt (* h l)))
       (* d (* (pow l -0.5) (pow h -0.5)))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -5.1e-77) {
		tmp = -d * pow((h * l), -0.5);
	} else if (l <= -6.4e-301) {
		tmp = d * exp(((1.5 * -log1p(((h * l) + -1.0))) * 0.3333333333333333));
	} else if (l <= 1.8e+104) {
		tmp = (d * (1.0 + ((-0.5 * (h / l)) * pow((0.5 * (D_m * (M_m / d))), 2.0)))) / sqrt((h * l));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -5.1e-77) {
		tmp = -d * Math.pow((h * l), -0.5);
	} else if (l <= -6.4e-301) {
		tmp = d * Math.exp(((1.5 * -Math.log1p(((h * l) + -1.0))) * 0.3333333333333333));
	} else if (l <= 1.8e+104) {
		tmp = (d * (1.0 + ((-0.5 * (h / l)) * Math.pow((0.5 * (D_m * (M_m / d))), 2.0)))) / Math.sqrt((h * l));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= -5.1e-77:
		tmp = -d * math.pow((h * l), -0.5)
	elif l <= -6.4e-301:
		tmp = d * math.exp(((1.5 * -math.log1p(((h * l) + -1.0))) * 0.3333333333333333))
	elif l <= 1.8e+104:
		tmp = (d * (1.0 + ((-0.5 * (h / l)) * math.pow((0.5 * (D_m * (M_m / d))), 2.0)))) / math.sqrt((h * l))
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -5.1e-77)
		tmp = Float64(Float64(-d) * (Float64(h * l) ^ -0.5));
	elseif (l <= -6.4e-301)
		tmp = Float64(d * exp(Float64(Float64(1.5 * Float64(-log1p(Float64(Float64(h * l) + -1.0)))) * 0.3333333333333333)));
	elseif (l <= 1.8e+104)
		tmp = Float64(Float64(d * Float64(1.0 + Float64(Float64(-0.5 * Float64(h / l)) * (Float64(0.5 * Float64(D_m * Float64(M_m / d))) ^ 2.0)))) / sqrt(Float64(h * l)));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -5.1e-77], N[((-d) * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -6.4e-301], N[(d * N[Exp[N[(N[(1.5 * (-N[Log[1 + N[(N[(h * l), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.8e+104], N[(N[(d * N[(1.0 + N[(N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(0.5 * N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5.1 \cdot 10^{-77}:\\
\;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\

\mathbf{elif}\;\ell \leq -6.4 \cdot 10^{-301}:\\
\;\;\;\;d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(h \cdot \ell + -1\right)\right)\right) \cdot 0.3333333333333333}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -5.10000000000000032e-77

    1. Initial program 68.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      3. distribute-rgt-neg-in54.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.10000000000000032e-77 < l < -6.3999999999999998e-301

    1. Initial program 76.1%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto d \cdot \color{blue}{\sqrt[3]{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}}} \]
    7. Step-by-step derivation
      1. pow1/326.0%

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

        \[\leadsto d \cdot {\color{blue}{\left(e^{\log \left(\frac{\frac{1}{h}}{\ell}\right) \cdot 1.5}\right)}}^{0.3333333333333333} \]
      3. pow-exp19.5%

        \[\leadsto d \cdot \color{blue}{e^{\left(\log \left(\frac{\frac{1}{h}}{\ell}\right) \cdot 1.5\right) \cdot 0.3333333333333333}} \]
      4. rem-log-exp26.0%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(e^{\log \left(\frac{\frac{1}{h}}{\ell}\right) \cdot 1.5}\right)} \cdot 0.3333333333333333} \]
      5. pow-to-exp26.0%

        \[\leadsto d \cdot e^{\log \color{blue}{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)} \cdot 0.3333333333333333} \]
      6. log-pow19.5%

        \[\leadsto d \cdot e^{\color{blue}{\left(1.5 \cdot \log \left(\frac{\frac{1}{h}}{\ell}\right)\right)} \cdot 0.3333333333333333} \]
      7. associate-/l/19.5%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \log \color{blue}{\left(\frac{1}{\ell \cdot h}\right)}\right) \cdot 0.3333333333333333} \]
      8. log-rec17.4%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \color{blue}{\left(-\log \left(\ell \cdot h\right)\right)}\right) \cdot 0.3333333333333333} \]
    8. Applied egg-rr17.4%

      \[\leadsto d \cdot \color{blue}{e^{\left(1.5 \cdot \left(-\log \left(\ell \cdot h\right)\right)\right) \cdot 0.3333333333333333}} \]
    9. Step-by-step derivation
      1. log1p-expm1-u45.3%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(\ell \cdot h\right)\right)\right)}\right)\right) \cdot 0.3333333333333333} \]
      2. expm1-udef45.3%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(\color{blue}{e^{\log \left(\ell \cdot h\right)} - 1}\right)\right)\right) \cdot 0.3333333333333333} \]
      3. add-exp-log45.3%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(\color{blue}{\ell \cdot h} - 1\right)\right)\right) \cdot 0.3333333333333333} \]
      4. *-commutative45.3%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(\color{blue}{h \cdot \ell} - 1\right)\right)\right) \cdot 0.3333333333333333} \]
    10. Applied egg-rr45.3%

      \[\leadsto d \cdot e^{\left(1.5 \cdot \left(-\color{blue}{\mathsf{log1p}\left(h \cdot \ell - 1\right)}\right)\right) \cdot 0.3333333333333333} \]

    if -6.3999999999999998e-301 < l < 1.8e104

    1. Initial program 72.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. associate-*r/86.0%

        \[\leadsto \frac{\mathsf{fma}\left({\color{blue}{\left(\frac{D \cdot M}{2 \cdot d}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. *-commutative86.0%

        \[\leadsto \frac{\mathsf{fma}\left({\left(\frac{D \cdot M}{\color{blue}{d \cdot 2}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      7. metadata-eval86.0%

        \[\leadsto \frac{\mathsf{fma}\left({\left(\frac{D \cdot M}{d \cdot \color{blue}{\frac{1}{0.5}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      8. div-inv86.0%

        \[\leadsto \frac{\mathsf{fma}\left({\left(\frac{D \cdot M}{\color{blue}{\frac{d}{0.5}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      9. associate-*r/84.9%

        \[\leadsto \frac{\mathsf{fma}\left({\color{blue}{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      10. associate-/r/84.9%

        \[\leadsto \frac{\mathsf{fma}\left({\left(D \cdot \color{blue}{\left(\frac{M}{d} \cdot 0.5\right)}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      11. sqrt-unprod78.8%

        \[\leadsto \frac{\mathsf{fma}\left({\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      12. *-commutative78.8%

        \[\leadsto \frac{\mathsf{fma}\left({\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{\color{blue}{\ell \cdot h}}} \]
    9. Applied egg-rr78.8%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{\ell \cdot h}}} \]
    10. Step-by-step derivation
      1. fma-udef78.8%

        \[\leadsto \frac{\color{blue}{\left({\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right) + 1\right)} \cdot d}{\sqrt{\ell \cdot h}} \]
      2. associate-*r*78.8%

        \[\leadsto \frac{\left({\color{blue}{\left(\left(D \cdot \frac{M}{d}\right) \cdot 0.5\right)}}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right) + 1\right) \cdot d}{\sqrt{\ell \cdot h}} \]
      3. *-commutative78.8%

        \[\leadsto \frac{\left({\left(\left(D \cdot \frac{M}{d}\right) \cdot 0.5\right)}^{2} \cdot \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right)} + 1\right) \cdot d}{\sqrt{\ell \cdot h}} \]
    11. Applied egg-rr78.8%

      \[\leadsto \frac{\color{blue}{\left({\left(\left(D \cdot \frac{M}{d}\right) \cdot 0.5\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right) + 1\right)} \cdot d}{\sqrt{\ell \cdot h}} \]

    if 1.8e104 < l

    1. Initial program 43.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. Simplified43.8%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. expm1-log1p-u43.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
      2. expm1-udef43.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} - 1\right)}\right) \]
      3. *-commutative43.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{h}{\ell} \cdot {\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2}}\right)} - 1\right)\right) \]
      4. frac-times43.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{D \cdot M}{2 \cdot d}\right)}}^{2}\right)} - 1\right)\right) \]
      5. *-commutative43.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2}\right)} - 1\right)\right) \]
      6. frac-times41.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2}\right)} - 1\right)\right) \]
      7. div-inv41.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(M \cdot \frac{1}{2}\right)} \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
      8. metadata-eval41.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot \color{blue}{0.5}\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
    5. Applied egg-rr41.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)}\right) \]
    6. Step-by-step derivation
      1. expm1-def41.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)}\right) \]
      2. expm1-log1p41.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)}\right) \]
      3. associate-*l/42.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{h \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}}\right) \]
      4. *-commutative42.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}}{\ell}\right) \]
      5. associate-*l/44.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell} \cdot h\right)}\right) \]
      6. *-commutative44.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)}\right) \]
      7. associate-*r/46.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      8. associate-*l*46.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{M \cdot \left(0.5 \cdot D\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
      9. *-commutative46.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{M \cdot \color{blue}{\left(D \cdot 0.5\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
      10. *-commutative46.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{\left(D \cdot 0.5\right) \cdot M}}{d}\right)}^{2}}{\ell}\right)\right) \]
      11. associate-*r/46.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\left(D \cdot 0.5\right) \cdot \frac{M}{d}\right)}}^{2}}{\ell}\right)\right) \]
      12. associate-*l*46.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)}}^{2}}{\ell}\right)\right) \]
      13. associate-*r/46.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{0.5 \cdot M}{d}}\right)}^{2}}{\ell}\right)\right) \]
      14. *-commutative46.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \frac{\color{blue}{M \cdot 0.5}}{d}\right)}^{2}}{\ell}\right)\right) \]
      15. associate-/l*46.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{M}{\frac{d}{0.5}}}\right)}^{2}}{\ell}\right)\right) \]
    7. Simplified46.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}{\ell}\right)}\right) \]
    8. Taylor expanded in d around inf 37.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. associate-/r*38.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. unpow1/238.4%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
      3. associate-/l/37.1%

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{0.5} \]
      4. rem-exp-log34.8%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{0.5} \]
      5. exp-neg34.8%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(\ell \cdot h\right)}\right)}}^{0.5} \]
      6. exp-prod34.8%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}} \]
      7. distribute-lft-neg-out34.8%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in34.8%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval34.8%

        \[\leadsto d \cdot e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}} \]
      10. exp-to-pow37.1%

        \[\leadsto d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
    10. Simplified37.1%

      \[\leadsto \color{blue}{d \cdot {\left(\ell \cdot h\right)}^{-0.5}} \]
    11. Step-by-step derivation
      1. unpow-prod-down48.0%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    12. Applied egg-rr48.0%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification60.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5.1 \cdot 10^{-77}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{elif}\;\ell \leq -6.4 \cdot 10^{-301}:\\ \;\;\;\;d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(h \cdot \ell + -1\right)\right)\right) \cdot 0.3333333333333333}\\ \mathbf{elif}\;\ell \leq 1.8 \cdot 10^{+104}:\\ \;\;\;\;\frac{d \cdot \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(0.5 \cdot \left(D \cdot \frac{M}{d}\right)\right)}^{2}\right)}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 65.8% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1.75 \cdot 10^{+72}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{elif}\;\ell \leq 1.36 \cdot 10^{-276}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M_m \cdot \left(0.5 \cdot D_m\right)}{d}\right)}^{2}\right)\right)\\ \mathbf{elif}\;\ell \leq 8.6 \cdot 10^{+104}:\\ \;\;\;\;\frac{d \cdot \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(0.5 \cdot \left(D_m \cdot \frac{M_m}{d}\right)\right)}^{2}\right)}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l -1.75e+72)
   (* (- d) (pow (* h l) -0.5))
   (if (<= l 1.36e-276)
     (*
      (sqrt (* (/ d l) (/ d h)))
      (+ 1.0 (* -0.5 (* (/ h l) (pow (/ (* M_m (* 0.5 D_m)) d) 2.0)))))
     (if (<= l 8.6e+104)
       (/
        (* d (+ 1.0 (* (* -0.5 (/ h l)) (pow (* 0.5 (* D_m (/ M_m d))) 2.0))))
        (sqrt (* h l)))
       (* d (* (pow l -0.5) (pow h -0.5)))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -1.75e+72) {
		tmp = -d * pow((h * l), -0.5);
	} else if (l <= 1.36e-276) {
		tmp = sqrt(((d / l) * (d / h))) * (1.0 + (-0.5 * ((h / l) * pow(((M_m * (0.5 * D_m)) / d), 2.0))));
	} else if (l <= 8.6e+104) {
		tmp = (d * (1.0 + ((-0.5 * (h / l)) * pow((0.5 * (D_m * (M_m / d))), 2.0)))) / sqrt((h * l));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= (-1.75d+72)) then
        tmp = -d * ((h * l) ** (-0.5d0))
    else if (l <= 1.36d-276) then
        tmp = sqrt(((d / l) * (d / h))) * (1.0d0 + ((-0.5d0) * ((h / l) * (((m_m * (0.5d0 * d_m)) / d) ** 2.0d0))))
    else if (l <= 8.6d+104) then
        tmp = (d * (1.0d0 + (((-0.5d0) * (h / l)) * ((0.5d0 * (d_m * (m_m / d))) ** 2.0d0)))) / sqrt((h * l))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -1.75e+72) {
		tmp = -d * Math.pow((h * l), -0.5);
	} else if (l <= 1.36e-276) {
		tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 + (-0.5 * ((h / l) * Math.pow(((M_m * (0.5 * D_m)) / d), 2.0))));
	} else if (l <= 8.6e+104) {
		tmp = (d * (1.0 + ((-0.5 * (h / l)) * Math.pow((0.5 * (D_m * (M_m / d))), 2.0)))) / Math.sqrt((h * l));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= -1.75e+72:
		tmp = -d * math.pow((h * l), -0.5)
	elif l <= 1.36e-276:
		tmp = math.sqrt(((d / l) * (d / h))) * (1.0 + (-0.5 * ((h / l) * math.pow(((M_m * (0.5 * D_m)) / d), 2.0))))
	elif l <= 8.6e+104:
		tmp = (d * (1.0 + ((-0.5 * (h / l)) * math.pow((0.5 * (D_m * (M_m / d))), 2.0)))) / math.sqrt((h * l))
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -1.75e+72)
		tmp = Float64(Float64(-d) * (Float64(h * l) ^ -0.5));
	elseif (l <= 1.36e-276)
		tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(M_m * Float64(0.5 * D_m)) / d) ^ 2.0)))));
	elseif (l <= 8.6e+104)
		tmp = Float64(Float64(d * Float64(1.0 + Float64(Float64(-0.5 * Float64(h / l)) * (Float64(0.5 * Float64(D_m * Float64(M_m / d))) ^ 2.0)))) / sqrt(Float64(h * l)));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= -1.75e+72)
		tmp = -d * ((h * l) ^ -0.5);
	elseif (l <= 1.36e-276)
		tmp = sqrt(((d / l) * (d / h))) * (1.0 + (-0.5 * ((h / l) * (((M_m * (0.5 * D_m)) / d) ^ 2.0))));
	elseif (l <= 8.6e+104)
		tmp = (d * (1.0 + ((-0.5 * (h / l)) * ((0.5 * (D_m * (M_m / d))) ^ 2.0)))) / sqrt((h * l));
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -1.75e+72], N[((-d) * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.36e-276], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M$95$m * N[(0.5 * D$95$m), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 8.6e+104], N[(N[(d * N[(1.0 + N[(N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(0.5 * N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.75 \cdot 10^{+72}:\\
\;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\

\mathbf{elif}\;\ell \leq 1.36 \cdot 10^{-276}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M_m \cdot \left(0.5 \cdot D_m\right)}{d}\right)}^{2}\right)\right)\\

\mathbf{elif}\;\ell \leq 8.6 \cdot 10^{+104}:\\
\;\;\;\;\frac{d \cdot \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(0.5 \cdot \left(D_m \cdot \frac{M_m}{d}\right)\right)}^{2}\right)}{\sqrt{h \cdot \ell}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -1.75000000000000005e72

    1. Initial program 52.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. Simplified54.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt47.5%

        \[\leadsto \color{blue}{\sqrt{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \cdot \sqrt{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
      2. sqrt-unprod39.5%

        \[\leadsto \color{blue}{\sqrt{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}} \]
      3. *-commutative39.5%

        \[\leadsto \sqrt{\color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)} \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} \]
      4. *-commutative39.5%

        \[\leadsto \sqrt{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right) \cdot \color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}} \]
      5. swap-sqr39.6%

        \[\leadsto \sqrt{\color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}} \]
    5. Applied egg-rr30.2%

      \[\leadsto \color{blue}{\sqrt{{\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)}^{2} \cdot \frac{{d}^{2}}{h \cdot \ell}}} \]
    6. Simplified30.5%

      \[\leadsto \color{blue}{\sqrt{{\left(\mathsf{fma}\left(h, \frac{-0.5}{\frac{\ell}{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}}, 1\right)\right)}^{2} \cdot \frac{{d}^{2}}{h \cdot \ell}}} \]
    7. Taylor expanded in d around -inf 62.3%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    8. Step-by-step derivation
      1. mul-1-neg62.3%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. *-commutative62.3%

        \[\leadsto -\color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      3. distribute-rgt-neg-in62.3%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(-d\right)} \]
      4. associate-/r*63.1%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(-d\right) \]
      5. unpow1/263.1%

        \[\leadsto \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \cdot \left(-d\right) \]
      6. associate-/l/62.3%

        \[\leadsto {\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{0.5} \cdot \left(-d\right) \]
      7. rem-exp-log58.6%

        \[\leadsto {\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{0.5} \cdot \left(-d\right) \]
      8. exp-neg58.6%

        \[\leadsto {\color{blue}{\left(e^{-\log \left(\ell \cdot h\right)}\right)}}^{0.5} \cdot \left(-d\right) \]
      9. exp-prod58.6%

        \[\leadsto \color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}} \cdot \left(-d\right) \]
      10. distribute-lft-neg-out58.6%

        \[\leadsto e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}} \cdot \left(-d\right) \]
      11. distribute-rgt-neg-in58.6%

        \[\leadsto e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}} \cdot \left(-d\right) \]
      12. metadata-eval58.6%

        \[\leadsto e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}} \cdot \left(-d\right) \]
      13. exp-to-pow62.5%

        \[\leadsto \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \cdot \left(-d\right) \]
    9. Simplified62.5%

      \[\leadsto \color{blue}{{\left(\ell \cdot h\right)}^{-0.5} \cdot \left(-d\right)} \]

    if -1.75000000000000005e72 < l < 1.35999999999999993e-276

    1. Initial program 82.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.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. sqrt-div5.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. div-inv5.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot \frac{1}{\sqrt{\ell}}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr5.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(\sqrt{d} \cdot \frac{1}{\sqrt{\ell}}\right)}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. associate-*r/5.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{d} \cdot 1}{\sqrt{\ell}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. *-rgt-identity5.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{\sqrt{d}}}{\sqrt{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. Simplified5.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    8. Step-by-step derivation
      1. expm1-log1p-u2.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)\right)} \]
      2. expm1-udef2.3%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} - 1} \]
    9. Applied egg-rr25.0%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left({\left(\left(D \cdot 0.5\right) \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} - 1} \]
    10. Step-by-step derivation
      1. expm1-def28.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left({\left(\left(D \cdot 0.5\right) \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)\right)} \]
      2. expm1-log1p72.4%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left({\left(\left(D \cdot 0.5\right) \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
      3. associate-*r/73.5%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left({\color{blue}{\left(\frac{\left(D \cdot 0.5\right) \cdot M}{d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. *-commutative73.5%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left({\left(\frac{\color{blue}{M \cdot \left(D \cdot 0.5\right)}}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    11. Simplified73.5%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left({\left(\frac{M \cdot \left(D \cdot 0.5\right)}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]

    if 1.35999999999999993e-276 < l < 8.6000000000000003e104

    1. Initial program 70.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified70.8%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. sub-neg70.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \color{blue}{\left(1 + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} \]
      2. distribute-rgt-in56.7%

        \[\leadsto \color{blue}{1 \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)} \]
      3. *-un-lft-identity56.7%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      4. sqrt-div58.9%

        \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}} + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      5. sqrt-div62.5%

        \[\leadsto \frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      6. frac-times62.5%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}} + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      7. add-sqr-sqrt62.6%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
    5. Applied egg-rr74.9%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} + \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    6. Step-by-step derivation
      1. distribute-rgt1-in85.7%

        \[\leadsto \color{blue}{\left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right) + 1\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      2. +-commutative85.7%

        \[\leadsto \color{blue}{\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      3. associate-*r*85.7%

        \[\leadsto \left(1 + \color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      4. *-commutative85.7%

        \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\color{blue}{\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. /-rgt-identity85.7%

        \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{D}{d} \cdot \color{blue}{\frac{M \cdot 0.5}{1}}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. associate-/l*85.7%

        \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{D}{d} \cdot \color{blue}{\frac{M}{\frac{1}{0.5}}}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      7. metadata-eval85.7%

        \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{D}{d} \cdot \frac{M}{\color{blue}{2}}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      8. times-frac88.0%

        \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\color{blue}{\left(\frac{D \cdot M}{d \cdot 2}\right)}}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      9. associate-*r/88.0%

        \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)}}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      10. *-commutative88.0%

        \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M}{\color{blue}{2 \cdot d}}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. Simplified88.0%

      \[\leadsto \color{blue}{\left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Step-by-step derivation
      1. associate-*r/88.0%

        \[\leadsto \color{blue}{\frac{\left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      2. +-commutative88.0%

        \[\leadsto \frac{\color{blue}{\left(\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2} + 1\right)} \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      3. *-commutative88.0%

        \[\leadsto \frac{\left(\color{blue}{{\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right)} + 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      4. fma-def88.0%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. associate-*r/88.0%

        \[\leadsto \frac{\mathsf{fma}\left({\color{blue}{\left(\frac{D \cdot M}{2 \cdot d}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. *-commutative88.0%

        \[\leadsto \frac{\mathsf{fma}\left({\left(\frac{D \cdot M}{\color{blue}{d \cdot 2}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      7. metadata-eval88.0%

        \[\leadsto \frac{\mathsf{fma}\left({\left(\frac{D \cdot M}{d \cdot \color{blue}{\frac{1}{0.5}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      8. div-inv88.0%

        \[\leadsto \frac{\mathsf{fma}\left({\left(\frac{D \cdot M}{\color{blue}{\frac{d}{0.5}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      9. associate-*r/88.0%

        \[\leadsto \frac{\mathsf{fma}\left({\color{blue}{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      10. associate-/r/88.0%

        \[\leadsto \frac{\mathsf{fma}\left({\left(D \cdot \color{blue}{\left(\frac{M}{d} \cdot 0.5\right)}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      11. sqrt-unprod81.2%

        \[\leadsto \frac{\mathsf{fma}\left({\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      12. *-commutative81.2%

        \[\leadsto \frac{\mathsf{fma}\left({\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{\color{blue}{\ell \cdot h}}} \]
    9. Applied egg-rr81.2%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{\ell \cdot h}}} \]
    10. Step-by-step derivation
      1. fma-udef81.2%

        \[\leadsto \frac{\color{blue}{\left({\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right) + 1\right)} \cdot d}{\sqrt{\ell \cdot h}} \]
      2. associate-*r*81.2%

        \[\leadsto \frac{\left({\color{blue}{\left(\left(D \cdot \frac{M}{d}\right) \cdot 0.5\right)}}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right) + 1\right) \cdot d}{\sqrt{\ell \cdot h}} \]
      3. *-commutative81.2%

        \[\leadsto \frac{\left({\left(\left(D \cdot \frac{M}{d}\right) \cdot 0.5\right)}^{2} \cdot \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right)} + 1\right) \cdot d}{\sqrt{\ell \cdot h}} \]
    11. Applied egg-rr81.2%

      \[\leadsto \frac{\color{blue}{\left({\left(\left(D \cdot \frac{M}{d}\right) \cdot 0.5\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right) + 1\right)} \cdot d}{\sqrt{\ell \cdot h}} \]

    if 8.6000000000000003e104 < l

    1. Initial program 43.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. Simplified43.8%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. expm1-log1p-u43.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
      2. expm1-udef43.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} - 1\right)}\right) \]
      3. *-commutative43.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{h}{\ell} \cdot {\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2}}\right)} - 1\right)\right) \]
      4. frac-times43.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{D \cdot M}{2 \cdot d}\right)}}^{2}\right)} - 1\right)\right) \]
      5. *-commutative43.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2}\right)} - 1\right)\right) \]
      6. frac-times41.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2}\right)} - 1\right)\right) \]
      7. div-inv41.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(M \cdot \frac{1}{2}\right)} \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
      8. metadata-eval41.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot \color{blue}{0.5}\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
    5. Applied egg-rr41.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)}\right) \]
    6. Step-by-step derivation
      1. expm1-def41.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)}\right) \]
      2. expm1-log1p41.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)}\right) \]
      3. associate-*l/42.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{h \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}}\right) \]
      4. *-commutative42.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}}{\ell}\right) \]
      5. associate-*l/44.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell} \cdot h\right)}\right) \]
      6. *-commutative44.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)}\right) \]
      7. associate-*r/46.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      8. associate-*l*46.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{M \cdot \left(0.5 \cdot D\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
      9. *-commutative46.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{M \cdot \color{blue}{\left(D \cdot 0.5\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
      10. *-commutative46.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{\left(D \cdot 0.5\right) \cdot M}}{d}\right)}^{2}}{\ell}\right)\right) \]
      11. associate-*r/46.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\left(D \cdot 0.5\right) \cdot \frac{M}{d}\right)}}^{2}}{\ell}\right)\right) \]
      12. associate-*l*46.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)}}^{2}}{\ell}\right)\right) \]
      13. associate-*r/46.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{0.5 \cdot M}{d}}\right)}^{2}}{\ell}\right)\right) \]
      14. *-commutative46.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \frac{\color{blue}{M \cdot 0.5}}{d}\right)}^{2}}{\ell}\right)\right) \]
      15. associate-/l*46.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{M}{\frac{d}{0.5}}}\right)}^{2}}{\ell}\right)\right) \]
    7. Simplified46.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}{\ell}\right)}\right) \]
    8. Taylor expanded in d around inf 37.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. associate-/r*38.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. unpow1/238.4%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
      3. associate-/l/37.1%

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{0.5} \]
      4. rem-exp-log34.8%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{0.5} \]
      5. exp-neg34.8%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(\ell \cdot h\right)}\right)}}^{0.5} \]
      6. exp-prod34.8%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}} \]
      7. distribute-lft-neg-out34.8%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in34.8%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval34.8%

        \[\leadsto d \cdot e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}} \]
      10. exp-to-pow37.1%

        \[\leadsto d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
    10. Simplified37.1%

      \[\leadsto \color{blue}{d \cdot {\left(\ell \cdot h\right)}^{-0.5}} \]
    11. Step-by-step derivation
      1. unpow-prod-down48.0%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    12. Applied egg-rr48.0%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification69.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.75 \cdot 10^{+72}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{elif}\;\ell \leq 1.36 \cdot 10^{-276}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot \left(0.5 \cdot D\right)}{d}\right)}^{2}\right)\right)\\ \mathbf{elif}\;\ell \leq 8.6 \cdot 10^{+104}:\\ \;\;\;\;\frac{d \cdot \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(0.5 \cdot \left(D \cdot \frac{M}{d}\right)\right)}^{2}\right)}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 66.9% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1.3 \cdot 10^{+75}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{elif}\;\ell \leq 5 \cdot 10^{-240}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \frac{{\left(\frac{M_m}{2} \cdot \frac{D_m}{d}\right)}^{2} \cdot \left(h \cdot 0.5\right)}{\ell}\right)\\ \mathbf{elif}\;\ell \leq 5 \cdot 10^{+104}:\\ \;\;\;\;\frac{d \cdot \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(0.5 \cdot \left(D_m \cdot \frac{M_m}{d}\right)\right)}^{2}\right)}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l -1.3e+75)
   (* (- d) (pow (* h l) -0.5))
   (if (<= l 5e-240)
     (*
      (sqrt (* (/ d l) (/ d h)))
      (- 1.0 (/ (* (pow (* (/ M_m 2.0) (/ D_m d)) 2.0) (* h 0.5)) l)))
     (if (<= l 5e+104)
       (/
        (* d (+ 1.0 (* (* -0.5 (/ h l)) (pow (* 0.5 (* D_m (/ M_m d))) 2.0))))
        (sqrt (* h l)))
       (* d (* (pow l -0.5) (pow h -0.5)))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -1.3e+75) {
		tmp = -d * pow((h * l), -0.5);
	} else if (l <= 5e-240) {
		tmp = sqrt(((d / l) * (d / h))) * (1.0 - ((pow(((M_m / 2.0) * (D_m / d)), 2.0) * (h * 0.5)) / l));
	} else if (l <= 5e+104) {
		tmp = (d * (1.0 + ((-0.5 * (h / l)) * pow((0.5 * (D_m * (M_m / d))), 2.0)))) / sqrt((h * l));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= (-1.3d+75)) then
        tmp = -d * ((h * l) ** (-0.5d0))
    else if (l <= 5d-240) then
        tmp = sqrt(((d / l) * (d / h))) * (1.0d0 - (((((m_m / 2.0d0) * (d_m / d)) ** 2.0d0) * (h * 0.5d0)) / l))
    else if (l <= 5d+104) then
        tmp = (d * (1.0d0 + (((-0.5d0) * (h / l)) * ((0.5d0 * (d_m * (m_m / d))) ** 2.0d0)))) / sqrt((h * l))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -1.3e+75) {
		tmp = -d * Math.pow((h * l), -0.5);
	} else if (l <= 5e-240) {
		tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 - ((Math.pow(((M_m / 2.0) * (D_m / d)), 2.0) * (h * 0.5)) / l));
	} else if (l <= 5e+104) {
		tmp = (d * (1.0 + ((-0.5 * (h / l)) * Math.pow((0.5 * (D_m * (M_m / d))), 2.0)))) / Math.sqrt((h * l));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= -1.3e+75:
		tmp = -d * math.pow((h * l), -0.5)
	elif l <= 5e-240:
		tmp = math.sqrt(((d / l) * (d / h))) * (1.0 - ((math.pow(((M_m / 2.0) * (D_m / d)), 2.0) * (h * 0.5)) / l))
	elif l <= 5e+104:
		tmp = (d * (1.0 + ((-0.5 * (h / l)) * math.pow((0.5 * (D_m * (M_m / d))), 2.0)))) / math.sqrt((h * l))
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -1.3e+75)
		tmp = Float64(Float64(-d) * (Float64(h * l) ^ -0.5));
	elseif (l <= 5e-240)
		tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 - Float64(Float64((Float64(Float64(M_m / 2.0) * Float64(D_m / d)) ^ 2.0) * Float64(h * 0.5)) / l)));
	elseif (l <= 5e+104)
		tmp = Float64(Float64(d * Float64(1.0 + Float64(Float64(-0.5 * Float64(h / l)) * (Float64(0.5 * Float64(D_m * Float64(M_m / d))) ^ 2.0)))) / sqrt(Float64(h * l)));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= -1.3e+75)
		tmp = -d * ((h * l) ^ -0.5);
	elseif (l <= 5e-240)
		tmp = sqrt(((d / l) * (d / h))) * (1.0 - (((((M_m / 2.0) * (D_m / d)) ^ 2.0) * (h * 0.5)) / l));
	elseif (l <= 5e+104)
		tmp = (d * (1.0 + ((-0.5 * (h / l)) * ((0.5 * (D_m * (M_m / d))) ^ 2.0)))) / sqrt((h * l));
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -1.3e+75], N[((-d) * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5e-240], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h * 0.5), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5e+104], N[(N[(d * N[(1.0 + N[(N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(0.5 * N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.3 \cdot 10^{+75}:\\
\;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\

\mathbf{elif}\;\ell \leq 5 \cdot 10^{-240}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \frac{{\left(\frac{M_m}{2} \cdot \frac{D_m}{d}\right)}^{2} \cdot \left(h \cdot 0.5\right)}{\ell}\right)\\

\mathbf{elif}\;\ell \leq 5 \cdot 10^{+104}:\\
\;\;\;\;\frac{d \cdot \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(0.5 \cdot \left(D_m \cdot \frac{M_m}{d}\right)\right)}^{2}\right)}{\sqrt{h \cdot \ell}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -1.29999999999999992e75

    1. Initial program 52.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. Simplified54.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt47.5%

        \[\leadsto \color{blue}{\sqrt{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \cdot \sqrt{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
      2. sqrt-unprod39.5%

        \[\leadsto \color{blue}{\sqrt{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}} \]
      3. *-commutative39.5%

        \[\leadsto \sqrt{\color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)} \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} \]
      4. *-commutative39.5%

        \[\leadsto \sqrt{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right) \cdot \color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}} \]
      5. swap-sqr39.6%

        \[\leadsto \sqrt{\color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}} \]
    5. Applied egg-rr30.2%

      \[\leadsto \color{blue}{\sqrt{{\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)}^{2} \cdot \frac{{d}^{2}}{h \cdot \ell}}} \]
    6. Simplified30.5%

      \[\leadsto \color{blue}{\sqrt{{\left(\mathsf{fma}\left(h, \frac{-0.5}{\frac{\ell}{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}}, 1\right)\right)}^{2} \cdot \frac{{d}^{2}}{h \cdot \ell}}} \]
    7. Taylor expanded in d around -inf 62.3%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    8. Step-by-step derivation
      1. mul-1-neg62.3%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. *-commutative62.3%

        \[\leadsto -\color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      3. distribute-rgt-neg-in62.3%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(-d\right)} \]
      4. associate-/r*63.1%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(-d\right) \]
      5. unpow1/263.1%

        \[\leadsto \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \cdot \left(-d\right) \]
      6. associate-/l/62.3%

        \[\leadsto {\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{0.5} \cdot \left(-d\right) \]
      7. rem-exp-log58.6%

        \[\leadsto {\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{0.5} \cdot \left(-d\right) \]
      8. exp-neg58.6%

        \[\leadsto {\color{blue}{\left(e^{-\log \left(\ell \cdot h\right)}\right)}}^{0.5} \cdot \left(-d\right) \]
      9. exp-prod58.6%

        \[\leadsto \color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}} \cdot \left(-d\right) \]
      10. distribute-lft-neg-out58.6%

        \[\leadsto e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}} \cdot \left(-d\right) \]
      11. distribute-rgt-neg-in58.6%

        \[\leadsto e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}} \cdot \left(-d\right) \]
      12. metadata-eval58.6%

        \[\leadsto e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}} \cdot \left(-d\right) \]
      13. exp-to-pow62.5%

        \[\leadsto \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \cdot \left(-d\right) \]
    9. Simplified62.5%

      \[\leadsto \color{blue}{{\left(\ell \cdot h\right)}^{-0.5} \cdot \left(-d\right)} \]

    if -1.29999999999999992e75 < l < 5.0000000000000004e-240

    1. Initial program 78.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified77.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. expm1-log1p-u77.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
      2. expm1-udef77.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} - 1\right)}\right) \]
      3. *-commutative77.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{h}{\ell} \cdot {\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2}}\right)} - 1\right)\right) \]
      4. frac-times78.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{D \cdot M}{2 \cdot d}\right)}}^{2}\right)} - 1\right)\right) \]
      5. *-commutative78.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2}\right)} - 1\right)\right) \]
      6. frac-times78.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2}\right)} - 1\right)\right) \]
      7. div-inv78.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(M \cdot \frac{1}{2}\right)} \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
      8. metadata-eval78.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot \color{blue}{0.5}\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
    5. Applied egg-rr78.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)}\right) \]
    6. Step-by-step derivation
      1. expm1-def78.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)}\right) \]
      2. expm1-log1p78.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)}\right) \]
      3. associate-*l/81.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{h \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}}\right) \]
      4. *-commutative81.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}}{\ell}\right) \]
      5. associate-*l/81.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell} \cdot h\right)}\right) \]
      6. *-commutative81.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)}\right) \]
      7. associate-*r/81.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      8. associate-*l*81.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{M \cdot \left(0.5 \cdot D\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
      9. *-commutative81.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{M \cdot \color{blue}{\left(D \cdot 0.5\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
      10. *-commutative81.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{\left(D \cdot 0.5\right) \cdot M}}{d}\right)}^{2}}{\ell}\right)\right) \]
      11. associate-*r/81.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\left(D \cdot 0.5\right) \cdot \frac{M}{d}\right)}}^{2}}{\ell}\right)\right) \]
      12. associate-*l*81.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)}}^{2}}{\ell}\right)\right) \]
      13. associate-*r/81.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{0.5 \cdot M}{d}}\right)}^{2}}{\ell}\right)\right) \]
      14. *-commutative81.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \frac{\color{blue}{M \cdot 0.5}}{d}\right)}^{2}}{\ell}\right)\right) \]
      15. associate-/l*81.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{M}{\frac{d}{0.5}}}\right)}^{2}}{\ell}\right)\right) \]
    7. Simplified81.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}{\ell}\right)}\right) \]
    8. Step-by-step derivation
      1. expm1-log1p-u33.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}{\ell}\right)\right)\right)\right)} \]
      2. expm1-udef29.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}{\ell}\right)\right)\right)} - 1} \]
    9. Applied egg-rr27.3%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - \left(0.5 \cdot h\right) \cdot \frac{{\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell}\right)\right)} - 1} \]
    10. Step-by-step derivation
      1. expm1-def30.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - \left(0.5 \cdot h\right) \cdot \frac{{\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell}\right)\right)\right)} \]
      2. expm1-log1p73.8%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - \left(0.5 \cdot h\right) \cdot \frac{{\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell}\right)} \]
      3. associate-*r/74.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - \color{blue}{\frac{\left(0.5 \cdot h\right) \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell}}\right) \]
      4. *-commutative74.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - \frac{\color{blue}{\left(h \cdot 0.5\right)} \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell}\right) \]
      5. times-frac74.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - \frac{\left(h \cdot 0.5\right) \cdot {\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)}}^{2}}{\ell}\right) \]
    11. Simplified74.7%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - \frac{\left(h \cdot 0.5\right) \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell}\right)} \]

    if 5.0000000000000004e-240 < l < 4.9999999999999997e104

    1. Initial program 74.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified74.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. sub-neg74.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \color{blue}{\left(1 + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} \]
      2. distribute-rgt-in61.2%

        \[\leadsto \color{blue}{1 \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)} \]
      3. *-un-lft-identity61.2%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      4. sqrt-div63.7%

        \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}} + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      5. sqrt-div66.5%

        \[\leadsto \frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      6. frac-times66.5%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}} + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      7. add-sqr-sqrt66.6%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
    5. Applied egg-rr78.0%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} + \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    6. Step-by-step derivation
      1. distribute-rgt1-in89.1%

        \[\leadsto \color{blue}{\left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right) + 1\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      2. +-commutative89.1%

        \[\leadsto \color{blue}{\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      3. associate-*r*89.1%

        \[\leadsto \left(1 + \color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      4. *-commutative89.1%

        \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\color{blue}{\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. /-rgt-identity89.1%

        \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{D}{d} \cdot \color{blue}{\frac{M \cdot 0.5}{1}}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. associate-/l*89.1%

        \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{D}{d} \cdot \color{blue}{\frac{M}{\frac{1}{0.5}}}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      7. metadata-eval89.1%

        \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{D}{d} \cdot \frac{M}{\color{blue}{2}}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      8. times-frac91.8%

        \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\color{blue}{\left(\frac{D \cdot M}{d \cdot 2}\right)}}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      9. associate-*r/91.8%

        \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)}}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      10. *-commutative91.8%

        \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M}{\color{blue}{2 \cdot d}}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. Simplified91.8%

      \[\leadsto \color{blue}{\left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Step-by-step derivation
      1. associate-*r/91.8%

        \[\leadsto \color{blue}{\frac{\left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      2. +-commutative91.8%

        \[\leadsto \frac{\color{blue}{\left(\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2} + 1\right)} \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      3. *-commutative91.8%

        \[\leadsto \frac{\left(\color{blue}{{\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right)} + 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      4. fma-def91.8%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. associate-*r/91.8%

        \[\leadsto \frac{\mathsf{fma}\left({\color{blue}{\left(\frac{D \cdot M}{2 \cdot d}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. *-commutative91.8%

        \[\leadsto \frac{\mathsf{fma}\left({\left(\frac{D \cdot M}{\color{blue}{d \cdot 2}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      7. metadata-eval91.8%

        \[\leadsto \frac{\mathsf{fma}\left({\left(\frac{D \cdot M}{d \cdot \color{blue}{\frac{1}{0.5}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      8. div-inv91.8%

        \[\leadsto \frac{\mathsf{fma}\left({\left(\frac{D \cdot M}{\color{blue}{\frac{d}{0.5}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      9. associate-*r/91.8%

        \[\leadsto \frac{\mathsf{fma}\left({\color{blue}{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      10. associate-/r/91.8%

        \[\leadsto \frac{\mathsf{fma}\left({\left(D \cdot \color{blue}{\left(\frac{M}{d} \cdot 0.5\right)}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      11. sqrt-unprod83.9%

        \[\leadsto \frac{\mathsf{fma}\left({\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      12. *-commutative83.9%

        \[\leadsto \frac{\mathsf{fma}\left({\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{\color{blue}{\ell \cdot h}}} \]
    9. Applied egg-rr83.9%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{\ell \cdot h}}} \]
    10. Step-by-step derivation
      1. fma-udef83.9%

        \[\leadsto \frac{\color{blue}{\left({\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right) + 1\right)} \cdot d}{\sqrt{\ell \cdot h}} \]
      2. associate-*r*83.9%

        \[\leadsto \frac{\left({\color{blue}{\left(\left(D \cdot \frac{M}{d}\right) \cdot 0.5\right)}}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right) + 1\right) \cdot d}{\sqrt{\ell \cdot h}} \]
      3. *-commutative83.9%

        \[\leadsto \frac{\left({\left(\left(D \cdot \frac{M}{d}\right) \cdot 0.5\right)}^{2} \cdot \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right)} + 1\right) \cdot d}{\sqrt{\ell \cdot h}} \]
    11. Applied egg-rr83.9%

      \[\leadsto \frac{\color{blue}{\left({\left(\left(D \cdot \frac{M}{d}\right) \cdot 0.5\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right) + 1\right)} \cdot d}{\sqrt{\ell \cdot h}} \]

    if 4.9999999999999997e104 < l

    1. Initial program 43.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. Simplified43.8%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. expm1-log1p-u43.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
      2. expm1-udef43.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} - 1\right)}\right) \]
      3. *-commutative43.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{h}{\ell} \cdot {\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2}}\right)} - 1\right)\right) \]
      4. frac-times43.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{D \cdot M}{2 \cdot d}\right)}}^{2}\right)} - 1\right)\right) \]
      5. *-commutative43.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2}\right)} - 1\right)\right) \]
      6. frac-times41.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2}\right)} - 1\right)\right) \]
      7. div-inv41.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(M \cdot \frac{1}{2}\right)} \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
      8. metadata-eval41.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot \color{blue}{0.5}\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
    5. Applied egg-rr41.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)}\right) \]
    6. Step-by-step derivation
      1. expm1-def41.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)}\right) \]
      2. expm1-log1p41.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)}\right) \]
      3. associate-*l/42.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{h \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}}\right) \]
      4. *-commutative42.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}}{\ell}\right) \]
      5. associate-*l/44.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell} \cdot h\right)}\right) \]
      6. *-commutative44.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)}\right) \]
      7. associate-*r/46.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      8. associate-*l*46.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{M \cdot \left(0.5 \cdot D\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
      9. *-commutative46.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{M \cdot \color{blue}{\left(D \cdot 0.5\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
      10. *-commutative46.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{\left(D \cdot 0.5\right) \cdot M}}{d}\right)}^{2}}{\ell}\right)\right) \]
      11. associate-*r/46.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\left(D \cdot 0.5\right) \cdot \frac{M}{d}\right)}}^{2}}{\ell}\right)\right) \]
      12. associate-*l*46.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)}}^{2}}{\ell}\right)\right) \]
      13. associate-*r/46.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{0.5 \cdot M}{d}}\right)}^{2}}{\ell}\right)\right) \]
      14. *-commutative46.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \frac{\color{blue}{M \cdot 0.5}}{d}\right)}^{2}}{\ell}\right)\right) \]
      15. associate-/l*46.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{M}{\frac{d}{0.5}}}\right)}^{2}}{\ell}\right)\right) \]
    7. Simplified46.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}{\ell}\right)}\right) \]
    8. Taylor expanded in d around inf 37.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. associate-/r*38.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. unpow1/238.4%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
      3. associate-/l/37.1%

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{0.5} \]
      4. rem-exp-log34.8%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{0.5} \]
      5. exp-neg34.8%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(\ell \cdot h\right)}\right)}}^{0.5} \]
      6. exp-prod34.8%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}} \]
      7. distribute-lft-neg-out34.8%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in34.8%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval34.8%

        \[\leadsto d \cdot e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}} \]
      10. exp-to-pow37.1%

        \[\leadsto d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
    10. Simplified37.1%

      \[\leadsto \color{blue}{d \cdot {\left(\ell \cdot h\right)}^{-0.5}} \]
    11. Step-by-step derivation
      1. unpow-prod-down48.0%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    12. Applied egg-rr48.0%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification70.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.3 \cdot 10^{+75}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{elif}\;\ell \leq 5 \cdot 10^{-240}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \frac{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \left(h \cdot 0.5\right)}{\ell}\right)\\ \mathbf{elif}\;\ell \leq 5 \cdot 10^{+104}:\\ \;\;\;\;\frac{d \cdot \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(0.5 \cdot \left(D \cdot \frac{M}{d}\right)\right)}^{2}\right)}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 47.7% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(h \cdot \ell + -1\right)\right)\right) \cdot 0.3333333333333333}\\ \mathbf{if}\;d \leq -4.4 \cdot 10^{+81}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{elif}\;d \leq -3.7 \cdot 10^{+44}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -6.2 \cdot 10^{-140}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -4 \cdot 10^{-310}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0
         (*
          d
          (exp (* (* 1.5 (- (log1p (+ (* h l) -1.0)))) 0.3333333333333333)))))
   (if (<= d -4.4e+81)
     (* (- d) (pow (* h l) -0.5))
     (if (<= d -3.7e+44)
       t_0
       (if (<= d -6.2e-140)
         (* (sqrt (/ d l)) (sqrt (/ d h)))
         (if (<= d -4e-310) t_0 (* d (/ (sqrt (/ 1.0 l)) (sqrt h)))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = d * exp(((1.5 * -log1p(((h * l) + -1.0))) * 0.3333333333333333));
	double tmp;
	if (d <= -4.4e+81) {
		tmp = -d * pow((h * l), -0.5);
	} else if (d <= -3.7e+44) {
		tmp = t_0;
	} else if (d <= -6.2e-140) {
		tmp = sqrt((d / l)) * sqrt((d / h));
	} else if (d <= -4e-310) {
		tmp = t_0;
	} else {
		tmp = d * (sqrt((1.0 / l)) / sqrt(h));
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = d * Math.exp(((1.5 * -Math.log1p(((h * l) + -1.0))) * 0.3333333333333333));
	double tmp;
	if (d <= -4.4e+81) {
		tmp = -d * Math.pow((h * l), -0.5);
	} else if (d <= -3.7e+44) {
		tmp = t_0;
	} else if (d <= -6.2e-140) {
		tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
	} else if (d <= -4e-310) {
		tmp = t_0;
	} else {
		tmp = d * (Math.sqrt((1.0 / l)) / Math.sqrt(h));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = d * math.exp(((1.5 * -math.log1p(((h * l) + -1.0))) * 0.3333333333333333))
	tmp = 0
	if d <= -4.4e+81:
		tmp = -d * math.pow((h * l), -0.5)
	elif d <= -3.7e+44:
		tmp = t_0
	elif d <= -6.2e-140:
		tmp = math.sqrt((d / l)) * math.sqrt((d / h))
	elif d <= -4e-310:
		tmp = t_0
	else:
		tmp = d * (math.sqrt((1.0 / l)) / math.sqrt(h))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(d * exp(Float64(Float64(1.5 * Float64(-log1p(Float64(Float64(h * l) + -1.0)))) * 0.3333333333333333)))
	tmp = 0.0
	if (d <= -4.4e+81)
		tmp = Float64(Float64(-d) * (Float64(h * l) ^ -0.5));
	elseif (d <= -3.7e+44)
		tmp = t_0;
	elseif (d <= -6.2e-140)
		tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h)));
	elseif (d <= -4e-310)
		tmp = t_0;
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / l)) / sqrt(h)));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(d * N[Exp[N[(N[(1.5 * (-N[Log[1 + N[(N[(h * l), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.4e+81], N[((-d) * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -3.7e+44], t$95$0, If[LessEqual[d, -6.2e-140], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -4e-310], t$95$0, N[(d * N[(N[Sqrt[N[(1.0 / l), $MachinePrecision]], $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 \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(h \cdot \ell + -1\right)\right)\right) \cdot 0.3333333333333333}\\
\mathbf{if}\;d \leq -4.4 \cdot 10^{+81}:\\
\;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\

\mathbf{elif}\;d \leq -3.7 \cdot 10^{+44}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq -6.2 \cdot 10^{-140}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\

\mathbf{elif}\;d \leq -4 \cdot 10^{-310}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -4.39999999999999974e81

    1. Initial program 68.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified70.2%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt54.4%

        \[\leadsto \color{blue}{\sqrt{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \cdot \sqrt{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
      2. sqrt-unprod46.2%

        \[\leadsto \color{blue}{\sqrt{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}} \]
      3. *-commutative46.2%

        \[\leadsto \sqrt{\color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)} \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} \]
      4. *-commutative46.2%

        \[\leadsto \sqrt{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right) \cdot \color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}} \]
      5. swap-sqr46.2%

        \[\leadsto \sqrt{\color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}} \]
    5. Applied egg-rr35.4%

      \[\leadsto \color{blue}{\sqrt{{\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)}^{2} \cdot \frac{{d}^{2}}{h \cdot \ell}}} \]
    6. Simplified38.1%

      \[\leadsto \color{blue}{\sqrt{{\left(\mathsf{fma}\left(h, \frac{-0.5}{\frac{\ell}{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}}, 1\right)\right)}^{2} \cdot \frac{{d}^{2}}{h \cdot \ell}}} \]
    7. Taylor expanded in d around -inf 75.9%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    8. Step-by-step derivation
      1. mul-1-neg75.9%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. *-commutative75.9%

        \[\leadsto -\color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      3. distribute-rgt-neg-in75.9%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(-d\right)} \]
      4. associate-/r*76.5%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(-d\right) \]
      5. unpow1/276.5%

        \[\leadsto \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \cdot \left(-d\right) \]
      6. associate-/l/75.9%

        \[\leadsto {\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{0.5} \cdot \left(-d\right) \]
      7. rem-exp-log72.7%

        \[\leadsto {\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{0.5} \cdot \left(-d\right) \]
      8. exp-neg72.7%

        \[\leadsto {\color{blue}{\left(e^{-\log \left(\ell \cdot h\right)}\right)}}^{0.5} \cdot \left(-d\right) \]
      9. exp-prod72.7%

        \[\leadsto \color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}} \cdot \left(-d\right) \]
      10. distribute-lft-neg-out72.7%

        \[\leadsto e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}} \cdot \left(-d\right) \]
      11. distribute-rgt-neg-in72.7%

        \[\leadsto e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}} \cdot \left(-d\right) \]
      12. metadata-eval72.7%

        \[\leadsto e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}} \cdot \left(-d\right) \]
      13. exp-to-pow76.0%

        \[\leadsto \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \cdot \left(-d\right) \]
    9. Simplified76.0%

      \[\leadsto \color{blue}{{\left(\ell \cdot h\right)}^{-0.5} \cdot \left(-d\right)} \]

    if -4.39999999999999974e81 < d < -3.7000000000000001e44 or -6.1999999999999998e-140 < d < -3.999999999999988e-310

    1. Initial program 66.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified66.2%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 25.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. add-cbrt-cube31.8%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}}} \]
      2. add-sqr-sqrt31.8%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      3. pow131.8%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{1}} \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      4. pow1/231.8%

        \[\leadsto d \cdot \sqrt[3]{{\left(\frac{1}{h \cdot \ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}} \]
      5. pow-prod-up31.8%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{\left(1 + 0.5\right)}}} \]
      6. associate-/r*31.8%

        \[\leadsto d \cdot \sqrt[3]{{\color{blue}{\left(\frac{\frac{1}{h}}{\ell}\right)}}^{\left(1 + 0.5\right)}} \]
      7. metadata-eval31.8%

        \[\leadsto d \cdot \sqrt[3]{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{1.5}}} \]
    6. Applied egg-rr31.8%

      \[\leadsto d \cdot \color{blue}{\sqrt[3]{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}}} \]
    7. Step-by-step derivation
      1. pow1/331.8%

        \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
      2. pow-to-exp31.8%

        \[\leadsto d \cdot {\color{blue}{\left(e^{\log \left(\frac{\frac{1}{h}}{\ell}\right) \cdot 1.5}\right)}}^{0.3333333333333333} \]
      3. pow-exp25.3%

        \[\leadsto d \cdot \color{blue}{e^{\left(\log \left(\frac{\frac{1}{h}}{\ell}\right) \cdot 1.5\right) \cdot 0.3333333333333333}} \]
      4. rem-log-exp31.8%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(e^{\log \left(\frac{\frac{1}{h}}{\ell}\right) \cdot 1.5}\right)} \cdot 0.3333333333333333} \]
      5. pow-to-exp31.8%

        \[\leadsto d \cdot e^{\log \color{blue}{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)} \cdot 0.3333333333333333} \]
      6. log-pow25.3%

        \[\leadsto d \cdot e^{\color{blue}{\left(1.5 \cdot \log \left(\frac{\frac{1}{h}}{\ell}\right)\right)} \cdot 0.3333333333333333} \]
      7. associate-/l/25.3%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \log \color{blue}{\left(\frac{1}{\ell \cdot h}\right)}\right) \cdot 0.3333333333333333} \]
      8. log-rec23.1%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \color{blue}{\left(-\log \left(\ell \cdot h\right)\right)}\right) \cdot 0.3333333333333333} \]
    8. Applied egg-rr23.1%

      \[\leadsto d \cdot \color{blue}{e^{\left(1.5 \cdot \left(-\log \left(\ell \cdot h\right)\right)\right) \cdot 0.3333333333333333}} \]
    9. Step-by-step derivation
      1. log1p-expm1-u45.1%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(\ell \cdot h\right)\right)\right)}\right)\right) \cdot 0.3333333333333333} \]
      2. expm1-udef45.1%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(\color{blue}{e^{\log \left(\ell \cdot h\right)} - 1}\right)\right)\right) \cdot 0.3333333333333333} \]
      3. add-exp-log45.1%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(\color{blue}{\ell \cdot h} - 1\right)\right)\right) \cdot 0.3333333333333333} \]
      4. *-commutative45.1%

        \[\leadsto d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(\color{blue}{h \cdot \ell} - 1\right)\right)\right) \cdot 0.3333333333333333} \]
    10. Applied egg-rr45.1%

      \[\leadsto d \cdot e^{\left(1.5 \cdot \left(-\color{blue}{\mathsf{log1p}\left(h \cdot \ell - 1\right)}\right)\right) \cdot 0.3333333333333333} \]

    if -3.7000000000000001e44 < d < -6.1999999999999998e-140

    1. Initial program 84.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. Simplified84.2%

      \[\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. frac-2neg84.2%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\color{blue}{\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) \]
      2. sqrt-div85.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\frac{\sqrt{-d}}{\sqrt{-\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) \]
    5. Applied egg-rr85.1%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\frac{\sqrt{-d}}{\sqrt{-\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) \]
    6. Taylor expanded in h around 0 52.4%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]

    if -3.999999999999988e-310 < d

    1. Initial program 62.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified62.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. expm1-log1p-u61.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
      2. expm1-udef61.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} - 1\right)}\right) \]
      3. *-commutative61.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{h}{\ell} \cdot {\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2}}\right)} - 1\right)\right) \]
      4. frac-times62.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{D \cdot M}{2 \cdot d}\right)}}^{2}\right)} - 1\right)\right) \]
      5. *-commutative62.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2}\right)} - 1\right)\right) \]
      6. frac-times60.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2}\right)} - 1\right)\right) \]
      7. div-inv60.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(M \cdot \frac{1}{2}\right)} \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
      8. metadata-eval60.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot \color{blue}{0.5}\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
    5. Applied egg-rr60.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)}\right) \]
    6. Step-by-step derivation
      1. expm1-def60.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)}\right) \]
      2. expm1-log1p61.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)}\right) \]
      3. associate-*l/64.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{h \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}}\right) \]
      4. *-commutative64.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}}{\ell}\right) \]
      5. associate-*l/65.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell} \cdot h\right)}\right) \]
      6. *-commutative65.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)}\right) \]
      7. associate-*r/65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      8. associate-*l*65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{M \cdot \left(0.5 \cdot D\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
      9. *-commutative65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{M \cdot \color{blue}{\left(D \cdot 0.5\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
      10. *-commutative65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{\left(D \cdot 0.5\right) \cdot M}}{d}\right)}^{2}}{\ell}\right)\right) \]
      11. associate-*r/65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\left(D \cdot 0.5\right) \cdot \frac{M}{d}\right)}}^{2}}{\ell}\right)\right) \]
      12. associate-*l*65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)}}^{2}}{\ell}\right)\right) \]
      13. associate-*r/65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{0.5 \cdot M}{d}}\right)}^{2}}{\ell}\right)\right) \]
      14. *-commutative65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \frac{\color{blue}{M \cdot 0.5}}{d}\right)}^{2}}{\ell}\right)\right) \]
      15. associate-/l*65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{M}{\frac{d}{0.5}}}\right)}^{2}}{\ell}\right)\right) \]
    7. Simplified65.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}{\ell}\right)}\right) \]
    8. Taylor expanded in d around inf 37.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. associate-/r*37.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. unpow1/237.9%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
      3. associate-/l/37.2%

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{0.5} \]
      4. rem-exp-log35.2%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{0.5} \]
      5. exp-neg35.2%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(\ell \cdot h\right)}\right)}}^{0.5} \]
      6. exp-prod35.2%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}} \]
      7. distribute-lft-neg-out35.2%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in35.2%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval35.2%

        \[\leadsto d \cdot e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}} \]
      10. exp-to-pow37.2%

        \[\leadsto d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
    10. Simplified37.2%

      \[\leadsto \color{blue}{d \cdot {\left(\ell \cdot h\right)}^{-0.5}} \]
    11. Taylor expanded in d around 0 37.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    12. Step-by-step derivation
      1. associate-/l/37.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    13. Simplified37.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    14. Step-by-step derivation
      1. sqrt-div43.6%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
    15. Applied egg-rr43.6%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification50.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.4 \cdot 10^{+81}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{elif}\;d \leq -3.7 \cdot 10^{+44}:\\ \;\;\;\;d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(h \cdot \ell + -1\right)\right)\right) \cdot 0.3333333333333333}\\ \mathbf{elif}\;d \leq -6.2 \cdot 10^{-140}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -4 \cdot 10^{-310}:\\ \;\;\;\;d \cdot e^{\left(1.5 \cdot \left(-\mathsf{log1p}\left(h \cdot \ell + -1\right)\right)\right) \cdot 0.3333333333333333}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 46.0% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -9.6 \cdot 10^{-142}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{elif}\;d \leq -4 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt[3]{{\left(\frac{1}{h \cdot \ell}\right)}^{1.5}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= d -9.6e-142)
   (* (- d) (pow (* h l) -0.5))
   (if (<= d -4e-310)
     (* d (cbrt (pow (/ 1.0 (* h l)) 1.5)))
     (* d (/ (sqrt (/ 1.0 l)) (sqrt h))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -9.6e-142) {
		tmp = -d * pow((h * l), -0.5);
	} else if (d <= -4e-310) {
		tmp = d * cbrt(pow((1.0 / (h * l)), 1.5));
	} else {
		tmp = d * (sqrt((1.0 / l)) / sqrt(h));
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (d <= -9.6e-142) {
		tmp = -d * Math.pow((h * l), -0.5);
	} else if (d <= -4e-310) {
		tmp = d * Math.cbrt(Math.pow((1.0 / (h * l)), 1.5));
	} else {
		tmp = d * (Math.sqrt((1.0 / l)) / Math.sqrt(h));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (d <= -9.6e-142)
		tmp = Float64(Float64(-d) * (Float64(h * l) ^ -0.5));
	elseif (d <= -4e-310)
		tmp = Float64(d * cbrt((Float64(1.0 / Float64(h * l)) ^ 1.5)));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / l)) / sqrt(h)));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, -9.6e-142], N[((-d) * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -4e-310], N[(d * N[Power[N[Power[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / l), $MachinePrecision]], $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}
\mathbf{if}\;d \leq -9.6 \cdot 10^{-142}:\\
\;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\

\mathbf{elif}\;d \leq -4 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \sqrt[3]{{\left(\frac{1}{h \cdot \ell}\right)}^{1.5}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -9.59999999999999952e-142

    1. Initial program 76.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. Simplified77.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt47.8%

        \[\leadsto \color{blue}{\sqrt{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \cdot \sqrt{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
      2. sqrt-unprod42.0%

        \[\leadsto \color{blue}{\sqrt{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}} \]
      3. *-commutative42.0%

        \[\leadsto \sqrt{\color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)} \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} \]
      4. *-commutative42.0%

        \[\leadsto \sqrt{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right) \cdot \color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}} \]
      5. swap-sqr42.0%

        \[\leadsto \sqrt{\color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}} \]
    5. Applied egg-rr34.3%

      \[\leadsto \color{blue}{\sqrt{{\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)}^{2} \cdot \frac{{d}^{2}}{h \cdot \ell}}} \]
    6. Simplified36.8%

      \[\leadsto \color{blue}{\sqrt{{\left(\mathsf{fma}\left(h, \frac{-0.5}{\frac{\ell}{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}}, 1\right)\right)}^{2} \cdot \frac{{d}^{2}}{h \cdot \ell}}} \]
    7. Taylor expanded in d around -inf 58.4%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    8. Step-by-step derivation
      1. mul-1-neg58.4%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. *-commutative58.4%

        \[\leadsto -\color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      3. distribute-rgt-neg-in58.4%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(-d\right)} \]
      4. associate-/r*58.7%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(-d\right) \]
      5. unpow1/258.7%

        \[\leadsto \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \cdot \left(-d\right) \]
      6. associate-/l/58.4%

        \[\leadsto {\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{0.5} \cdot \left(-d\right) \]
      7. rem-exp-log55.4%

        \[\leadsto {\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{0.5} \cdot \left(-d\right) \]
      8. exp-neg55.4%

        \[\leadsto {\color{blue}{\left(e^{-\log \left(\ell \cdot h\right)}\right)}}^{0.5} \cdot \left(-d\right) \]
      9. exp-prod55.4%

        \[\leadsto \color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}} \cdot \left(-d\right) \]
      10. distribute-lft-neg-out55.4%

        \[\leadsto e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}} \cdot \left(-d\right) \]
      11. distribute-rgt-neg-in55.4%

        \[\leadsto e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}} \cdot \left(-d\right) \]
      12. metadata-eval55.4%

        \[\leadsto e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}} \cdot \left(-d\right) \]
      13. exp-to-pow58.5%

        \[\leadsto \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \cdot \left(-d\right) \]
    9. Simplified58.5%

      \[\leadsto \color{blue}{{\left(\ell \cdot h\right)}^{-0.5} \cdot \left(-d\right)} \]

    if -9.59999999999999952e-142 < d < -3.999999999999988e-310

    1. Initial program 60.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. Simplified60.2%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 25.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. add-cbrt-cube33.5%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}}} \]
      2. pow1/333.5%

        \[\leadsto d \cdot \color{blue}{{\left(\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{0.3333333333333333}} \]
      3. add-sqr-sqrt33.5%

        \[\leadsto d \cdot {\left(\color{blue}{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{0.3333333333333333} \]
      4. pow133.5%

        \[\leadsto d \cdot {\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{1}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{0.3333333333333333} \]
      5. pow1/233.5%

        \[\leadsto d \cdot {\left({\left(\frac{1}{h \cdot \ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)}^{0.3333333333333333} \]
      6. pow-prod-up33.5%

        \[\leadsto d \cdot {\color{blue}{\left({\left(\frac{1}{h \cdot \ell}\right)}^{\left(1 + 0.5\right)}\right)}}^{0.3333333333333333} \]
      7. associate-/r*33.5%

        \[\leadsto d \cdot {\left({\color{blue}{\left(\frac{\frac{1}{h}}{\ell}\right)}}^{\left(1 + 0.5\right)}\right)}^{0.3333333333333333} \]
      8. metadata-eval33.5%

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    6. Applied egg-rr33.5%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    7. Step-by-step derivation
      1. unpow1/333.5%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}}} \]
      2. associate-/l/33.5%

        \[\leadsto d \cdot \sqrt[3]{{\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{1.5}} \]
    8. Simplified33.5%

      \[\leadsto d \cdot \color{blue}{\sqrt[3]{{\left(\frac{1}{\ell \cdot h}\right)}^{1.5}}} \]

    if -3.999999999999988e-310 < d

    1. Initial program 62.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified62.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. expm1-log1p-u61.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
      2. expm1-udef61.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} - 1\right)}\right) \]
      3. *-commutative61.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{h}{\ell} \cdot {\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2}}\right)} - 1\right)\right) \]
      4. frac-times62.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{D \cdot M}{2 \cdot d}\right)}}^{2}\right)} - 1\right)\right) \]
      5. *-commutative62.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2}\right)} - 1\right)\right) \]
      6. frac-times60.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2}\right)} - 1\right)\right) \]
      7. div-inv60.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(M \cdot \frac{1}{2}\right)} \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
      8. metadata-eval60.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot \color{blue}{0.5}\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
    5. Applied egg-rr60.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)}\right) \]
    6. Step-by-step derivation
      1. expm1-def60.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)}\right) \]
      2. expm1-log1p61.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)}\right) \]
      3. associate-*l/64.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{h \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}}\right) \]
      4. *-commutative64.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}}{\ell}\right) \]
      5. associate-*l/65.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell} \cdot h\right)}\right) \]
      6. *-commutative65.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)}\right) \]
      7. associate-*r/65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      8. associate-*l*65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{M \cdot \left(0.5 \cdot D\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
      9. *-commutative65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{M \cdot \color{blue}{\left(D \cdot 0.5\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
      10. *-commutative65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{\left(D \cdot 0.5\right) \cdot M}}{d}\right)}^{2}}{\ell}\right)\right) \]
      11. associate-*r/65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\left(D \cdot 0.5\right) \cdot \frac{M}{d}\right)}}^{2}}{\ell}\right)\right) \]
      12. associate-*l*65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)}}^{2}}{\ell}\right)\right) \]
      13. associate-*r/65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{0.5 \cdot M}{d}}\right)}^{2}}{\ell}\right)\right) \]
      14. *-commutative65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \frac{\color{blue}{M \cdot 0.5}}{d}\right)}^{2}}{\ell}\right)\right) \]
      15. associate-/l*65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{M}{\frac{d}{0.5}}}\right)}^{2}}{\ell}\right)\right) \]
    7. Simplified65.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}{\ell}\right)}\right) \]
    8. Taylor expanded in d around inf 37.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. associate-/r*37.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. unpow1/237.9%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
      3. associate-/l/37.2%

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{0.5} \]
      4. rem-exp-log35.2%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{0.5} \]
      5. exp-neg35.2%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(\ell \cdot h\right)}\right)}}^{0.5} \]
      6. exp-prod35.2%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}} \]
      7. distribute-lft-neg-out35.2%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in35.2%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval35.2%

        \[\leadsto d \cdot e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}} \]
      10. exp-to-pow37.2%

        \[\leadsto d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
    10. Simplified37.2%

      \[\leadsto \color{blue}{d \cdot {\left(\ell \cdot h\right)}^{-0.5}} \]
    11. Taylor expanded in d around 0 37.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    12. Step-by-step derivation
      1. associate-/l/37.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    13. Simplified37.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    14. Step-by-step derivation
      1. sqrt-div43.6%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
    15. Applied egg-rr43.6%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification47.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9.6 \cdot 10^{-142}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{elif}\;d \leq -4 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt[3]{{\left(\frac{1}{h \cdot \ell}\right)}^{1.5}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 46.0% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 3.6 \cdot 10^{-279}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l 3.6e-279)
   (* (- d) (pow (* h l) -0.5))
   (* d (* (pow l -0.5) (pow h -0.5)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 3.6e-279) {
		tmp = -d * pow((h * l), -0.5);
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= 3.6d-279) then
        tmp = -d * ((h * l) ** (-0.5d0))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 3.6e-279) {
		tmp = -d * Math.pow((h * l), -0.5);
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= 3.6e-279:
		tmp = -d * math.pow((h * l), -0.5)
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= 3.6e-279)
		tmp = Float64(Float64(-d) * (Float64(h * l) ^ -0.5));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= 3.6e-279)
		tmp = -d * ((h * l) ^ -0.5);
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, 3.6e-279], N[((-d) * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 3.6 \cdot 10^{-279}:\\
\;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 3.5999999999999997e-279

    1. Initial program 72.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. Simplified72.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt36.1%

        \[\leadsto \color{blue}{\sqrt{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \cdot \sqrt{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
      2. sqrt-unprod31.4%

        \[\leadsto \color{blue}{\sqrt{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}} \]
      3. *-commutative31.4%

        \[\leadsto \sqrt{\color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)} \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} \]
      4. *-commutative31.4%

        \[\leadsto \sqrt{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right) \cdot \color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}} \]
      5. swap-sqr31.4%

        \[\leadsto \sqrt{\color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}} \]
    5. Applied egg-rr26.1%

      \[\leadsto \color{blue}{\sqrt{{\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)}^{2} \cdot \frac{{d}^{2}}{h \cdot \ell}}} \]
    6. Simplified27.9%

      \[\leadsto \color{blue}{\sqrt{{\left(\mathsf{fma}\left(h, \frac{-0.5}{\frac{\ell}{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}}, 1\right)\right)}^{2} \cdot \frac{{d}^{2}}{h \cdot \ell}}} \]
    7. Taylor expanded in d around -inf 45.2%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    8. Step-by-step derivation
      1. mul-1-neg45.2%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. *-commutative45.2%

        \[\leadsto -\color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      3. distribute-rgt-neg-in45.2%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(-d\right)} \]
      4. associate-/r*45.5%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(-d\right) \]
      5. unpow1/245.5%

        \[\leadsto \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \cdot \left(-d\right) \]
      6. associate-/l/45.2%

        \[\leadsto {\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{0.5} \cdot \left(-d\right) \]
      7. rem-exp-log43.1%

        \[\leadsto {\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{0.5} \cdot \left(-d\right) \]
      8. exp-neg43.1%

        \[\leadsto {\color{blue}{\left(e^{-\log \left(\ell \cdot h\right)}\right)}}^{0.5} \cdot \left(-d\right) \]
      9. exp-prod43.1%

        \[\leadsto \color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}} \cdot \left(-d\right) \]
      10. distribute-lft-neg-out43.1%

        \[\leadsto e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}} \cdot \left(-d\right) \]
      11. distribute-rgt-neg-in43.1%

        \[\leadsto e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}} \cdot \left(-d\right) \]
      12. metadata-eval43.1%

        \[\leadsto e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}} \cdot \left(-d\right) \]
      13. exp-to-pow45.3%

        \[\leadsto \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \cdot \left(-d\right) \]
    9. Simplified45.3%

      \[\leadsto \color{blue}{{\left(\ell \cdot h\right)}^{-0.5} \cdot \left(-d\right)} \]

    if 3.5999999999999997e-279 < l

    1. Initial program 62.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified61.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. expm1-log1p-u60.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
      2. expm1-udef60.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} - 1\right)}\right) \]
      3. *-commutative60.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{h}{\ell} \cdot {\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2}}\right)} - 1\right)\right) \]
      4. frac-times61.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{D \cdot M}{2 \cdot d}\right)}}^{2}\right)} - 1\right)\right) \]
      5. *-commutative61.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2}\right)} - 1\right)\right) \]
      6. frac-times60.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2}\right)} - 1\right)\right) \]
      7. div-inv60.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(M \cdot \frac{1}{2}\right)} \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
      8. metadata-eval60.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot \color{blue}{0.5}\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
    5. Applied egg-rr60.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)}\right) \]
    6. Step-by-step derivation
      1. expm1-def60.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)}\right) \]
      2. expm1-log1p60.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)}\right) \]
      3. associate-*l/64.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{h \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}}\right) \]
      4. *-commutative64.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}}{\ell}\right) \]
      5. associate-*l/64.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell} \cdot h\right)}\right) \]
      6. *-commutative64.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)}\right) \]
      7. associate-*r/65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      8. associate-*l*65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{M \cdot \left(0.5 \cdot D\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
      9. *-commutative65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{M \cdot \color{blue}{\left(D \cdot 0.5\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
      10. *-commutative65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{\left(D \cdot 0.5\right) \cdot M}}{d}\right)}^{2}}{\ell}\right)\right) \]
      11. associate-*r/65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\left(D \cdot 0.5\right) \cdot \frac{M}{d}\right)}}^{2}}{\ell}\right)\right) \]
      12. associate-*l*65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)}}^{2}}{\ell}\right)\right) \]
      13. associate-*r/65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{0.5 \cdot M}{d}}\right)}^{2}}{\ell}\right)\right) \]
      14. *-commutative65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \frac{\color{blue}{M \cdot 0.5}}{d}\right)}^{2}}{\ell}\right)\right) \]
      15. associate-/l*65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{M}{\frac{d}{0.5}}}\right)}^{2}}{\ell}\right)\right) \]
    7. Simplified65.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}{\ell}\right)}\right) \]
    8. Taylor expanded in d around inf 37.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. associate-/r*38.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. unpow1/238.6%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
      3. associate-/l/37.9%

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{0.5} \]
      4. rem-exp-log35.7%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{0.5} \]
      5. exp-neg35.8%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(\ell \cdot h\right)}\right)}}^{0.5} \]
      6. exp-prod35.8%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}} \]
      7. distribute-lft-neg-out35.8%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in35.8%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval35.8%

        \[\leadsto d \cdot e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}} \]
      10. exp-to-pow37.9%

        \[\leadsto d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
    10. Simplified37.9%

      \[\leadsto \color{blue}{d \cdot {\left(\ell \cdot h\right)}^{-0.5}} \]
    11. Step-by-step derivation
      1. unpow-prod-down44.4%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    12. Applied egg-rr44.4%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification44.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 3.6 \cdot 10^{-279}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 46.0% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 7.5 \cdot 10^{-281}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l 7.5e-281)
   (* (- d) (pow (* h l) -0.5))
   (* d (/ (sqrt (/ 1.0 l)) (sqrt h)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 7.5e-281) {
		tmp = -d * pow((h * l), -0.5);
	} else {
		tmp = d * (sqrt((1.0 / l)) / sqrt(h));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= 7.5d-281) then
        tmp = -d * ((h * l) ** (-0.5d0))
    else
        tmp = d * (sqrt((1.0d0 / l)) / sqrt(h))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 7.5e-281) {
		tmp = -d * Math.pow((h * l), -0.5);
	} else {
		tmp = d * (Math.sqrt((1.0 / l)) / Math.sqrt(h));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= 7.5e-281:
		tmp = -d * math.pow((h * l), -0.5)
	else:
		tmp = d * (math.sqrt((1.0 / l)) / math.sqrt(h))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= 7.5e-281)
		tmp = Float64(Float64(-d) * (Float64(h * l) ^ -0.5));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / l)) / sqrt(h)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= 7.5e-281)
		tmp = -d * ((h * l) ^ -0.5);
	else
		tmp = d * (sqrt((1.0 / l)) / sqrt(h));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, 7.5e-281], N[((-d) * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / l), $MachinePrecision]], $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}
\mathbf{if}\;\ell \leq 7.5 \cdot 10^{-281}:\\
\;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 7.49999999999999968e-281

    1. Initial program 72.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. Simplified72.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt36.1%

        \[\leadsto \color{blue}{\sqrt{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \cdot \sqrt{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
      2. sqrt-unprod31.4%

        \[\leadsto \color{blue}{\sqrt{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}} \]
      3. *-commutative31.4%

        \[\leadsto \sqrt{\color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)} \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} \]
      4. *-commutative31.4%

        \[\leadsto \sqrt{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right) \cdot \color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}} \]
      5. swap-sqr31.4%

        \[\leadsto \sqrt{\color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}} \]
    5. Applied egg-rr26.1%

      \[\leadsto \color{blue}{\sqrt{{\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)}^{2} \cdot \frac{{d}^{2}}{h \cdot \ell}}} \]
    6. Simplified27.9%

      \[\leadsto \color{blue}{\sqrt{{\left(\mathsf{fma}\left(h, \frac{-0.5}{\frac{\ell}{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}}, 1\right)\right)}^{2} \cdot \frac{{d}^{2}}{h \cdot \ell}}} \]
    7. Taylor expanded in d around -inf 45.2%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    8. Step-by-step derivation
      1. mul-1-neg45.2%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. *-commutative45.2%

        \[\leadsto -\color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      3. distribute-rgt-neg-in45.2%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(-d\right)} \]
      4. associate-/r*45.5%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(-d\right) \]
      5. unpow1/245.5%

        \[\leadsto \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \cdot \left(-d\right) \]
      6. associate-/l/45.2%

        \[\leadsto {\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{0.5} \cdot \left(-d\right) \]
      7. rem-exp-log43.1%

        \[\leadsto {\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{0.5} \cdot \left(-d\right) \]
      8. exp-neg43.1%

        \[\leadsto {\color{blue}{\left(e^{-\log \left(\ell \cdot h\right)}\right)}}^{0.5} \cdot \left(-d\right) \]
      9. exp-prod43.1%

        \[\leadsto \color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}} \cdot \left(-d\right) \]
      10. distribute-lft-neg-out43.1%

        \[\leadsto e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}} \cdot \left(-d\right) \]
      11. distribute-rgt-neg-in43.1%

        \[\leadsto e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}} \cdot \left(-d\right) \]
      12. metadata-eval43.1%

        \[\leadsto e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}} \cdot \left(-d\right) \]
      13. exp-to-pow45.3%

        \[\leadsto \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \cdot \left(-d\right) \]
    9. Simplified45.3%

      \[\leadsto \color{blue}{{\left(\ell \cdot h\right)}^{-0.5} \cdot \left(-d\right)} \]

    if 7.49999999999999968e-281 < l

    1. Initial program 62.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified61.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. expm1-log1p-u60.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
      2. expm1-udef60.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} - 1\right)}\right) \]
      3. *-commutative60.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{h}{\ell} \cdot {\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2}}\right)} - 1\right)\right) \]
      4. frac-times61.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{D \cdot M}{2 \cdot d}\right)}}^{2}\right)} - 1\right)\right) \]
      5. *-commutative61.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2}\right)} - 1\right)\right) \]
      6. frac-times60.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2}\right)} - 1\right)\right) \]
      7. div-inv60.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(M \cdot \frac{1}{2}\right)} \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
      8. metadata-eval60.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot \color{blue}{0.5}\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
    5. Applied egg-rr60.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)}\right) \]
    6. Step-by-step derivation
      1. expm1-def60.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)}\right) \]
      2. expm1-log1p60.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)}\right) \]
      3. associate-*l/64.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{h \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}}\right) \]
      4. *-commutative64.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}}{\ell}\right) \]
      5. associate-*l/64.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell} \cdot h\right)}\right) \]
      6. *-commutative64.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)}\right) \]
      7. associate-*r/65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell}\right)\right) \]
      8. associate-*l*65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{M \cdot \left(0.5 \cdot D\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
      9. *-commutative65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{M \cdot \color{blue}{\left(D \cdot 0.5\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
      10. *-commutative65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{\left(D \cdot 0.5\right) \cdot M}}{d}\right)}^{2}}{\ell}\right)\right) \]
      11. associate-*r/65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\left(D \cdot 0.5\right) \cdot \frac{M}{d}\right)}}^{2}}{\ell}\right)\right) \]
      12. associate-*l*65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)}}^{2}}{\ell}\right)\right) \]
      13. associate-*r/65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{0.5 \cdot M}{d}}\right)}^{2}}{\ell}\right)\right) \]
      14. *-commutative65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \frac{\color{blue}{M \cdot 0.5}}{d}\right)}^{2}}{\ell}\right)\right) \]
      15. associate-/l*65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{M}{\frac{d}{0.5}}}\right)}^{2}}{\ell}\right)\right) \]
    7. Simplified65.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}{\ell}\right)}\right) \]
    8. Taylor expanded in d around inf 37.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. associate-/r*38.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. unpow1/238.6%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
      3. associate-/l/37.9%

        \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{0.5} \]
      4. rem-exp-log35.7%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{0.5} \]
      5. exp-neg35.8%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(\ell \cdot h\right)}\right)}}^{0.5} \]
      6. exp-prod35.8%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}} \]
      7. distribute-lft-neg-out35.8%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}} \]
      8. distribute-rgt-neg-in35.8%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}} \]
      9. metadata-eval35.8%

        \[\leadsto d \cdot e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}} \]
      10. exp-to-pow37.9%

        \[\leadsto d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
    10. Simplified37.9%

      \[\leadsto \color{blue}{d \cdot {\left(\ell \cdot h\right)}^{-0.5}} \]
    11. Taylor expanded in d around 0 37.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    12. Step-by-step derivation
      1. associate-/l/38.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    13. Simplified38.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    14. Step-by-step derivation
      1. sqrt-div44.5%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
    15. Applied egg-rr44.5%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification44.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 7.5 \cdot 10^{-281}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 41.6% 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 -1.36 \cdot 10^{-142}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \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 -1.36e-142)
   (* (- d) (pow (* h l) -0.5))
   (* 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 <= -1.36e-142) {
		tmp = -d * pow((h * l), -0.5);
	} 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 <= (-1.36d-142)) then
        tmp = -d * ((h * l) ** (-0.5d0))
    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 <= -1.36e-142) {
		tmp = -d * Math.pow((h * l), -0.5);
	} 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 <= -1.36e-142:
		tmp = -d * math.pow((h * l), -0.5)
	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 <= -1.36e-142)
		tmp = Float64(Float64(-d) * (Float64(h * l) ^ -0.5));
	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 <= -1.36e-142)
		tmp = -d * ((h * l) ^ -0.5);
	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, -1.36e-142], N[((-d) * N[Power[N[(h * l), $MachinePrecision], -0.5], $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 -1.36 \cdot 10^{-142}:\\
\;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.35999999999999993e-142

    1. Initial program 76.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. Simplified77.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt47.8%

        \[\leadsto \color{blue}{\sqrt{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \cdot \sqrt{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
      2. sqrt-unprod42.0%

        \[\leadsto \color{blue}{\sqrt{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}} \]
      3. *-commutative42.0%

        \[\leadsto \sqrt{\color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)} \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} \]
      4. *-commutative42.0%

        \[\leadsto \sqrt{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right) \cdot \color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}} \]
      5. swap-sqr42.0%

        \[\leadsto \sqrt{\color{blue}{\left(\left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right) \cdot \left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}} \]
    5. Applied egg-rr34.3%

      \[\leadsto \color{blue}{\sqrt{{\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)}^{2} \cdot \frac{{d}^{2}}{h \cdot \ell}}} \]
    6. Simplified36.8%

      \[\leadsto \color{blue}{\sqrt{{\left(\mathsf{fma}\left(h, \frac{-0.5}{\frac{\ell}{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}}, 1\right)\right)}^{2} \cdot \frac{{d}^{2}}{h \cdot \ell}}} \]
    7. Taylor expanded in d around -inf 58.4%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    8. Step-by-step derivation
      1. mul-1-neg58.4%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. *-commutative58.4%

        \[\leadsto -\color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      3. distribute-rgt-neg-in58.4%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(-d\right)} \]
      4. associate-/r*58.7%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(-d\right) \]
      5. unpow1/258.7%

        \[\leadsto \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \cdot \left(-d\right) \]
      6. associate-/l/58.4%

        \[\leadsto {\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{0.5} \cdot \left(-d\right) \]
      7. rem-exp-log55.4%

        \[\leadsto {\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{0.5} \cdot \left(-d\right) \]
      8. exp-neg55.4%

        \[\leadsto {\color{blue}{\left(e^{-\log \left(\ell \cdot h\right)}\right)}}^{0.5} \cdot \left(-d\right) \]
      9. exp-prod55.4%

        \[\leadsto \color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}} \cdot \left(-d\right) \]
      10. distribute-lft-neg-out55.4%

        \[\leadsto e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}} \cdot \left(-d\right) \]
      11. distribute-rgt-neg-in55.4%

        \[\leadsto e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}} \cdot \left(-d\right) \]
      12. metadata-eval55.4%

        \[\leadsto e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}} \cdot \left(-d\right) \]
      13. exp-to-pow58.5%

        \[\leadsto \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \cdot \left(-d\right) \]
    9. Simplified58.5%

      \[\leadsto \color{blue}{{\left(\ell \cdot h\right)}^{-0.5} \cdot \left(-d\right)} \]

    if -1.35999999999999993e-142 < d

    1. Initial program 62.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified61.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 34.7%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*35.2%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified35.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification43.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.36 \cdot 10^{-142}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 25.9% accurate, 3.1× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ d \cdot \sqrt{\frac{1}{h \cdot \ell}} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (* d (sqrt (/ 1.0 (* h l)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d * sqrt((1.0 / (h * l)));
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d * sqrt((1.0d0 / (h * l)))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d * Math.sqrt((1.0 / (h * l)));
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d * math.sqrt((1.0 / (h * l)))
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d * sqrt(Float64(1.0 / Float64(h * l))))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d * sqrt((1.0 / (h * l)));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
d \cdot \sqrt{\frac{1}{h \cdot \ell}}
\end{array}
Derivation
  1. Initial program 67.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. Simplified67.2%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in d around inf 24.5%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  5. Final simplification24.5%

    \[\leadsto d \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
  6. Add Preprocessing

Alternative 21: 26.1% accurate, 3.1× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (* d (sqrt (/ (/ 1.0 h) l))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d * sqrt(((1.0 / h) / l));
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d * sqrt(((1.0d0 / h) / l))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d * Math.sqrt(((1.0 / h) / l));
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d * math.sqrt(((1.0 / h) / l))
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d * sqrt(Float64(Float64(1.0 / h) / l)))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d * sqrt(((1.0 / h) / l));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}
\end{array}
Derivation
  1. Initial program 67.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. Simplified67.2%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in d around inf 24.5%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  5. Step-by-step derivation
    1. associate-/r*24.9%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
  6. Simplified24.9%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  7. Final simplification24.9%

    \[\leadsto d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}} \]
  8. Add Preprocessing

Alternative 22: 25.7% accurate, 3.1× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ d \cdot {\left(h \cdot \ell\right)}^{-0.5} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (* d (pow (* h l) -0.5)))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d * pow((h * l), -0.5);
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d * ((h * l) ** (-0.5d0))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d * Math.pow((h * l), -0.5);
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d * math.pow((h * l), -0.5)
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d * (Float64(h * l) ^ -0.5))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d * ((h * l) ^ -0.5);
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
d \cdot {\left(h \cdot \ell\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 67.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. Simplified67.2%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. expm1-log1p-u66.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}\right) \]
    2. expm1-udef66.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} - 1\right)}\right) \]
    3. *-commutative66.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{h}{\ell} \cdot {\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2}}\right)} - 1\right)\right) \]
    4. frac-times66.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{D \cdot M}{2 \cdot d}\right)}}^{2}\right)} - 1\right)\right) \]
    5. *-commutative66.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2}\right)} - 1\right)\right) \]
    6. frac-times66.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2}\right)} - 1\right)\right) \]
    7. div-inv66.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(M \cdot \frac{1}{2}\right)} \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
    8. metadata-eval66.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot \color{blue}{0.5}\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)\right) \]
  5. Applied egg-rr66.0%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)} - 1\right)}\right) \]
  6. Step-by-step derivation
    1. expm1-def66.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)}\right) \]
    2. expm1-log1p66.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)}\right) \]
    3. associate-*l/68.3%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\frac{h \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}}\right) \]
    4. *-commutative68.3%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{\color{blue}{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}}{\ell}\right) \]
    5. associate-*l/68.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell} \cdot h\right)}\right) \]
    6. *-commutative68.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)}\right) \]
    7. associate-*r/69.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\frac{\left(M \cdot 0.5\right) \cdot D}{d}\right)}}^{2}}{\ell}\right)\right) \]
    8. associate-*l*69.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{M \cdot \left(0.5 \cdot D\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
    9. *-commutative69.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{M \cdot \color{blue}{\left(D \cdot 0.5\right)}}{d}\right)}^{2}}{\ell}\right)\right) \]
    10. *-commutative69.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{\left(D \cdot 0.5\right) \cdot M}}{d}\right)}^{2}}{\ell}\right)\right) \]
    11. associate-*r/69.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(\left(D \cdot 0.5\right) \cdot \frac{M}{d}\right)}}^{2}}{\ell}\right)\right) \]
    12. associate-*l*69.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\color{blue}{\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)}}^{2}}{\ell}\right)\right) \]
    13. associate-*r/69.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{0.5 \cdot M}{d}}\right)}^{2}}{\ell}\right)\right) \]
    14. *-commutative69.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \frac{\color{blue}{M \cdot 0.5}}{d}\right)}^{2}}{\ell}\right)\right) \]
    15. associate-/l*69.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \color{blue}{\frac{M}{\frac{d}{0.5}}}\right)}^{2}}{\ell}\right)\right) \]
  7. Simplified69.5%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(h \cdot \frac{{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}^{2}}{\ell}\right)}\right) \]
  8. Taylor expanded in d around inf 24.5%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  9. Step-by-step derivation
    1. associate-/r*24.9%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    2. unpow1/224.9%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{0.5}} \]
    3. associate-/l/24.5%

      \[\leadsto d \cdot {\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{0.5} \]
    4. rem-exp-log23.5%

      \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{0.5} \]
    5. exp-neg23.5%

      \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(\ell \cdot h\right)}\right)}}^{0.5} \]
    6. exp-prod23.1%

      \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}} \]
    7. distribute-lft-neg-out23.1%

      \[\leadsto d \cdot e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}} \]
    8. distribute-rgt-neg-in23.1%

      \[\leadsto d \cdot e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}} \]
    9. metadata-eval23.1%

      \[\leadsto d \cdot e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}} \]
    10. exp-to-pow24.2%

      \[\leadsto d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
  10. Simplified24.2%

    \[\leadsto \color{blue}{d \cdot {\left(\ell \cdot h\right)}^{-0.5}} \]
  11. Final simplification24.2%

    \[\leadsto d \cdot {\left(h \cdot \ell\right)}^{-0.5} \]
  12. Add Preprocessing

Alternative 23: 25.7% accurate, 3.2× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \frac{d}{\sqrt{h \cdot \ell}} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (/ d (sqrt (* h l))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d / sqrt((h * l));
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d / sqrt((h * l))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d / Math.sqrt((h * l));
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d / math.sqrt((h * l))
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d / sqrt(Float64(h * l)))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d / sqrt((h * l));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\frac{d}{\sqrt{h \cdot \ell}}
\end{array}
Derivation
  1. Initial program 67.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. Simplified67.2%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. sub-neg67.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \color{blue}{\left(1 + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} \]
    2. distribute-rgt-in56.8%

      \[\leadsto \color{blue}{1 \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)} \]
    3. *-un-lft-identity56.8%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
    4. sqrt-div27.6%

      \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}} + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
    5. sqrt-div29.2%

      \[\leadsto \frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
    6. frac-times29.3%

      \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}} + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
    7. add-sqr-sqrt29.3%

      \[\leadsto \frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} + \left(-0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
  5. Applied egg-rr34.1%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} + \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
  6. Step-by-step derivation
    1. distribute-rgt1-in38.4%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right) + 1\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    2. +-commutative38.4%

      \[\leadsto \color{blue}{\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    3. associate-*r*38.4%

      \[\leadsto \left(1 + \color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    4. *-commutative38.4%

      \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\color{blue}{\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    5. /-rgt-identity38.4%

      \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{D}{d} \cdot \color{blue}{\frac{M \cdot 0.5}{1}}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    6. associate-/l*38.4%

      \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{D}{d} \cdot \color{blue}{\frac{M}{\frac{1}{0.5}}}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. metadata-eval38.4%

      \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(\frac{D}{d} \cdot \frac{M}{\color{blue}{2}}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    8. times-frac39.5%

      \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\color{blue}{\left(\frac{D \cdot M}{d \cdot 2}\right)}}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    9. associate-*r/39.1%

      \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)}}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    10. *-commutative39.1%

      \[\leadsto \left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M}{\color{blue}{2 \cdot d}}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
  7. Simplified39.1%

    \[\leadsto \color{blue}{\left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
  8. Step-by-step derivation
    1. associate-*r/41.0%

      \[\leadsto \color{blue}{\frac{\left(1 + \left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    2. +-commutative41.0%

      \[\leadsto \frac{\color{blue}{\left(\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2} + 1\right)} \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    3. *-commutative41.0%

      \[\leadsto \frac{\left(\color{blue}{{\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right)} + 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    4. fma-def41.0%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    5. associate-*r/41.4%

      \[\leadsto \frac{\mathsf{fma}\left({\color{blue}{\left(\frac{D \cdot M}{2 \cdot d}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    6. *-commutative41.4%

      \[\leadsto \frac{\mathsf{fma}\left({\left(\frac{D \cdot M}{\color{blue}{d \cdot 2}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. metadata-eval41.4%

      \[\leadsto \frac{\mathsf{fma}\left({\left(\frac{D \cdot M}{d \cdot \color{blue}{\frac{1}{0.5}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    8. div-inv41.4%

      \[\leadsto \frac{\mathsf{fma}\left({\left(\frac{D \cdot M}{\color{blue}{\frac{d}{0.5}}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    9. associate-*r/41.0%

      \[\leadsto \frac{\mathsf{fma}\left({\color{blue}{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right)}}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    10. associate-/r/41.0%

      \[\leadsto \frac{\mathsf{fma}\left({\left(D \cdot \color{blue}{\left(\frac{M}{d} \cdot 0.5\right)}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
    11. sqrt-unprod34.7%

      \[\leadsto \frac{\mathsf{fma}\left({\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\color{blue}{\sqrt{h \cdot \ell}}} \]
    12. *-commutative34.7%

      \[\leadsto \frac{\mathsf{fma}\left({\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{\color{blue}{\ell \cdot h}}} \]
  9. Applied egg-rr34.7%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot d}{\sqrt{\ell \cdot h}}} \]
  10. Taylor expanded in D around 0 24.1%

    \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell \cdot h}} \]
  11. Final simplification24.1%

    \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
  12. Add Preprocessing

Reproduce

?
herbie shell --seed 2024010 
(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)))))