Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.8% → 80.1%
Time: 23.9s
Alternatives: 17
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 17 alternatives:

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

Initial Program: 66.8% accurate, 1.0× speedup?

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

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

Alternative 1: 80.1% accurate, 0.8× speedup?

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

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

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


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

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

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

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

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

      \[\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 -4.89999999999999985e104 < h < 1.38000000000000008e-151

    1. Initial program 72.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified72.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-sqrt72.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. pow272.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-prod72.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-pow177.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.38000000000000008e-151 < h

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

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

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

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{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) \]
      3. frac-times75.8%

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

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} \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-rr75.9%

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

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

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\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. Taylor expanded in M around 0 58.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}} \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \left(\left(\left(\frac{M}{d} \cdot \frac{M}{d}\right) \cdot \color{blue}{\left(D \cdot D\right)}\right) \cdot \frac{h}{\ell}\right)\right)\right) \]
      9. swap-sqr77.0%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 78.5% accurate, 0.8× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.1000000000000002e103 < h < 9.49999999999999925e-152

    1. Initial program 72.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. Simplified72.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-sqrt72.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. pow272.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-prod72.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-pow178.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.49999999999999925e-152 < h

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

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

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

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{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) \]
      3. frac-times75.8%

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

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} \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-rr75.9%

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

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

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\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. Taylor expanded in M around 0 58.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}} \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \left(\left(\left(\frac{M}{d} \cdot \frac{M}{d}\right) \cdot \color{blue}{\left(D \cdot D\right)}\right) \cdot \frac{h}{\ell}\right)\right)\right) \]
      9. swap-sqr77.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 75.1% accurate, 0.8× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < h

    1. Initial program 69.5%

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

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

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

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{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) \]
      3. frac-times76.4%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\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. Taylor expanded in M around 0 59.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 75.2% accurate, 1.0× speedup?

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

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


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

    1. Initial program 69.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.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-sqrt69.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. pow269.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-prod69.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-pow171.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. metadata-eval71.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. associate-*l/71.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 \frac{D}{d}}{2}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. div-inv71.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < h

    1. Initial program 69.5%

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

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

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

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{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) \]
      3. frac-times76.4%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\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. Taylor expanded in M around 0 59.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 68.6% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 1.15000000000000009e171

    1. Initial program 69.1%

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

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt68.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. pow268.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-prod68.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-pow173.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 + h \cdot \left(-0.125 \cdot \frac{\left(D \cdot D\right) \cdot \color{blue}{\left(\frac{M}{d} \cdot \frac{M}{d}\right)}}{\ell}\right)\right) \]
      13. swap-sqr70.3%

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

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

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

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

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

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

    if 1.15000000000000009e171 < d

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

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

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

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{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) \]
      3. frac-times93.3%

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

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} \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-rr93.3%

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

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

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\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. Taylor expanded in d around 0 84.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) \]
    9. Step-by-step derivation
      1. associate-/r*84.4%

        \[\leadsto \left(d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\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. associate-/l/84.4%

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

        \[\leadsto \left(d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{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) \]
    10. Simplified84.4%

      \[\leadsto \color{blue}{\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{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. Recombined 2 regimes into one program.
  4. Final simplification72.8%

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

Alternative 6: 64.7% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 78.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified78.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-sqrt78.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. pow278.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-prod78.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-pow180.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. metadata-eval80.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. associate-*l/80.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 \frac{D}{d}}{2}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. div-inv80.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4e-116 < d < 2.59999999999999997e-304

    1. Initial program 53.4%

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    5. 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)} \]
    6. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.59999999999999997e-304 < d

    1. Initial program 70.5%

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

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

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

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{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) \]
      3. frac-times76.8%

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

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} \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-rr76.9%

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

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

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\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. Taylor expanded in d around 0 70.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) \]
    9. Step-by-step derivation
      1. associate-/r*70.9%

        \[\leadsto \left(d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\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. associate-/l/70.1%

        \[\leadsto \left(d \cdot \sqrt{\color{blue}{\frac{1}{\ell \cdot 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. associate-/r*70.9%

        \[\leadsto \left(d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{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) \]
    10. Simplified70.9%

      \[\leadsto \color{blue}{\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{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. Recombined 3 regimes into one program.
  4. Final simplification66.5%

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

Alternative 7: 63.5% accurate, 1.0× speedup?

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

\mathbf{elif}\;d \leq 2.6 \cdot 10^{-304}:\\
\;\;\;\;d \cdot \sqrt{\frac{\log \left(e^{\frac{1}{\ell}}\right)}{h}}\\

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


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

    1. Initial program 78.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. Simplified78.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-sqrt78.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. pow278.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-prod78.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-pow180.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. metadata-eval80.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.60000000000000006e-165 < d < 2.59999999999999997e-304

    1. Initial program 47.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.59999999999999997e-304 < d

    1. Initial program 70.5%

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

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

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

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{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) \]
      3. frac-times76.8%

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

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} \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-rr76.9%

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

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

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\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. Taylor expanded in d around 0 70.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) \]
    9. Step-by-step derivation
      1. associate-/r*70.9%

        \[\leadsto \left(d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\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. associate-/l/70.1%

        \[\leadsto \left(d \cdot \sqrt{\color{blue}{\frac{1}{\ell \cdot 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. associate-/r*70.9%

        \[\leadsto \left(d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{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) \]
    10. Simplified70.9%

      \[\leadsto \color{blue}{\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{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. Recombined 3 regimes into one program.
  4. Final simplification65.3%

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

Alternative 8: 59.7% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;\ell \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\

\mathbf{elif}\;\ell \leq 9 \cdot 10^{+199}:\\
\;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M\_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}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if l < -6.99999999999999996e-94

    1. Initial program 66.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      7. exp-prod0.0%

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

        \[\leadsto e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      9. distribute-rgt-neg-in0.0%

        \[\leadsto e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      10. metadata-eval0.0%

        \[\leadsto e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      11. exp-to-pow0.0%

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

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

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

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      15. mul-1-neg46.3%

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

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

    if -6.99999999999999996e-94 < l < -1.05e-235

    1. Initial program 87.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. Simplified87.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-sqrt87.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. pow287.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-prod87.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-pow187.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. metadata-eval87.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.05e-235 < l < -3.999999999999988e-310

    1. Initial program 62.3%

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

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

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

    if -3.999999999999988e-310 < l < 8.9999999999999994e199

    1. Initial program 74.9%

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

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

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

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{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) \]
      3. frac-times80.5%

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

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

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

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

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

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

        \[\leadsto \left(1 \cdot \color{blue}{\frac{d}{\sqrt{\ell} \cdot \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) \]
      3. pow1/280.6%

        \[\leadsto \left(1 \cdot \frac{d}{\color{blue}{{\ell}^{0.5}} \cdot \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. pow1/280.6%

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

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

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

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

      \[\leadsto \color{blue}{\left(1 \cdot \frac{d}{\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) \]
    10. Step-by-step derivation
      1. *-lft-identity77.0%

        \[\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) \]
    11. Simplified77.0%

      \[\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 8.9999999999999994e199 < l

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

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

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

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

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

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

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

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

      \[\leadsto d \cdot \color{blue}{\left(1 \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    7. Step-by-step derivation
      1. *-lft-identity40.4%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr56.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7 \cdot 10^{-94}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{elif}\;\ell \leq -1.05 \cdot 10^{-235}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(-0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}\right)\right)\\ \mathbf{elif}\;\ell \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;\ell \leq 9 \cdot 10^{+199}:\\ \;\;\;\;\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 9: 60.8% accurate, 1.4× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -1.95000000000000006e-49 or 2.7500000000000001e137 < h

    1. Initial program 69.1%

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

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt68.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. pow268.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-prod68.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-pow170.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. metadata-eval70.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. associate-*l/70.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 \frac{D}{d}}{2}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. div-inv70.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.95000000000000006e-49 < h < -1.000000000000002e-309

    1. Initial program 71.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      7. exp-prod0.0%

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

        \[\leadsto e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      9. distribute-rgt-neg-in0.0%

        \[\leadsto e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      10. metadata-eval0.0%

        \[\leadsto e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      11. exp-to-pow0.0%

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

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

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      14. rem-square-sqrt64.2%

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      15. mul-1-neg64.2%

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \color{blue}{\left(-d\right)} \]
    7. Simplified64.2%

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

    if -1.000000000000002e-309 < h < 2.7500000000000001e137

    1. Initial program 69.5%

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

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

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{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) \]
      3. frac-times79.2%

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

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} \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-rr79.3%

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

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

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{h}}}{\sqrt{\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. Taylor expanded in d around 0 76.6%

      \[\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) \]
    9. Step-by-step derivation
      1. associate-/r*77.5%

        \[\leadsto \left(d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\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. associate-/l/76.6%

        \[\leadsto \left(d \cdot \sqrt{\color{blue}{\frac{1}{\ell \cdot 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. associate-/r*77.5%

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

      \[\leadsto \color{blue}{\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{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. Recombined 3 regimes into one program.
  4. Final simplification67.0%

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

Alternative 10: 60.8% accurate, 1.4× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -1.74999999999999998e-50 or 6.50000000000000054e138 < h

    1. Initial program 69.1%

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

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt68.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. pow268.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-prod68.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-pow170.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. metadata-eval70.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. associate-*l/70.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 \frac{D}{d}}{2}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. div-inv70.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.74999999999999998e-50 < h < -1.000000000000002e-309

    1. Initial program 71.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      7. exp-prod0.0%

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

        \[\leadsto e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      9. distribute-rgt-neg-in0.0%

        \[\leadsto e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      10. metadata-eval0.0%

        \[\leadsto e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      11. exp-to-pow0.0%

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

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

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      14. rem-square-sqrt64.2%

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      15. mul-1-neg64.2%

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \color{blue}{\left(-d\right)} \]
    7. Simplified64.2%

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

    if -1.000000000000002e-309 < h < 6.50000000000000054e138

    1. Initial program 69.5%

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

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

        \[\leadsto \left(\frac{\sqrt{d}}{\sqrt{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) \]
      3. frac-times79.2%

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

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} \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-rr79.3%

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

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

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

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

        \[\leadsto \left(1 \cdot \color{blue}{\frac{d}{\sqrt{\ell} \cdot \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) \]
      3. pow1/279.3%

        \[\leadsto \left(1 \cdot \frac{d}{\color{blue}{{\ell}^{0.5}} \cdot \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. pow1/279.3%

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

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

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

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

      \[\leadsto \color{blue}{\left(1 \cdot \frac{d}{\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) \]
    10. Step-by-step derivation
      1. *-lft-identity76.5%

        \[\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) \]
    11. Simplified76.5%

      \[\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) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification66.5%

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

Alternative 11: 52.1% accurate, 1.4× speedup?

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

\mathbf{elif}\;d \leq -4.6 \cdot 10^{-154}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\

\mathbf{elif}\;d \leq -1.25 \cdot 10^{-294}:\\
\;\;\;\;d \cdot {\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}^{-0.5}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -6.8e122

    1. Initial program 72.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      7. exp-prod0.0%

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

        \[\leadsto e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      9. distribute-rgt-neg-in0.0%

        \[\leadsto e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      10. metadata-eval0.0%

        \[\leadsto e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      11. exp-to-pow0.0%

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

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

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

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      15. mul-1-neg66.3%

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

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

    if -6.8e122 < d < -4.5999999999999999e-154

    1. Initial program 82.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. Simplified82.5%

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

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

    if -4.5999999999999999e-154 < d < -1.2500000000000001e-294

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. expm1-log1p-u13.2%

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

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

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{e^{\mathsf{log1p}\left(h \cdot \ell\right)} - 1}}} \]
    7. Step-by-step derivation
      1. sub-neg39.1%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{e^{\mathsf{log1p}\left(h \cdot \ell\right)} + \left(-1\right)}}} \]
      2. metadata-eval39.1%

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

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + e^{\mathsf{log1p}\left(h \cdot \ell\right)}}}} \]
      4. log1p-undefine39.1%

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\left(h \cdot \ell + 1\right)}}} \]
      7. fma-define39.1%

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified39.1%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. pow1/239.1%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}\right)}^{0.5}} \]
      2. inv-pow39.1%

        \[\leadsto d \cdot {\color{blue}{\left({\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}^{-1}\right)}}^{0.5} \]
      3. pow-pow39.1%

        \[\leadsto d \cdot \color{blue}{{\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}^{\left(-1 \cdot 0.5\right)}} \]
      4. metadata-eval39.1%

        \[\leadsto d \cdot {\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}^{\color{blue}{-0.5}} \]
    10. Applied egg-rr39.1%

      \[\leadsto d \cdot \color{blue}{{\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}^{-0.5}} \]

    if -1.2500000000000001e-294 < d < 1.35e-77

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

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

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

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

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

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

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

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

    if 1.35e-77 < d

    1. Initial program 74.4%

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

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

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

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

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

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

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

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

      \[\leadsto d \cdot \color{blue}{\left(1 \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    7. Step-by-step derivation
      1. *-lft-identity60.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.8 \cdot 10^{+122}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{elif}\;d \leq -4.6 \cdot 10^{-154}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -1.25 \cdot 10^{-294}:\\ \;\;\;\;d \cdot {\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}^{-0.5}\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{-77}:\\ \;\;\;\;-0.125 \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 48.0% accurate, 1.5× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 1.8999999999999999e154

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

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

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

    if 1.8999999999999999e154 < D

    1. Initial program 65.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. Simplified65.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. add-sqr-sqrt65.4%

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow168.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. metadata-eval68.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 45.9% accurate, 1.5× speedup?

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

\mathbf{elif}\;\ell \leq -1.05 \cdot 10^{-235}:\\
\;\;\;\;d \cdot {\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}^{-0.5}\\

\mathbf{elif}\;\ell \leq 2.8 \cdot 10^{-238}:\\
\;\;\;\;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 l < -9.5000000000000008e-99 or -1.05e-235 < l < 2.80000000000000004e-238

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

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

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

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      7. exp-prod0.0%

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

        \[\leadsto e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      9. distribute-rgt-neg-in0.0%

        \[\leadsto e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      10. metadata-eval0.0%

        \[\leadsto e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      11. exp-to-pow0.0%

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

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

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

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      15. mul-1-neg47.2%

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \color{blue}{\left(-d\right)} \]
    7. Simplified47.2%

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

    if -9.5000000000000008e-99 < l < -1.05e-235

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. expm1-log1p-u20.1%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(h \cdot \ell\right)\right)}}} \]
      2. expm1-undefine61.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{e^{\mathsf{log1p}\left(h \cdot \ell\right)} - 1}}} \]
    6. Applied egg-rr61.9%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{e^{\mathsf{log1p}\left(h \cdot \ell\right)} - 1}}} \]
    7. Step-by-step derivation
      1. sub-neg61.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{e^{\mathsf{log1p}\left(h \cdot \ell\right)} + \left(-1\right)}}} \]
      2. metadata-eval61.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{e^{\mathsf{log1p}\left(h \cdot \ell\right)} + \color{blue}{-1}}} \]
      3. +-commutative61.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + e^{\mathsf{log1p}\left(h \cdot \ell\right)}}}} \]
      4. log1p-undefine61.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + e^{\color{blue}{\log \left(1 + h \cdot \ell\right)}}}} \]
      5. rem-exp-log61.9%

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\left(h \cdot \ell + 1\right)}}} \]
      7. fma-define61.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified61.9%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. pow1/261.9%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}\right)}^{0.5}} \]
      2. inv-pow61.9%

        \[\leadsto d \cdot {\color{blue}{\left({\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}^{-1}\right)}}^{0.5} \]
      3. pow-pow61.9%

        \[\leadsto d \cdot \color{blue}{{\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}^{\left(-1 \cdot 0.5\right)}} \]
      4. metadata-eval61.9%

        \[\leadsto d \cdot {\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}^{\color{blue}{-0.5}} \]
    10. Applied egg-rr61.9%

      \[\leadsto d \cdot \color{blue}{{\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}^{-0.5}} \]

    if 2.80000000000000004e-238 < l

    1. Initial program 66.6%

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

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

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

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

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

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

        \[\leadsto d \cdot \left(1 \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right) \]
      5. metadata-eval52.8%

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

      \[\leadsto d \cdot \color{blue}{\left(1 \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    7. Step-by-step derivation
      1. *-lft-identity52.8%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr57.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9.5 \cdot 10^{-99}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{elif}\;\ell \leq -1.05 \cdot 10^{-235}:\\ \;\;\;\;d \cdot {\left(-1 + \mathsf{fma}\left(h, \ell, 1\right)\right)}^{-0.5}\\ \mathbf{elif}\;\ell \leq 2.8 \cdot 10^{-238}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 45.9% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 5 \cdot 10^{-238}:\\ \;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (if (<= l 5e-238)
   (* (- d) (pow (* h l) -0.5))
   (* d (* (pow l -0.5) (pow h -0.5)))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (l <= 5e-238) {
		tmp = -d * pow((h * l), -0.5);
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    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_1
    real(8) :: tmp
    if (l <= 5d-238) 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);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (l <= 5e-238) {
		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, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	tmp = 0
	if l <= 5e-238:
		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, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	tmp = 0.0
	if (l <= 5e-238)
		tmp = Float64(Float64(-d) * (Float64(h * l) ^ -0.5));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
	tmp = 0.0;
	if (l <= 5e-238)
		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]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, 5e-238], 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, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 5 \cdot 10^{-238}:\\
\;\;\;\;\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\\

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


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

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      7. exp-prod0.0%

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

        \[\leadsto e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      9. distribute-rgt-neg-in0.0%

        \[\leadsto e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      10. metadata-eval0.0%

        \[\leadsto e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      11. exp-to-pow0.0%

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

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

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      14. rem-square-sqrt42.4%

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

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

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

    if 5e-238 < l

    1. Initial program 66.6%

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

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

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

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

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

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

        \[\leadsto d \cdot \left(1 \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right) \]
      5. metadata-eval52.8%

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

      \[\leadsto d \cdot \color{blue}{\left(1 \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    7. Step-by-step derivation
      1. *-lft-identity52.8%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr57.7%

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

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

Alternative 15: 42.4% accurate, 3.0× speedup?

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

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


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

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      7. exp-prod0.0%

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

        \[\leadsto e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      9. distribute-rgt-neg-in0.0%

        \[\leadsto e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      10. metadata-eval0.0%

        \[\leadsto e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      11. exp-to-pow0.0%

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

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

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      14. rem-square-sqrt42.4%

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

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

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

    if 2.6000000000000001e-238 < l

    1. Initial program 66.6%

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

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

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

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

Alternative 16: 26.9% accurate, 3.1× speedup?

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

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

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

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  5. Add Preprocessing

Alternative 17: 26.8% accurate, 3.1× speedup?

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

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

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

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

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

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

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

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

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

    \[\leadsto d \cdot \color{blue}{\left(1 \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)} \]
  7. Step-by-step derivation
    1. *-lft-identity28.5%

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

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

Reproduce

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