Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.1% → 84.1%
Time: 31.9s
Alternatives: 27
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 27 alternatives:

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

Initial Program: 66.1% accurate, 1.0× speedup?

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

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

Alternative 1: 84.1% accurate, 0.6× speedup?

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

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


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

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

        \[\leadsto \sqrt{\color{blue}{\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) \]
      2. sqrt-div74.4%

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

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

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\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-div85.1%

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\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) \]
    7. Applied egg-rr85.1%

      \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\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 -9.999999999999969e-311 < h

    1. Initial program 71.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. Simplified71.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. Applied egg-rr84.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 79.0% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 53.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. Simplified55.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. frac-2neg55.5%

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\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-div82.8%

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

    if -7.2000000000000007e125 < h < -9.999999999999969e-311

    1. Initial program 68.5%

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

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

        \[\leadsto \sqrt{\color{blue}{\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) \]
      2. sqrt-div83.1%

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

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

    if -9.999999999999969e-311 < h

    1. Initial program 71.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. Simplified71.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. Applied egg-rr84.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 79.7% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 53.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. Simplified55.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. frac-2neg55.5%

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\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-div82.8%

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

    if -9.99999999999999925e125 < h < -9.999999999999969e-311

    1. Initial program 68.5%

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

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

        \[\leadsto \sqrt{\color{blue}{\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) \]
      2. sqrt-div83.1%

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

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

    if -9.999999999999969e-311 < h

    1. Initial program 71.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. Simplified71.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. Applied egg-rr84.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 80.6% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 53.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. Simplified55.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. frac-2neg55.5%

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\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-div82.8%

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

    if -1.20000000000000006e126 < h < -9.999999999999969e-311

    1. Initial program 68.5%

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

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

        \[\leadsto \sqrt{\color{blue}{\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) \]
      2. sqrt-div83.1%

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

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

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

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

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

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

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

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

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

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

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

    if -9.999999999999969e-311 < h

    1. Initial program 71.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. Simplified71.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. Applied egg-rr84.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 80.6% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 53.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. Simplified55.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-sqrt55.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. pow255.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-prod55.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-pow155.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-eval55.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. frac-times52.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\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-div82.8%

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\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) \]
    15. Applied egg-rr75.4%

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

    if -1.02e127 < h < -9.999999999999969e-311

    1. Initial program 68.5%

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

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

        \[\leadsto \sqrt{\color{blue}{\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) \]
      2. sqrt-div83.1%

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

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

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

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

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

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

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

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

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

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

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

    if -9.999999999999969e-311 < h

    1. Initial program 71.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. Simplified71.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. Applied egg-rr84.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 75.1% accurate, 0.8× speedup?

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

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

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

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


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

    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. Simplified73.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-sqrt73.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. pow273.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-prod73.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-pow174.1%

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

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

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

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

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

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

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

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

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

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

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

    if -3.2000000000000001e-201 < d < -7.20000000000000031e-300

    1. Initial program 35.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. Simplified35.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.20000000000000031e-300 < d < 6.4999999999999994e-244

    1. Initial program 20.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. Simplified20.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-sqrt20.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. pow220.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-prod20.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-pow120.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-eval20.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. frac-times30.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.4999999999999994e-244 < d

    1. Initial program 74.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. Simplified74.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. Applied egg-rr88.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 75.1% accurate, 0.8× speedup?

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

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

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

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


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

    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. Simplified73.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-sqrt73.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. pow273.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-prod73.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-pow174.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.84999999999999995e-202 < d < -7.20000000000000031e-300

    1. Initial program 35.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. Simplified35.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.20000000000000031e-300 < d < 4.6999999999999998e-244

    1. Initial program 20.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. Simplified20.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-sqrt20.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. pow220.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-prod20.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-pow120.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-eval20.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. frac-times30.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.6999999999999998e-244 < d

    1. Initial program 74.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. Simplified74.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. Applied egg-rr88.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 77.3% accurate, 0.8× speedup?

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

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


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

    1. Initial program 63.6%

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

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

        \[\leadsto \sqrt{\color{blue}{\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) \]
      2. sqrt-div74.4%

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

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

    if -9.999999999999969e-311 < h

    1. Initial program 71.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. Simplified71.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. Applied egg-rr84.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 75.7% accurate, 0.8× speedup?

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

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


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

    1. Initial program 61.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.19999999999999976e-254 < d

    1. Initial program 73.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 73.0% accurate, 1.0× speedup?

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

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


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

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

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

    if -4.69999999999999986e-297 < d

    1. Initial program 69.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. Simplified70.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. Applied egg-rr82.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -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. unpow250.8%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -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. unpow250.8%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -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-frac57.9%

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

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

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

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

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

Alternative 11: 75.2% accurate, 1.0× speedup?

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

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


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

    1. Initial program 62.7%

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

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

    if 1.5599999999999999e-288 < d

    1. Initial program 72.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. Simplified73.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. Applied egg-rr86.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 67.4% accurate, 1.0× speedup?

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

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


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

    1. Initial program 63.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.999999999999988e-310 < l

    1. Initial program 71.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. Simplified71.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. Applied egg-rr84.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -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-frac59.3%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -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-sqr70.3%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -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. unpow270.3%

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

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

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

Alternative 13: 72.3% accurate, 1.0× speedup?

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

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


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

    1. Initial program 65.5%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified66.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-sqrt66.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. pow266.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-prod66.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-pow167.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -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-sqr65.9%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -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. unpow265.9%

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

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

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

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

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

    if 1.8999999999999999e-243 < l

    1. Initial program 69.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. 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. Applied egg-rr84.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -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-frac58.4%

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

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

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

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

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

Alternative 14: 64.3% accurate, 1.0× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.09999999999999997e-254 < h

    1. Initial program 70.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 67.4% accurate, 1.0× speedup?

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

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


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

    1. Initial program 63.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.00000000000000013e-308 < l

    1. Initial program 71.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. Simplified71.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. Applied egg-rr84.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -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-frac59.3%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -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-sqr70.3%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -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. unpow270.3%

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

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

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

Alternative 16: 60.5% accurate, 1.4× speedup?

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

\mathbf{elif}\;\ell \leq -4 \cdot 10^{-310}:\\
\;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\

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

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


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

    1. Initial program 62.1%

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

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

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

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

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

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

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

    if -4.5999999999999998e-215 < l < -3.999999999999988e-310

    1. Initial program 72.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. Simplified72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{\color{blue}{-0.25}} \]
    10. Applied egg-rr51.1%

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

    if -3.999999999999988e-310 < l < 4.1999999999999998e175

    1. Initial program 73.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.1999999999999998e175 < l

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

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

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

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

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

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

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

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

Alternative 17: 58.3% accurate, 1.4× speedup?

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

\mathbf{elif}\;\ell \leq -4 \cdot 10^{-310}:\\
\;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\

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

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


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

    1. Initial program 62.1%

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

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

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

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

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

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

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

    if -3.79999999999999977e-215 < l < -3.999999999999988e-310

    1. Initial program 72.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. Simplified72.7%

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

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

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

        \[\leadsto d \cdot \color{blue}{\log \left(e^{\sqrt{\frac{1}{\ell \cdot h}}}\right)} \]
      2. pow1/267.4%

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(\frac{1}{\ell \cdot h}\right)}^{0.5}}}\right) \]
      3. inv-pow67.4%

        \[\leadsto d \cdot \log \left(e^{{\color{blue}{\left({\left(\ell \cdot h\right)}^{-1}\right)}}^{0.5}}\right) \]
      4. pow-pow67.4%

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(\ell \cdot h\right)}^{\left(-1 \cdot 0.5\right)}}}\right) \]
      5. *-commutative67.4%

        \[\leadsto d \cdot \log \left(e^{{\color{blue}{\left(h \cdot \ell\right)}}^{\left(-1 \cdot 0.5\right)}}\right) \]
      6. metadata-eval67.4%

        \[\leadsto d \cdot \log \left(e^{{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}}\right) \]
    8. Applied egg-rr67.4%

      \[\leadsto d \cdot \color{blue}{\log \left(e^{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
    9. Step-by-step derivation
      1. rem-log-exp40.4%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      2. sqr-pow40.4%

        \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      3. pow-prod-down51.1%

        \[\leadsto d \cdot \color{blue}{{\left(\left(h \cdot \ell\right) \cdot \left(h \cdot \ell\right)\right)}^{\left(\frac{-0.5}{2}\right)}} \]
      4. pow251.1%

        \[\leadsto d \cdot {\color{blue}{\left({\left(h \cdot \ell\right)}^{2}\right)}}^{\left(\frac{-0.5}{2}\right)} \]
      5. *-commutative51.1%

        \[\leadsto d \cdot {\left({\color{blue}{\left(\ell \cdot h\right)}}^{2}\right)}^{\left(\frac{-0.5}{2}\right)} \]
      6. metadata-eval51.1%

        \[\leadsto d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{\color{blue}{-0.25}} \]
    10. Applied egg-rr51.1%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}} \]

    if -3.999999999999988e-310 < l < 3.1e174

    1. Initial program 73.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified74.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. Applied egg-rr86.1%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{4}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow186.1%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{4}\right)\right)} \]
      2. associate-*r*86.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{4}}\right) \]
      3. *-commutative86.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right)} \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{4}\right) \]
      4. associate-*r/86.0%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}}{4}\right) \]
      5. *-commutative86.0%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2}}{4}\right) \]
      6. associate-/l*85.1%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}}{4}\right) \]
    6. Simplified85.1%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right)} \]
    7. Taylor expanded in l around 0 74.7%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right) \]
    8. Step-by-step derivation
      1. *-commutative74.7%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\ell \cdot h}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right) \]
    9. Simplified74.7%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right) \]
    10. Taylor expanded in h around 0 52.1%

      \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \color{blue}{-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}}\right) \]
    11. Step-by-step derivation
      1. associate-*r*52.2%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -0.125 \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2} \cdot \ell}\right) \]
      2. times-frac52.4%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -0.125 \cdot \color{blue}{\left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \frac{h}{\ell}\right)}\right) \]
      3. associate-/l*54.2%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -0.125 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{{M}^{2}}{{d}^{2}}\right)} \cdot \frac{h}{\ell}\right)\right) \]
      4. unpow254.2%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -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. unpow254.2%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -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. unpow254.2%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -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-frac63.1%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -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-sqr74.7%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -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. unpow274.7%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -0.125 \cdot \left(\color{blue}{{\left(D \cdot \frac{M}{d}\right)}^{2}} \cdot \frac{h}{\ell}\right)\right) \]
    12. Simplified74.7%

      \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \color{blue}{-0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right) \]

    if 3.1e174 < l

    1. Initial program 59.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. Simplified59.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 43.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*48.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified48.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. Step-by-step derivation
      1. sqrt-div71.3%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    8. Applied egg-rr71.3%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification56.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.8 \cdot 10^{-215}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\ \mathbf{elif}\;\ell \leq -4 \cdot 10^{-310}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{elif}\;\ell \leq 3.1 \cdot 10^{+174}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 66.0% accurate, 1.4× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.75 \cdot 10^{-221}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - h \cdot \left(0.125 \cdot \frac{{\left(M\_m \cdot \frac{D\_m}{d}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{elif}\;\ell \leq 2.7 \cdot 10^{+174}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + h \cdot \left(\frac{-0.5}{\ell} \cdot \frac{{\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}}{4}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l 1.75e-221)
   (*
    (sqrt (* (/ d h) (/ d l)))
    (- 1.0 (* h (* 0.125 (/ (pow (* M_m (/ D_m d)) 2.0) l)))))
   (if (<= l 2.7e+174)
     (*
      (/ d (sqrt (* h l)))
      (+ 1.0 (* h (* (/ -0.5 l) (/ (pow (* D_m (/ M_m d)) 2.0) 4.0)))))
     (* d (/ (sqrt (/ 1.0 h)) (sqrt l))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 1.75e-221) {
		tmp = sqrt(((d / h) * (d / l))) * (1.0 - (h * (0.125 * (pow((M_m * (D_m / d)), 2.0) / l))));
	} else if (l <= 2.7e+174) {
		tmp = (d / sqrt((h * l))) * (1.0 + (h * ((-0.5 / l) * (pow((D_m * (M_m / d)), 2.0) / 4.0))));
	} else {
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= 1.75d-221) then
        tmp = sqrt(((d / h) * (d / l))) * (1.0d0 - (h * (0.125d0 * (((m_m * (d_m / d)) ** 2.0d0) / l))))
    else if (l <= 2.7d+174) then
        tmp = (d / sqrt((h * l))) * (1.0d0 + (h * (((-0.5d0) / l) * (((d_m * (m_m / d)) ** 2.0d0) / 4.0d0))))
    else
        tmp = d * (sqrt((1.0d0 / h)) / sqrt(l))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 1.75e-221) {
		tmp = Math.sqrt(((d / h) * (d / l))) * (1.0 - (h * (0.125 * (Math.pow((M_m * (D_m / d)), 2.0) / l))));
	} else if (l <= 2.7e+174) {
		tmp = (d / Math.sqrt((h * l))) * (1.0 + (h * ((-0.5 / l) * (Math.pow((D_m * (M_m / d)), 2.0) / 4.0))));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= 1.75e-221:
		tmp = math.sqrt(((d / h) * (d / l))) * (1.0 - (h * (0.125 * (math.pow((M_m * (D_m / d)), 2.0) / l))))
	elif l <= 2.7e+174:
		tmp = (d / math.sqrt((h * l))) * (1.0 + (h * ((-0.5 / l) * (math.pow((D_m * (M_m / d)), 2.0) / 4.0))))
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= 1.75e-221)
		tmp = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 - Float64(h * Float64(0.125 * Float64((Float64(M_m * Float64(D_m / d)) ^ 2.0) / l)))));
	elseif (l <= 2.7e+174)
		tmp = Float64(Float64(d / sqrt(Float64(h * l))) * Float64(1.0 + Float64(h * Float64(Float64(-0.5 / l) * Float64((Float64(D_m * Float64(M_m / d)) ^ 2.0) / 4.0)))));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / h)) / sqrt(l)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= 1.75e-221)
		tmp = sqrt(((d / h) * (d / l))) * (1.0 - (h * (0.125 * (((M_m * (D_m / d)) ^ 2.0) / l))));
	elseif (l <= 2.7e+174)
		tmp = (d / sqrt((h * l))) * (1.0 + (h * ((-0.5 / l) * (((D_m * (M_m / d)) ^ 2.0) / 4.0))));
	else
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, 1.75e-221], N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(h * N[(0.125 * N[(N[Power[N[(M$95$m * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.7e+174], N[(N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(h * N[(N[(-0.5 / l), $MachinePrecision] * N[(N[Power[N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.75 \cdot 10^{-221}:\\
\;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - h \cdot \left(0.125 \cdot \frac{{\left(M\_m \cdot \frac{D\_m}{d}\right)}^{2}}{\ell}\right)\right)\\

\mathbf{elif}\;\ell \leq 2.7 \cdot 10^{+174}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + h \cdot \left(\frac{-0.5}{\ell} \cdot \frac{{\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}}{4}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < 1.7499999999999999e-221

    1. Initial program 66.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. Simplified66.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-sqrt66.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow266.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod66.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-pow168.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-eval68.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. frac-times67.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*68.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. pow168.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative68.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr68.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/67.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. *-commutative67.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. associate-*r/66.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. associate-*l*65.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    7. Simplified65.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Step-by-step derivation
      1. pow165.0%

        \[\leadsto \color{blue}{{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1}} \]
    9. Applied egg-rr59.8%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}^{1}} \]
    10. Step-by-step derivation
      1. unpow159.8%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
      2. +-commutative59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left(-0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right) + 1\right)} \]
      3. associate-*r*59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\color{blue}{\left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}} + 1\right) \]
      4. *-commutative59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right)} + 1\right) \]
      5. fma-undefine59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}, 1\right)} \]
      6. *-commutative59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(D \cdot \frac{M}{\color{blue}{2 \cdot d}}\right)}^{2}, 1\right) \]
    11. Simplified59.8%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}, 1\right)} \]
    12. Taylor expanded in h around -inf 36.4%

      \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left(-1 \cdot \left(h \cdot \left(0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} - \frac{1}{h}\right)\right)\right)} \]
    13. Step-by-step derivation
      1. associate-*r*36.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left(\left(-1 \cdot h\right) \cdot \left(0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} - \frac{1}{h}\right)\right)} \]
      2. sub-neg36.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\left(-1 \cdot h\right) \cdot \color{blue}{\left(0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} + \left(-\frac{1}{h}\right)\right)}\right) \]
      3. +-commutative36.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\left(-1 \cdot h\right) \cdot \color{blue}{\left(\left(-\frac{1}{h}\right) + 0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)}\right) \]
      4. distribute-lft-in36.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left(\left(-1 \cdot h\right) \cdot \left(-\frac{1}{h}\right) + \left(-1 \cdot h\right) \cdot \left(0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)\right)} \]
      5. distribute-neg-frac236.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\left(-1 \cdot h\right) \cdot \color{blue}{\frac{1}{-h}} + \left(-1 \cdot h\right) \cdot \left(0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)\right) \]
      6. mul-1-neg36.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\left(-1 \cdot h\right) \cdot \frac{1}{\color{blue}{-1 \cdot h}} + \left(-1 \cdot h\right) \cdot \left(0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)\right) \]
      7. rgt-mult-inverse36.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\color{blue}{1} + \left(-1 \cdot h\right) \cdot \left(0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)\right) \]
      8. mul-1-neg36.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{\left(-h\right)} \cdot \left(0.125 \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)\right) \]
      9. associate-/r*38.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \left(-h\right) \cdot \left(0.125 \cdot \color{blue}{\frac{\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}}}{\ell}}\right)\right) \]
    14. Simplified59.9%

      \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left(1 + \left(-h\right) \cdot \left(0.125 \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\right)} \]

    if 1.7499999999999999e-221 < l < 2.6999999999999999e174

    1. Initial program 71.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.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. Applied egg-rr85.8%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{4}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow185.8%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{4}\right)\right)} \]
      2. associate-*r*85.8%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{4}}\right) \]
      3. *-commutative85.8%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right)} \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{4}\right) \]
      4. associate-*r/85.7%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}}{4}\right) \]
      5. *-commutative85.7%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2}}{4}\right) \]
      6. associate-/l*84.6%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}}{4}\right) \]
    6. Simplified84.6%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right)} \]
    7. Taylor expanded in l around 0 75.6%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right) \]
    8. Step-by-step derivation
      1. *-commutative75.6%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\ell \cdot h}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right) \]
    9. Simplified75.6%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right) \]
    10. Step-by-step derivation
      1. associate-*r/75.6%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \color{blue}{\frac{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}}{4}}\right) \]
      2. associate-*l/75.6%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \frac{\color{blue}{\frac{h \cdot -0.5}{\ell}} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right) \]
    11. Applied egg-rr75.6%

      \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \color{blue}{\frac{\frac{h \cdot -0.5}{\ell} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}}{4}}\right) \]
    12. Step-by-step derivation
      1. associate-/l*75.6%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \color{blue}{\frac{h \cdot -0.5}{\ell} \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}}\right) \]
      2. associate-/l*75.6%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \color{blue}{\left(h \cdot \frac{-0.5}{\ell}\right)} \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right) \]
      3. associate-*l*76.7%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \color{blue}{h \cdot \left(\frac{-0.5}{\ell} \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right)}\right) \]
    13. Simplified76.7%

      \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \color{blue}{h \cdot \left(\frac{-0.5}{\ell} \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right)}\right) \]

    if 2.6999999999999999e174 < l

    1. Initial program 59.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. Simplified59.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 43.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*48.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified48.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. Step-by-step derivation
      1. sqrt-div71.3%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    8. Applied egg-rr71.3%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification66.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 1.75 \cdot 10^{-221}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - h \cdot \left(0.125 \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{elif}\;\ell \leq 2.7 \cdot 10^{+174}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + h \cdot \left(\frac{-0.5}{\ell} \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 64.7% accurate, 1.4× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.75 \cdot 10^{-221}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D\_m \cdot M\_m}{d \cdot 2}\right)}^{2}\right)\right)\\ \mathbf{elif}\;\ell \leq 5.5 \cdot 10^{+174}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + h \cdot \left(\frac{-0.5}{\ell} \cdot \frac{{\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}}{4}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l 1.75e-221)
   (*
    (sqrt (* (/ d h) (/ d l)))
    (+ 1.0 (* -0.5 (* (/ h l) (pow (/ (* D_m M_m) (* d 2.0)) 2.0)))))
   (if (<= l 5.5e+174)
     (*
      (/ d (sqrt (* h l)))
      (+ 1.0 (* h (* (/ -0.5 l) (/ (pow (* D_m (/ M_m d)) 2.0) 4.0)))))
     (* d (/ (sqrt (/ 1.0 h)) (sqrt l))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 1.75e-221) {
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * pow(((D_m * M_m) / (d * 2.0)), 2.0))));
	} else if (l <= 5.5e+174) {
		tmp = (d / sqrt((h * l))) * (1.0 + (h * ((-0.5 / l) * (pow((D_m * (M_m / d)), 2.0) / 4.0))));
	} else {
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= 1.75d-221) then
        tmp = sqrt(((d / h) * (d / l))) * (1.0d0 + ((-0.5d0) * ((h / l) * (((d_m * m_m) / (d * 2.0d0)) ** 2.0d0))))
    else if (l <= 5.5d+174) then
        tmp = (d / sqrt((h * l))) * (1.0d0 + (h * (((-0.5d0) / l) * (((d_m * (m_m / d)) ** 2.0d0) / 4.0d0))))
    else
        tmp = d * (sqrt((1.0d0 / h)) / sqrt(l))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 1.75e-221) {
		tmp = Math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * Math.pow(((D_m * M_m) / (d * 2.0)), 2.0))));
	} else if (l <= 5.5e+174) {
		tmp = (d / Math.sqrt((h * l))) * (1.0 + (h * ((-0.5 / l) * (Math.pow((D_m * (M_m / d)), 2.0) / 4.0))));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= 1.75e-221:
		tmp = math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * math.pow(((D_m * M_m) / (d * 2.0)), 2.0))))
	elif l <= 5.5e+174:
		tmp = (d / math.sqrt((h * l))) * (1.0 + (h * ((-0.5 / l) * (math.pow((D_m * (M_m / d)), 2.0) / 4.0))))
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= 1.75e-221)
		tmp = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(D_m * M_m) / Float64(d * 2.0)) ^ 2.0)))));
	elseif (l <= 5.5e+174)
		tmp = Float64(Float64(d / sqrt(Float64(h * l))) * Float64(1.0 + Float64(h * Float64(Float64(-0.5 / l) * Float64((Float64(D_m * Float64(M_m / d)) ^ 2.0) / 4.0)))));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / h)) / sqrt(l)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= 1.75e-221)
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * (((D_m * M_m) / (d * 2.0)) ^ 2.0))));
	elseif (l <= 5.5e+174)
		tmp = (d / sqrt((h * l))) * (1.0 + (h * ((-0.5 / l) * (((D_m * (M_m / d)) ^ 2.0) / 4.0))));
	else
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, 1.75e-221], N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D$95$m * M$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.5e+174], N[(N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(h * N[(N[(-0.5 / l), $MachinePrecision] * N[(N[Power[N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.75 \cdot 10^{-221}:\\
\;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D\_m \cdot M\_m}{d \cdot 2}\right)}^{2}\right)\right)\\

\mathbf{elif}\;\ell \leq 5.5 \cdot 10^{+174}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + h \cdot \left(\frac{-0.5}{\ell} \cdot \frac{{\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}}{4}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < 1.7499999999999999e-221

    1. Initial program 66.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. Simplified66.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-sqrt66.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow266.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod66.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-pow168.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-eval68.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. frac-times67.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*68.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. pow168.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative68.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr68.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/67.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. *-commutative67.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. associate-*r/66.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. associate-*l*65.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    7. Simplified65.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Step-by-step derivation
      1. pow165.0%

        \[\leadsto \color{blue}{{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1}} \]
    9. Applied egg-rr59.8%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}^{1}} \]
    10. Step-by-step derivation
      1. unpow159.8%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
      2. +-commutative59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left(-0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right) + 1\right)} \]
      3. associate-*r*59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\color{blue}{\left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}} + 1\right) \]
      4. *-commutative59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right)} + 1\right) \]
      5. fma-undefine59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}, 1\right)} \]
      6. *-commutative59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(D \cdot \frac{M}{\color{blue}{2 \cdot d}}\right)}^{2}, 1\right) \]
    11. Simplified59.8%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}, 1\right)} \]
    12. Step-by-step derivation
      1. fma-undefine59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left(\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}\right) + 1\right)} \]
      2. associate-/l/59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2}\right) + 1\right) \]
      3. *-commutative59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\color{blue}{\left(-0.5 \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right) \cdot \frac{h}{\ell}} + 1\right) \]
      4. associate-*l*59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\color{blue}{-0.5 \cdot \left({\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2} \cdot \frac{h}{\ell}\right)} + 1\right) \]
      5. associate-/l/59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(-0.5 \cdot \left({\left(D \cdot \color{blue}{\frac{M}{2 \cdot d}}\right)}^{2} \cdot \frac{h}{\ell}\right) + 1\right) \]
      6. associate-*r/59.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(-0.5 \cdot \left({\color{blue}{\left(\frac{D \cdot M}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}\right) + 1\right) \]
      7. *-commutative59.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(-0.5 \cdot \left({\left(\frac{D \cdot M}{\color{blue}{d \cdot 2}}\right)}^{2} \cdot \frac{h}{\ell}\right) + 1\right) \]
    13. Applied egg-rr59.7%

      \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left(-0.5 \cdot \left({\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right) + 1\right)} \]

    if 1.7499999999999999e-221 < l < 5.4999999999999998e174

    1. Initial program 71.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.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. Applied egg-rr85.8%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{4}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow185.8%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{4}\right)\right)} \]
      2. associate-*r*85.8%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{4}}\right) \]
      3. *-commutative85.8%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right)} \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{4}\right) \]
      4. associate-*r/85.7%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}}{4}\right) \]
      5. *-commutative85.7%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2}}{4}\right) \]
      6. associate-/l*84.6%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}}{4}\right) \]
    6. Simplified84.6%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right)} \]
    7. Taylor expanded in l around 0 75.6%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right) \]
    8. Step-by-step derivation
      1. *-commutative75.6%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\ell \cdot h}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right) \]
    9. Simplified75.6%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right) \]
    10. Step-by-step derivation
      1. associate-*r/75.6%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \color{blue}{\frac{\left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}}{4}}\right) \]
      2. associate-*l/75.6%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \frac{\color{blue}{\frac{h \cdot -0.5}{\ell}} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right) \]
    11. Applied egg-rr75.6%

      \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \color{blue}{\frac{\frac{h \cdot -0.5}{\ell} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}}{4}}\right) \]
    12. Step-by-step derivation
      1. associate-/l*75.6%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \color{blue}{\frac{h \cdot -0.5}{\ell} \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}}\right) \]
      2. associate-/l*75.6%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \color{blue}{\left(h \cdot \frac{-0.5}{\ell}\right)} \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right) \]
      3. associate-*l*76.7%

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \color{blue}{h \cdot \left(\frac{-0.5}{\ell} \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right)}\right) \]
    13. Simplified76.7%

      \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \color{blue}{h \cdot \left(\frac{-0.5}{\ell} \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right)}\right) \]

    if 5.4999999999999998e174 < l

    1. Initial program 59.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. Simplified59.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 43.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*48.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified48.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. Step-by-step derivation
      1. sqrt-div71.3%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    8. Applied egg-rr71.3%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification66.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 1.75 \cdot 10^{-221}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right)\right)\\ \mathbf{elif}\;\ell \leq 5.5 \cdot 10^{+174}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + h \cdot \left(\frac{-0.5}{\ell} \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 64.7% accurate, 1.4× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 2.5 \cdot 10^{-221}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D\_m \cdot M\_m}{d \cdot 2}\right)}^{2}\right)\right)\\ \mathbf{elif}\;\ell \leq 6.8 \cdot 10^{+174}:\\ \;\;\;\;\left(1 + \left(h \cdot -0.5\right) \cdot \frac{{\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2} \cdot 0.25}{\ell}\right) \cdot \frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l 2.5e-221)
   (*
    (sqrt (* (/ d h) (/ d l)))
    (+ 1.0 (* -0.5 (* (/ h l) (pow (/ (* D_m M_m) (* d 2.0)) 2.0)))))
   (if (<= l 6.8e+174)
     (*
      (+ 1.0 (* (* h -0.5) (/ (* (pow (* D_m (/ M_m d)) 2.0) 0.25) l)))
      (/ d (sqrt (* h l))))
     (* d (/ (sqrt (/ 1.0 h)) (sqrt l))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 2.5e-221) {
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * pow(((D_m * M_m) / (d * 2.0)), 2.0))));
	} else if (l <= 6.8e+174) {
		tmp = (1.0 + ((h * -0.5) * ((pow((D_m * (M_m / d)), 2.0) * 0.25) / l))) * (d / sqrt((h * l)));
	} else {
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= 2.5d-221) then
        tmp = sqrt(((d / h) * (d / l))) * (1.0d0 + ((-0.5d0) * ((h / l) * (((d_m * m_m) / (d * 2.0d0)) ** 2.0d0))))
    else if (l <= 6.8d+174) then
        tmp = (1.0d0 + ((h * (-0.5d0)) * ((((d_m * (m_m / d)) ** 2.0d0) * 0.25d0) / l))) * (d / sqrt((h * l)))
    else
        tmp = d * (sqrt((1.0d0 / h)) / sqrt(l))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 2.5e-221) {
		tmp = Math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * Math.pow(((D_m * M_m) / (d * 2.0)), 2.0))));
	} else if (l <= 6.8e+174) {
		tmp = (1.0 + ((h * -0.5) * ((Math.pow((D_m * (M_m / d)), 2.0) * 0.25) / l))) * (d / Math.sqrt((h * l)));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= 2.5e-221:
		tmp = math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * math.pow(((D_m * M_m) / (d * 2.0)), 2.0))))
	elif l <= 6.8e+174:
		tmp = (1.0 + ((h * -0.5) * ((math.pow((D_m * (M_m / d)), 2.0) * 0.25) / l))) * (d / math.sqrt((h * l)))
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= 2.5e-221)
		tmp = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(D_m * M_m) / Float64(d * 2.0)) ^ 2.0)))));
	elseif (l <= 6.8e+174)
		tmp = Float64(Float64(1.0 + Float64(Float64(h * -0.5) * Float64(Float64((Float64(D_m * Float64(M_m / d)) ^ 2.0) * 0.25) / l))) * Float64(d / sqrt(Float64(h * l))));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / h)) / sqrt(l)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= 2.5e-221)
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * (((D_m * M_m) / (d * 2.0)) ^ 2.0))));
	elseif (l <= 6.8e+174)
		tmp = (1.0 + ((h * -0.5) * ((((D_m * (M_m / d)) ^ 2.0) * 0.25) / l))) * (d / sqrt((h * l)));
	else
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, 2.5e-221], N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D$95$m * M$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6.8e+174], N[(N[(1.0 + N[(N[(h * -0.5), $MachinePrecision] * N[(N[(N[Power[N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.25), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2.5 \cdot 10^{-221}:\\
\;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D\_m \cdot M\_m}{d \cdot 2}\right)}^{2}\right)\right)\\

\mathbf{elif}\;\ell \leq 6.8 \cdot 10^{+174}:\\
\;\;\;\;\left(1 + \left(h \cdot -0.5\right) \cdot \frac{{\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2} \cdot 0.25}{\ell}\right) \cdot \frac{d}{\sqrt{h \cdot \ell}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < 2.49999999999999998e-221

    1. Initial program 66.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. Simplified66.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-sqrt66.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow266.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod66.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-pow168.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-eval68.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. frac-times67.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*68.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. pow168.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative68.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr68.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/67.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. *-commutative67.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. associate-*r/66.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. associate-*l*65.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    7. Simplified65.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Step-by-step derivation
      1. pow165.0%

        \[\leadsto \color{blue}{{\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1}} \]
    9. Applied egg-rr59.8%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}^{1}} \]
    10. Step-by-step derivation
      1. unpow159.8%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
      2. +-commutative59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left(-0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right) + 1\right)} \]
      3. associate-*r*59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\color{blue}{\left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}} + 1\right) \]
      4. *-commutative59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\color{blue}{\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right)} + 1\right) \]
      5. fma-undefine59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}, 1\right)} \]
      6. *-commutative59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(D \cdot \frac{M}{\color{blue}{2 \cdot d}}\right)}^{2}, 1\right) \]
    11. Simplified59.8%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}, 1\right)} \]
    12. Step-by-step derivation
      1. fma-undefine59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left(\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}\right) + 1\right)} \]
      2. associate-/l/59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2}\right) + 1\right) \]
      3. *-commutative59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\color{blue}{\left(-0.5 \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right) \cdot \frac{h}{\ell}} + 1\right) \]
      4. associate-*l*59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\color{blue}{-0.5 \cdot \left({\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2} \cdot \frac{h}{\ell}\right)} + 1\right) \]
      5. associate-/l/59.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(-0.5 \cdot \left({\left(D \cdot \color{blue}{\frac{M}{2 \cdot d}}\right)}^{2} \cdot \frac{h}{\ell}\right) + 1\right) \]
      6. associate-*r/59.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(-0.5 \cdot \left({\color{blue}{\left(\frac{D \cdot M}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}\right) + 1\right) \]
      7. *-commutative59.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(-0.5 \cdot \left({\left(\frac{D \cdot M}{\color{blue}{d \cdot 2}}\right)}^{2} \cdot \frac{h}{\ell}\right) + 1\right) \]
    13. Applied egg-rr59.7%

      \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left(-0.5 \cdot \left({\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right) + 1\right)} \]

    if 2.49999999999999998e-221 < l < 6.8000000000000002e174

    1. Initial program 71.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.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. Applied egg-rr85.8%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{4}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow185.8%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{4}\right)\right)} \]
      2. associate-*r*85.8%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{4}}\right) \]
      3. *-commutative85.8%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right)} \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{4}\right) \]
      4. associate-*r/85.7%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}}{4}\right) \]
      5. *-commutative85.7%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2}}{4}\right) \]
      6. associate-/l*84.6%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}}{4}\right) \]
    6. Simplified84.6%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right)} \]
    7. Taylor expanded in l around 0 75.6%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right) \]
    8. Step-by-step derivation
      1. *-commutative75.6%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\ell \cdot h}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right) \]
    9. Simplified75.6%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right) \]
    10. Step-by-step derivation
      1. expm1-log1p-u35.0%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right)\right)}\right) \]
      2. log1p-define35.0%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \mathsf{expm1}\left(\color{blue}{\log \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right)}\right)\right) \]
      3. expm1-undefine35.0%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(e^{\log \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right)} - 1\right)}\right) \]
      4. add-exp-log84.6%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\color{blue}{\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}\right)} - 1\right)\right) \]
      5. +-commutative84.6%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\color{blue}{\left(\left(\frac{h}{\ell} \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4} + 1\right)} - 1\right)\right) \]
      6. fma-define84.6%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\color{blue}{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}, 1\right)} - 1\right)\right) \]
      7. associate-*l/84.6%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\mathsf{fma}\left(\color{blue}{\frac{h \cdot -0.5}{\ell}}, \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{4}, 1\right) - 1\right)\right) \]
      8. div-inv84.6%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\mathsf{fma}\left(\frac{h \cdot -0.5}{\ell}, \color{blue}{{\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{1}{4}}, 1\right) - 1\right)\right) \]
      9. metadata-eval84.6%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\mathsf{fma}\left(\frac{h \cdot -0.5}{\ell}, {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \color{blue}{0.25}, 1\right) - 1\right)\right) \]
    11. Applied egg-rr75.6%

      \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \color{blue}{\left(\mathsf{fma}\left(\frac{h \cdot -0.5}{\ell}, {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot 0.25, 1\right) - 1\right)}\right) \]
    12. Step-by-step derivation
      1. fma-undefine84.6%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\color{blue}{\left(\frac{h \cdot -0.5}{\ell} \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot 0.25\right) + 1\right)} - 1\right)\right) \]
      2. associate--l+84.6%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \color{blue}{\left(\frac{h \cdot -0.5}{\ell} \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot 0.25\right) + \left(1 - 1\right)\right)}\right) \]
      3. associate-*l/83.6%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\color{blue}{\frac{\left(h \cdot -0.5\right) \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot 0.25\right)}{\ell}} + \left(1 - 1\right)\right)\right) \]
      4. associate-/l*85.8%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\color{blue}{\left(h \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2} \cdot 0.25}{\ell}} + \left(1 - 1\right)\right)\right) \]
      5. metadata-eval85.8%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \left(\left(h \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2} \cdot 0.25}{\ell} + \color{blue}{0}\right)\right) \]
    13. Simplified76.7%

      \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \color{blue}{\left(\left(h \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2} \cdot 0.25}{\ell} + 0\right)}\right) \]

    if 6.8000000000000002e174 < l

    1. Initial program 59.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. Simplified59.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 43.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*48.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified48.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. Step-by-step derivation
      1. sqrt-div71.3%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    8. Applied egg-rr71.3%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification66.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 2.5 \cdot 10^{-221}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right)\right)\\ \mathbf{elif}\;\ell \leq 6.8 \cdot 10^{+174}:\\ \;\;\;\;\left(1 + \left(h \cdot -0.5\right) \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2} \cdot 0.25}{\ell}\right) \cdot \frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 21: 46.4% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -7.2 \cdot 10^{-215}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\ \mathbf{elif}\;\ell \leq 7.5 \cdot 10^{-288}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l -7.2e-215)
   (* d (- (sqrt (/ (/ 1.0 h) l))))
   (if (<= l 7.5e-288)
     (/ d (sqrt (* h l)))
     (* d (* (pow l -0.5) (pow h -0.5))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -7.2e-215) {
		tmp = d * -sqrt(((1.0 / h) / l));
	} else if (l <= 7.5e-288) {
		tmp = d / sqrt((h * l));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= (-7.2d-215)) then
        tmp = d * -sqrt(((1.0d0 / h) / l))
    else if (l <= 7.5d-288) then
        tmp = d / sqrt((h * l))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -7.2e-215) {
		tmp = d * -Math.sqrt(((1.0 / h) / l));
	} else if (l <= 7.5e-288) {
		tmp = d / Math.sqrt((h * l));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= -7.2e-215:
		tmp = d * -math.sqrt(((1.0 / h) / l))
	elif l <= 7.5e-288:
		tmp = d / math.sqrt((h * l))
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -7.2e-215)
		tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / h) / l))));
	elseif (l <= 7.5e-288)
		tmp = Float64(d / sqrt(Float64(h * l)));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= -7.2e-215)
		tmp = d * -sqrt(((1.0 / h) / l));
	elseif (l <= 7.5e-288)
		tmp = d / sqrt((h * l));
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -7.2e-215], N[(d * (-N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[l, 7.5e-288], N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7.2 \cdot 10^{-215}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\

\mathbf{elif}\;\ell \leq 7.5 \cdot 10^{-288}:\\
\;\;\;\;\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 3 regimes
  2. if l < -7.1999999999999998e-215

    1. Initial program 62.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified62.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. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. 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. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt36.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-136.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified36.5%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if -7.1999999999999998e-215 < l < 7.4999999999999998e-288

    1. Initial program 71.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. Simplified71.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-sqrt71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow271.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow171.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-eval71.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. frac-times71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. pow171.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr71.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. *-commutative71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. associate-*r/71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. associate-*l*71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    7. Simplified71.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Step-by-step derivation
      1. clear-num71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      2. sqrt-div71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      3. metadata-eval71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    9. Applied egg-rr71.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    10. Step-by-step derivation
      1. pow171.8%

        \[\leadsto \color{blue}{{\left(\left(\sqrt{\frac{d}{h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1}} \]
      2. un-div-inv71.8%

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}}} \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1} \]
      3. cancel-sign-sub-inv71.8%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \color{blue}{\left(1 + \left(-0.5\right) \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)}\right)}^{1} \]
      4. metadata-eval71.8%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{-0.5} \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1} \]
      5. associate-*r*71.8%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot {\color{blue}{\left(\left(D \cdot \frac{M}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right)\right)}^{1} \]
      6. unpow-prod-down71.7%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot {\left(\sqrt{\frac{h}{\ell}}\right)}^{2}\right)}\right)\right)}^{1} \]
      7. pow271.7%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \color{blue}{\left(\sqrt{\frac{h}{\ell}} \cdot \sqrt{\frac{h}{\ell}}\right)}\right)\right)\right)}^{1} \]
      8. add-sqr-sqrt71.8%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \color{blue}{\frac{h}{\ell}}\right)\right)\right)}^{1} \]
    11. Applied egg-rr71.8%

      \[\leadsto \color{blue}{{\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}^{1}} \]
    12. Step-by-step derivation
      1. unpow171.8%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
      2. associate-*r*71.8%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}}\right) \]
      3. associate-/r*71.8%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(-0.5 \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    13. Simplified71.8%

      \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(-0.5 \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
    14. Taylor expanded in d around inf 44.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    15. Step-by-step derivation
      1. unpow1/244.1%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      2. rem-exp-log43.7%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      3. exp-neg43.7%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod43.7%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out43.7%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. exp-neg43.7%

        \[\leadsto d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      7. exp-to-pow44.1%

        \[\leadsto d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      8. unpow1/244.1%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      9. associate-/l*44.1%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      10. *-rgt-identity44.1%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    16. Simplified44.1%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]

    if 7.4999999999999998e-288 < l

    1. Initial program 71.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. Simplified71.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-sqrt71.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. pow271.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-prod71.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-pow173.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-eval73.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. frac-times72.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*72.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. pow172.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative72.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr72.3%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/72.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. *-commutative72.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. associate-*r/71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. associate-*l*71.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    7. Simplified71.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Taylor expanded in d around inf 33.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. unpow-133.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. metadata-eval33.9%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr33.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square33.9%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt33.8%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr33.8%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt33.9%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Simplified33.9%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    11. Step-by-step derivation
      1. *-commutative33.9%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down45.2%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    12. Applied egg-rr45.2%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification41.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7.2 \cdot 10^{-215}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\ \mathbf{elif}\;\ell \leq 7.5 \cdot 10^{-288}:\\ \;\;\;\;\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 22: 46.4% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -6.5 \cdot 10^{-215}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\ \mathbf{elif}\;\ell \leq 7.5 \cdot 10^{-288}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l -6.5e-215)
   (* d (- (sqrt (/ (/ 1.0 h) l))))
   (if (<= l 7.5e-288)
     (/ d (sqrt (* h l)))
     (* d (/ (sqrt (/ 1.0 h)) (sqrt l))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -6.5e-215) {
		tmp = d * -sqrt(((1.0 / h) / l));
	} else if (l <= 7.5e-288) {
		tmp = d / sqrt((h * l));
	} else {
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= (-6.5d-215)) then
        tmp = d * -sqrt(((1.0d0 / h) / l))
    else if (l <= 7.5d-288) then
        tmp = d / sqrt((h * l))
    else
        tmp = d * (sqrt((1.0d0 / h)) / sqrt(l))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -6.5e-215) {
		tmp = d * -Math.sqrt(((1.0 / h) / l));
	} else if (l <= 7.5e-288) {
		tmp = d / Math.sqrt((h * l));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= -6.5e-215:
		tmp = d * -math.sqrt(((1.0 / h) / l))
	elif l <= 7.5e-288:
		tmp = d / math.sqrt((h * l))
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -6.5e-215)
		tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / h) / l))));
	elseif (l <= 7.5e-288)
		tmp = Float64(d / sqrt(Float64(h * l)));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / h)) / sqrt(l)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= -6.5e-215)
		tmp = d * -sqrt(((1.0 / h) / l));
	elseif (l <= 7.5e-288)
		tmp = d / sqrt((h * l));
	else
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -6.5e-215], N[(d * (-N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[l, 7.5e-288], N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6.5 \cdot 10^{-215}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\

\mathbf{elif}\;\ell \leq 7.5 \cdot 10^{-288}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -6.4999999999999999e-215

    1. Initial program 62.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified62.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. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. 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. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt36.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-136.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified36.5%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if -6.4999999999999999e-215 < l < 7.4999999999999998e-288

    1. Initial program 71.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. Simplified71.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-sqrt71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow271.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow171.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-eval71.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. frac-times71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. pow171.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr71.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. *-commutative71.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. associate-*r/71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. associate-*l*71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    7. Simplified71.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Step-by-step derivation
      1. clear-num71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      2. sqrt-div71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      3. metadata-eval71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    9. Applied egg-rr71.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    10. Step-by-step derivation
      1. pow171.8%

        \[\leadsto \color{blue}{{\left(\left(\sqrt{\frac{d}{h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1}} \]
      2. un-div-inv71.8%

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}}} \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1} \]
      3. cancel-sign-sub-inv71.8%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \color{blue}{\left(1 + \left(-0.5\right) \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)}\right)}^{1} \]
      4. metadata-eval71.8%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{-0.5} \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1} \]
      5. associate-*r*71.8%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot {\color{blue}{\left(\left(D \cdot \frac{M}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right)\right)}^{1} \]
      6. unpow-prod-down71.7%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot {\left(\sqrt{\frac{h}{\ell}}\right)}^{2}\right)}\right)\right)}^{1} \]
      7. pow271.7%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \color{blue}{\left(\sqrt{\frac{h}{\ell}} \cdot \sqrt{\frac{h}{\ell}}\right)}\right)\right)\right)}^{1} \]
      8. add-sqr-sqrt71.8%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \color{blue}{\frac{h}{\ell}}\right)\right)\right)}^{1} \]
    11. Applied egg-rr71.8%

      \[\leadsto \color{blue}{{\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}^{1}} \]
    12. Step-by-step derivation
      1. unpow171.8%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
      2. associate-*r*71.8%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}}\right) \]
      3. associate-/r*71.8%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(-0.5 \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    13. Simplified71.8%

      \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(-0.5 \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
    14. Taylor expanded in d around inf 44.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    15. Step-by-step derivation
      1. unpow1/244.1%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      2. rem-exp-log43.7%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      3. exp-neg43.7%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod43.7%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out43.7%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. exp-neg43.7%

        \[\leadsto d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      7. exp-to-pow44.1%

        \[\leadsto d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      8. unpow1/244.1%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      9. associate-/l*44.1%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      10. *-rgt-identity44.1%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    16. Simplified44.1%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]

    if 7.4999999999999998e-288 < l

    1. Initial program 71.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. Simplified71.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. Taylor expanded in d around inf 33.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*36.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified36.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. Step-by-step derivation
      1. sqrt-div45.2%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    8. Applied egg-rr45.2%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification41.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -6.5 \cdot 10^{-215}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\ \mathbf{elif}\;\ell \leq 7.5 \cdot 10^{-288}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 23: 47.4% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -4.4 \cdot 10^{-215}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\ \mathbf{elif}\;\ell \leq -4 \cdot 10^{-310}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l -4.4e-215)
   (* d (- (sqrt (/ (/ 1.0 h) l))))
   (if (<= l -4e-310)
     (* d (pow (pow (* h l) 2.0) -0.25))
     (* d (/ (sqrt (/ 1.0 h)) (sqrt l))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -4.4e-215) {
		tmp = d * -sqrt(((1.0 / h) / l));
	} else if (l <= -4e-310) {
		tmp = d * pow(pow((h * l), 2.0), -0.25);
	} else {
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= (-4.4d-215)) then
        tmp = d * -sqrt(((1.0d0 / h) / l))
    else if (l <= (-4d-310)) then
        tmp = d * (((h * l) ** 2.0d0) ** (-0.25d0))
    else
        tmp = d * (sqrt((1.0d0 / h)) / sqrt(l))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -4.4e-215) {
		tmp = d * -Math.sqrt(((1.0 / h) / l));
	} else if (l <= -4e-310) {
		tmp = d * Math.pow(Math.pow((h * l), 2.0), -0.25);
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= -4.4e-215:
		tmp = d * -math.sqrt(((1.0 / h) / l))
	elif l <= -4e-310:
		tmp = d * math.pow(math.pow((h * l), 2.0), -0.25)
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -4.4e-215)
		tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / h) / l))));
	elseif (l <= -4e-310)
		tmp = Float64(d * ((Float64(h * l) ^ 2.0) ^ -0.25));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / h)) / sqrt(l)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= -4.4e-215)
		tmp = d * -sqrt(((1.0 / h) / l));
	elseif (l <= -4e-310)
		tmp = d * (((h * l) ^ 2.0) ^ -0.25);
	else
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -4.4e-215], N[(d * (-N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[l, -4e-310], N[(d * N[Power[N[Power[N[(h * l), $MachinePrecision], 2.0], $MachinePrecision], -0.25], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.4 \cdot 10^{-215}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\

\mathbf{elif}\;\ell \leq -4 \cdot 10^{-310}:\\
\;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -4.39999999999999993e-215

    1. Initial program 62.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified62.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. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. 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. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt36.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-136.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified36.5%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if -4.39999999999999993e-215 < l < -3.999999999999988e-310

    1. Initial program 72.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. Simplified72.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\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. *-commutative40.4%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified40.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. Step-by-step derivation
      1. add-log-exp67.4%

        \[\leadsto d \cdot \color{blue}{\log \left(e^{\sqrt{\frac{1}{\ell \cdot h}}}\right)} \]
      2. pow1/267.4%

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(\frac{1}{\ell \cdot h}\right)}^{0.5}}}\right) \]
      3. inv-pow67.4%

        \[\leadsto d \cdot \log \left(e^{{\color{blue}{\left({\left(\ell \cdot h\right)}^{-1}\right)}}^{0.5}}\right) \]
      4. pow-pow67.4%

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(\ell \cdot h\right)}^{\left(-1 \cdot 0.5\right)}}}\right) \]
      5. *-commutative67.4%

        \[\leadsto d \cdot \log \left(e^{{\color{blue}{\left(h \cdot \ell\right)}}^{\left(-1 \cdot 0.5\right)}}\right) \]
      6. metadata-eval67.4%

        \[\leadsto d \cdot \log \left(e^{{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}}\right) \]
    8. Applied egg-rr67.4%

      \[\leadsto d \cdot \color{blue}{\log \left(e^{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
    9. Step-by-step derivation
      1. rem-log-exp40.4%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      2. sqr-pow40.4%

        \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      3. pow-prod-down51.1%

        \[\leadsto d \cdot \color{blue}{{\left(\left(h \cdot \ell\right) \cdot \left(h \cdot \ell\right)\right)}^{\left(\frac{-0.5}{2}\right)}} \]
      4. pow251.1%

        \[\leadsto d \cdot {\color{blue}{\left({\left(h \cdot \ell\right)}^{2}\right)}}^{\left(\frac{-0.5}{2}\right)} \]
      5. *-commutative51.1%

        \[\leadsto d \cdot {\left({\color{blue}{\left(\ell \cdot h\right)}}^{2}\right)}^{\left(\frac{-0.5}{2}\right)} \]
      6. metadata-eval51.1%

        \[\leadsto d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{\color{blue}{-0.25}} \]
    10. Applied egg-rr51.1%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}} \]

    if -3.999999999999988e-310 < l

    1. Initial program 71.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. Simplified71.8%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 34.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*36.7%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified36.7%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
    7. Step-by-step derivation
      1. sqrt-div45.7%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    8. Applied egg-rr45.7%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification42.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.4 \cdot 10^{-215}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\ \mathbf{elif}\;\ell \leq -4 \cdot 10^{-310}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 24: 42.7% accurate, 2.9× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{if}\;\ell \leq -6.6 \cdot 10^{-215}:\\ \;\;\;\;d \cdot \left(-t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot t\_0\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (/ (/ 1.0 h) l))))
   (if (<= l -6.6e-215) (* d (- t_0)) (* d t_0))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt(((1.0 / h) / l));
	double tmp;
	if (l <= -6.6e-215) {
		tmp = d * -t_0;
	} else {
		tmp = d * t_0;
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt(((1.0d0 / h) / l))
    if (l <= (-6.6d-215)) then
        tmp = d * -t_0
    else
        tmp = d * t_0
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = Math.sqrt(((1.0 / h) / l));
	double tmp;
	if (l <= -6.6e-215) {
		tmp = d * -t_0;
	} else {
		tmp = d * t_0;
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = math.sqrt(((1.0 / h) / l))
	tmp = 0
	if l <= -6.6e-215:
		tmp = d * -t_0
	else:
		tmp = d * t_0
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = sqrt(Float64(Float64(1.0 / h) / l))
	tmp = 0.0
	if (l <= -6.6e-215)
		tmp = Float64(d * Float64(-t_0));
	else
		tmp = Float64(d * t_0);
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = sqrt(((1.0 / h) / l));
	tmp = 0.0;
	if (l <= -6.6e-215)
		tmp = d * -t_0;
	else
		tmp = d * t_0;
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -6.6e-215], N[(d * (-t$95$0)), $MachinePrecision], N[(d * t$95$0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{\frac{1}{h}}{\ell}}\\
\mathbf{if}\;\ell \leq -6.6 \cdot 10^{-215}:\\
\;\;\;\;d \cdot \left(-t\_0\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -6.5999999999999996e-215

    1. Initial program 62.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified62.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. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. 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. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt36.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-136.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified36.5%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if -6.5999999999999996e-215 < l

    1. Initial program 71.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. Simplified71.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. Taylor expanded in d around inf 35.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*37.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified37.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification36.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -6.6 \cdot 10^{-215}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{h}}{\ell}}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 25: 42.5% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -4 \cdot 10^{-215}:\\ \;\;\;\;\frac{d}{-\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l -4e-215) (/ d (- (sqrt (* h l)))) (* d (sqrt (/ (/ 1.0 h) l)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -4e-215) {
		tmp = d / -sqrt((h * l));
	} else {
		tmp = d * sqrt(((1.0 / h) / l));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= (-4d-215)) then
        tmp = d / -sqrt((h * l))
    else
        tmp = d * sqrt(((1.0d0 / h) / l))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= -4e-215) {
		tmp = d / -Math.sqrt((h * l));
	} else {
		tmp = d * Math.sqrt(((1.0 / h) / l));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= -4e-215:
		tmp = d / -math.sqrt((h * l))
	else:
		tmp = d * math.sqrt(((1.0 / h) / l))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= -4e-215)
		tmp = Float64(d / Float64(-sqrt(Float64(h * l))));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / h) / l)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= -4e-215)
		tmp = d / -sqrt((h * l));
	else
		tmp = d * sqrt(((1.0 / h) / l));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -4e-215], N[(d / (-N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4 \cdot 10^{-215}:\\
\;\;\;\;\frac{d}{-\sqrt{h \cdot \ell}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -4.00000000000000017e-215

    1. Initial program 62.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified62.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-sqrt62.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. pow262.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-prod62.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-pow164.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval64.6%

        \[\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. frac-times63.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*64.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. pow164.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative64.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr64.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/63.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. *-commutative63.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. associate-*r/62.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. associate-*l*61.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    7. Simplified61.3%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Step-by-step derivation
      1. clear-num61.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      2. sqrt-div61.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      3. metadata-eval61.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    9. Applied egg-rr61.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    10. Step-by-step derivation
      1. pow161.9%

        \[\leadsto \color{blue}{{\left(\left(\sqrt{\frac{d}{h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1}} \]
      2. un-div-inv61.8%

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}}} \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1} \]
      3. cancel-sign-sub-inv61.8%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \color{blue}{\left(1 + \left(-0.5\right) \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)}\right)}^{1} \]
      4. metadata-eval61.8%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{-0.5} \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1} \]
      5. associate-*r*62.7%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot {\color{blue}{\left(\left(D \cdot \frac{M}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right)\right)}^{1} \]
      6. unpow-prod-down62.7%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot {\left(\sqrt{\frac{h}{\ell}}\right)}^{2}\right)}\right)\right)}^{1} \]
      7. pow262.7%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \color{blue}{\left(\sqrt{\frac{h}{\ell}} \cdot \sqrt{\frac{h}{\ell}}\right)}\right)\right)\right)}^{1} \]
      8. add-sqr-sqrt62.6%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \color{blue}{\frac{h}{\ell}}\right)\right)\right)}^{1} \]
    11. Applied egg-rr62.6%

      \[\leadsto \color{blue}{{\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}^{1}} \]
    12. Step-by-step derivation
      1. unpow162.6%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
      2. associate-*r*62.6%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}}\right) \]
      3. associate-/r*62.6%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(-0.5 \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    13. Simplified62.6%

      \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(-0.5 \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
    14. Taylor expanded in d around -inf 35.7%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    15. Step-by-step derivation
      1. mul-1-neg35.7%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. unpow1/235.7%

        \[\leadsto -d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      3. rem-exp-log33.8%

        \[\leadsto -d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      4. exp-neg33.9%

        \[\leadsto -d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      5. exp-prod33.8%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      6. distribute-lft-neg-out33.8%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      7. exp-neg33.8%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      8. exp-to-pow35.7%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      9. unpow1/235.7%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      10. associate-/l*35.7%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      11. *-rgt-identity35.7%

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
      12. distribute-neg-frac235.7%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]
    16. Simplified35.7%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if -4.00000000000000017e-215 < l

    1. Initial program 71.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. Simplified71.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. Taylor expanded in d around inf 35.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*37.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified37.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification36.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4 \cdot 10^{-215}:\\ \;\;\;\;\frac{d}{-\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 26: 42.5% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{h \cdot \ell}\\ \mathbf{if}\;\ell \leq -4.2 \cdot 10^{-215}:\\ \;\;\;\;\frac{d}{-t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{t\_0}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (* h l)))) (if (<= l -4.2e-215) (/ d (- t_0)) (/ d t_0))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt((h * l));
	double tmp;
	if (l <= -4.2e-215) {
		tmp = d / -t_0;
	} else {
		tmp = d / t_0;
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((h * l))
    if (l <= (-4.2d-215)) then
        tmp = d / -t_0
    else
        tmp = d / t_0
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = Math.sqrt((h * l));
	double tmp;
	if (l <= -4.2e-215) {
		tmp = d / -t_0;
	} else {
		tmp = d / t_0;
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = math.sqrt((h * l))
	tmp = 0
	if l <= -4.2e-215:
		tmp = d / -t_0
	else:
		tmp = d / t_0
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = sqrt(Float64(h * l))
	tmp = 0.0
	if (l <= -4.2e-215)
		tmp = Float64(d / Float64(-t_0));
	else
		tmp = Float64(d / t_0);
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = sqrt((h * l));
	tmp = 0.0;
	if (l <= -4.2e-215)
		tmp = d / -t_0;
	else
		tmp = d / t_0;
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -4.2e-215], N[(d / (-t$95$0)), $MachinePrecision], N[(d / t$95$0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;\ell \leq -4.2 \cdot 10^{-215}:\\
\;\;\;\;\frac{d}{-t\_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -4.2e-215

    1. Initial program 62.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified62.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-sqrt62.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. pow262.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-prod62.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-pow164.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval64.6%

        \[\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. frac-times63.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*64.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. pow164.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative64.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr64.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/63.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. *-commutative63.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. associate-*r/62.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. associate-*l*61.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    7. Simplified61.3%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Step-by-step derivation
      1. clear-num61.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      2. sqrt-div61.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      3. metadata-eval61.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    9. Applied egg-rr61.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    10. Step-by-step derivation
      1. pow161.9%

        \[\leadsto \color{blue}{{\left(\left(\sqrt{\frac{d}{h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1}} \]
      2. un-div-inv61.8%

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}}} \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1} \]
      3. cancel-sign-sub-inv61.8%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \color{blue}{\left(1 + \left(-0.5\right) \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)}\right)}^{1} \]
      4. metadata-eval61.8%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{-0.5} \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1} \]
      5. associate-*r*62.7%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot {\color{blue}{\left(\left(D \cdot \frac{M}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right)\right)}^{1} \]
      6. unpow-prod-down62.7%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot {\left(\sqrt{\frac{h}{\ell}}\right)}^{2}\right)}\right)\right)}^{1} \]
      7. pow262.7%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \color{blue}{\left(\sqrt{\frac{h}{\ell}} \cdot \sqrt{\frac{h}{\ell}}\right)}\right)\right)\right)}^{1} \]
      8. add-sqr-sqrt62.6%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \color{blue}{\frac{h}{\ell}}\right)\right)\right)}^{1} \]
    11. Applied egg-rr62.6%

      \[\leadsto \color{blue}{{\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}^{1}} \]
    12. Step-by-step derivation
      1. unpow162.6%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
      2. associate-*r*62.6%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}}\right) \]
      3. associate-/r*62.6%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(-0.5 \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    13. Simplified62.6%

      \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(-0.5 \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
    14. Taylor expanded in d around -inf 35.7%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    15. Step-by-step derivation
      1. mul-1-neg35.7%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. unpow1/235.7%

        \[\leadsto -d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      3. rem-exp-log33.8%

        \[\leadsto -d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      4. exp-neg33.9%

        \[\leadsto -d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      5. exp-prod33.8%

        \[\leadsto -d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      6. distribute-lft-neg-out33.8%

        \[\leadsto -d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      7. exp-neg33.8%

        \[\leadsto -d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      8. exp-to-pow35.7%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      9. unpow1/235.7%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      10. associate-/l*35.7%

        \[\leadsto -\color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      11. *-rgt-identity35.7%

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
      12. distribute-neg-frac235.7%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]
    16. Simplified35.7%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if -4.2e-215 < l

    1. Initial program 71.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. Simplified71.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-sqrt71.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. pow271.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-prod71.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-pow172.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval72.9%

        \[\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. frac-times72.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*72.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. pow172.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative72.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr72.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/72.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. *-commutative72.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. associate-*r/71.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. associate-*l*71.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    7. Simplified71.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Step-by-step derivation
      1. clear-num70.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      2. sqrt-div70.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      3. metadata-eval70.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    9. Applied egg-rr70.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    10. Step-by-step derivation
      1. pow170.5%

        \[\leadsto \color{blue}{{\left(\left(\sqrt{\frac{d}{h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1}} \]
      2. un-div-inv70.5%

        \[\leadsto {\left(\color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}}} \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1} \]
      3. cancel-sign-sub-inv70.5%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \color{blue}{\left(1 + \left(-0.5\right) \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)}\right)}^{1} \]
      4. metadata-eval70.5%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{-0.5} \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1} \]
      5. associate-*r*71.1%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot {\color{blue}{\left(\left(D \cdot \frac{M}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right)\right)}^{1} \]
      6. unpow-prod-down69.8%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot {\left(\sqrt{\frac{h}{\ell}}\right)}^{2}\right)}\right)\right)}^{1} \]
      7. pow269.8%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \color{blue}{\left(\sqrt{\frac{h}{\ell}} \cdot \sqrt{\frac{h}{\ell}}\right)}\right)\right)\right)}^{1} \]
      8. add-sqr-sqrt69.8%

        \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \color{blue}{\frac{h}{\ell}}\right)\right)\right)}^{1} \]
    11. Applied egg-rr69.8%

      \[\leadsto \color{blue}{{\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}^{1}} \]
    12. Step-by-step derivation
      1. unpow169.8%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
      2. associate-*r*69.8%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}}\right) \]
      3. associate-/r*70.5%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(-0.5 \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    13. Simplified70.5%

      \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(-0.5 \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
    14. Taylor expanded in d around inf 35.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    15. Step-by-step derivation
      1. unpow1/235.3%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      2. rem-exp-log33.7%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      3. exp-neg33.7%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod33.7%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out33.7%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. exp-neg33.7%

        \[\leadsto d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
      7. exp-to-pow35.4%

        \[\leadsto d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      8. unpow1/235.4%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      9. associate-/l*35.4%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      10. *-rgt-identity35.4%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    16. Simplified35.4%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification35.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.2 \cdot 10^{-215}:\\ \;\;\;\;\frac{d}{-\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 27: 26.7% accurate, 3.2× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \frac{d}{\sqrt{h \cdot \ell}} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (/ d (sqrt (* h l))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d / sqrt((h * l));
}
M_m = abs(m)
D_m = abs(d)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d / sqrt((h * l))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d / Math.sqrt((h * l));
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d / math.sqrt((h * l))
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d / sqrt(Float64(h * l)))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d / sqrt((h * l));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\frac{d}{\sqrt{h \cdot \ell}}
\end{array}
Derivation
  1. Initial program 67.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. Simplified68.0%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. add-sqr-sqrt68.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. pow268.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-prod68.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-pow169.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-eval69.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. frac-times68.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    7. associate-/l*68.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{1} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    8. pow168.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    9. *-commutative68.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
  5. Applied egg-rr68.9%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
  6. Step-by-step derivation
    1. associate-*r/68.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    2. *-commutative68.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    3. associate-*r/67.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    4. associate-*l*67.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
  7. Simplified67.0%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
  8. Step-by-step derivation
    1. clear-num66.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    2. sqrt-div66.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    3. metadata-eval66.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
  9. Applied egg-rr66.8%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
  10. Step-by-step derivation
    1. pow166.8%

      \[\leadsto \color{blue}{{\left(\left(\sqrt{\frac{d}{h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1}} \]
    2. un-div-inv66.8%

      \[\leadsto {\left(\color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}}} \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1} \]
    3. cancel-sign-sub-inv66.8%

      \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \color{blue}{\left(1 + \left(-0.5\right) \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)}\right)}^{1} \]
    4. metadata-eval66.8%

      \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{-0.5} \cdot {\left(D \cdot \left(\frac{M}{d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right)\right)}^{1} \]
    5. associate-*r*67.5%

      \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot {\color{blue}{\left(\left(D \cdot \frac{M}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right)\right)}^{1} \]
    6. unpow-prod-down66.8%

      \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot {\left(\sqrt{\frac{h}{\ell}}\right)}^{2}\right)}\right)\right)}^{1} \]
    7. pow266.8%

      \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \color{blue}{\left(\sqrt{\frac{h}{\ell}} \cdot \sqrt{\frac{h}{\ell}}\right)}\right)\right)\right)}^{1} \]
    8. add-sqr-sqrt66.7%

      \[\leadsto {\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \color{blue}{\frac{h}{\ell}}\right)\right)\right)}^{1} \]
  11. Applied egg-rr66.7%

    \[\leadsto \color{blue}{{\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}^{1}} \]
  12. Step-by-step derivation
    1. unpow166.7%

      \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left({\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    2. associate-*r*66.7%

      \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}}\right) \]
    3. associate-/r*67.1%

      \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(-0.5 \cdot {\left(D \cdot \color{blue}{\frac{\frac{M}{d}}{2}}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  13. Simplified67.1%

    \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(-0.5 \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)} \]
  14. Taylor expanded in d around inf 22.9%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  15. Step-by-step derivation
    1. unpow1/222.9%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    2. rem-exp-log22.0%

      \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
    3. exp-neg22.0%

      \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
    4. exp-prod22.0%

      \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
    5. distribute-lft-neg-out22.0%

      \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
    6. exp-neg22.0%

      \[\leadsto d \cdot \color{blue}{\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}} \]
    7. exp-to-pow22.9%

      \[\leadsto d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
    8. unpow1/222.9%

      \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
    9. associate-/l*22.9%

      \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
    10. *-rgt-identity22.9%

      \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
  16. Simplified22.9%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  17. Final simplification22.9%

    \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
  18. Add Preprocessing

Reproduce

?
herbie shell --seed 2024131 
(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)))))