Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.6% → 83.0%
Time: 25.5s
Alternatives: 17
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 17 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.6% 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: 83.0% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -1.5e118

    1. Initial program 45.1%

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

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

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

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

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

    if -1.5e118 < h < -4.999999999999985e-310

    1. Initial program 57.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(d \cdot \left(-\color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}}\right)\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. distribute-lft-neg-out76.6%

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

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

        \[\leadsto \left(d \cdot \left(-e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}}\right)\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      12. exp-to-pow79.3%

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

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

    if -4.999999999999985e-310 < h

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 81.6% accurate, 0.8× speedup?

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

\mathbf{elif}\;\ell \leq -1 \cdot 10^{-311}:\\
\;\;\;\;d \cdot \left(\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(t\_0 + -1\right)\right)\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.75000000000000011e248 < l < -9.99999999999948e-312

    1. Initial program 53.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. Simplified52.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999948e-312 < l

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 81.7% accurate, 1.0× speedup?

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

\mathbf{elif}\;h \leq -1.25 \cdot 10^{+35}:\\
\;\;\;\;d \cdot \left(\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(t\_1 + -1\right)\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if h < -2.94999999999999989e273

    1. Initial program 66.8%

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

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

    if -2.94999999999999989e273 < h < -1.25000000000000005e35

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.25000000000000005e35 < h < -4.999999999999985e-310

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(d \cdot \left(-\color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}}\right)\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. distribute-lft-neg-out79.8%

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

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

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

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

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

    if -4.999999999999985e-310 < h

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 81.7% accurate, 1.0× speedup?

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

\mathbf{elif}\;h \leq -6.4 \cdot 10^{+35}:\\
\;\;\;\;d \cdot \left(\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(t\_1 + -1\right)\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if h < -2.5999999999999998e274

    1. Initial program 66.8%

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

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

    if -2.5999999999999998e274 < h < -6.39999999999999965e35

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.39999999999999965e35 < h < -4.999999999999985e-310

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(d \cdot \left(-\color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}}\right)\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. distribute-lft-neg-out79.8%

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

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

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

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

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

    if -4.999999999999985e-310 < h

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 81.3% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -1.52e274

    1. Initial program 66.8%

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

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

    if -1.52e274 < h < -4.999999999999985e-310

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 78.1% accurate, 1.0× speedup?

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

\mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+49}:\\
\;\;\;\;d \cdot \left({\left(h \cdot \ell\right)}^{-0.5} \cdot \left(1 + -0.5 \cdot \frac{h \cdot {\left(M \cdot \frac{0.5}{\frac{d}{D\_m}}\right)}^{2}}{\ell}\right)\right)\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999909e-308 < l < 1.29999999999999994e49

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.29999999999999994e49 < l

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 77.9% accurate, 1.0× speedup?

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

\mathbf{elif}\;\ell \leq 4.8 \cdot 10^{+16}:\\
\;\;\;\;d \cdot \left({\left(h \cdot \ell\right)}^{-0.5} \cdot \left(1 + -0.5 \cdot \frac{h \cdot {\left(M \cdot \frac{0.5}{\frac{d}{D\_m}}\right)}^{2}}{\ell}\right)\right)\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999909e-308 < l < 4.8e16

    1. Initial program 68.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.8e16 < l

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

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

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

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

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

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

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

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

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

Alternative 8: 81.6% accurate, 1.0× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999948e-312 < l

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 65.4% accurate, 1.4× speedup?

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

\mathbf{elif}\;\ell \leq -4.7 \cdot 10^{-300}:\\
\;\;\;\;t\_0 \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. associate-*l*0.0%

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

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

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

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

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

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

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

    if -1.15e-75 < l < -4.7e-300

    1. Initial program 64.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.7e-300 < l

    1. Initial program 63.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 75.4% accurate, 1.4× speedup?

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

\mathbf{else}:\\
\;\;\;\;d \cdot \left(\left(1 - t\_0\right) \cdot t\_1\right)\\


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999909e-308 < l

    1. Initial program 64.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 59.1% accurate, 1.4× speedup?

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

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


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

    1. Initial program 54.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. Simplified53.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. associate-*l*0.0%

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

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

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

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

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

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

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

    if -4.7e-300 < l

    1. Initial program 63.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 59.2% accurate, 2.5× speedup?

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

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


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

    1. Initial program 54.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. Simplified53.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. associate-*l*0.0%

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

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

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

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

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

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

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

    if -4.7e-300 < l

    1. Initial program 63.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 42.6% accurate, 2.9× speedup?

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

\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\


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

    1. Initial program 51.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. Simplified50.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. associate-*l*0.0%

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

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

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

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

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

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

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

    if -4.8e-229 < l

    1. Initial program 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 42.5% accurate, 3.0× speedup?

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

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


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

    1. Initial program 51.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. Simplified50.5%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{\frac{M \cdot D}{2}}{d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. div-inv54.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(M \cdot D\right) \cdot \frac{1}{2}}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      10. *-commutative54.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(D \cdot M\right)} \cdot \frac{1}{2}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      11. associate-*r*54.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot \left(M \cdot \frac{1}{2}\right)}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      12. div-inv54.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{D \cdot \color{blue}{\frac{M}{2}}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      13. associate-*r/54.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{\frac{M}{2}}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      14. associate-/l/54.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \color{blue}{\frac{M}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      15. *-un-lft-identity54.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \frac{\color{blue}{1 \cdot M}}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      16. *-commutative54.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \frac{1 \cdot M}{\color{blue}{2 \cdot d}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      17. times-frac54.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \color{blue}{\left(\frac{1}{2} \cdot \frac{M}{d}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      18. metadata-eval54.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \left(\color{blue}{0.5} \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr54.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Taylor expanded in D around 0 54.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(0.5 \cdot \left(\frac{D \cdot M}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    7. Step-by-step derivation
      1. associate-*r*54.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\left(0.5 \cdot \frac{D \cdot M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      2. associate-/l*54.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(0.5 \cdot \color{blue}{\left(D \cdot \frac{M}{d}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. associate-*r*54.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\left(0.5 \cdot D\right) \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. *-commutative54.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\color{blue}{\left(D \cdot 0.5\right)} \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. associate-*r*54.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. associate-/l*54.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \color{blue}{\frac{0.5 \cdot M}{d}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-*l*54.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{0.5 \cdot M}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
      8. *-commutative54.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \color{blue}{\left(\sqrt{\frac{h}{\ell}} \cdot \frac{0.5 \cdot M}{d}\right)}\right)}^{2}\right) \]
      9. *-commutative54.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\sqrt{\frac{h}{\ell}} \cdot \frac{\color{blue}{M \cdot 0.5}}{d}\right)\right)}^{2}\right) \]
      10. associate-/l*54.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\sqrt{\frac{h}{\ell}} \cdot \color{blue}{\left(M \cdot \frac{0.5}{d}\right)}\right)\right)}^{2}\right) \]
    8. Simplified54.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\sqrt{\frac{h}{\ell}} \cdot \left(M \cdot \frac{0.5}{d}\right)\right)\right)}}^{2}\right) \]
    9. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    10. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      2. rem-exp-log0.0%

        \[\leadsto \sqrt{\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. exp-neg0.0%

        \[\leadsto \sqrt{\color{blue}{e^{-\log \left(h \cdot \ell\right)}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      4. unpow1/20.0%

        \[\leadsto \color{blue}{{\left(e^{-\log \left(h \cdot \ell\right)}\right)}^{0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      5. exp-prod0.0%

        \[\leadsto \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      6. distribute-lft-neg-out0.0%

        \[\leadsto e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      7. distribute-rgt-neg-in0.0%

        \[\leadsto e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      8. metadata-eval0.0%

        \[\leadsto e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      9. exp-to-pow0.0%

        \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      10. *-commutative0.0%

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      11. unpow20.0%

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      12. rem-square-sqrt47.4%

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      13. mul-1-neg47.4%

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \color{blue}{\left(-d\right)} \]
    11. Simplified47.4%

      \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot \left(-d\right)} \]

    if -4.59999999999999992e-229 < l

    1. Initial program 65.6%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified65.2%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow265.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow166.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. frac-times67.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{\left(\frac{2}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. associate-/r*67.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{\frac{M \cdot D}{2}}{d}\right)}}^{\left(\frac{2}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. metadata-eval67.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{\frac{M \cdot D}{2}}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. pow167.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{\frac{M \cdot D}{2}}{d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. div-inv67.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(M \cdot D\right) \cdot \frac{1}{2}}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      10. *-commutative67.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(D \cdot M\right)} \cdot \frac{1}{2}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      11. associate-*r*67.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot \left(M \cdot \frac{1}{2}\right)}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      12. div-inv67.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{D \cdot \color{blue}{\frac{M}{2}}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      13. associate-*r/67.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{\frac{M}{2}}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      14. associate-/l/67.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \color{blue}{\frac{M}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      15. *-un-lft-identity67.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \frac{\color{blue}{1 \cdot M}}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      16. *-commutative67.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \frac{1 \cdot M}{\color{blue}{2 \cdot d}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      17. times-frac67.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \color{blue}{\left(\frac{1}{2} \cdot \frac{M}{d}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      18. metadata-eval67.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \left(\color{blue}{0.5} \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr67.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Taylor expanded in d around inf 41.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. *-commutative41.8%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*42.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    8. Simplified42.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification44.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.6 \cdot 10^{-229}:\\ \;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 26.7% accurate, 3.1× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m) :precision binary64 (* d (sqrt (/ (/ 1.0 l) h))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	return d * sqrt(((1.0 / l) / h));
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    code = d * sqrt(((1.0d0 / l) / h))
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	return d * Math.sqrt(((1.0 / l) / h));
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	return d * math.sqrt(((1.0 / l) / h))
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	return Float64(d * sqrt(Float64(Float64(1.0 / l) / h)))
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp = code(d, h, l, M, D_m)
	tmp = d * sqrt(((1.0 / l) / h));
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}
\end{array}
Derivation
  1. Initial program 58.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. Simplified58.1%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. add-sqr-sqrt58.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
    2. pow258.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
    3. sqrt-prod58.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
    4. sqrt-pow160.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. frac-times61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{\left(\frac{2}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    6. associate-/r*61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{\frac{M \cdot D}{2}}{d}\right)}}^{\left(\frac{2}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    7. metadata-eval61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{\frac{M \cdot D}{2}}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    8. pow161.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{\frac{M \cdot D}{2}}{d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    9. div-inv61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(M \cdot D\right) \cdot \frac{1}{2}}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    10. *-commutative61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(D \cdot M\right)} \cdot \frac{1}{2}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    11. associate-*r*61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot \left(M \cdot \frac{1}{2}\right)}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    12. div-inv61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{D \cdot \color{blue}{\frac{M}{2}}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    13. associate-*r/61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{\frac{M}{2}}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    14. associate-/l/61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \color{blue}{\frac{M}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    15. *-un-lft-identity61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \frac{\color{blue}{1 \cdot M}}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    16. *-commutative61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \frac{1 \cdot M}{\color{blue}{2 \cdot d}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    17. times-frac61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \color{blue}{\left(\frac{1}{2} \cdot \frac{M}{d}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    18. metadata-eval61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \left(\color{blue}{0.5} \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
  5. Applied egg-rr61.5%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
  6. Taylor expanded in d around inf 25.2%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  7. Step-by-step derivation
    1. *-commutative25.2%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    2. associate-/r*25.3%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
  8. Simplified25.3%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
  9. Add Preprocessing

Alternative 16: 26.6% accurate, 3.1× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ d \cdot \sqrt{\frac{1}{h \cdot \ell}} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m) :precision binary64 (* d (sqrt (/ 1.0 (* h l)))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	return d * sqrt((1.0 / (h * l)));
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    code = d * sqrt((1.0d0 / (h * l)))
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	return d * Math.sqrt((1.0 / (h * l)));
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	return d * math.sqrt((1.0 / (h * l)))
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	return Float64(d * sqrt(Float64(1.0 / Float64(h * l))))
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp = code(d, h, l, M, D_m)
	tmp = d * sqrt((1.0 / (h * l)));
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
d \cdot \sqrt{\frac{1}{h \cdot \ell}}
\end{array}
Derivation
  1. Initial program 58.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. Simplified58.1%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. add-sqr-sqrt58.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
    2. pow258.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
    3. sqrt-prod58.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
    4. sqrt-pow160.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. frac-times61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{\left(\frac{2}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    6. associate-/r*61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{\frac{M \cdot D}{2}}{d}\right)}}^{\left(\frac{2}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    7. metadata-eval61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{\frac{M \cdot D}{2}}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    8. pow161.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{\frac{M \cdot D}{2}}{d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    9. div-inv61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(M \cdot D\right) \cdot \frac{1}{2}}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    10. *-commutative61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(D \cdot M\right)} \cdot \frac{1}{2}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    11. associate-*r*61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot \left(M \cdot \frac{1}{2}\right)}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    12. div-inv61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{D \cdot \color{blue}{\frac{M}{2}}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    13. associate-*r/61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{\frac{M}{2}}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    14. associate-/l/61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \color{blue}{\frac{M}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    15. *-un-lft-identity61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \frac{\color{blue}{1 \cdot M}}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    16. *-commutative61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \frac{1 \cdot M}{\color{blue}{2 \cdot d}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    17. times-frac61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \color{blue}{\left(\frac{1}{2} \cdot \frac{M}{d}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    18. metadata-eval61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \left(\color{blue}{0.5} \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
  5. Applied egg-rr61.5%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
  6. Taylor expanded in d around inf 25.2%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  7. Add Preprocessing

Alternative 17: 26.5% accurate, 3.1× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ d \cdot {\left(h \cdot \ell\right)}^{-0.5} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m) :precision binary64 (* d (pow (* h l) -0.5)))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	return d * pow((h * l), -0.5);
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    code = d * ((h * l) ** (-0.5d0))
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	return d * Math.pow((h * l), -0.5);
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	return d * math.pow((h * l), -0.5)
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	return Float64(d * (Float64(h * l) ^ -0.5))
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp = code(d, h, l, M, D_m)
	tmp = d * ((h * l) ^ -0.5);
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
d \cdot {\left(h \cdot \ell\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 58.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. Simplified58.1%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. add-sqr-sqrt58.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
    2. pow258.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
    3. sqrt-prod58.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
    4. sqrt-pow160.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. frac-times61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{\left(\frac{2}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    6. associate-/r*61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{\frac{M \cdot D}{2}}{d}\right)}}^{\left(\frac{2}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    7. metadata-eval61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{\frac{M \cdot D}{2}}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    8. pow161.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{\frac{M \cdot D}{2}}{d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    9. div-inv61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(M \cdot D\right) \cdot \frac{1}{2}}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    10. *-commutative61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(D \cdot M\right)} \cdot \frac{1}{2}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    11. associate-*r*61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot \left(M \cdot \frac{1}{2}\right)}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    12. div-inv61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{D \cdot \color{blue}{\frac{M}{2}}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    13. associate-*r/61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{\frac{M}{2}}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    14. associate-/l/61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \color{blue}{\frac{M}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    15. *-un-lft-identity61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \frac{\color{blue}{1 \cdot M}}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    16. *-commutative61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \frac{1 \cdot M}{\color{blue}{2 \cdot d}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    17. times-frac61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \color{blue}{\left(\frac{1}{2} \cdot \frac{M}{d}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    18. metadata-eval61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \left(\color{blue}{0.5} \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
  5. Applied egg-rr61.5%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
  6. Taylor expanded in D around 0 61.1%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(0.5 \cdot \left(\frac{D \cdot M}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
  7. Step-by-step derivation
    1. associate-*r*61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\left(0.5 \cdot \frac{D \cdot M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
    2. associate-/l*61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(0.5 \cdot \color{blue}{\left(D \cdot \frac{M}{d}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    3. associate-*r*61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\left(0.5 \cdot D\right) \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    4. *-commutative61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\color{blue}{\left(D \cdot 0.5\right)} \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. associate-*r*61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    6. associate-/l*61.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(D \cdot \color{blue}{\frac{0.5 \cdot M}{d}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    7. associate-*l*61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{0.5 \cdot M}{d} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    8. *-commutative61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \color{blue}{\left(\sqrt{\frac{h}{\ell}} \cdot \frac{0.5 \cdot M}{d}\right)}\right)}^{2}\right) \]
    9. *-commutative61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\sqrt{\frac{h}{\ell}} \cdot \frac{\color{blue}{M \cdot 0.5}}{d}\right)\right)}^{2}\right) \]
    10. associate-/l*61.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\sqrt{\frac{h}{\ell}} \cdot \color{blue}{\left(M \cdot \frac{0.5}{d}\right)}\right)\right)}^{2}\right) \]
  8. Simplified61.1%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\sqrt{\frac{h}{\ell}} \cdot \left(M \cdot \frac{0.5}{d}\right)\right)\right)}}^{2}\right) \]
  9. Taylor expanded in d around inf 25.2%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  10. Step-by-step derivation
    1. rem-exp-log24.2%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}} \]
    2. exp-neg24.2%

      \[\leadsto d \cdot \sqrt{\color{blue}{e^{-\log \left(h \cdot \ell\right)}}} \]
    3. unpow1/224.2%

      \[\leadsto d \cdot \color{blue}{{\left(e^{-\log \left(h \cdot \ell\right)}\right)}^{0.5}} \]
    4. exp-prod24.2%

      \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
    5. distribute-lft-neg-out24.2%

      \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
    6. distribute-rgt-neg-in24.2%

      \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
    7. metadata-eval24.2%

      \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
    8. exp-to-pow25.1%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  11. Simplified25.1%

    \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
  12. Add Preprocessing

Reproduce

?
herbie shell --seed 2024166 
(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)))))