Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.9% → 82.0%
Time: 24.6s
Alternatives: 20
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 20 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.9% accurate, 1.0× speedup?

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

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

Alternative 1: 82.0% accurate, 0.6× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.7e29

    1. Initial program 80.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. Simplified78.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. associate-*r/80.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.7e29 < d < -3.999999999999988e-310

    1. Initial program 66.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.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
    4. Step-by-step derivation
      1. *-commutative64.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.999999999999988e-310 < d

    1. Initial program 66.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. Simplified66.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-rr72.8%

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

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

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

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

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

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

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

Alternative 2: 81.2% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -6.8000000000000005e30

    1. Initial program 79.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.8000000000000005e30 < d < -3.999999999999988e-310

    1. Initial program 67.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.999999999999988e-310 < d

    1. Initial program 66.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. Simplified66.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-rr72.8%

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

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

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

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

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

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

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

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

Alternative 3: 81.7% accurate, 0.8× speedup?

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

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

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


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

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

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

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

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

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

    if -2.64999999999999986e-233 < d < -3.999999999999988e-310

    1. Initial program 27.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. Simplified27.2%

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

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

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

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

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      2. metadata-eval24.8%

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

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

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{\ell \cdot h}}} \]
      5. div-inv3.0%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{\ell \cdot h}}} \]
      6. sqrt-div3.0%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{\ell \cdot h}}} \]
      7. sqrt-pow119.6%

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

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{\ell \cdot h}} \]
      9. pow119.6%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell \cdot h}} \]
      10. *-commutative19.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(1 + \ell \cdot h\right)} - 1}} \]
      3. associate-+r-40.0%

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

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

        \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{\mathsf{fma}\left(h, \ell, -1\right)}}} \]
      6. metadata-eval40.0%

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

      \[\leadsto \frac{d}{\sqrt{\color{blue}{1 + \mathsf{fma}\left(h, \ell, -1\right)}}} \]
    13. Taylor expanded in h around 0 58.9%

      \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{-1}}} \]

    if -3.999999999999988e-310 < d

    1. Initial program 66.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. Simplified66.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-rr72.8%

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

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

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

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

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

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

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

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

Alternative 4: 78.8% accurate, 0.8× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.8000000000000001e-231 < d < -3.999999999999988e-310

    1. Initial program 27.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. Simplified27.2%

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

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

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

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

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      2. metadata-eval24.8%

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

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

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{\ell \cdot h}}} \]
      5. div-inv3.0%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{\ell \cdot h}}} \]
      6. sqrt-div3.0%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{\ell \cdot h}}} \]
      7. sqrt-pow119.6%

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

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{\ell \cdot h}} \]
      9. pow119.6%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell \cdot h}} \]
      10. *-commutative19.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(1 + \ell \cdot h\right)} - 1}} \]
      3. associate-+r-40.0%

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

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

        \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{\mathsf{fma}\left(h, \ell, -1\right)}}} \]
      6. metadata-eval40.0%

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

      \[\leadsto \frac{d}{\sqrt{\color{blue}{1 + \mathsf{fma}\left(h, \ell, -1\right)}}} \]
    13. Taylor expanded in h around 0 58.9%

      \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{-1}}} \]

    if -3.999999999999988e-310 < d

    1. Initial program 66.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. Simplified66.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-rr72.8%

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

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

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

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

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

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

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

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

Alternative 5: 68.9% accurate, 1.0× speedup?

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

\mathbf{elif}\;\ell \leq 8 \cdot 10^{-272}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \mathsf{fma}\left(h \cdot \frac{{\left(\frac{0.5}{d} \cdot \left(D\_m \cdot M\right)\right)}^{2}}{\ell}, -0.5, 1\right)\\

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

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


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

    1. Initial program 61.4%

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

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

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

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

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

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

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

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

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

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

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

    if -42000 < l < 7.99999999999999944e-272

    1. Initial program 82.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. Simplified79.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
    4. Step-by-step derivation
      1. *-commutative79.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.99999999999999944e-272 < l < 8.20000000000000006e192

    1. Initial program 71.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.20000000000000006e192 < l

    1. Initial program 38.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. Simplified38.1%

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified37.1%

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

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

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
    8. Applied egg-rr65.4%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification74.8%

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

Alternative 6: 75.3% accurate, 1.0× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.15000000000000006e-227 < d < -3.999999999999988e-310

    1. Initial program 27.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. Simplified27.2%

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

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

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

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

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      2. metadata-eval24.8%

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

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

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{\ell \cdot h}}} \]
      5. div-inv3.0%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{\ell \cdot h}}} \]
      6. sqrt-div3.0%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{\ell \cdot h}}} \]
      7. sqrt-pow119.6%

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

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{\ell \cdot h}} \]
      9. pow119.6%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell \cdot h}} \]
      10. *-commutative19.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(1 + \ell \cdot h\right)} - 1}} \]
      3. associate-+r-40.0%

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

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

        \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{\mathsf{fma}\left(h, \ell, -1\right)}}} \]
      6. metadata-eval40.0%

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

      \[\leadsto \frac{d}{\sqrt{\color{blue}{1 + \mathsf{fma}\left(h, \ell, -1\right)}}} \]
    13. Taylor expanded in h around 0 58.9%

      \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{-1}}} \]

    if -3.999999999999988e-310 < d

    1. Initial program 66.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. Simplified66.1%

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

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

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

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

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

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

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

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

Alternative 7: 72.1% accurate, 1.0× speedup?

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

\mathbf{elif}\;\ell \leq 4.8 \cdot 10^{-305}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \mathsf{fma}\left(h \cdot \frac{{\left(\frac{0.5}{d} \cdot \left(D\_m \cdot M\right)\right)}^{2}}{\ell}, -0.5, 1\right)\\

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


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

    1. Initial program 61.4%

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

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

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

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

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

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

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

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

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

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

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

    if -42000 < l < 4.80000000000000039e-305

    1. Initial program 81.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.80000000000000039e-305 < l

    1. Initial program 66.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. Simplified66.1%

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

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

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

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

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

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

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

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

Alternative 8: 70.8% accurate, 1.0× speedup?

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

\mathbf{elif}\;\ell \leq 10^{-307}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \mathsf{fma}\left(h \cdot \frac{t\_0}{\ell}, -0.5, 1\right)\\

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


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

    1. Initial program 61.4%

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

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

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

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

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

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

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

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

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

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

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

    if -42000 < l < 9.99999999999999909e-308

    1. Initial program 81.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999909e-308 < l

    1. Initial program 66.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. Simplified66.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-rr72.8%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 63.8% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -7e14 or -1.21999999999999995e-275 < l < -9.999999999999969e-311

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified9.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. 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}}} \]
    8. 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. unpow-10.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      12. neg-mul-158.3%

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

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

    if -7e14 < l < -1.21999999999999995e-275

    1. Initial program 89.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. Simplified90.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-sqrt89.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. pow289.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-prod89.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-pow192.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-eval92.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-times92.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. pow192.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}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*92.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. *-un-lft-identity92.8%

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \left(\color{blue}{0.5} \cdot \frac{D}{d}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr92.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 \left(0.5 \cdot \frac{D}{d}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. pow192.8%

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

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

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

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

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

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

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

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

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

    if -9.999999999999969e-311 < l < 4.9999999999999997e174

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.5} \cdot d\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 4.9999999999999997e174 < l

    1. Initial program 39.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. Simplified39.2%

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
      2. sqrt-div60.7%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
    8. Applied egg-rr60.7%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification73.3%

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

Alternative 10: 61.2% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;\ell \leq 1.8 \cdot 10^{+175}:\\
\;\;\;\;t\_0 \cdot \left(d \cdot t\_1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -2.69999999999999989e-18 or -6.99999999999999986e-276 < l < -9.999999999999969e-311

    1. Initial program 58.8%

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified9.7%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. 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}}} \]
    8. 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. unpow-10.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      12. neg-mul-160.0%

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

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

    if -2.69999999999999989e-18 < l < -6.99999999999999986e-276

    1. Initial program 90.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. Simplified90.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{\color{blue}{d \cdot d}}{\ell \cdot h}} \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 < l < 1.80000000000000017e175

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.5} \cdot d\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.80000000000000017e175 < l

    1. Initial program 39.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. Simplified39.2%

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
      2. sqrt-div60.7%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
    8. Applied egg-rr60.7%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification67.8%

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

Alternative 11: 60.7% accurate, 1.4× speedup?

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

\mathbf{elif}\;\ell \leq -6.3 \cdot 10^{-276}:\\
\;\;\;\;\frac{d}{\sqrt{0}}\\

\mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -2.7999999999999999e-81 or -6.29999999999999979e-276 < l < -9.999999999999969e-311

    1. Initial program 63.3%

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified8.7%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. 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}}} \]
    8. 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. unpow-10.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      12. neg-mul-156.6%

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

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

    if -2.7999999999999999e-81 < l < -6.29999999999999979e-276

    1. Initial program 91.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. Simplified91.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 26.1%

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

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified26.1%

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

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      2. metadata-eval26.1%

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

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

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{\ell \cdot h}}} \]
      5. div-inv20.3%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{\ell \cdot h}}} \]
      6. sqrt-div20.3%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{\ell \cdot h}}} \]
      7. sqrt-pow124.0%

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

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{\ell \cdot h}} \]
      9. pow124.0%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell \cdot h}} \]
      10. *-commutative24.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    8. Applied egg-rr24.0%

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(1 + \ell \cdot h\right)} - 1}} \]
      3. associate-+r-51.0%

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

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

        \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{\mathsf{fma}\left(h, \ell, -1\right)}}} \]
      6. metadata-eval51.0%

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

      \[\leadsto \frac{d}{\sqrt{\color{blue}{1 + \mathsf{fma}\left(h, \ell, -1\right)}}} \]
    13. Taylor expanded in h around 0 61.5%

      \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{-1}}} \]

    if -9.999999999999969e-311 < l < 1.5000000000000001e175

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.5} \cdot d\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.5000000000000001e175 < l

    1. Initial program 39.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. Simplified39.2%

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
      2. sqrt-div60.7%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
    8. Applied egg-rr60.7%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification65.5%

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

Alternative 12: 60.7% accurate, 1.4× speedup?

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

\mathbf{elif}\;\ell \leq -6.2 \cdot 10^{-276}:\\
\;\;\;\;\frac{d}{\sqrt{0}}\\

\mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -8e-82 or -6.19999999999999978e-276 < l < -9.999999999999969e-311

    1. Initial program 63.3%

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified8.7%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. 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}}} \]
    8. 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. unpow-10.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      12. neg-mul-156.6%

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

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

    if -8e-82 < l < -6.19999999999999978e-276

    1. Initial program 91.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. Simplified91.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 26.1%

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

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified26.1%

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

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      2. metadata-eval26.1%

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

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

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{\ell \cdot h}}} \]
      5. div-inv20.3%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{\ell \cdot h}}} \]
      6. sqrt-div20.3%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{\ell \cdot h}}} \]
      7. sqrt-pow124.0%

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

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{\ell \cdot h}} \]
      9. pow124.0%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell \cdot h}} \]
      10. *-commutative24.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    8. Applied egg-rr24.0%

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(1 + \ell \cdot h\right)} - 1}} \]
      3. associate-+r-51.0%

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

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

        \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{\mathsf{fma}\left(h, \ell, -1\right)}}} \]
      6. metadata-eval51.0%

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

      \[\leadsto \frac{d}{\sqrt{\color{blue}{1 + \mathsf{fma}\left(h, \ell, -1\right)}}} \]
    13. Taylor expanded in h around 0 61.5%

      \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{-1}}} \]

    if -9.999999999999969e-311 < l < 1.3e175

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3e175 < l

    1. Initial program 39.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. Simplified39.2%

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
      2. sqrt-div60.7%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
    8. Applied egg-rr60.7%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification65.4%

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

Alternative 13: 70.6% accurate, 1.4× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

    if -7e-308 < l < 4.8e175

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.5} \cdot d\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 4.8e175 < l

    1. Initial program 39.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. Simplified39.2%

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
      2. sqrt-div60.7%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
    8. Applied egg-rr60.7%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification72.1%

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

Alternative 14: 49.0% accurate, 1.5× speedup?

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

\mathbf{elif}\;\ell \leq -6.2 \cdot 10^{-276}:\\
\;\;\;\;\frac{d}{\sqrt{0}}\\

\mathbf{elif}\;\ell \leq 3.7 \cdot 10^{-284}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -2.8999999999999999e-83 or -6.19999999999999978e-276 < l < 3.7e-284

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified8.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. 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}}} \]
    8. 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. unpow-10.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      12. neg-mul-157.0%

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

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

    if -2.8999999999999999e-83 < l < -6.19999999999999978e-276

    1. Initial program 91.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. Simplified91.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 26.1%

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

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified26.1%

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

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      2. metadata-eval26.1%

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

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

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{\ell \cdot h}}} \]
      5. div-inv20.3%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{\ell \cdot h}}} \]
      6. sqrt-div20.3%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{\ell \cdot h}}} \]
      7. sqrt-pow124.0%

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

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{\ell \cdot h}} \]
      9. pow124.0%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell \cdot h}} \]
      10. *-commutative24.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    8. Applied egg-rr24.0%

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(1 + \ell \cdot h\right)} - 1}} \]
      3. associate-+r-51.0%

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

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

        \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{\mathsf{fma}\left(h, \ell, -1\right)}}} \]
      6. metadata-eval51.0%

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

      \[\leadsto \frac{d}{\sqrt{\color{blue}{1 + \mathsf{fma}\left(h, \ell, -1\right)}}} \]
    13. Taylor expanded in h around 0 61.5%

      \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{-1}}} \]

    if 3.7e-284 < l

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
      2. sqrt-div43.7%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
    8. Applied egg-rr43.7%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification51.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.9 \cdot 10^{-83}:\\ \;\;\;\;d \cdot \left(-{\left(\ell \cdot h\right)}^{-0.5}\right)\\ \mathbf{elif}\;\ell \leq -6.2 \cdot 10^{-276}:\\ \;\;\;\;\frac{d}{\sqrt{0}}\\ \mathbf{elif}\;\ell \leq 3.7 \cdot 10^{-284}:\\ \;\;\;\;d \cdot \left(-{\left(\ell \cdot h\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 48.8% accurate, 1.5× speedup?

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

\mathbf{elif}\;\ell \leq -2.05 \cdot 10^{-274}:\\
\;\;\;\;\frac{d}{\sqrt{0}}\\

\mathbf{elif}\;\ell \leq 3.9 \cdot 10^{-277}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1.5e-79 or -2.04999999999999994e-274 < l < 3.89999999999999987e-277

    1. Initial program 63.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.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 8.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative8.6%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified8.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. 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}}} \]
    8. 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. unpow-10.0%

        \[\leadsto \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. metadata-eval0.0%

        \[\leadsto \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      4. pow-sqr0.0%

        \[\leadsto \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      5. rem-sqrt-square0.0%

        \[\leadsto \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      6. rem-square-sqrt0.0%

        \[\leadsto \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      7. fabs-sqr0.0%

        \[\leadsto \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      8. rem-square-sqrt0.0%

        \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      9. *-commutative0.0%

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      10. unpow20.0%

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      11. rem-square-sqrt57.0%

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      12. neg-mul-157.0%

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \color{blue}{\left(-d\right)} \]
    9. Simplified57.0%

      \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot \left(-d\right)} \]

    if -1.5e-79 < l < -2.04999999999999994e-274

    1. Initial program 91.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. Simplified91.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 26.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative26.1%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified26.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. Step-by-step derivation
      1. pow126.1%

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      2. metadata-eval26.1%

        \[\leadsto {d}^{\color{blue}{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      3. sqrt-pow120.2%

        \[\leadsto \color{blue}{\sqrt{{d}^{2}}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      4. sqrt-prod20.2%

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{\ell \cdot h}}} \]
      5. div-inv20.3%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{\ell \cdot h}}} \]
      6. sqrt-div20.3%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{\ell \cdot h}}} \]
      7. sqrt-pow124.0%

        \[\leadsto \frac{\color{blue}{{d}^{\left(\frac{2}{2}\right)}}}{\sqrt{\ell \cdot h}} \]
      8. metadata-eval24.0%

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{\ell \cdot h}} \]
      9. pow124.0%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell \cdot h}} \]
      10. *-commutative24.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    8. Applied egg-rr24.0%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. expm1-log1p-u24.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(h \cdot \ell\right)\right)}}} \]
      2. expm1-undefine51.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{e^{\mathsf{log1p}\left(h \cdot \ell\right)} - 1}}} \]
      3. *-commutative51.0%

        \[\leadsto \frac{d}{\sqrt{e^{\mathsf{log1p}\left(\color{blue}{\ell \cdot h}\right)} - 1}} \]
    10. Applied egg-rr51.0%

      \[\leadsto \frac{d}{\sqrt{\color{blue}{e^{\mathsf{log1p}\left(\ell \cdot h\right)} - 1}}} \]
    11. Step-by-step derivation
      1. log1p-undefine51.0%

        \[\leadsto \frac{d}{\sqrt{e^{\color{blue}{\log \left(1 + \ell \cdot h\right)}} - 1}} \]
      2. rem-exp-log51.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(1 + \ell \cdot h\right)} - 1}} \]
      3. associate-+r-51.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{1 + \left(\ell \cdot h - 1\right)}}} \]
      4. *-commutative51.0%

        \[\leadsto \frac{d}{\sqrt{1 + \left(\color{blue}{h \cdot \ell} - 1\right)}} \]
      5. fma-neg51.0%

        \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{\mathsf{fma}\left(h, \ell, -1\right)}}} \]
      6. metadata-eval51.0%

        \[\leadsto \frac{d}{\sqrt{1 + \mathsf{fma}\left(h, \ell, \color{blue}{-1}\right)}} \]
    12. Simplified51.0%

      \[\leadsto \frac{d}{\sqrt{\color{blue}{1 + \mathsf{fma}\left(h, \ell, -1\right)}}} \]
    13. Taylor expanded in h around 0 61.5%

      \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{-1}}} \]

    if 3.89999999999999987e-277 < l

    1. Initial program 65.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. Simplified65.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.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative34.8%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified34.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. Step-by-step derivation
      1. pow134.8%

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      2. metadata-eval34.8%

        \[\leadsto {d}^{\color{blue}{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      3. sqrt-pow125.9%

        \[\leadsto \color{blue}{\sqrt{{d}^{2}}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      4. sqrt-prod21.1%

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{\ell \cdot h}}} \]
      5. div-inv21.2%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{\ell \cdot h}}} \]
      6. sqrt-div25.9%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{\ell \cdot h}}} \]
      7. sqrt-pow135.1%

        \[\leadsto \frac{\color{blue}{{d}^{\left(\frac{2}{2}\right)}}}{\sqrt{\ell \cdot h}} \]
      8. metadata-eval35.1%

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{\ell \cdot h}} \]
      9. pow135.1%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell \cdot h}} \]
      10. *-commutative35.1%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    8. Applied egg-rr35.1%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. *-commutative35.1%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      2. sqrt-prod43.6%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    10. Applied egg-rr43.6%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification51.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.5 \cdot 10^{-79}:\\ \;\;\;\;d \cdot \left(-{\left(\ell \cdot h\right)}^{-0.5}\right)\\ \mathbf{elif}\;\ell \leq -2.05 \cdot 10^{-274}:\\ \;\;\;\;\frac{d}{\sqrt{0}}\\ \mathbf{elif}\;\ell \leq 3.9 \cdot 10^{-277}:\\ \;\;\;\;d \cdot \left(-{\left(\ell \cdot h\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 44.9% accurate, 2.7× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} t_0 := d \cdot \left(-{\left(\ell \cdot h\right)}^{-0.5}\right)\\ \mathbf{if}\;\ell \leq -2.45 \cdot 10^{-82}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq -1.68 \cdot 10^{-273}:\\ \;\;\;\;\frac{d}{\sqrt{0}}\\ \mathbf{elif}\;\ell \leq 1.28 \cdot 10^{-270}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (let* ((t_0 (* d (- (pow (* l h) -0.5)))))
   (if (<= l -2.45e-82)
     t_0
     (if (<= l -1.68e-273)
       (/ d (sqrt 0.0))
       (if (<= l 1.28e-270) t_0 (* d (sqrt (/ (/ 1.0 h) l))))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double t_0 = d * -pow((l * h), -0.5);
	double tmp;
	if (l <= -2.45e-82) {
		tmp = t_0;
	} else if (l <= -1.68e-273) {
		tmp = d / sqrt(0.0);
	} else if (l <= 1.28e-270) {
		tmp = t_0;
	} else {
		tmp = d * sqrt(((1.0 / h) / l));
	}
	return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = d * -((l * h) ** (-0.5d0))
    if (l <= (-2.45d-82)) then
        tmp = t_0
    else if (l <= (-1.68d-273)) then
        tmp = d / sqrt(0.0d0)
    else if (l <= 1.28d-270) then
        tmp = t_0
    else
        tmp = d * sqrt(((1.0d0 / h) / l))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double t_0 = d * -Math.pow((l * h), -0.5);
	double tmp;
	if (l <= -2.45e-82) {
		tmp = t_0;
	} else if (l <= -1.68e-273) {
		tmp = d / Math.sqrt(0.0);
	} else if (l <= 1.28e-270) {
		tmp = t_0;
	} else {
		tmp = d * Math.sqrt(((1.0 / h) / l));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	t_0 = d * -math.pow((l * h), -0.5)
	tmp = 0
	if l <= -2.45e-82:
		tmp = t_0
	elif l <= -1.68e-273:
		tmp = d / math.sqrt(0.0)
	elif l <= 1.28e-270:
		tmp = t_0
	else:
		tmp = d * math.sqrt(((1.0 / h) / l))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	t_0 = Float64(d * Float64(-(Float64(l * h) ^ -0.5)))
	tmp = 0.0
	if (l <= -2.45e-82)
		tmp = t_0;
	elseif (l <= -1.68e-273)
		tmp = Float64(d / sqrt(0.0));
	elseif (l <= 1.28e-270)
		tmp = t_0;
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / h) / l)));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	t_0 = d * -((l * h) ^ -0.5);
	tmp = 0.0;
	if (l <= -2.45e-82)
		tmp = t_0;
	elseif (l <= -1.68e-273)
		tmp = d / sqrt(0.0);
	elseif (l <= 1.28e-270)
		tmp = t_0;
	else
		tmp = d * sqrt(((1.0 / h) / l));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(d * (-N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[l, -2.45e-82], t$95$0, If[LessEqual[l, -1.68e-273], N[(d / N[Sqrt[0.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.28e-270], t$95$0, N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := d \cdot \left(-{\left(\ell \cdot h\right)}^{-0.5}\right)\\
\mathbf{if}\;\ell \leq -2.45 \cdot 10^{-82}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;\ell \leq -1.68 \cdot 10^{-273}:\\
\;\;\;\;\frac{d}{\sqrt{0}}\\

\mathbf{elif}\;\ell \leq 1.28 \cdot 10^{-270}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -2.4500000000000001e-82 or -1.67999999999999995e-273 < l < 1.27999999999999991e-270

    1. Initial program 64.5%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.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 8.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative8.4%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified8.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. 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}}} \]
    8. 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. unpow-10.0%

        \[\leadsto \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. metadata-eval0.0%

        \[\leadsto \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      4. pow-sqr0.0%

        \[\leadsto \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      5. rem-sqrt-square0.0%

        \[\leadsto \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      6. rem-square-sqrt0.0%

        \[\leadsto \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      7. fabs-sqr0.0%

        \[\leadsto \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      8. rem-square-sqrt0.0%

        \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      9. *-commutative0.0%

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      10. unpow20.0%

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      11. rem-square-sqrt55.9%

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      12. neg-mul-155.9%

        \[\leadsto {\left(h \cdot \ell\right)}^{-0.5} \cdot \color{blue}{\left(-d\right)} \]
    9. Simplified55.9%

      \[\leadsto \color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot \left(-d\right)} \]

    if -2.4500000000000001e-82 < l < -1.67999999999999995e-273

    1. Initial program 91.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. Simplified91.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 26.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative26.1%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified26.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. Step-by-step derivation
      1. pow126.1%

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      2. metadata-eval26.1%

        \[\leadsto {d}^{\color{blue}{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      3. sqrt-pow120.2%

        \[\leadsto \color{blue}{\sqrt{{d}^{2}}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      4. sqrt-prod20.2%

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{\ell \cdot h}}} \]
      5. div-inv20.3%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{\ell \cdot h}}} \]
      6. sqrt-div20.3%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{\ell \cdot h}}} \]
      7. sqrt-pow124.0%

        \[\leadsto \frac{\color{blue}{{d}^{\left(\frac{2}{2}\right)}}}{\sqrt{\ell \cdot h}} \]
      8. metadata-eval24.0%

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{\ell \cdot h}} \]
      9. pow124.0%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell \cdot h}} \]
      10. *-commutative24.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    8. Applied egg-rr24.0%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. expm1-log1p-u24.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(h \cdot \ell\right)\right)}}} \]
      2. expm1-undefine51.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{e^{\mathsf{log1p}\left(h \cdot \ell\right)} - 1}}} \]
      3. *-commutative51.0%

        \[\leadsto \frac{d}{\sqrt{e^{\mathsf{log1p}\left(\color{blue}{\ell \cdot h}\right)} - 1}} \]
    10. Applied egg-rr51.0%

      \[\leadsto \frac{d}{\sqrt{\color{blue}{e^{\mathsf{log1p}\left(\ell \cdot h\right)} - 1}}} \]
    11. Step-by-step derivation
      1. log1p-undefine51.0%

        \[\leadsto \frac{d}{\sqrt{e^{\color{blue}{\log \left(1 + \ell \cdot h\right)}} - 1}} \]
      2. rem-exp-log51.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(1 + \ell \cdot h\right)} - 1}} \]
      3. associate-+r-51.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{1 + \left(\ell \cdot h - 1\right)}}} \]
      4. *-commutative51.0%

        \[\leadsto \frac{d}{\sqrt{1 + \left(\color{blue}{h \cdot \ell} - 1\right)}} \]
      5. fma-neg51.0%

        \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{\mathsf{fma}\left(h, \ell, -1\right)}}} \]
      6. metadata-eval51.0%

        \[\leadsto \frac{d}{\sqrt{1 + \mathsf{fma}\left(h, \ell, \color{blue}{-1}\right)}} \]
    12. Simplified51.0%

      \[\leadsto \frac{d}{\sqrt{\color{blue}{1 + \mathsf{fma}\left(h, \ell, -1\right)}}} \]
    13. Taylor expanded in h around 0 61.5%

      \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{-1}}} \]

    if 1.27999999999999991e-270 < l

    1. Initial program 65.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified65.2%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 35.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative35.4%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified35.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. Taylor expanded in l around 0 35.4%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/r*36.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    9. Simplified36.1%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification48.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.45 \cdot 10^{-82}:\\ \;\;\;\;d \cdot \left(-{\left(\ell \cdot h\right)}^{-0.5}\right)\\ \mathbf{elif}\;\ell \leq -1.68 \cdot 10^{-273}:\\ \;\;\;\;\frac{d}{\sqrt{0}}\\ \mathbf{elif}\;\ell \leq 1.28 \cdot 10^{-270}:\\ \;\;\;\;d \cdot \left(-{\left(\ell \cdot h\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 29.5% accurate, 3.0× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 6.4 \cdot 10^{-115}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{0}}\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (if (<= M 6.4e-115) (* d (sqrt (/ (/ 1.0 h) l))) (/ d (sqrt 0.0))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (M <= 6.4e-115) {
		tmp = d * sqrt(((1.0 / h) / l));
	} else {
		tmp = d / sqrt(0.0);
	}
	return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (m <= 6.4d-115) then
        tmp = d * sqrt(((1.0d0 / h) / l))
    else
        tmp = d / sqrt(0.0d0)
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (M <= 6.4e-115) {
		tmp = d * Math.sqrt(((1.0 / h) / l));
	} else {
		tmp = d / Math.sqrt(0.0);
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	tmp = 0
	if M <= 6.4e-115:
		tmp = d * math.sqrt(((1.0 / h) / l))
	else:
		tmp = d / math.sqrt(0.0)
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	tmp = 0.0
	if (M <= 6.4e-115)
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / h) / l)));
	else
		tmp = Float64(d / sqrt(0.0));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	tmp = 0.0;
	if (M <= 6.4e-115)
		tmp = d * sqrt(((1.0 / h) / l));
	else
		tmp = d / sqrt(0.0);
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[M, 6.4e-115], N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[Sqrt[0.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 6.4 \cdot 10^{-115}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{0}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 6.4e-115

    1. Initial program 69.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.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 24.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative24.5%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified24.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. Taylor expanded in l around 0 24.5%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/r*25.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    9. Simplified25.0%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}}} \]

    if 6.4e-115 < M

    1. Initial program 70.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. 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. Taylor expanded in d around inf 22.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative22.1%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified22.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. Step-by-step derivation
      1. pow122.1%

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      2. metadata-eval22.1%

        \[\leadsto {d}^{\color{blue}{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      3. sqrt-pow123.9%

        \[\leadsto \color{blue}{\sqrt{{d}^{2}}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      4. sqrt-prod20.1%

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{\ell \cdot h}}} \]
      5. div-inv20.1%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{\ell \cdot h}}} \]
      6. sqrt-div24.0%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{\ell \cdot h}}} \]
      7. sqrt-pow121.2%

        \[\leadsto \frac{\color{blue}{{d}^{\left(\frac{2}{2}\right)}}}{\sqrt{\ell \cdot h}} \]
      8. metadata-eval21.2%

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{\ell \cdot h}} \]
      9. pow121.2%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell \cdot h}} \]
      10. *-commutative21.2%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    8. Applied egg-rr21.2%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. expm1-log1p-u21.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(h \cdot \ell\right)\right)}}} \]
      2. expm1-undefine28.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{e^{\mathsf{log1p}\left(h \cdot \ell\right)} - 1}}} \]
      3. *-commutative28.0%

        \[\leadsto \frac{d}{\sqrt{e^{\mathsf{log1p}\left(\color{blue}{\ell \cdot h}\right)} - 1}} \]
    10. Applied egg-rr28.0%

      \[\leadsto \frac{d}{\sqrt{\color{blue}{e^{\mathsf{log1p}\left(\ell \cdot h\right)} - 1}}} \]
    11. Step-by-step derivation
      1. log1p-undefine28.0%

        \[\leadsto \frac{d}{\sqrt{e^{\color{blue}{\log \left(1 + \ell \cdot h\right)}} - 1}} \]
      2. rem-exp-log28.2%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(1 + \ell \cdot h\right)} - 1}} \]
      3. associate-+r-28.2%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{1 + \left(\ell \cdot h - 1\right)}}} \]
      4. *-commutative28.2%

        \[\leadsto \frac{d}{\sqrt{1 + \left(\color{blue}{h \cdot \ell} - 1\right)}} \]
      5. fma-neg28.2%

        \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{\mathsf{fma}\left(h, \ell, -1\right)}}} \]
      6. metadata-eval28.2%

        \[\leadsto \frac{d}{\sqrt{1 + \mathsf{fma}\left(h, \ell, \color{blue}{-1}\right)}} \]
    12. Simplified28.2%

      \[\leadsto \frac{d}{\sqrt{\color{blue}{1 + \mathsf{fma}\left(h, \ell, -1\right)}}} \]
    13. Taylor expanded in h around 0 31.8%

      \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{-1}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification27.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 6.4 \cdot 10^{-115}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{0}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 29.4% accurate, 3.0× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 2.7 \cdot 10^{-115}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{0}}\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (if (<= M 2.7e-115) (* d (pow (* l h) -0.5)) (/ d (sqrt 0.0))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (M <= 2.7e-115) {
		tmp = d * pow((l * h), -0.5);
	} else {
		tmp = d / sqrt(0.0);
	}
	return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (m <= 2.7d-115) then
        tmp = d * ((l * h) ** (-0.5d0))
    else
        tmp = d / sqrt(0.0d0)
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (M <= 2.7e-115) {
		tmp = d * Math.pow((l * h), -0.5);
	} else {
		tmp = d / Math.sqrt(0.0);
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	tmp = 0
	if M <= 2.7e-115:
		tmp = d * math.pow((l * h), -0.5)
	else:
		tmp = d / math.sqrt(0.0)
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	tmp = 0.0
	if (M <= 2.7e-115)
		tmp = Float64(d * (Float64(l * h) ^ -0.5));
	else
		tmp = Float64(d / sqrt(0.0));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	tmp = 0.0;
	if (M <= 2.7e-115)
		tmp = d * ((l * h) ^ -0.5);
	else
		tmp = d / sqrt(0.0);
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[M, 2.7e-115], N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(d / N[Sqrt[0.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.7 \cdot 10^{-115}:\\
\;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{0}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 2.7e-115

    1. Initial program 69.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.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 24.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative24.5%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified24.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. Taylor expanded in l around 0 24.5%

      \[\leadsto d \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. unpow-124.5%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. metadata-eval24.5%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr24.5%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square24.7%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt24.6%

        \[\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-sqr24.6%

        \[\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-sqrt24.7%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Simplified24.7%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]

    if 2.7e-115 < M

    1. Initial program 70.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. 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. Taylor expanded in d around inf 22.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative22.1%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified22.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. Step-by-step derivation
      1. pow122.1%

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      2. metadata-eval22.1%

        \[\leadsto {d}^{\color{blue}{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      3. sqrt-pow123.9%

        \[\leadsto \color{blue}{\sqrt{{d}^{2}}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      4. sqrt-prod20.1%

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{\ell \cdot h}}} \]
      5. div-inv20.1%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{\ell \cdot h}}} \]
      6. sqrt-div24.0%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{\ell \cdot h}}} \]
      7. sqrt-pow121.2%

        \[\leadsto \frac{\color{blue}{{d}^{\left(\frac{2}{2}\right)}}}{\sqrt{\ell \cdot h}} \]
      8. metadata-eval21.2%

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{\ell \cdot h}} \]
      9. pow121.2%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell \cdot h}} \]
      10. *-commutative21.2%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    8. Applied egg-rr21.2%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. expm1-log1p-u21.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(h \cdot \ell\right)\right)}}} \]
      2. expm1-undefine28.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{e^{\mathsf{log1p}\left(h \cdot \ell\right)} - 1}}} \]
      3. *-commutative28.0%

        \[\leadsto \frac{d}{\sqrt{e^{\mathsf{log1p}\left(\color{blue}{\ell \cdot h}\right)} - 1}} \]
    10. Applied egg-rr28.0%

      \[\leadsto \frac{d}{\sqrt{\color{blue}{e^{\mathsf{log1p}\left(\ell \cdot h\right)} - 1}}} \]
    11. Step-by-step derivation
      1. log1p-undefine28.0%

        \[\leadsto \frac{d}{\sqrt{e^{\color{blue}{\log \left(1 + \ell \cdot h\right)}} - 1}} \]
      2. rem-exp-log28.2%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(1 + \ell \cdot h\right)} - 1}} \]
      3. associate-+r-28.2%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{1 + \left(\ell \cdot h - 1\right)}}} \]
      4. *-commutative28.2%

        \[\leadsto \frac{d}{\sqrt{1 + \left(\color{blue}{h \cdot \ell} - 1\right)}} \]
      5. fma-neg28.2%

        \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{\mathsf{fma}\left(h, \ell, -1\right)}}} \]
      6. metadata-eval28.2%

        \[\leadsto \frac{d}{\sqrt{1 + \mathsf{fma}\left(h, \ell, \color{blue}{-1}\right)}} \]
    12. Simplified28.2%

      \[\leadsto \frac{d}{\sqrt{\color{blue}{1 + \mathsf{fma}\left(h, \ell, -1\right)}}} \]
    13. Taylor expanded in h around 0 31.8%

      \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{-1}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification27.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 2.7 \cdot 10^{-115}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{0}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 29.4% accurate, 3.0× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 2.75 \cdot 10^{-115}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{0}}\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (if (<= M 2.75e-115) (/ d (sqrt (* l h))) (/ d (sqrt 0.0))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (M <= 2.75e-115) {
		tmp = d / sqrt((l * h));
	} else {
		tmp = d / sqrt(0.0);
	}
	return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (m <= 2.75d-115) then
        tmp = d / sqrt((l * h))
    else
        tmp = d / sqrt(0.0d0)
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (M <= 2.75e-115) {
		tmp = d / Math.sqrt((l * h));
	} else {
		tmp = d / Math.sqrt(0.0);
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	tmp = 0
	if M <= 2.75e-115:
		tmp = d / math.sqrt((l * h))
	else:
		tmp = d / math.sqrt(0.0)
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	tmp = 0.0
	if (M <= 2.75e-115)
		tmp = Float64(d / sqrt(Float64(l * h)));
	else
		tmp = Float64(d / sqrt(0.0));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	tmp = 0.0;
	if (M <= 2.75e-115)
		tmp = d / sqrt((l * h));
	else
		tmp = d / sqrt(0.0);
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[M, 2.75e-115], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[Sqrt[0.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.75 \cdot 10^{-115}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{0}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 2.75000000000000014e-115

    1. Initial program 69.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.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 24.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative24.5%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified24.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. Step-by-step derivation
      1. pow124.5%

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      2. metadata-eval24.5%

        \[\leadsto {d}^{\color{blue}{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      3. sqrt-pow132.0%

        \[\leadsto \color{blue}{\sqrt{{d}^{2}}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      4. sqrt-prod28.1%

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{\ell \cdot h}}} \]
      5. div-inv28.6%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{\ell \cdot h}}} \]
      6. sqrt-div32.4%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{\ell \cdot h}}} \]
      7. sqrt-pow124.7%

        \[\leadsto \frac{\color{blue}{{d}^{\left(\frac{2}{2}\right)}}}{\sqrt{\ell \cdot h}} \]
      8. metadata-eval24.7%

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{\ell \cdot h}} \]
      9. pow124.7%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell \cdot h}} \]
      10. *-commutative24.7%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    8. Applied egg-rr24.7%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]

    if 2.75000000000000014e-115 < M

    1. Initial program 70.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. 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. Taylor expanded in d around inf 22.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative22.1%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    6. Simplified22.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    7. Step-by-step derivation
      1. pow122.1%

        \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      2. metadata-eval22.1%

        \[\leadsto {d}^{\color{blue}{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      3. sqrt-pow123.9%

        \[\leadsto \color{blue}{\sqrt{{d}^{2}}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      4. sqrt-prod20.1%

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{\ell \cdot h}}} \]
      5. div-inv20.1%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{\ell \cdot h}}} \]
      6. sqrt-div24.0%

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{\ell \cdot h}}} \]
      7. sqrt-pow121.2%

        \[\leadsto \frac{\color{blue}{{d}^{\left(\frac{2}{2}\right)}}}{\sqrt{\ell \cdot h}} \]
      8. metadata-eval21.2%

        \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{\ell \cdot h}} \]
      9. pow121.2%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell \cdot h}} \]
      10. *-commutative21.2%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
    8. Applied egg-rr21.2%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. expm1-log1p-u21.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(h \cdot \ell\right)\right)}}} \]
      2. expm1-undefine28.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{e^{\mathsf{log1p}\left(h \cdot \ell\right)} - 1}}} \]
      3. *-commutative28.0%

        \[\leadsto \frac{d}{\sqrt{e^{\mathsf{log1p}\left(\color{blue}{\ell \cdot h}\right)} - 1}} \]
    10. Applied egg-rr28.0%

      \[\leadsto \frac{d}{\sqrt{\color{blue}{e^{\mathsf{log1p}\left(\ell \cdot h\right)} - 1}}} \]
    11. Step-by-step derivation
      1. log1p-undefine28.0%

        \[\leadsto \frac{d}{\sqrt{e^{\color{blue}{\log \left(1 + \ell \cdot h\right)}} - 1}} \]
      2. rem-exp-log28.2%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(1 + \ell \cdot h\right)} - 1}} \]
      3. associate-+r-28.2%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{1 + \left(\ell \cdot h - 1\right)}}} \]
      4. *-commutative28.2%

        \[\leadsto \frac{d}{\sqrt{1 + \left(\color{blue}{h \cdot \ell} - 1\right)}} \]
      5. fma-neg28.2%

        \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{\mathsf{fma}\left(h, \ell, -1\right)}}} \]
      6. metadata-eval28.2%

        \[\leadsto \frac{d}{\sqrt{1 + \mathsf{fma}\left(h, \ell, \color{blue}{-1}\right)}} \]
    12. Simplified28.2%

      \[\leadsto \frac{d}{\sqrt{\color{blue}{1 + \mathsf{fma}\left(h, \ell, -1\right)}}} \]
    13. Taylor expanded in h around 0 31.8%

      \[\leadsto \frac{d}{\sqrt{1 + \color{blue}{-1}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification27.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 2.75 \cdot 10^{-115}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{0}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 26.5% accurate, 3.2× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \frac{d}{\sqrt{\ell \cdot h}} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m) :precision binary64 (/ d (sqrt (* l h))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	return d / sqrt((l * h));
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_m
    code = d / sqrt((l * h))
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	return d / Math.sqrt((l * h));
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	return d / math.sqrt((l * h))
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	return Float64(d / sqrt(Float64(l * h)))
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp = code(d, h, l, M, D_m)
	tmp = d / sqrt((l * h));
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Derivation
  1. Initial program 69.6%

    \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  2. Simplified69.3%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in d around inf 23.6%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  5. Step-by-step derivation
    1. *-commutative23.6%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
  6. Simplified23.6%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
  7. Step-by-step derivation
    1. pow123.6%

      \[\leadsto \color{blue}{{d}^{1}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
    2. metadata-eval23.6%

      \[\leadsto {d}^{\color{blue}{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
    3. sqrt-pow129.0%

      \[\leadsto \color{blue}{\sqrt{{d}^{2}}} \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
    4. sqrt-prod25.1%

      \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{1}{\ell \cdot h}}} \]
    5. div-inv25.4%

      \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{\ell \cdot h}}} \]
    6. sqrt-div29.2%

      \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{\ell \cdot h}}} \]
    7. sqrt-pow123.3%

      \[\leadsto \frac{\color{blue}{{d}^{\left(\frac{2}{2}\right)}}}{\sqrt{\ell \cdot h}} \]
    8. metadata-eval23.3%

      \[\leadsto \frac{{d}^{\color{blue}{1}}}{\sqrt{\ell \cdot h}} \]
    9. pow123.3%

      \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell \cdot h}} \]
    10. *-commutative23.3%

      \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
  8. Applied egg-rr23.3%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  9. Final simplification23.3%

    \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
  10. Add Preprocessing

Reproduce

?
herbie shell --seed 2024135 
(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)))))