Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.0% → 78.6%
Time: 27.1s
Alternatives: 24
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 24 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.0% accurate, 1.0× speedup?

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

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

Alternative 1: 78.6% accurate, 0.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -3.4000000000000001e111

    1. Initial program 59.3%

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

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

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

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

    if -3.4000000000000001e111 < l < -1.999999999999994e-310

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

      \[\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. associate-*r/74.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < l < 4e51

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

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

      \[\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. sqrt-div76.6%

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

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

      \[\leadsto \left(d \cdot \color{blue}{\frac{1}{\sqrt{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) \]
    7. Step-by-step derivation
      1. associate-*r/84.4%

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

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

    if 4e51 < l

    1. Initial program 42.5%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{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) \]
      5. add-sqr-sqrt68.9%

        \[\leadsto \frac{\color{blue}{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) \]
    5. Applied egg-rr68.9%

      \[\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 4 regimes into one program.
  4. Final simplification79.3%

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

Alternative 2: 77.2% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 70.5%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified69.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-sqrt69.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. pow269.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-prod69.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-pow171.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-times74.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*74.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-eval74.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. pow174.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-inv74.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. *-commutative74.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*74.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-inv74.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/70.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/70.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-identity70.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. *-commutative70.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-frac70.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-eval70.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-rr70.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. Step-by-step derivation
      1. pow170.6%

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

        \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}} \cdot \sqrt{\frac{d}{\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) \]
      3. sqr-pow70.5%

        \[\leadsto \left(\color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right)} \cdot \sqrt{\frac{d}{\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) \]
      4. pow270.5%

        \[\leadsto \left(\color{blue}{{\left({\left(\frac{d}{h}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right)}^{2}} \cdot \sqrt{\frac{d}{\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) \]
      5. metadata-eval70.5%

        \[\leadsto \left({\left({\left(\frac{d}{h}\right)}^{\left(\frac{\color{blue}{0.5}}{2}\right)}\right)}^{2} \cdot \sqrt{\frac{d}{\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) \]
      6. metadata-eval70.5%

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

      \[\leadsto \left(\color{blue}{{\left({\left(\frac{d}{h}\right)}^{0.25}\right)}^{2}} \cdot \sqrt{\frac{d}{\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. Step-by-step derivation
      1. frac-2neg70.5%

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

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

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

    if -1.000000000000002e-309 < d < 7.00000000000000032e-103

    1. Initial program 41.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified34.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 41.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. pow141.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}} \]
    6. Applied egg-rr58.4%

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

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

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

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

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

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

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

    if 7.00000000000000032e-103 < d

    1. Initial program 67.4%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{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) \]
      5. add-sqr-sqrt89.9%

        \[\leadsto \frac{\color{blue}{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) \]
    5. Applied egg-rr89.9%

      \[\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 simplification77.9%

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

Alternative 3: 78.0% accurate, 0.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -2.4499999999999998e111

    1. Initial program 59.3%

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

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

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

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

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

    if -2.4499999999999998e111 < l < -1.999999999999994e-310

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

      \[\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. associate-*r/74.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < l < 7.4999999999999999e51

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

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

      \[\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. sqrt-div76.6%

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

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

      \[\leadsto \left(d \cdot \color{blue}{\frac{1}{\sqrt{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) \]
    7. Step-by-step derivation
      1. associate-*r/84.4%

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

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

    if 7.4999999999999999e51 < l

    1. Initial program 42.5%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{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) \]
      5. add-sqr-sqrt68.9%

        \[\leadsto \frac{\color{blue}{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) \]
    5. Applied egg-rr68.9%

      \[\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 4 regimes into one program.
  4. Final simplification79.3%

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

Alternative 4: 79.1% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 70.5%

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

      \[\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. associate-*r/70.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < d < 2.19999999999999994e-106

    1. Initial program 41.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified34.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 41.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. pow141.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}} \]
    6. Applied egg-rr58.4%

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

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

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

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

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

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

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

    if 2.19999999999999994e-106 < d

    1. Initial program 67.4%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{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) \]
      5. add-sqr-sqrt89.9%

        \[\leadsto \frac{\color{blue}{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) \]
    5. Applied egg-rr89.9%

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

Alternative 5: 79.2% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 70.5%

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

      \[\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-2neg68.5%

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

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

      \[\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.000000000000002e-309 < d < 1.9e-106

    1. Initial program 41.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified34.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 41.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. pow141.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}} \]
    6. Applied egg-rr58.4%

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

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

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

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

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

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

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

    if 1.9e-106 < d

    1. Initial program 67.4%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{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) \]
      5. add-sqr-sqrt89.9%

        \[\leadsto \frac{\color{blue}{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) \]
    5. Applied egg-rr89.9%

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

Alternative 6: 76.8% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 79.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. Simplified78.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt78.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. pow278.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-prod78.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-pow180.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}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. frac-times83.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*83.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-eval83.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. pow183.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-inv83.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. *-commutative83.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*83.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-inv83.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/82.0%

        \[\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/82.0%

        \[\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-identity82.0%

        \[\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. *-commutative82.0%

        \[\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-frac82.0%

        \[\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-eval82.0%

        \[\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-rr82.0%

      \[\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. pow182.0%

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \color{blue}{0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{0.5 \cdot M}{d}\right)}^{2}\right)}\right) \]
      2. *-commutative79.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 \frac{0.5 \cdot M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right) \]
      3. associate-*r/79.4%

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

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

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

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

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

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

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

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

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

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

    if -3.9000000000000002e-78 < d < -1.000000000000002e-309

    1. Initial program 56.8%

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

      \[\leadsto \color{blue}{\left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \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. *-commutative0.0%

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

        \[\leadsto \left(\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\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. *-commutative0.0%

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

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

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

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

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

    if -1.000000000000002e-309 < d < 1.01999999999999998e-103

    1. Initial program 41.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified34.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 41.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. pow141.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}} \]
    6. Applied egg-rr58.4%

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

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

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

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

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

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

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

    if 1.01999999999999998e-103 < d

    1. Initial program 67.4%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{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) \]
      5. add-sqr-sqrt89.9%

        \[\leadsto \frac{\color{blue}{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) \]
    5. Applied egg-rr89.9%

      \[\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 4 regimes into one program.
  4. Final simplification78.2%

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

Alternative 7: 76.0% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -2.50000000000000004e-88

    1. Initial program 80.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. Simplified79.9%

      \[\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. associate-*r/80.9%

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

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

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

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

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

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

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

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

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

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

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

    if -2.50000000000000004e-88 < d < -1.000000000000002e-309

    1. Initial program 51.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. Simplified51.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 h around -inf 0.0%

      \[\leadsto \color{blue}{\left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \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. *-commutative0.0%

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

        \[\leadsto \left(\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\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. *-commutative0.0%

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

        \[\leadsto \left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right)\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. rem-square-sqrt70.4%

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

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

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

    if -1.000000000000002e-309 < d < 2.2999999999999999e-104

    1. Initial program 41.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified34.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 41.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. pow141.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}} \]
    6. Applied egg-rr58.4%

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

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

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

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

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

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

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

    if 2.2999999999999999e-104 < d

    1. Initial program 67.4%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{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) \]
      5. add-sqr-sqrt89.9%

        \[\leadsto \frac{\color{blue}{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) \]
    5. Applied egg-rr89.9%

      \[\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 4 regimes into one program.
  4. Final simplification77.8%

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

Alternative 8: 75.8% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.10000000000000002e-88

    1. Initial program 80.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. Simplified79.9%

      \[\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. associate-*r/80.9%

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

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

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

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

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

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

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

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

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

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

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

    if -1.10000000000000002e-88 < d < -1.000000000000002e-309

    1. Initial program 51.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. Simplified51.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 h around -inf 0.0%

      \[\leadsto \color{blue}{\left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \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. *-commutative0.0%

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

        \[\leadsto \left(\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\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. *-commutative0.0%

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

        \[\leadsto \left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right)\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. rem-square-sqrt70.4%

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

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

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

    if -1.000000000000002e-309 < d < 3.6999999999999999e-103

    1. Initial program 41.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified34.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 41.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. pow141.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}} \]
    6. Applied egg-rr58.4%

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

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

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

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

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

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

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

    if 3.6999999999999999e-103 < d

    1. Initial program 67.4%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{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) \]
      5. add-sqr-sqrt89.9%

        \[\leadsto \frac{\color{blue}{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) \]
    5. Applied egg-rr89.9%

      \[\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 4 regimes into one program.
  4. Final simplification77.5%

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

Alternative 9: 75.8% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -9.8e-89

    1. Initial program 80.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. Simplified79.9%

      \[\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 -9.8e-89 < d < -1.000000000000002e-309

    1. Initial program 51.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. Simplified51.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 h around -inf 0.0%

      \[\leadsto \color{blue}{\left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \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. *-commutative0.0%

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

        \[\leadsto \left(\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\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. *-commutative0.0%

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

        \[\leadsto \left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right)\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. rem-square-sqrt70.4%

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

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

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

    if -1.000000000000002e-309 < d < 7e-106

    1. Initial program 41.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified34.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 41.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. pow141.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}} \]
    6. Applied egg-rr58.4%

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

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

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

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

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

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

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

    if 7e-106 < d

    1. Initial program 67.4%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{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) \]
      5. add-sqr-sqrt89.9%

        \[\leadsto \frac{\color{blue}{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) \]
    5. Applied egg-rr89.9%

      \[\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 4 regimes into one program.
  4. Final simplification77.5%

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

Alternative 10: 75.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 70.5%

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

      \[\leadsto \color{blue}{\left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \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. *-commutative0.0%

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

        \[\leadsto \left(\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\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. *-commutative0.0%

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

        \[\leadsto \left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right)\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. rem-square-sqrt73.3%

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

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

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

    if -1.000000000000002e-309 < d < 2.04999999999999992e-104

    1. Initial program 41.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified34.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 41.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. pow141.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}} \]
    6. Applied egg-rr58.4%

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

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

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

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

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

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

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

    if 2.04999999999999992e-104 < d

    1. Initial program 67.4%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{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) \]
      5. add-sqr-sqrt89.9%

        \[\leadsto \frac{\color{blue}{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) \]
    5. Applied egg-rr89.9%

      \[\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 simplification75.8%

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

Alternative 11: 66.2% accurate, 1.4× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -3.3e149

    1. Initial program 75.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. Simplified75.6%

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

        \[\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. pow275.6%

        \[\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-prod75.6%

        \[\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-pow175.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}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. frac-times78.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*78.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-eval78.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. pow178.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-inv78.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. *-commutative78.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*78.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-inv78.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/78.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/78.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-identity78.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. *-commutative78.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-frac78.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-eval78.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-rr78.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. Step-by-step derivation
      1. clear-num78.5%

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\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. Taylor expanded in d around -inf 68.5%

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \cdot \left(-d\right) \]
      8. pow-sqr68.6%

        \[\leadsto \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \cdot \left(-d\right) \]
      9. rem-sqrt-square68.6%

        \[\leadsto \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \cdot \left(-d\right) \]
      10. metadata-eval68.6%

        \[\leadsto \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right| \cdot \left(-d\right) \]
      11. pow-sqr68.5%

        \[\leadsto \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right| \cdot \left(-d\right) \]
      12. fabs-sqr68.5%

        \[\leadsto \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \cdot \left(-d\right) \]
      13. pow-sqr68.6%

        \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{\left(2 \cdot -0.25\right)}} \cdot \left(-d\right) \]
      14. metadata-eval68.6%

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

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

    if -3.3e149 < d < -1.000000000000002e-309

    1. Initial program 68.7%

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

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

        \[\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.6%

        \[\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.6%

        \[\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-pow169.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}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. frac-times72.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*72.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-eval72.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. pow172.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-inv72.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. *-commutative72.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*72.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-inv72.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/67.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

      \[\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. pow167.7%

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

        \[\leadsto {\left(\color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \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} \]
      3. cancel-sign-sub-inv57.5%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \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)}\right)}^{1} \]
      4. metadata-eval57.5%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{-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} \]
      5. *-commutative57.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < d < 1e-61

    1. Initial program 51.3%

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

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

      \[\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. pow148.1%

        \[\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}} \]
    6. Applied egg-rr63.7%

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

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

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

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

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

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

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

    if 1e-61 < d

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

      \[\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. associate-*r/86.4%

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

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

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

Alternative 12: 64.2% accurate, 1.4× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -3.3e149

    1. Initial program 75.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. Simplified75.6%

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

        \[\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. pow275.6%

        \[\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-prod75.6%

        \[\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-pow175.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}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. frac-times78.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*78.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-eval78.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. pow178.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-inv78.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. *-commutative78.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*78.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-inv78.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/78.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/78.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-identity78.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. *-commutative78.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-frac78.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-eval78.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-rr78.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. Step-by-step derivation
      1. clear-num78.5%

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\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. Taylor expanded in d around -inf 68.5%

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \cdot \left(-d\right) \]
      8. pow-sqr68.6%

        \[\leadsto \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \cdot \left(-d\right) \]
      9. rem-sqrt-square68.6%

        \[\leadsto \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \cdot \left(-d\right) \]
      10. metadata-eval68.6%

        \[\leadsto \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right| \cdot \left(-d\right) \]
      11. pow-sqr68.5%

        \[\leadsto \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right| \cdot \left(-d\right) \]
      12. fabs-sqr68.5%

        \[\leadsto \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \cdot \left(-d\right) \]
      13. pow-sqr68.6%

        \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{\left(2 \cdot -0.25\right)}} \cdot \left(-d\right) \]
      14. metadata-eval68.6%

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

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

    if -3.3e149 < d < -1.000000000000002e-309

    1. Initial program 68.7%

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

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

        \[\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.6%

        \[\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.6%

        \[\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-pow169.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}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. frac-times72.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*72.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-eval72.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. pow172.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-inv72.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. *-commutative72.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*72.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-inv72.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/67.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

      \[\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. pow167.7%

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

        \[\leadsto {\left(\color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \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} \]
      3. cancel-sign-sub-inv57.5%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \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)}\right)}^{1} \]
      4. metadata-eval57.5%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{-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} \]
      5. *-commutative57.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < d < 8.50000000000000033e118

    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. Simplified59.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. Taylor expanded in d around 0 59.1%

      \[\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. pow159.1%

        \[\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}} \]
    6. Applied egg-rr68.0%

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

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

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

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

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

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

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

    if 8.50000000000000033e118 < d

    1. Initial program 49.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. Simplified49.6%

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

        \[\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. pow249.6%

        \[\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-prod49.6%

        \[\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-pow149.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-times49.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*49.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-eval49.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. pow149.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-inv49.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. *-commutative49.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*49.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-inv49.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/49.7%

        \[\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/49.7%

        \[\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-identity49.7%

        \[\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. *-commutative49.7%

        \[\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-frac49.7%

        \[\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-eval49.7%

        \[\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-rr49.7%

      \[\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 82.4%

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

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

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

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

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

        \[\leadsto {\left(d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{\left(-1 \cdot 0.5\right)}}\right)}^{1} \]
      6. *-commutative82.3%

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

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

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

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    11. Step-by-step derivation
      1. *-commutative82.3%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down90.6%

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

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

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

Alternative 13: 64.2% accurate, 1.4× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.1e150

    1. Initial program 75.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. Simplified75.6%

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

        \[\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. pow275.6%

        \[\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-prod75.6%

        \[\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-pow175.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}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. frac-times78.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*78.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-eval78.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. pow178.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-inv78.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. *-commutative78.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*78.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-inv78.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/78.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/78.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-identity78.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. *-commutative78.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-frac78.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-eval78.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-rr78.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. Step-by-step derivation
      1. clear-num78.5%

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\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. Taylor expanded in d around -inf 68.5%

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \cdot \left(-d\right) \]
      8. pow-sqr68.6%

        \[\leadsto \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \cdot \left(-d\right) \]
      9. rem-sqrt-square68.6%

        \[\leadsto \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \cdot \left(-d\right) \]
      10. metadata-eval68.6%

        \[\leadsto \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right| \cdot \left(-d\right) \]
      11. pow-sqr68.5%

        \[\leadsto \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right| \cdot \left(-d\right) \]
      12. fabs-sqr68.5%

        \[\leadsto \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \cdot \left(-d\right) \]
      13. pow-sqr68.6%

        \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{\left(2 \cdot -0.25\right)}} \cdot \left(-d\right) \]
      14. metadata-eval68.6%

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

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

    if -1.1e150 < d < -1.000000000000002e-309

    1. Initial program 68.7%

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

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

        \[\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.6%

        \[\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.6%

        \[\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-pow169.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}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. frac-times72.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*72.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-eval72.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. pow172.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-inv72.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. *-commutative72.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*72.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-inv72.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/67.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

      \[\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. pow167.7%

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

        \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}} \cdot \sqrt{\frac{d}{\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) \]
      3. sqr-pow67.6%

        \[\leadsto \left(\color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right)} \cdot \sqrt{\frac{d}{\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) \]
      4. pow267.6%

        \[\leadsto \left(\color{blue}{{\left({\left(\frac{d}{h}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right)}^{2}} \cdot \sqrt{\frac{d}{\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) \]
      5. metadata-eval67.6%

        \[\leadsto \left({\left({\left(\frac{d}{h}\right)}^{\left(\frac{\color{blue}{0.5}}{2}\right)}\right)}^{2} \cdot \sqrt{\frac{d}{\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) \]
      6. metadata-eval67.6%

        \[\leadsto \left({\left({\left(\frac{d}{h}\right)}^{\color{blue}{0.25}}\right)}^{2} \cdot \sqrt{\frac{d}{\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. Applied egg-rr67.6%

      \[\leadsto \left(\color{blue}{{\left({\left(\frac{d}{h}\right)}^{0.25}\right)}^{2}} \cdot \sqrt{\frac{d}{\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. Step-by-step derivation
      1. pow167.6%

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < d < 7.00000000000000033e118

    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. Simplified59.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. Taylor expanded in d around 0 59.1%

      \[\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. pow159.1%

        \[\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}} \]
    6. Applied egg-rr68.0%

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

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

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

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

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

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

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

    if 7.00000000000000033e118 < d

    1. Initial program 49.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. Simplified49.6%

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

        \[\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. pow249.6%

        \[\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-prod49.6%

        \[\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-pow149.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-times49.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*49.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-eval49.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. pow149.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-inv49.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. *-commutative49.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*49.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-inv49.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/49.7%

        \[\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/49.7%

        \[\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-identity49.7%

        \[\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. *-commutative49.7%

        \[\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-frac49.7%

        \[\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-eval49.7%

        \[\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-rr49.7%

      \[\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 82.4%

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

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

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

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

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

        \[\leadsto {\left(d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{\left(-1 \cdot 0.5\right)}}\right)}^{1} \]
      6. *-commutative82.3%

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

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

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

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    11. Step-by-step derivation
      1. *-commutative82.3%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down90.6%

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

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

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

Alternative 14: 64.2% accurate, 1.4× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -8.99999999999999965e149

    1. Initial program 75.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. Simplified75.6%

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

        \[\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. pow275.6%

        \[\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-prod75.6%

        \[\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-pow175.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}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. frac-times78.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*78.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-eval78.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. pow178.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-inv78.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. *-commutative78.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*78.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-inv78.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/78.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/78.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-identity78.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. *-commutative78.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-frac78.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-eval78.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-rr78.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. Step-by-step derivation
      1. clear-num78.5%

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\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. Taylor expanded in d around -inf 68.5%

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \cdot \left(-d\right) \]
      8. pow-sqr68.6%

        \[\leadsto \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \cdot \left(-d\right) \]
      9. rem-sqrt-square68.6%

        \[\leadsto \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \cdot \left(-d\right) \]
      10. metadata-eval68.6%

        \[\leadsto \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right| \cdot \left(-d\right) \]
      11. pow-sqr68.5%

        \[\leadsto \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right| \cdot \left(-d\right) \]
      12. fabs-sqr68.5%

        \[\leadsto \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \cdot \left(-d\right) \]
      13. pow-sqr68.6%

        \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{\left(2 \cdot -0.25\right)}} \cdot \left(-d\right) \]
      14. metadata-eval68.6%

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

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

    if -8.99999999999999965e149 < d < -1.000000000000002e-309

    1. Initial program 68.7%

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

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

        \[\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.6%

        \[\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.6%

        \[\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-pow169.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}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. frac-times72.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*72.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-eval72.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. pow172.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-inv72.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. *-commutative72.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*72.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-inv72.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/67.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

      \[\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. pow167.7%

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

        \[\leadsto {\left(\color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \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} \]
      3. cancel-sign-sub-inv57.5%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \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)}\right)}^{1} \]
      4. metadata-eval57.5%

        \[\leadsto {\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{-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} \]
      5. *-commutative57.5%

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

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < d < 9.00000000000000004e118

    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. Simplified59.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. Taylor expanded in d around 0 59.1%

      \[\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. pow159.1%

        \[\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}} \]
    6. Applied egg-rr68.0%

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

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

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

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

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

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

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

    if 9.00000000000000004e118 < d

    1. Initial program 49.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. Simplified49.6%

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

        \[\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. pow249.6%

        \[\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-prod49.6%

        \[\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-pow149.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-times49.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*49.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-eval49.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. pow149.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-inv49.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. *-commutative49.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*49.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-inv49.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/49.7%

        \[\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/49.7%

        \[\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-identity49.7%

        \[\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. *-commutative49.7%

        \[\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-frac49.7%

        \[\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-eval49.7%

        \[\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-rr49.7%

      \[\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 82.4%

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

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

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

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

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

        \[\leadsto {\left(d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{\left(-1 \cdot 0.5\right)}}\right)}^{1} \]
      6. *-commutative82.3%

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

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

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

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    11. Step-by-step derivation
      1. *-commutative82.3%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down90.6%

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

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

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

Alternative 15: 56.2% accurate, 1.4× speedup?

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

\mathbf{elif}\;d \leq -1.8 \cdot 10^{-274}:\\
\;\;\;\;0.125 \cdot \left(\left(\left(D\_m \cdot D\_m\right) \cdot \left(M\_m \cdot M\_m\right)\right) \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}}}{d}\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -3.6000000000000001e106

    1. Initial program 76.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified74.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-sqrt74.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. pow274.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-prod74.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-pow174.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-times78.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*78.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-eval78.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. pow178.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-inv78.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. *-commutative78.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*78.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-inv78.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/78.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/78.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-identity78.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. *-commutative78.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-frac78.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-eval78.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-rr78.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. Step-by-step derivation
      1. clear-num78.6%

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\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. Taylor expanded in d around -inf 66.2%

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \cdot \left(-d\right) \]
      8. pow-sqr66.2%

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

        \[\leadsto \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \cdot \left(-d\right) \]
      10. metadata-eval66.2%

        \[\leadsto \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right| \cdot \left(-d\right) \]
      11. pow-sqr66.1%

        \[\leadsto \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right| \cdot \left(-d\right) \]
      12. fabs-sqr66.1%

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

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

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

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

    if -3.6000000000000001e106 < d < -1.79999999999999991e-274

    1. Initial program 68.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.79999999999999991e-274 < d < 6.5e118

    1. Initial program 62.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. Simplified59.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. Taylor expanded in d around 0 56.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. pow156.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}} \]
    6. Applied egg-rr64.4%

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

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

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

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

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

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

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

    if 6.5e118 < d

    1. Initial program 49.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. Simplified49.6%

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

        \[\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. pow249.6%

        \[\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-prod49.6%

        \[\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-pow149.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-times49.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*49.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-eval49.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. pow149.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-inv49.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. *-commutative49.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*49.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-inv49.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/49.7%

        \[\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/49.7%

        \[\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-identity49.7%

        \[\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. *-commutative49.7%

        \[\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-frac49.7%

        \[\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-eval49.7%

        \[\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-rr49.7%

      \[\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 82.4%

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

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

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

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

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

        \[\leadsto {\left(d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{\left(-1 \cdot 0.5\right)}}\right)}^{1} \]
      6. *-commutative82.3%

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

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

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

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    11. Step-by-step derivation
      1. *-commutative82.3%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down90.6%

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

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

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

Alternative 16: 55.0% accurate, 1.4× speedup?

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

\mathbf{elif}\;d \leq -1.8 \cdot 10^{-274}:\\
\;\;\;\;0.125 \cdot \left(\left(\left(D\_m \cdot D\_m\right) \cdot \left(M\_m \cdot M\_m\right)\right) \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}}}{d}\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -5.00000000000000025e95

    1. Initial program 76.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified74.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-sqrt74.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. pow274.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-prod74.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-pow174.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-times78.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*78.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-eval78.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. pow178.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-inv78.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. *-commutative78.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*78.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-inv78.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/78.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/78.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-identity78.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. *-commutative78.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-frac78.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-eval78.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-rr78.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. Step-by-step derivation
      1. clear-num78.6%

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\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. Taylor expanded in d around -inf 66.2%

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \cdot \left(-d\right) \]
      8. pow-sqr66.2%

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

        \[\leadsto \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \cdot \left(-d\right) \]
      10. metadata-eval66.2%

        \[\leadsto \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right| \cdot \left(-d\right) \]
      11. pow-sqr66.1%

        \[\leadsto \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right| \cdot \left(-d\right) \]
      12. fabs-sqr66.1%

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

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

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

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

    if -5.00000000000000025e95 < d < -1.79999999999999991e-274

    1. Initial program 68.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.79999999999999991e-274 < d < 7.99999999999999973e118

    1. Initial program 62.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. Simplified59.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. Taylor expanded in d around 0 56.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. sqrt-div57.3%

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

        \[\leadsto \left(d \cdot \frac{\color{blue}{1}}{\sqrt{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) \]
    6. Applied egg-rr57.3%

      \[\leadsto \left(d \cdot \color{blue}{\frac{1}{\sqrt{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) \]
    7. Step-by-step derivation
      1. un-div-inv57.3%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{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) \]
    8. Applied egg-rr57.3%

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

    if 7.99999999999999973e118 < d

    1. Initial program 49.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. Simplified49.6%

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

        \[\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. pow249.6%

        \[\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-prod49.6%

        \[\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-pow149.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-times49.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*49.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-eval49.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. pow149.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-inv49.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. *-commutative49.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*49.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-inv49.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/49.7%

        \[\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/49.7%

        \[\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-identity49.7%

        \[\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. *-commutative49.7%

        \[\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-frac49.7%

        \[\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-eval49.7%

        \[\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-rr49.7%

      \[\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 82.4%

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

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

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

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

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

        \[\leadsto {\left(d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{\left(-1 \cdot 0.5\right)}}\right)}^{1} \]
      6. *-commutative82.3%

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

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

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

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    11. Step-by-step derivation
      1. *-commutative82.3%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down90.6%

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

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

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

Alternative 17: 72.3% accurate, 1.4× speedup?

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

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

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


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

    1. Initial program 70.5%

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

      \[\leadsto \color{blue}{\left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \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. *-commutative0.0%

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

        \[\leadsto \left(\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\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. *-commutative0.0%

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

        \[\leadsto \left(\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right)\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. rem-square-sqrt73.3%

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

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

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

    if -1.000000000000002e-309 < d < 3.8000000000000002e-65

    1. Initial program 51.3%

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

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

      \[\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. pow148.1%

        \[\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}} \]
    6. Applied egg-rr63.7%

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

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

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

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

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

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

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

    if 3.8000000000000002e-65 < d

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

      \[\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. associate-*r/86.4%

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

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

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

Alternative 18: 45.6% accurate, 1.5× speedup?

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

\mathbf{elif}\;d \leq -1.8 \cdot 10^{-274}:\\
\;\;\;\;0.125 \cdot \left(\left(\left(D\_m \cdot D\_m\right) \cdot \left(M\_m \cdot M\_m\right)\right) \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}}}{d}\right)\\

\mathbf{elif}\;d \leq 1.22 \cdot 10^{-223}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -5.00000000000000025e95 or -1.79999999999999991e-274 < d < 1.21999999999999998e-223

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

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

        \[\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. pow259.6%

        \[\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-prod59.6%

        \[\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-pow161.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-times63.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*63.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-eval63.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. pow163.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-inv63.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. *-commutative63.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*63.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-inv63.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/59.7%

        \[\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/59.7%

        \[\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-identity59.7%

        \[\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. *-commutative59.7%

        \[\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-frac59.7%

        \[\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-eval59.7%

        \[\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-rr59.7%

      \[\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. clear-num59.7%

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\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. Taylor expanded in d around -inf 50.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \cdot \left(-d\right) \]
      10. metadata-eval50.9%

        \[\leadsto \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right| \cdot \left(-d\right) \]
      11. pow-sqr50.8%

        \[\leadsto \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right| \cdot \left(-d\right) \]
      12. fabs-sqr50.8%

        \[\leadsto \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \cdot \left(-d\right) \]
      13. pow-sqr50.9%

        \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{\left(2 \cdot -0.25\right)}} \cdot \left(-d\right) \]
      14. metadata-eval50.9%

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

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

    if -5.00000000000000025e95 < d < -1.79999999999999991e-274

    1. Initial program 68.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.21999999999999998e-223 < d

    1. Initial program 63.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. Simplified61.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-sqrt61.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. pow261.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-prod61.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-pow161.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-times63.9%

        \[\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*63.9%

        \[\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-eval63.9%

        \[\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. pow163.9%

        \[\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-inv63.9%

        \[\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. *-commutative63.9%

        \[\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*63.9%

        \[\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-inv63.9%

        \[\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.0%

        \[\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.0%

        \[\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.0%

        \[\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.0%

        \[\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.0%

        \[\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.0%

        \[\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.0%

      \[\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 61.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5 \cdot 10^{+95}:\\ \;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\ \mathbf{elif}\;d \leq -1.8 \cdot 10^{-274}:\\ \;\;\;\;0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}}}{d}\right)\\ \mathbf{elif}\;d \leq 1.22 \cdot 10^{-223}:\\ \;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 46.7% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 68.2%

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

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt67.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. pow267.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-prod67.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-pow169.9%

        \[\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-times71.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*71.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-eval71.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. pow171.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-inv71.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. *-commutative71.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*71.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-inv71.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/67.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/67.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-identity67.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. *-commutative67.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-frac67.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-eval67.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-rr67.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. Step-by-step derivation
      1. clear-num66.4%

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\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. Taylor expanded in d around -inf 41.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right| \cdot \left(-d\right) \]
      11. pow-sqr41.1%

        \[\leadsto \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right| \cdot \left(-d\right) \]
      12. fabs-sqr41.1%

        \[\leadsto \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \cdot \left(-d\right) \]
      13. pow-sqr41.1%

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

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

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

    if -1.0500000000000001e-226 < l < -1.999999999999994e-310

    1. Initial program 82.2%

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

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

        \[\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. pow277.6%

        \[\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-prod77.6%

        \[\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-pow177.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}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. frac-times86.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*86.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-eval86.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. pow186.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-inv86.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. *-commutative86.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*86.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-inv86.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/86.7%

        \[\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/86.7%

        \[\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-identity86.7%

        \[\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. *-commutative86.7%

        \[\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-frac86.7%

        \[\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-eval86.7%

        \[\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-rr86.7%

      \[\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 38.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{{\left(\frac{1}{h \cdot \ell}\right)}^{1.5}}} \]
    10. Simplified42.5%

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

    if -1.999999999999994e-310 < l

    1. Initial program 58.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. 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-pow156.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-times58.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*58.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-eval58.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. pow158.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-inv58.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. *-commutative58.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*58.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-inv58.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/57.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

      \[\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 52.4%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}^{1}} \]
    9. Step-by-step derivation
      1. unpow153.1%

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

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

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

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

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

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

Alternative 20: 46.3% accurate, 1.6× speedup?

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

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


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

    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. Simplified63.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt63.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. pow263.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-prod63.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 \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow165.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-times68.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 \cdot D}{2 \cdot d}\right)}}^{\left(\frac{2}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. associate-/r*68.4%

        \[\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.4%

        \[\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.4%

        \[\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.4%

        \[\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.4%

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

        \[\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.4%

        \[\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.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/64.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-identity64.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. *-commutative64.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-frac64.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-eval64.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-rr64.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. Step-by-step derivation
      1. clear-num64.0%

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\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. Taylor expanded in d around -inf 34.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \cdot \left(-d\right) \]
      10. metadata-eval34.2%

        \[\leadsto \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right| \cdot \left(-d\right) \]
      11. pow-sqr34.1%

        \[\leadsto \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right| \cdot \left(-d\right) \]
      12. fabs-sqr34.1%

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

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

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

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

    if 1.21999999999999998e-223 < d

    1. Initial program 63.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. Simplified61.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-sqrt61.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. pow261.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-prod61.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-pow161.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-times63.9%

        \[\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*63.9%

        \[\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-eval63.9%

        \[\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. pow163.9%

        \[\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-inv63.9%

        \[\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. *-commutative63.9%

        \[\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*63.9%

        \[\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-inv63.9%

        \[\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.0%

        \[\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.0%

        \[\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.0%

        \[\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.0%

        \[\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.0%

        \[\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.0%

        \[\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.0%

      \[\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 61.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 1.22 \cdot 10^{-223}:\\ \;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 21: 42.4% accurate, 2.9× speedup?

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

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


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

    1. Initial program 68.2%

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

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt67.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. pow267.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-prod67.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-pow169.9%

        \[\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-times71.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*71.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-eval71.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. pow171.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-inv71.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. *-commutative71.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*71.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-inv71.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/67.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/67.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-identity67.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. *-commutative67.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-frac67.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-eval67.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-rr67.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. Step-by-step derivation
      1. clear-num66.4%

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\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. Taylor expanded in d around -inf 41.1%

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \cdot \left(-d\right) \]
      9. rem-sqrt-square41.1%

        \[\leadsto \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \cdot \left(-d\right) \]
      10. metadata-eval41.1%

        \[\leadsto \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right| \cdot \left(-d\right) \]
      11. pow-sqr41.1%

        \[\leadsto \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right| \cdot \left(-d\right) \]
      12. fabs-sqr41.1%

        \[\leadsto \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \cdot \left(-d\right) \]
      13. pow-sqr41.1%

        \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{\left(2 \cdot -0.25\right)}} \cdot \left(-d\right) \]
      14. metadata-eval41.1%

        \[\leadsto {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \cdot \left(-d\right) \]
    10. Simplified41.1%

      \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot \left(-d\right)} \]

    if -6.79999999999999981e-228 < l

    1. Initial program 62.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. Simplified59.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt59.3%

        \[\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. pow259.3%

        \[\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-prod59.3%

        \[\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.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-times62.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*62.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-eval62.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. pow162.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-inv62.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. *-commutative62.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*62.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-inv62.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/62.1%

        \[\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/62.1%

        \[\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-identity62.1%

        \[\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. *-commutative62.1%

        \[\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-frac62.1%

        \[\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-eval62.1%

        \[\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-rr62.1%

      \[\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 50.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. inv-pow50.2%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. *-commutative50.2%

        \[\leadsto d \cdot \sqrt{{\color{blue}{\left(\ell \cdot h\right)}}^{-1}} \]
      3. unpow-prod-down50.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\ell}^{-1} \cdot {h}^{-1}}} \]
      4. inv-pow50.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{\ell}} \cdot {h}^{-1}} \]
      5. inv-pow50.6%

        \[\leadsto d \cdot \sqrt{\frac{1}{\ell} \cdot \color{blue}{\frac{1}{h}}} \]
    8. Applied egg-rr50.6%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{\ell} \cdot \frac{1}{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification46.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -6.8 \cdot 10^{-228}:\\ \;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 22: 42.2% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -7.2 \cdot 10^{-227}:\\ \;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l -7.2e-227)
   (* d (- (pow (* h l) -0.5)))
   (* d (sqrt (/ 1.0 (* h l))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -7.2e-227) {
		tmp = d * -pow((h * l), -0.5);
	} else {
		tmp = d * sqrt((1.0 / (h * l)));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= (-7.2d-227)) then
        tmp = d * -((h * l) ** (-0.5d0))
    else
        tmp = d * sqrt((1.0d0 / (h * l)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -7.2e-227) {
		tmp = d * -Math.pow((h * l), -0.5);
	} else {
		tmp = d * Math.sqrt((1.0 / (h * l)));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= -7.2e-227:
		tmp = d * -math.pow((h * l), -0.5)
	else:
		tmp = d * math.sqrt((1.0 / (h * l)))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -7.2e-227)
		tmp = Float64(d * Float64(-(Float64(h * l) ^ -0.5)));
	else
		tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * l))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= -7.2e-227)
		tmp = d * -((h * l) ^ -0.5);
	else
		tmp = d * sqrt((1.0 / (h * l)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -7.2e-227], N[(d * (-N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision])), $MachinePrecision], N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7.2 \cdot 10^{-227}:\\
\;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -7.1999999999999999e-227

    1. Initial program 68.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified67.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt67.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. pow267.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-prod67.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-pow169.9%

        \[\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-times71.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*71.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-eval71.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. pow171.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-inv71.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. *-commutative71.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*71.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-inv71.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/67.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/67.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-identity67.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. *-commutative67.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-frac67.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-eval67.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-rr67.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. Step-by-step derivation
      1. clear-num66.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\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. sqrt-div66.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\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. metadata-eval66.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\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. Applied egg-rr66.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\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. Taylor expanded in d around -inf 41.1%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    9. Step-by-step derivation
      1. mul-1-neg41.1%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. *-commutative41.1%

        \[\leadsto -\color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      3. associate-/r*41.1%

        \[\leadsto -\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot d \]
      4. distribute-rgt-neg-in41.1%

        \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]
      5. associate-/r*41.1%

        \[\leadsto \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \cdot \left(-d\right) \]
      6. unpow-141.1%

        \[\leadsto \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \cdot \left(-d\right) \]
      7. metadata-eval41.1%

        \[\leadsto \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \cdot \left(-d\right) \]
      8. pow-sqr41.1%

        \[\leadsto \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \cdot \left(-d\right) \]
      9. rem-sqrt-square41.1%

        \[\leadsto \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \cdot \left(-d\right) \]
      10. metadata-eval41.1%

        \[\leadsto \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right| \cdot \left(-d\right) \]
      11. pow-sqr41.1%

        \[\leadsto \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right| \cdot \left(-d\right) \]
      12. fabs-sqr41.1%

        \[\leadsto \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \cdot \left(-d\right) \]
      13. pow-sqr41.1%

        \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{\left(2 \cdot -0.25\right)}} \cdot \left(-d\right) \]
      14. metadata-eval41.1%

        \[\leadsto {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \cdot \left(-d\right) \]
    10. Simplified41.1%

      \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot \left(-d\right)} \]

    if -7.1999999999999999e-227 < l

    1. Initial program 62.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. Simplified59.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt59.3%

        \[\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. pow259.3%

        \[\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-prod59.3%

        \[\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.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-times62.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*62.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-eval62.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. pow162.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-inv62.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. *-commutative62.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*62.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-inv62.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/62.1%

        \[\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/62.1%

        \[\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-identity62.1%

        \[\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. *-commutative62.1%

        \[\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-frac62.1%

        \[\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-eval62.1%

        \[\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-rr62.1%

      \[\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 50.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification46.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7.2 \cdot 10^{-227}:\\ \;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 23: 26.3% accurate, 3.1× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ d \cdot \sqrt{\frac{1}{h \cdot \ell}} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (* d (sqrt (/ 1.0 (* h l)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d * sqrt((1.0 / (h * l)));
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d * sqrt((1.0d0 / (h * l)))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d * Math.sqrt((1.0 / (h * l)));
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d * math.sqrt((1.0 / (h * l)))
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d * sqrt(Float64(1.0 / Float64(h * l))))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d * sqrt((1.0 / (h * l)));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
d \cdot \sqrt{\frac{1}{h \cdot \ell}}
\end{array}
Derivation
  1. Initial program 64.7%

    \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  2. Simplified62.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-sqrt62.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. pow262.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-prod62.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-pow163.9%

      \[\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-times66.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*66.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-eval66.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. pow166.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-inv66.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. *-commutative66.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*66.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-inv66.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/64.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/64.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-identity64.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. *-commutative64.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-frac64.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-eval64.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-rr64.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 inf 32.5%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  7. Add Preprocessing

Alternative 24: 26.2% accurate, 3.1× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ d \cdot {\left(h \cdot \ell\right)}^{-0.5} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (* d (pow (* h l) -0.5)))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d * pow((h * l), -0.5);
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d * ((h * l) ** (-0.5d0))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d * Math.pow((h * l), -0.5);
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d * math.pow((h * l), -0.5)
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d * (Float64(h * l) ^ -0.5))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d * ((h * l) ^ -0.5);
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
d \cdot {\left(h \cdot \ell\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 64.7%

    \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  2. Simplified62.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-sqrt62.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. pow262.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-prod62.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-pow163.9%

      \[\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-times66.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*66.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-eval66.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. pow166.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-inv66.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. *-commutative66.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*66.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-inv66.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/64.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/64.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-identity64.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. *-commutative64.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-frac64.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-eval64.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-rr64.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 inf 32.5%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  7. Step-by-step derivation
    1. pow132.5%

      \[\leadsto \color{blue}{{\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{1}} \]
    2. pow1/232.5%

      \[\leadsto {\left(d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)}^{1} \]
    3. inv-pow32.5%

      \[\leadsto {\left(d \cdot {\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)}^{1} \]
    4. *-commutative32.5%

      \[\leadsto {\left(d \cdot {\left({\color{blue}{\left(\ell \cdot h\right)}}^{-1}\right)}^{0.5}\right)}^{1} \]
    5. pow-pow31.7%

      \[\leadsto {\left(d \cdot \color{blue}{{\left(\ell \cdot h\right)}^{\left(-1 \cdot 0.5\right)}}\right)}^{1} \]
    6. *-commutative31.7%

      \[\leadsto {\left(d \cdot {\color{blue}{\left(h \cdot \ell\right)}}^{\left(-1 \cdot 0.5\right)}\right)}^{1} \]
    7. metadata-eval31.7%

      \[\leadsto {\left(d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)}^{1} \]
  8. Applied egg-rr31.7%

    \[\leadsto \color{blue}{{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}^{1}} \]
  9. Step-by-step derivation
    1. unpow131.7%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
  10. Simplified31.7%

    \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
  11. Add Preprocessing

Reproduce

?
herbie shell --seed 2024148 
(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)))))