Henrywood and Agarwal, Equation (12)

Percentage Accurate: 65.9% → 78.9%
Time: 28.1s
Alternatives: 20
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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: 65.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: 78.9% 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.2 \cdot 10^{-113}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D_m}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}}{\ell}\right)\\ \mathbf{elif}\;d \leq -1.06 \cdot 10^{-306}:\\ \;\;\;\;\left(\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \mathsf{fma}\left(-0.5, {\left(\left(\left(M \cdot D_m\right) \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D_m}{d} \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{h} \cdot \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
 (if (<= d -2.2e-113)
   (*
    (* (sqrt (/ d h)) (/ (sqrt (- d)) (sqrt (- l))))
    (- 1.0 (* 0.5 (/ (* h (pow (* (/ D_m d) (* M 0.5)) 2.0)) l))))
   (if (<= d -1.06e-306)
     (*
      (* (- d) (sqrt (/ (/ 1.0 h) l)))
      (fma -0.5 (pow (* (* (* M D_m) (/ 0.5 d)) (sqrt (/ h l))) 2.0) 1.0))
     (*
      (- 1.0 (* 0.5 (* (/ h l) (pow (* M (* (/ D_m d) 0.5)) 2.0))))
      (/ 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 tmp;
	if (d <= -2.2e-113) {
		tmp = (sqrt((d / h)) * (sqrt(-d) / sqrt(-l))) * (1.0 - (0.5 * ((h * pow(((D_m / d) * (M * 0.5)), 2.0)) / l)));
	} else if (d <= -1.06e-306) {
		tmp = (-d * sqrt(((1.0 / h) / l))) * fma(-0.5, pow((((M * D_m) * (0.5 / d)) * sqrt((h / l))), 2.0), 1.0);
	} else {
		tmp = (1.0 - (0.5 * ((h / l) * pow((M * ((D_m / d) * 0.5)), 2.0)))) * (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)
	tmp = 0.0
	if (d <= -2.2e-113)
		tmp = Float64(Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-l)))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(D_m / d) * Float64(M * 0.5)) ^ 2.0)) / l))));
	elseif (d <= -1.06e-306)
		tmp = Float64(Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l))) * fma(-0.5, (Float64(Float64(Float64(M * D_m) * Float64(0.5 / d)) * sqrt(Float64(h / l))) ^ 2.0), 1.0));
	else
		tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(M * Float64(Float64(D_m / d) * 0.5)) ^ 2.0)))) * Float64(d / Float64(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_] := If[LessEqual[d, -2.2e-113], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.06e-306], N[(N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(N[(M * D$95$m), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(N[(D$95$m / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.2 \cdot 10^{-113}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D_m}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}}{\ell}\right)\\

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

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


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

    1. Initial program 72.2%

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

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

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

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

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

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

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

    if -2.20000000000000004e-113 < d < -1.06e-306

    1. Initial program 43.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. Simplified43.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.06e-306 < d

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.2 \cdot 10^{-113}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}}{\ell}\right)\\ \mathbf{elif}\;d \leq -1.06 \cdot 10^{-306}:\\ \;\;\;\;\left(\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \mathsf{fma}\left(-0.5, {\left(\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

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

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


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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{-d}}{\sqrt{-h}}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right) \]
    4. Applied egg-rr73.9%

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

    if -4.999999999999985e-310 < h

    1. Initial program 60.3%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 77.6% accurate, 0.8× speedup?

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

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


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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 60.3%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 77.3% 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}\;h \leq -2.9 \cdot 10^{+195}:\\ \;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D_m}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}}{\ell}\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)\\ \mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left(\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \mathsf{fma}\left(-0.5, {\left(\left(\left(M \cdot D_m\right) \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D_m}{d} \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{h} \cdot \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
 (if (<= h -2.9e+195)
   (*
    (- 1.0 (* 0.5 (/ (* h (pow (* (/ D_m d) (* M 0.5)) 2.0)) l)))
    (* (sqrt (/ d l)) (sqrt (/ d h))))
   (if (<= h -5e-310)
     (*
      (* (- d) (sqrt (/ (/ 1.0 h) l)))
      (fma -0.5 (pow (* (* (* M D_m) (/ 0.5 d)) (sqrt (/ h l))) 2.0) 1.0))
     (*
      (- 1.0 (* 0.5 (* (/ h l) (pow (* M (* (/ D_m d) 0.5)) 2.0))))
      (/ 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 tmp;
	if (h <= -2.9e+195) {
		tmp = (1.0 - (0.5 * ((h * pow(((D_m / d) * (M * 0.5)), 2.0)) / l))) * (sqrt((d / l)) * sqrt((d / h)));
	} else if (h <= -5e-310) {
		tmp = (-d * sqrt(((1.0 / h) / l))) * fma(-0.5, pow((((M * D_m) * (0.5 / d)) * sqrt((h / l))), 2.0), 1.0);
	} else {
		tmp = (1.0 - (0.5 * ((h / l) * pow((M * ((D_m / d) * 0.5)), 2.0)))) * (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)
	tmp = 0.0
	if (h <= -2.9e+195)
		tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(D_m / d) * Float64(M * 0.5)) ^ 2.0)) / l))) * Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))));
	elseif (h <= -5e-310)
		tmp = Float64(Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l))) * fma(-0.5, (Float64(Float64(Float64(M * D_m) * Float64(0.5 / d)) * sqrt(Float64(h / l))) ^ 2.0), 1.0));
	else
		tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(M * Float64(Float64(D_m / d) * 0.5)) ^ 2.0)))) * Float64(d / Float64(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_] := If[LessEqual[h, -2.9e+195], N[(N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -5e-310], N[(N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(N[(M * D$95$m), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(N[(D$95$m / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -2.9 \cdot 10^{+195}:\\
\;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D_m}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}}{\ell}\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)\\

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

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


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

    1. Initial program 50.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. Simplified50.2%

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

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

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

    if -2.89999999999999992e195 < h < -4.999999999999985e-310

    1. Initial program 63.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 60.3%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 75.4% 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}\;h \leq -5.8 \cdot 10^{+224}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{h}}{\ell}} \cdot \left(1 + -0.5 \cdot \left(h \cdot \frac{{\left(\frac{D_m \cdot 0.5}{\frac{d}{M}}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left(\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot {\left(D_m \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D_m}{d} \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{h} \cdot \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
 (if (<= h -5.8e+224)
   (*
    (sqrt (/ (* d (/ d h)) l))
    (+ 1.0 (* -0.5 (* h (/ (pow (/ (* D_m 0.5) (/ d M)) 2.0) l)))))
   (if (<= h -5e-310)
     (*
      (* (- d) (sqrt (/ (/ 1.0 h) l)))
      (fma -0.5 (* (/ h l) (pow (* D_m (* M (/ 0.5 d))) 2.0)) 1.0))
     (*
      (- 1.0 (* 0.5 (* (/ h l) (pow (* M (* (/ D_m d) 0.5)) 2.0))))
      (/ 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 tmp;
	if (h <= -5.8e+224) {
		tmp = sqrt(((d * (d / h)) / l)) * (1.0 + (-0.5 * (h * (pow(((D_m * 0.5) / (d / M)), 2.0) / l))));
	} else if (h <= -5e-310) {
		tmp = (-d * sqrt(((1.0 / h) / l))) * fma(-0.5, ((h / l) * pow((D_m * (M * (0.5 / d))), 2.0)), 1.0);
	} else {
		tmp = (1.0 - (0.5 * ((h / l) * pow((M * ((D_m / d) * 0.5)), 2.0)))) * (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)
	tmp = 0.0
	if (h <= -5.8e+224)
		tmp = Float64(sqrt(Float64(Float64(d * Float64(d / h)) / l)) * Float64(1.0 + Float64(-0.5 * Float64(h * Float64((Float64(Float64(D_m * 0.5) / Float64(d / M)) ^ 2.0) / l)))));
	elseif (h <= -5e-310)
		tmp = Float64(Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l))) * fma(-0.5, Float64(Float64(h / l) * (Float64(D_m * Float64(M * Float64(0.5 / d))) ^ 2.0)), 1.0));
	else
		tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(M * Float64(Float64(D_m / d) * 0.5)) ^ 2.0)))) * Float64(d / Float64(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_] := If[LessEqual[h, -5.8e+224], N[(N[Sqrt[N[(N[(d * N[(d / h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(h * N[(N[Power[N[(N[(D$95$m * 0.5), $MachinePrecision] / N[(d / M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -5e-310], N[(N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(D$95$m * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(N[(D$95$m / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -5.8 \cdot 10^{+224}:\\
\;\;\;\;\sqrt{\frac{d \cdot \frac{d}{h}}{\ell}} \cdot \left(1 + -0.5 \cdot \left(h \cdot \frac{{\left(\frac{D_m \cdot 0.5}{\frac{d}{M}}\right)}^{2}}{\ell}\right)\right)\\

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

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


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

    1. Initial program 50.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. Simplified50.4%

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

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

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

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

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

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

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

    if -5.79999999999999978e224 < h < -4.999999999999985e-310

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 60.3%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 76.3% accurate, 1.0× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} t_0 := {\left(D_m \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}\\ \mathbf{if}\;d \leq -1.4 \cdot 10^{-110}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot t_0}{\ell}\right)\\ \mathbf{elif}\;d \leq -1.06 \cdot 10^{-306}:\\ \;\;\;\;\left(\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot t_0, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D_m}{d} \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{h} \cdot \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 (* D_m (* M (/ 0.5 d))) 2.0)))
   (if (<= d -1.4e-110)
     (* (* (sqrt (/ d l)) (sqrt (/ d h))) (- 1.0 (* 0.5 (/ (* h t_0) l))))
     (if (<= d -1.06e-306)
       (* (* (- d) (sqrt (/ (/ 1.0 h) l))) (fma -0.5 (* (/ h l) t_0) 1.0))
       (*
        (- 1.0 (* 0.5 (* (/ h l) (pow (* M (* (/ D_m d) 0.5)) 2.0))))
        (/ 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((D_m * (M * (0.5 / d))), 2.0);
	double tmp;
	if (d <= -1.4e-110) {
		tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * ((h * t_0) / l)));
	} else if (d <= -1.06e-306) {
		tmp = (-d * sqrt(((1.0 / h) / l))) * fma(-0.5, ((h / l) * t_0), 1.0);
	} else {
		tmp = (1.0 - (0.5 * ((h / l) * pow((M * ((D_m / d) * 0.5)), 2.0)))) * (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(D_m * Float64(M * Float64(0.5 / d))) ^ 2.0
	tmp = 0.0
	if (d <= -1.4e-110)
		tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * t_0) / l))));
	elseif (d <= -1.06e-306)
		tmp = Float64(Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l))) * fma(-0.5, Float64(Float64(h / l) * t_0), 1.0));
	else
		tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(M * Float64(Float64(D_m / d) * 0.5)) ^ 2.0)))) * Float64(d / Float64(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[(D$95$m * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[d, -1.4e-110], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * t$95$0), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.06e-306], N[(N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.5 * N[(N[(h / l), $MachinePrecision] * t$95$0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(N[(D$95$m / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := {\left(D_m \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}\\
\mathbf{if}\;d \leq -1.4 \cdot 10^{-110}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot t_0}{\ell}\right)\\

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

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


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

    1. Initial program 72.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.4e-110 < d < -1.06e-306

    1. Initial program 43.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. Simplified43.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.06e-306 < d

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.4 \cdot 10^{-110}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}\right)\\ \mathbf{elif}\;d \leq -1.06 \cdot 10^{-306}:\\ \;\;\;\;\left(\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot {\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 7: 76.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 -2.8 \cdot 10^{-111}:\\ \;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D_m}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}}{\ell}\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)\\ \mathbf{elif}\;d \leq -1.06 \cdot 10^{-306}:\\ \;\;\;\;\left(\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot {\left(D_m \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D_m}{d} \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{h} \cdot \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
 (if (<= d -2.8e-111)
   (*
    (- 1.0 (* 0.5 (/ (* h (pow (* (/ D_m d) (* M 0.5)) 2.0)) l)))
    (* (sqrt (/ d l)) (sqrt (/ d h))))
   (if (<= d -1.06e-306)
     (*
      (* (- d) (sqrt (/ (/ 1.0 h) l)))
      (fma -0.5 (* (/ h l) (pow (* D_m (* M (/ 0.5 d))) 2.0)) 1.0))
     (*
      (- 1.0 (* 0.5 (* (/ h l) (pow (* M (* (/ D_m d) 0.5)) 2.0))))
      (/ 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 tmp;
	if (d <= -2.8e-111) {
		tmp = (1.0 - (0.5 * ((h * pow(((D_m / d) * (M * 0.5)), 2.0)) / l))) * (sqrt((d / l)) * sqrt((d / h)));
	} else if (d <= -1.06e-306) {
		tmp = (-d * sqrt(((1.0 / h) / l))) * fma(-0.5, ((h / l) * pow((D_m * (M * (0.5 / d))), 2.0)), 1.0);
	} else {
		tmp = (1.0 - (0.5 * ((h / l) * pow((M * ((D_m / d) * 0.5)), 2.0)))) * (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)
	tmp = 0.0
	if (d <= -2.8e-111)
		tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(D_m / d) * Float64(M * 0.5)) ^ 2.0)) / l))) * Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))));
	elseif (d <= -1.06e-306)
		tmp = Float64(Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l))) * fma(-0.5, Float64(Float64(h / l) * (Float64(D_m * Float64(M * Float64(0.5 / d))) ^ 2.0)), 1.0));
	else
		tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(M * Float64(Float64(D_m / d) * 0.5)) ^ 2.0)))) * Float64(d / Float64(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_] := If[LessEqual[d, -2.8e-111], N[(N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.06e-306], N[(N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(D$95$m * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(N[(D$95$m / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.8 \cdot 10^{-111}:\\
\;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D_m}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}}{\ell}\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)\\

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

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


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

    1. Initial program 72.2%

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

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

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

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

    if -2.79999999999999995e-111 < d < -1.06e-306

    1. Initial program 43.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. Simplified43.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.06e-306 < d

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.8 \cdot 10^{-111}:\\ \;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}}{\ell}\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)\\ \mathbf{elif}\;d \leq -1.06 \cdot 10^{-306}:\\ \;\;\;\;\left(\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot {\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 8: 66.7% accurate, 1.0× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1.16 \cdot 10^{+14}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq 6.5 \cdot 10^{-200}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \mathsf{fma}\left(-0.5, h \cdot \frac{{\left(\frac{M}{\frac{\frac{d}{D_m}}{0.5}}\right)}^{2}}{\ell}, 1\right)\\ \mathbf{elif}\;\ell \leq 6.2 \cdot 10^{+132}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \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
 (if (<= l -1.16e+14)
   (* (/ (sqrt (- d)) (sqrt (- h))) (sqrt (/ d l)))
   (if (<= l 6.5e-200)
     (*
      (sqrt (* (/ d l) (/ d h)))
      (fma -0.5 (* h (/ (pow (/ M (/ (/ d D_m) 0.5)) 2.0) l)) 1.0))
     (if (<= l 6.2e+132)
       (*
        (/ d (sqrt (* h l)))
        (+ 1.0 (* -0.125 (* (/ h l) (pow (* M (/ D_m d)) 2.0)))))
       (/ 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 tmp;
	if (l <= -1.16e+14) {
		tmp = (sqrt(-d) / sqrt(-h)) * sqrt((d / l));
	} else if (l <= 6.5e-200) {
		tmp = sqrt(((d / l) * (d / h))) * fma(-0.5, (h * (pow((M / ((d / D_m) / 0.5)), 2.0) / l)), 1.0);
	} else if (l <= 6.2e+132) {
		tmp = (d / sqrt((h * l))) * (1.0 + (-0.125 * ((h / l) * pow((M * (D_m / d)), 2.0))));
	} else {
		tmp = 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)
	tmp = 0.0
	if (l <= -1.16e+14)
		tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * sqrt(Float64(d / l)));
	elseif (l <= 6.5e-200)
		tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * fma(-0.5, Float64(h * Float64((Float64(M / Float64(Float64(d / D_m) / 0.5)) ^ 2.0) / l)), 1.0));
	elseif (l <= 6.2e+132)
		tmp = Float64(Float64(d / sqrt(Float64(h * l))) * Float64(1.0 + Float64(-0.125 * Float64(Float64(h / l) * (Float64(M * Float64(D_m / d)) ^ 2.0)))));
	else
		tmp = Float64(d / Float64(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_] := If[LessEqual[l, -1.16e+14], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6.5e-200], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-0.5 * N[(h * N[(N[Power[N[(M / N[(N[(d / D$95$m), $MachinePrecision] / 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6.2e+132], N[(N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $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}
\mathbf{if}\;\ell \leq -1.16 \cdot 10^{+14}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\\

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

\mathbf{elif}\;\ell \leq 6.2 \cdot 10^{+132}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\\

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


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

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

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

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

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

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

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

    if -1.16e14 < l < 6.5000000000000002e-200

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.5000000000000002e-200 < l < 6.1999999999999995e132

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.1999999999999995e132 < l

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    4. Step-by-step derivation
      1. *-rgt-identity41.5%

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      3. expm1-log1p-u37.4%

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
      8. add-sqr-sqrt28.6%

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

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

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Simplified46.5%

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

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      2. sqrt-prod64.9%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    9. Applied egg-rr64.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.16 \cdot 10^{+14}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq 6.5 \cdot 10^{-200}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \mathsf{fma}\left(-0.5, h \cdot \frac{{\left(\frac{M}{\frac{\frac{d}{D}}{0.5}}\right)}^{2}}{\ell}, 1\right)\\ \mathbf{elif}\;\ell \leq 6.2 \cdot 10^{+132}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 9: 67.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} \mathbf{if}\;\ell \leq -1900000000000:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq 6.5 \cdot 10^{-200}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \mathsf{fma}\left(-0.5, \frac{h \cdot {\left(\left(M \cdot D_m\right) \cdot \frac{0.5}{d}\right)}^{2}}{\ell}, 1\right)\\ \mathbf{elif}\;\ell \leq 1.6 \cdot 10^{+137}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \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
 (if (<= l -1900000000000.0)
   (* (/ (sqrt (- d)) (sqrt (- h))) (sqrt (/ d l)))
   (if (<= l 6.5e-200)
     (*
      (sqrt (* (/ d l) (/ d h)))
      (fma -0.5 (/ (* h (pow (* (* M D_m) (/ 0.5 d)) 2.0)) l) 1.0))
     (if (<= l 1.6e+137)
       (*
        (/ d (sqrt (* h l)))
        (+ 1.0 (* -0.125 (* (/ h l) (pow (* M (/ D_m d)) 2.0)))))
       (/ 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 tmp;
	if (l <= -1900000000000.0) {
		tmp = (sqrt(-d) / sqrt(-h)) * sqrt((d / l));
	} else if (l <= 6.5e-200) {
		tmp = sqrt(((d / l) * (d / h))) * fma(-0.5, ((h * pow(((M * D_m) * (0.5 / d)), 2.0)) / l), 1.0);
	} else if (l <= 1.6e+137) {
		tmp = (d / sqrt((h * l))) * (1.0 + (-0.125 * ((h / l) * pow((M * (D_m / d)), 2.0))));
	} else {
		tmp = 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)
	tmp = 0.0
	if (l <= -1900000000000.0)
		tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * sqrt(Float64(d / l)));
	elseif (l <= 6.5e-200)
		tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * fma(-0.5, Float64(Float64(h * (Float64(Float64(M * D_m) * Float64(0.5 / d)) ^ 2.0)) / l), 1.0));
	elseif (l <= 1.6e+137)
		tmp = Float64(Float64(d / sqrt(Float64(h * l))) * Float64(1.0 + Float64(-0.125 * Float64(Float64(h / l) * (Float64(M * Float64(D_m / d)) ^ 2.0)))));
	else
		tmp = Float64(d / Float64(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_] := If[LessEqual[l, -1900000000000.0], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6.5e-200], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-0.5 * N[(N[(h * N[Power[N[(N[(M * D$95$m), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.6e+137], N[(N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $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}
\mathbf{if}\;\ell \leq -1900000000000:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\\

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

\mathbf{elif}\;\ell \leq 1.6 \cdot 10^{+137}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\\

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


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

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

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

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

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

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

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

    if -1.9e12 < l < 6.5000000000000002e-200

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.5000000000000002e-200 < l < 1.60000000000000009e137

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.60000000000000009e137 < l

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    4. Step-by-step derivation
      1. *-rgt-identity41.5%

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      3. expm1-log1p-u37.4%

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
      8. add-sqr-sqrt28.6%

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

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

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Simplified46.5%

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

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      2. sqrt-prod64.9%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    9. Applied egg-rr64.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1900000000000:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq 6.5 \cdot 10^{-200}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \mathsf{fma}\left(-0.5, \frac{h \cdot {\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}^{2}}{\ell}, 1\right)\\ \mathbf{elif}\;\ell \leq 1.6 \cdot 10^{+137}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 10: 70.6% accurate, 1.0× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -3.2 \cdot 10^{+14}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq 2.7 \cdot 10^{-304}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \mathsf{fma}\left(-0.5, \frac{h \cdot {\left(\left(M \cdot D_m\right) \cdot \frac{0.5}{d}\right)}^{2}}{\ell}, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D_m}{d} \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{h} \cdot \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
 (if (<= l -3.2e+14)
   (* (/ (sqrt (- d)) (sqrt (- h))) (sqrt (/ d l)))
   (if (<= l 2.7e-304)
     (*
      (sqrt (* (/ d l) (/ d h)))
      (fma -0.5 (/ (* h (pow (* (* M D_m) (/ 0.5 d)) 2.0)) l) 1.0))
     (*
      (- 1.0 (* 0.5 (* (/ h l) (pow (* M (* (/ D_m d) 0.5)) 2.0))))
      (/ 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 tmp;
	if (l <= -3.2e+14) {
		tmp = (sqrt(-d) / sqrt(-h)) * sqrt((d / l));
	} else if (l <= 2.7e-304) {
		tmp = sqrt(((d / l) * (d / h))) * fma(-0.5, ((h * pow(((M * D_m) * (0.5 / d)), 2.0)) / l), 1.0);
	} else {
		tmp = (1.0 - (0.5 * ((h / l) * pow((M * ((D_m / d) * 0.5)), 2.0)))) * (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)
	tmp = 0.0
	if (l <= -3.2e+14)
		tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * sqrt(Float64(d / l)));
	elseif (l <= 2.7e-304)
		tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * fma(-0.5, Float64(Float64(h * (Float64(Float64(M * D_m) * Float64(0.5 / d)) ^ 2.0)) / l), 1.0));
	else
		tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(M * Float64(Float64(D_m / d) * 0.5)) ^ 2.0)))) * Float64(d / Float64(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_] := If[LessEqual[l, -3.2e+14], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.7e-304], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-0.5 * N[(N[(h * N[Power[N[(N[(M * D$95$m), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(N[(D$95$m / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.2 \cdot 10^{+14}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\\

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

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


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

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

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

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

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

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

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

    if -3.2e14 < l < 2.7000000000000001e-304

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.7000000000000001e-304 < l

    1. Initial program 60.1%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.2 \cdot 10^{+14}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq 2.7 \cdot 10^{-304}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \mathsf{fma}\left(-0.5, \frac{h \cdot {\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}^{2}}{\ell}, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 11: 64.5% accurate, 1.1× 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{h \cdot \ell}\\ \mathbf{if}\;\ell \leq -1 \cdot 10^{+196}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\\ \mathbf{elif}\;\ell \leq -5.5 \cdot 10^{+58}:\\ \;\;\;\;\frac{d}{-t_0}\\ \mathbf{elif}\;\ell \leq 5.5 \cdot 10^{-303}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{h}}{\ell}} \cdot \left(1 + -0.5 \cdot \left(h \cdot \frac{{\left(\frac{D_m \cdot 0.5}{\frac{d}{M}}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+132}:\\ \;\;\;\;\frac{d}{t_0} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \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 (sqrt (* h l))))
   (if (<= l -1e+196)
     (* (sqrt (/ d h)) (/ (sqrt (- d)) (sqrt (- l))))
     (if (<= l -5.5e+58)
       (/ d (- t_0))
       (if (<= l 5.5e-303)
         (*
          (sqrt (/ (* d (/ d h)) l))
          (+ 1.0 (* -0.5 (* h (/ (pow (/ (* D_m 0.5) (/ d M)) 2.0) l)))))
         (if (<= l 2.4e+132)
           (*
            (/ d t_0)
            (+ 1.0 (* -0.125 (* (/ h l) (pow (* M (/ D_m d)) 2.0)))))
           (/ 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 = sqrt((h * l));
	double tmp;
	if (l <= -1e+196) {
		tmp = sqrt((d / h)) * (sqrt(-d) / sqrt(-l));
	} else if (l <= -5.5e+58) {
		tmp = d / -t_0;
	} else if (l <= 5.5e-303) {
		tmp = sqrt(((d * (d / h)) / l)) * (1.0 + (-0.5 * (h * (pow(((D_m * 0.5) / (d / M)), 2.0) / l))));
	} else if (l <= 2.4e+132) {
		tmp = (d / t_0) * (1.0 + (-0.125 * ((h / l) * pow((M * (D_m / d)), 2.0))));
	} else {
		tmp = d / (sqrt(h) * sqrt(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 = sqrt((h * l))
    if (l <= (-1d+196)) then
        tmp = sqrt((d / h)) * (sqrt(-d) / sqrt(-l))
    else if (l <= (-5.5d+58)) then
        tmp = d / -t_0
    else if (l <= 5.5d-303) then
        tmp = sqrt(((d * (d / h)) / l)) * (1.0d0 + ((-0.5d0) * (h * ((((d_m * 0.5d0) / (d / m)) ** 2.0d0) / l))))
    else if (l <= 2.4d+132) then
        tmp = (d / t_0) * (1.0d0 + ((-0.125d0) * ((h / l) * ((m * (d_m / d)) ** 2.0d0))))
    else
        tmp = d / (sqrt(h) * sqrt(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 = Math.sqrt((h * l));
	double tmp;
	if (l <= -1e+196) {
		tmp = Math.sqrt((d / h)) * (Math.sqrt(-d) / Math.sqrt(-l));
	} else if (l <= -5.5e+58) {
		tmp = d / -t_0;
	} else if (l <= 5.5e-303) {
		tmp = Math.sqrt(((d * (d / h)) / l)) * (1.0 + (-0.5 * (h * (Math.pow(((D_m * 0.5) / (d / M)), 2.0) / l))));
	} else if (l <= 2.4e+132) {
		tmp = (d / t_0) * (1.0 + (-0.125 * ((h / l) * Math.pow((M * (D_m / d)), 2.0))));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(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 = math.sqrt((h * l))
	tmp = 0
	if l <= -1e+196:
		tmp = math.sqrt((d / h)) * (math.sqrt(-d) / math.sqrt(-l))
	elif l <= -5.5e+58:
		tmp = d / -t_0
	elif l <= 5.5e-303:
		tmp = math.sqrt(((d * (d / h)) / l)) * (1.0 + (-0.5 * (h * (math.pow(((D_m * 0.5) / (d / M)), 2.0) / l))))
	elif l <= 2.4e+132:
		tmp = (d / t_0) * (1.0 + (-0.125 * ((h / l) * math.pow((M * (D_m / d)), 2.0))))
	else:
		tmp = d / (math.sqrt(h) * math.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 = sqrt(Float64(h * l))
	tmp = 0.0
	if (l <= -1e+196)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-l))));
	elseif (l <= -5.5e+58)
		tmp = Float64(d / Float64(-t_0));
	elseif (l <= 5.5e-303)
		tmp = Float64(sqrt(Float64(Float64(d * Float64(d / h)) / l)) * Float64(1.0 + Float64(-0.5 * Float64(h * Float64((Float64(Float64(D_m * 0.5) / Float64(d / M)) ^ 2.0) / l)))));
	elseif (l <= 2.4e+132)
		tmp = Float64(Float64(d / t_0) * Float64(1.0 + Float64(-0.125 * Float64(Float64(h / l) * (Float64(M * Float64(D_m / d)) ^ 2.0)))));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(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 = sqrt((h * l));
	tmp = 0.0;
	if (l <= -1e+196)
		tmp = sqrt((d / h)) * (sqrt(-d) / sqrt(-l));
	elseif (l <= -5.5e+58)
		tmp = d / -t_0;
	elseif (l <= 5.5e-303)
		tmp = sqrt(((d * (d / h)) / l)) * (1.0 + (-0.5 * (h * ((((D_m * 0.5) / (d / M)) ^ 2.0) / l))));
	elseif (l <= 2.4e+132)
		tmp = (d / t_0) * (1.0 + (-0.125 * ((h / l) * ((M * (D_m / d)) ^ 2.0))));
	else
		tmp = d / (sqrt(h) * sqrt(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[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -1e+196], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5.5e+58], N[(d / (-t$95$0)), $MachinePrecision], If[LessEqual[l, 5.5e-303], N[(N[Sqrt[N[(N[(d * N[(d / h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(h * N[(N[Power[N[(N[(D$95$m * 0.5), $MachinePrecision] / N[(d / M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.4e+132], N[(N[(d / t$95$0), $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $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 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;\ell \leq -1 \cdot 10^{+196}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\\

\mathbf{elif}\;\ell \leq -5.5 \cdot 10^{+58}:\\
\;\;\;\;\frac{d}{-t_0}\\

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

\mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+132}:\\
\;\;\;\;\frac{d}{t_0} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if l < -9.9999999999999995e195

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

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

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

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

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

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

    if -9.9999999999999995e195 < l < -5.4999999999999999e58

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      6. rem-cube-cbrt53.1%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{3}}\right| \]
      7. sqr-pow52.9%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)}}\right| \]
      8. fabs-sqr52.9%

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

        \[\leadsto -d \cdot \color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{3}} \]
      10. rem-cube-cbrt53.8%

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

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

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

    if -5.4999999999999999e58 < l < 5.50000000000000018e-303

    1. Initial program 67.4%

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

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

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

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

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

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

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

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

    if 5.50000000000000018e-303 < l < 2.4000000000000001e132

    1. Initial program 70.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. 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{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. associate-*r/72.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.4000000000000001e132 < l

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    4. Step-by-step derivation
      1. *-rgt-identity41.5%

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      3. expm1-log1p-u37.4%

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
      8. add-sqr-sqrt28.6%

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

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

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Simplified46.5%

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

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      2. sqrt-prod64.9%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    9. Applied egg-rr64.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1 \cdot 10^{+196}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\\ \mathbf{elif}\;\ell \leq -5.5 \cdot 10^{+58}:\\ \;\;\;\;\frac{d}{-\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq 5.5 \cdot 10^{-303}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{h}}{\ell}} \cdot \left(1 + -0.5 \cdot \left(h \cdot \frac{{\left(\frac{D \cdot 0.5}{\frac{d}{M}}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+132}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 12: 64.7% accurate, 1.1× 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 -2.1 \cdot 10^{+15}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq 1.3 \cdot 10^{-300}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{h}}{\ell}} \cdot \left(1 + -0.5 \cdot \left(h \cdot \frac{{\left(\frac{D_m \cdot 0.5}{\frac{d}{M}}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{elif}\;\ell \leq 4.2 \cdot 10^{+130}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \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
 (if (<= l -2.1e+15)
   (* (/ (sqrt (- d)) (sqrt (- h))) (sqrt (/ d l)))
   (if (<= l 1.3e-300)
     (*
      (sqrt (/ (* d (/ d h)) l))
      (+ 1.0 (* -0.5 (* h (/ (pow (/ (* D_m 0.5) (/ d M)) 2.0) l)))))
     (if (<= l 4.2e+130)
       (*
        (/ d (sqrt (* h l)))
        (+ 1.0 (* -0.125 (* (/ h l) (pow (* M (/ D_m d)) 2.0)))))
       (/ 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 tmp;
	if (l <= -2.1e+15) {
		tmp = (sqrt(-d) / sqrt(-h)) * sqrt((d / l));
	} else if (l <= 1.3e-300) {
		tmp = sqrt(((d * (d / h)) / l)) * (1.0 + (-0.5 * (h * (pow(((D_m * 0.5) / (d / M)), 2.0) / l))));
	} else if (l <= 4.2e+130) {
		tmp = (d / sqrt((h * l))) * (1.0 + (-0.125 * ((h / l) * pow((M * (D_m / d)), 2.0))));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= (-2.1d+15)) then
        tmp = (sqrt(-d) / sqrt(-h)) * sqrt((d / l))
    else if (l <= 1.3d-300) then
        tmp = sqrt(((d * (d / h)) / l)) * (1.0d0 + ((-0.5d0) * (h * ((((d_m * 0.5d0) / (d / m)) ** 2.0d0) / l))))
    else if (l <= 4.2d+130) then
        tmp = (d / sqrt((h * l))) * (1.0d0 + ((-0.125d0) * ((h / l) * ((m * (d_m / d)) ** 2.0d0))))
    else
        tmp = d / (sqrt(h) * sqrt(l))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (l <= -2.1e+15) {
		tmp = (Math.sqrt(-d) / Math.sqrt(-h)) * Math.sqrt((d / l));
	} else if (l <= 1.3e-300) {
		tmp = Math.sqrt(((d * (d / h)) / l)) * (1.0 + (-0.5 * (h * (Math.pow(((D_m * 0.5) / (d / M)), 2.0) / l))));
	} else if (l <= 4.2e+130) {
		tmp = (d / Math.sqrt((h * l))) * (1.0 + (-0.125 * ((h / l) * Math.pow((M * (D_m / d)), 2.0))));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	tmp = 0
	if l <= -2.1e+15:
		tmp = (math.sqrt(-d) / math.sqrt(-h)) * math.sqrt((d / l))
	elif l <= 1.3e-300:
		tmp = math.sqrt(((d * (d / h)) / l)) * (1.0 + (-0.5 * (h * (math.pow(((D_m * 0.5) / (d / M)), 2.0) / l))))
	elif l <= 4.2e+130:
		tmp = (d / math.sqrt((h * l))) * (1.0 + (-0.125 * ((h / l) * math.pow((M * (D_m / d)), 2.0))))
	else:
		tmp = d / (math.sqrt(h) * math.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)
	tmp = 0.0
	if (l <= -2.1e+15)
		tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * sqrt(Float64(d / l)));
	elseif (l <= 1.3e-300)
		tmp = Float64(sqrt(Float64(Float64(d * Float64(d / h)) / l)) * Float64(1.0 + Float64(-0.5 * Float64(h * Float64((Float64(Float64(D_m * 0.5) / Float64(d / M)) ^ 2.0) / l)))));
	elseif (l <= 4.2e+130)
		tmp = Float64(Float64(d / sqrt(Float64(h * l))) * Float64(1.0 + Float64(-0.125 * Float64(Float64(h / l) * (Float64(M * Float64(D_m / d)) ^ 2.0)))));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	tmp = 0.0;
	if (l <= -2.1e+15)
		tmp = (sqrt(-d) / sqrt(-h)) * sqrt((d / l));
	elseif (l <= 1.3e-300)
		tmp = sqrt(((d * (d / h)) / l)) * (1.0 + (-0.5 * (h * ((((D_m * 0.5) / (d / M)) ^ 2.0) / l))));
	elseif (l <= 4.2e+130)
		tmp = (d / sqrt((h * l))) * (1.0 + (-0.125 * ((h / l) * ((M * (D_m / d)) ^ 2.0))));
	else
		tmp = d / (sqrt(h) * sqrt(l));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[l, -2.1e+15], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.3e-300], N[(N[Sqrt[N[(N[(d * N[(d / h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(h * N[(N[Power[N[(N[(D$95$m * 0.5), $MachinePrecision] / N[(d / M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4.2e+130], N[(N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $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}
\mathbf{if}\;\ell \leq -2.1 \cdot 10^{+15}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\\

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

\mathbf{elif}\;\ell \leq 4.2 \cdot 10^{+130}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\\

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


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

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

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

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

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

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

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

    if -2.1e15 < l < 1.29999999999999998e-300

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

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

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

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

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

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

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

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

    if 1.29999999999999998e-300 < l < 4.19999999999999981e130

    1. Initial program 70.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. 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{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. associate-*r/72.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.19999999999999981e130 < l

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    4. Step-by-step derivation
      1. *-rgt-identity41.5%

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      3. expm1-log1p-u37.4%

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
      8. add-sqr-sqrt28.6%

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

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

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Simplified46.5%

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

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      2. sqrt-prod64.9%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    9. Applied egg-rr64.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.1 \cdot 10^{+15}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq 1.3 \cdot 10^{-300}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{h}}{\ell}} \cdot \left(1 + -0.5 \cdot \left(h \cdot \frac{{\left(\frac{D \cdot 0.5}{\frac{d}{M}}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{elif}\;\ell \leq 4.2 \cdot 10^{+130}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 13: 63.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 := \sqrt{h \cdot \ell}\\ \mathbf{if}\;\ell \leq -4.8 \cdot 10^{+58}:\\ \;\;\;\;\frac{d}{-t_0}\\ \mathbf{elif}\;\ell \leq 5.4 \cdot 10^{-305}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{h}}{\ell}} \cdot \left(1 + -0.5 \cdot \left(h \cdot \frac{{\left(\frac{D_m \cdot 0.5}{\frac{d}{M}}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{elif}\;\ell \leq 4.6 \cdot 10^{+127}:\\ \;\;\;\;\frac{d}{t_0} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \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 (sqrt (* h l))))
   (if (<= l -4.8e+58)
     (/ d (- t_0))
     (if (<= l 5.4e-305)
       (*
        (sqrt (/ (* d (/ d h)) l))
        (+ 1.0 (* -0.5 (* h (/ (pow (/ (* D_m 0.5) (/ d M)) 2.0) l)))))
       (if (<= l 4.6e+127)
         (* (/ d t_0) (+ 1.0 (* -0.125 (* (/ h l) (pow (* M (/ D_m d)) 2.0)))))
         (/ 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 = sqrt((h * l));
	double tmp;
	if (l <= -4.8e+58) {
		tmp = d / -t_0;
	} else if (l <= 5.4e-305) {
		tmp = sqrt(((d * (d / h)) / l)) * (1.0 + (-0.5 * (h * (pow(((D_m * 0.5) / (d / M)), 2.0) / l))));
	} else if (l <= 4.6e+127) {
		tmp = (d / t_0) * (1.0 + (-0.125 * ((h / l) * pow((M * (D_m / d)), 2.0))));
	} else {
		tmp = d / (sqrt(h) * sqrt(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 = sqrt((h * l))
    if (l <= (-4.8d+58)) then
        tmp = d / -t_0
    else if (l <= 5.4d-305) then
        tmp = sqrt(((d * (d / h)) / l)) * (1.0d0 + ((-0.5d0) * (h * ((((d_m * 0.5d0) / (d / m)) ** 2.0d0) / l))))
    else if (l <= 4.6d+127) then
        tmp = (d / t_0) * (1.0d0 + ((-0.125d0) * ((h / l) * ((m * (d_m / d)) ** 2.0d0))))
    else
        tmp = d / (sqrt(h) * sqrt(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 = Math.sqrt((h * l));
	double tmp;
	if (l <= -4.8e+58) {
		tmp = d / -t_0;
	} else if (l <= 5.4e-305) {
		tmp = Math.sqrt(((d * (d / h)) / l)) * (1.0 + (-0.5 * (h * (Math.pow(((D_m * 0.5) / (d / M)), 2.0) / l))));
	} else if (l <= 4.6e+127) {
		tmp = (d / t_0) * (1.0 + (-0.125 * ((h / l) * Math.pow((M * (D_m / d)), 2.0))));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(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 = math.sqrt((h * l))
	tmp = 0
	if l <= -4.8e+58:
		tmp = d / -t_0
	elif l <= 5.4e-305:
		tmp = math.sqrt(((d * (d / h)) / l)) * (1.0 + (-0.5 * (h * (math.pow(((D_m * 0.5) / (d / M)), 2.0) / l))))
	elif l <= 4.6e+127:
		tmp = (d / t_0) * (1.0 + (-0.125 * ((h / l) * math.pow((M * (D_m / d)), 2.0))))
	else:
		tmp = d / (math.sqrt(h) * math.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 = sqrt(Float64(h * l))
	tmp = 0.0
	if (l <= -4.8e+58)
		tmp = Float64(d / Float64(-t_0));
	elseif (l <= 5.4e-305)
		tmp = Float64(sqrt(Float64(Float64(d * Float64(d / h)) / l)) * Float64(1.0 + Float64(-0.5 * Float64(h * Float64((Float64(Float64(D_m * 0.5) / Float64(d / M)) ^ 2.0) / l)))));
	elseif (l <= 4.6e+127)
		tmp = Float64(Float64(d / t_0) * Float64(1.0 + Float64(-0.125 * Float64(Float64(h / l) * (Float64(M * Float64(D_m / d)) ^ 2.0)))));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(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 = sqrt((h * l));
	tmp = 0.0;
	if (l <= -4.8e+58)
		tmp = d / -t_0;
	elseif (l <= 5.4e-305)
		tmp = sqrt(((d * (d / h)) / l)) * (1.0 + (-0.5 * (h * ((((D_m * 0.5) / (d / M)) ^ 2.0) / l))));
	elseif (l <= 4.6e+127)
		tmp = (d / t_0) * (1.0 + (-0.125 * ((h / l) * ((M * (D_m / d)) ^ 2.0))));
	else
		tmp = d / (sqrt(h) * sqrt(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[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -4.8e+58], N[(d / (-t$95$0)), $MachinePrecision], If[LessEqual[l, 5.4e-305], N[(N[Sqrt[N[(N[(d * N[(d / h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(h * N[(N[Power[N[(N[(D$95$m * 0.5), $MachinePrecision] / N[(d / M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4.6e+127], N[(N[(d / t$95$0), $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $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 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;\ell \leq -4.8 \cdot 10^{+58}:\\
\;\;\;\;\frac{d}{-t_0}\\

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

\mathbf{elif}\;\ell \leq 4.6 \cdot 10^{+127}:\\
\;\;\;\;\frac{d}{t_0} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      6. rem-cube-cbrt47.1%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{3}}\right| \]
      7. sqr-pow47.0%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)}}\right| \]
      8. fabs-sqr47.0%

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

        \[\leadsto -d \cdot \color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{3}} \]
      10. rem-cube-cbrt47.7%

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

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

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

    if -4.8e58 < l < 5.3999999999999998e-305

    1. Initial program 67.4%

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

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

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

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

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

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

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

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

    if 5.3999999999999998e-305 < l < 4.6000000000000003e127

    1. Initial program 70.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. 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{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. associate-*r/72.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.6000000000000003e127 < l

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    4. Step-by-step derivation
      1. *-rgt-identity41.5%

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      3. expm1-log1p-u37.4%

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
      8. add-sqr-sqrt28.6%

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

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

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Simplified46.5%

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

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      2. sqrt-prod64.9%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    9. Applied egg-rr64.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.8 \cdot 10^{+58}:\\ \;\;\;\;\frac{d}{-\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq 5.4 \cdot 10^{-305}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{h}}{\ell}} \cdot \left(1 + -0.5 \cdot \left(h \cdot \frac{{\left(\frac{D \cdot 0.5}{\frac{d}{M}}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{elif}\;\ell \leq 4.6 \cdot 10^{+127}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 14: 57.4% 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 := \sqrt{h \cdot \ell}\\ \mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{-t_0}\\ \mathbf{elif}\;\ell \leq 5.8 \cdot 10^{+130}:\\ \;\;\;\;\frac{d}{t_0} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \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 (sqrt (* h l))))
   (if (<= l -2e-310)
     (/ d (- t_0))
     (if (<= l 5.8e+130)
       (* (/ d t_0) (+ 1.0 (* -0.125 (* (/ h l) (pow (* M (/ D_m d)) 2.0)))))
       (/ 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 = sqrt((h * l));
	double tmp;
	if (l <= -2e-310) {
		tmp = d / -t_0;
	} else if (l <= 5.8e+130) {
		tmp = (d / t_0) * (1.0 + (-0.125 * ((h / l) * pow((M * (D_m / d)), 2.0))));
	} else {
		tmp = d / (sqrt(h) * sqrt(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 = sqrt((h * l))
    if (l <= (-2d-310)) then
        tmp = d / -t_0
    else if (l <= 5.8d+130) then
        tmp = (d / t_0) * (1.0d0 + ((-0.125d0) * ((h / l) * ((m * (d_m / d)) ** 2.0d0))))
    else
        tmp = d / (sqrt(h) * sqrt(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 = Math.sqrt((h * l));
	double tmp;
	if (l <= -2e-310) {
		tmp = d / -t_0;
	} else if (l <= 5.8e+130) {
		tmp = (d / t_0) * (1.0 + (-0.125 * ((h / l) * Math.pow((M * (D_m / d)), 2.0))));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(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 = math.sqrt((h * l))
	tmp = 0
	if l <= -2e-310:
		tmp = d / -t_0
	elif l <= 5.8e+130:
		tmp = (d / t_0) * (1.0 + (-0.125 * ((h / l) * math.pow((M * (D_m / d)), 2.0))))
	else:
		tmp = d / (math.sqrt(h) * math.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 = sqrt(Float64(h * l))
	tmp = 0.0
	if (l <= -2e-310)
		tmp = Float64(d / Float64(-t_0));
	elseif (l <= 5.8e+130)
		tmp = Float64(Float64(d / t_0) * Float64(1.0 + Float64(-0.125 * Float64(Float64(h / l) * (Float64(M * Float64(D_m / d)) ^ 2.0)))));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(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 = sqrt((h * l));
	tmp = 0.0;
	if (l <= -2e-310)
		tmp = d / -t_0;
	elseif (l <= 5.8e+130)
		tmp = (d / t_0) * (1.0 + (-0.125 * ((h / l) * ((M * (D_m / d)) ^ 2.0))));
	else
		tmp = d / (sqrt(h) * sqrt(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[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -2e-310], N[(d / (-t$95$0)), $MachinePrecision], If[LessEqual[l, 5.8e+130], N[(N[(d / t$95$0), $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $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 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{d}{-t_0}\\

\mathbf{elif}\;\ell \leq 5.8 \cdot 10^{+130}:\\
\;\;\;\;\frac{d}{t_0} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      6. rem-cube-cbrt38.5%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{3}}\right| \]
      7. sqr-pow38.4%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)}}\right| \]
      8. fabs-sqr38.4%

        \[\leadsto -d \cdot \color{blue}{\left({\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)}\right)} \]
      9. sqr-pow38.5%

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

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

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

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

    if -1.999999999999994e-310 < l < 5.7999999999999998e130

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.7999999999999998e130 < l

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    4. Step-by-step derivation
      1. *-rgt-identity41.5%

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      3. expm1-log1p-u37.4%

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
      8. add-sqr-sqrt28.6%

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

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

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Simplified46.5%

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

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      2. sqrt-prod64.9%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    9. Applied egg-rr64.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{-\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq 5.8 \cdot 10^{+130}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 15: 46.5% accurate, 1.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} \mathbf{if}\;h \leq -2.8 \cdot 10^{+212}:\\ \;\;\;\;\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}}\\ \mathbf{elif}\;h \leq 9.5 \cdot 10^{-303}:\\ \;\;\;\;\frac{d}{-\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \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
 (if (<= h -2.8e+212)
   (sqrt (/ (/ d h) (/ l d)))
   (if (<= h 9.5e-303) (/ d (- (sqrt (* h l)))) (/ 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 tmp;
	if (h <= -2.8e+212) {
		tmp = sqrt(((d / h) / (l / d)));
	} else if (h <= 9.5e-303) {
		tmp = d / -sqrt((h * l));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (h <= (-2.8d+212)) then
        tmp = sqrt(((d / h) / (l / d)))
    else if (h <= 9.5d-303) then
        tmp = d / -sqrt((h * l))
    else
        tmp = d / (sqrt(h) * sqrt(l))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (h <= -2.8e+212) {
		tmp = Math.sqrt(((d / h) / (l / d)));
	} else if (h <= 9.5e-303) {
		tmp = d / -Math.sqrt((h * l));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	tmp = 0
	if h <= -2.8e+212:
		tmp = math.sqrt(((d / h) / (l / d)))
	elif h <= 9.5e-303:
		tmp = d / -math.sqrt((h * l))
	else:
		tmp = d / (math.sqrt(h) * math.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)
	tmp = 0.0
	if (h <= -2.8e+212)
		tmp = sqrt(Float64(Float64(d / h) / Float64(l / d)));
	elseif (h <= 9.5e-303)
		tmp = Float64(d / Float64(-sqrt(Float64(h * l))));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	tmp = 0.0;
	if (h <= -2.8e+212)
		tmp = sqrt(((d / h) / (l / d)));
	elseif (h <= 9.5e-303)
		tmp = d / -sqrt((h * l));
	else
		tmp = d / (sqrt(h) * sqrt(l));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[h, -2.8e+212], N[Sqrt[N[(N[(d / h), $MachinePrecision] / N[(l / d), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[h, 9.5e-303], N[(d / (-N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d / N[(N[Sqrt[h], $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}
\mathbf{if}\;h \leq -2.8 \cdot 10^{+212}:\\
\;\;\;\;\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}}\\

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

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


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

    1. Initial program 48.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. Simplified48.5%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    4. Step-by-step derivation
      1. *-rgt-identity35.5%

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      3. expm1-log1p-u34.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

        \[\leadsto \frac{\color{blue}{\sqrt{d \cdot d}}}{\sqrt{h \cdot \ell}} \]
      3. sqrt-div15.0%

        \[\leadsto \color{blue}{\sqrt{\frac{d \cdot d}{h \cdot \ell}}} \]
      4. frac-times35.5%

        \[\leadsto \sqrt{\color{blue}{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      5. sqrt-prod35.5%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} \]
      6. clear-num35.5%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}} \]
      9. un-div-inv37.8%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}}} \]
      10. sqrt-undiv37.8%

        \[\leadsto \color{blue}{\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}}} \]
    9. Applied egg-rr37.8%

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

    if -2.79999999999999997e212 < h < 9.4999999999999999e-303

    1. Initial program 63.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      6. rem-cube-cbrt44.5%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{3}}\right| \]
      7. sqr-pow44.5%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)}}\right| \]
      8. fabs-sqr44.5%

        \[\leadsto -d \cdot \color{blue}{\left({\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)}\right)} \]
      9. sqr-pow44.5%

        \[\leadsto -d \cdot \color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{3}} \]
      10. rem-cube-cbrt45.0%

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

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

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

    if 9.4999999999999999e-303 < h

    1. Initial program 60.0%

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    4. Step-by-step derivation
      1. *-rgt-identity38.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. sqrt-prod32.8%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      3. expm1-log1p-u31.8%

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
      8. add-sqr-sqrt31.0%

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

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

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Simplified44.9%

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

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      2. sqrt-prod52.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -2.8 \cdot 10^{+212}:\\ \;\;\;\;\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}}\\ \mathbf{elif}\;h \leq 9.5 \cdot 10^{-303}:\\ \;\;\;\;\frac{d}{-\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 16: 42.7% accurate, 2.9× speedup?

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

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

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


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

    1. Initial program 48.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. Simplified48.5%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    4. Step-by-step derivation
      1. *-rgt-identity35.5%

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      3. expm1-log1p-u34.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

        \[\leadsto \frac{\color{blue}{\sqrt{d \cdot d}}}{\sqrt{h \cdot \ell}} \]
      3. sqrt-div15.0%

        \[\leadsto \color{blue}{\sqrt{\frac{d \cdot d}{h \cdot \ell}}} \]
      4. frac-times35.5%

        \[\leadsto \sqrt{\color{blue}{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      5. sqrt-prod35.5%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} \]
      6. clear-num35.5%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}} \]
      9. un-div-inv37.8%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}}} \]
      10. sqrt-undiv37.8%

        \[\leadsto \color{blue}{\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}}} \]
    9. Applied egg-rr37.8%

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

    if -1.6999999999999999e214 < h < 9.4999999999999999e-303

    1. Initial program 63.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      6. rem-cube-cbrt44.5%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{3}}\right| \]
      7. sqr-pow44.5%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)}}\right| \]
      8. fabs-sqr44.5%

        \[\leadsto -d \cdot \color{blue}{\left({\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)}\right)} \]
      9. sqr-pow44.5%

        \[\leadsto -d \cdot \color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{3}} \]
      10. rem-cube-cbrt45.0%

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

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

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

    if 9.4999999999999999e-303 < h

    1. Initial program 60.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -1.7 \cdot 10^{+214}:\\ \;\;\;\;\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}}\\ \mathbf{elif}\;h \leq 9.5 \cdot 10^{-303}:\\ \;\;\;\;\frac{d}{-\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h} \cdot \frac{1}{\ell}}\\ \end{array} \]

Alternative 17: 42.7% 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}\;h \leq -8 \cdot 10^{+212}:\\ \;\;\;\;\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}}\\ \mathbf{elif}\;h \leq 1.05 \cdot 10^{-302}:\\ \;\;\;\;\frac{d}{-\sqrt{h \cdot \ell}}\\ \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
 (if (<= h -8e+212)
   (sqrt (/ (/ d h) (/ l d)))
   (if (<= h 1.05e-302)
     (/ d (- (sqrt (* h l))))
     (* 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 tmp;
	if (h <= -8e+212) {
		tmp = sqrt(((d / h) / (l / d)));
	} else if (h <= 1.05e-302) {
		tmp = d / -sqrt((h * l));
	} 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) :: tmp
    if (h <= (-8d+212)) then
        tmp = sqrt(((d / h) / (l / d)))
    else if (h <= 1.05d-302) then
        tmp = d / -sqrt((h * l))
    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 tmp;
	if (h <= -8e+212) {
		tmp = Math.sqrt(((d / h) / (l / d)));
	} else if (h <= 1.05e-302) {
		tmp = d / -Math.sqrt((h * l));
	} 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):
	tmp = 0
	if h <= -8e+212:
		tmp = math.sqrt(((d / h) / (l / d)))
	elif h <= 1.05e-302:
		tmp = d / -math.sqrt((h * l))
	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)
	tmp = 0.0
	if (h <= -8e+212)
		tmp = sqrt(Float64(Float64(d / h) / Float64(l / d)));
	elseif (h <= 1.05e-302)
		tmp = Float64(d / Float64(-sqrt(Float64(h * l))));
	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)
	tmp = 0.0;
	if (h <= -8e+212)
		tmp = sqrt(((d / h) / (l / d)));
	elseif (h <= 1.05e-302)
		tmp = d / -sqrt((h * l));
	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_] := If[LessEqual[h, -8e+212], N[Sqrt[N[(N[(d / h), $MachinePrecision] / N[(l / d), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[h, 1.05e-302], N[(d / (-N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -8 \cdot 10^{+212}:\\
\;\;\;\;\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -7.9999999999999993e212

    1. Initial program 48.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. Simplified48.5%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(\frac{D}{\frac{2}{M} \cdot d}\right)}^{2} \cdot -0.5, 1\right)\right)} \]
    3. Taylor expanded in h around 0 35.5%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    4. Step-by-step derivation
      1. *-rgt-identity35.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. sqrt-prod35.5%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      3. expm1-log1p-u34.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)\right)} \]
      4. expm1-udef15.2%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)} - 1} \]
      5. frac-times11.4%

        \[\leadsto e^{\mathsf{log1p}\left(\sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}}\right)} - 1 \]
      6. sqrt-div11.4%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{d \cdot d}}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
      7. sqrt-unprod0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
      8. add-sqr-sqrt5.4%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
    5. Applied egg-rr5.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)} - 1} \]
    6. Step-by-step derivation
      1. expm1-def5.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)\right)} \]
      2. expm1-log1p6.1%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Simplified6.1%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}} \]
      2. sqrt-unprod15.0%

        \[\leadsto \frac{\color{blue}{\sqrt{d \cdot d}}}{\sqrt{h \cdot \ell}} \]
      3. sqrt-div15.0%

        \[\leadsto \color{blue}{\sqrt{\frac{d \cdot d}{h \cdot \ell}}} \]
      4. frac-times35.5%

        \[\leadsto \sqrt{\color{blue}{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      5. sqrt-prod35.5%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} \]
      6. clear-num35.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}} \]
      7. sqrt-div37.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}} \]
      8. metadata-eval37.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}} \]
      9. un-div-inv37.8%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}}} \]
      10. sqrt-undiv37.8%

        \[\leadsto \color{blue}{\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}}} \]
    9. Applied egg-rr37.8%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}}} \]

    if -7.9999999999999993e212 < h < 1.05000000000000006e-302

    1. Initial program 63.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. add-sqr-sqrt63.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow263.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
    4. Applied egg-rr65.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    5. Step-by-step derivation
      1. associate-*r/66.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{\left(M \cdot 0.5\right) \cdot D}{d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. associate-*l*66.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{M \cdot \left(0.5 \cdot D\right)}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. *-commutative66.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{M \cdot \color{blue}{\left(D \cdot 0.5\right)}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. associate-*l/66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{d} \cdot \left(D \cdot 0.5\right)\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. *-commutative66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\left(D \cdot 0.5\right) \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. associate-*l*66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-*l*65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
      8. metadata-eval65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(\color{blue}{\frac{1}{2}} \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      9. associate-/r/65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\frac{1}{\frac{2}{\frac{M}{d}}}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      10. associate-/l*65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{1}{\color{blue}{\frac{2 \cdot d}{M}}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      11. associate-/r/65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(\frac{1}{2 \cdot d} \cdot M\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      12. *-commutative65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(M \cdot \frac{1}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      13. associate-/r*65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      14. metadata-eval65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \frac{\color{blue}{0.5}}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    6. Simplified65.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\left(M \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    7. Step-by-step derivation
      1. clear-num65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      2. sqrt-div65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      3. metadata-eval65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    8. Applied egg-rr65.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    9. Taylor expanded in d around -inf 44.9%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    10. Step-by-step derivation
      1. mul-1-neg44.9%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. unpow-144.9%

        \[\leadsto -d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      3. metadata-eval44.9%

        \[\leadsto -d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      4. pow-sqr45.0%

        \[\leadsto -d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      5. rem-sqrt-square45.0%

        \[\leadsto -d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      6. rem-cube-cbrt44.5%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{3}}\right| \]
      7. sqr-pow44.5%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)}}\right| \]
      8. fabs-sqr44.5%

        \[\leadsto -d \cdot \color{blue}{\left({\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)}\right)} \]
      9. sqr-pow44.5%

        \[\leadsto -d \cdot \color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{3}} \]
      10. rem-cube-cbrt45.0%

        \[\leadsto -d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      11. *-commutative45.0%

        \[\leadsto -\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot d} \]
    11. Simplified45.0%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if 1.05000000000000006e-302 < h

    1. Initial program 60.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified59.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Taylor expanded in d around inf 44.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. associate-/r*45.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    5. Simplified45.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification44.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -8 \cdot 10^{+212}:\\ \;\;\;\;\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}}\\ \mathbf{elif}\;h \leq 1.05 \cdot 10^{-302}:\\ \;\;\;\;\frac{d}{-\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]

Alternative 18: 42.6% 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} t_0 := \sqrt{h \cdot \ell}\\ \mathbf{if}\;h \leq -1.65 \cdot 10^{+213}:\\ \;\;\;\;\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}}\\ \mathbf{elif}\;h \leq 9.5 \cdot 10^{-303}:\\ \;\;\;\;\frac{d}{-t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{t_0}\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (let* ((t_0 (sqrt (* h l))))
   (if (<= h -1.65e+213)
     (sqrt (/ (/ d h) (/ l d)))
     (if (<= h 9.5e-303) (/ d (- t_0)) (/ d t_0)))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double t_0 = sqrt((h * l));
	double tmp;
	if (h <= -1.65e+213) {
		tmp = sqrt(((d / h) / (l / d)));
	} else if (h <= 9.5e-303) {
		tmp = d / -t_0;
	} else {
		tmp = d / t_0;
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((h * l))
    if (h <= (-1.65d+213)) then
        tmp = sqrt(((d / h) / (l / d)))
    else if (h <= 9.5d-303) then
        tmp = d / -t_0
    else
        tmp = d / t_0
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double t_0 = Math.sqrt((h * l));
	double tmp;
	if (h <= -1.65e+213) {
		tmp = Math.sqrt(((d / h) / (l / d)));
	} else if (h <= 9.5e-303) {
		tmp = d / -t_0;
	} else {
		tmp = d / t_0;
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	t_0 = math.sqrt((h * l))
	tmp = 0
	if h <= -1.65e+213:
		tmp = math.sqrt(((d / h) / (l / d)))
	elif h <= 9.5e-303:
		tmp = d / -t_0
	else:
		tmp = d / t_0
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	t_0 = sqrt(Float64(h * l))
	tmp = 0.0
	if (h <= -1.65e+213)
		tmp = sqrt(Float64(Float64(d / h) / Float64(l / d)));
	elseif (h <= 9.5e-303)
		tmp = Float64(d / Float64(-t_0));
	else
		tmp = Float64(d / t_0);
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	t_0 = sqrt((h * l));
	tmp = 0.0;
	if (h <= -1.65e+213)
		tmp = sqrt(((d / h) / (l / d)));
	elseif (h <= 9.5e-303)
		tmp = d / -t_0;
	else
		tmp = d / t_0;
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -1.65e+213], N[Sqrt[N[(N[(d / h), $MachinePrecision] / N[(l / d), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[h, 9.5e-303], N[(d / (-t$95$0)), $MachinePrecision], N[(d / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;h \leq -1.65 \cdot 10^{+213}:\\
\;\;\;\;\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}}\\

\mathbf{elif}\;h \leq 9.5 \cdot 10^{-303}:\\
\;\;\;\;\frac{d}{-t_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{t_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -1.6500000000000001e213

    1. Initial program 48.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. Simplified48.5%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(\frac{D}{\frac{2}{M} \cdot d}\right)}^{2} \cdot -0.5, 1\right)\right)} \]
    3. Taylor expanded in h around 0 35.5%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    4. Step-by-step derivation
      1. *-rgt-identity35.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. sqrt-prod35.5%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      3. expm1-log1p-u34.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)\right)} \]
      4. expm1-udef15.2%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)} - 1} \]
      5. frac-times11.4%

        \[\leadsto e^{\mathsf{log1p}\left(\sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}}\right)} - 1 \]
      6. sqrt-div11.4%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{d \cdot d}}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
      7. sqrt-unprod0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
      8. add-sqr-sqrt5.4%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
    5. Applied egg-rr5.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)} - 1} \]
    6. Step-by-step derivation
      1. expm1-def5.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)\right)} \]
      2. expm1-log1p6.1%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Simplified6.1%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}} \]
      2. sqrt-unprod15.0%

        \[\leadsto \frac{\color{blue}{\sqrt{d \cdot d}}}{\sqrt{h \cdot \ell}} \]
      3. sqrt-div15.0%

        \[\leadsto \color{blue}{\sqrt{\frac{d \cdot d}{h \cdot \ell}}} \]
      4. frac-times35.5%

        \[\leadsto \sqrt{\color{blue}{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      5. sqrt-prod35.5%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} \]
      6. clear-num35.5%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}} \]
      7. sqrt-div37.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}} \]
      8. metadata-eval37.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}} \]
      9. un-div-inv37.8%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}}} \]
      10. sqrt-undiv37.8%

        \[\leadsto \color{blue}{\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}}} \]
    9. Applied egg-rr37.8%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}}} \]

    if -1.6500000000000001e213 < h < 9.4999999999999999e-303

    1. Initial program 63.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. add-sqr-sqrt63.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow263.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
    4. Applied egg-rr65.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    5. Step-by-step derivation
      1. associate-*r/66.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{\left(M \cdot 0.5\right) \cdot D}{d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. associate-*l*66.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{M \cdot \left(0.5 \cdot D\right)}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. *-commutative66.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{M \cdot \color{blue}{\left(D \cdot 0.5\right)}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. associate-*l/66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{d} \cdot \left(D \cdot 0.5\right)\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. *-commutative66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\left(D \cdot 0.5\right) \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. associate-*l*66.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-*l*65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
      8. metadata-eval65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(\color{blue}{\frac{1}{2}} \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      9. associate-/r/65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\frac{1}{\frac{2}{\frac{M}{d}}}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      10. associate-/l*65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{1}{\color{blue}{\frac{2 \cdot d}{M}}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      11. associate-/r/65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(\frac{1}{2 \cdot d} \cdot M\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      12. *-commutative65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(M \cdot \frac{1}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      13. associate-/r*65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      14. metadata-eval65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \frac{\color{blue}{0.5}}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    6. Simplified65.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\left(M \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    7. Step-by-step derivation
      1. clear-num65.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      2. sqrt-div65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      3. metadata-eval65.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    8. Applied egg-rr65.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    9. Taylor expanded in d around -inf 44.9%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    10. Step-by-step derivation
      1. mul-1-neg44.9%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. unpow-144.9%

        \[\leadsto -d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      3. metadata-eval44.9%

        \[\leadsto -d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      4. pow-sqr45.0%

        \[\leadsto -d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      5. rem-sqrt-square45.0%

        \[\leadsto -d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      6. rem-cube-cbrt44.5%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{3}}\right| \]
      7. sqr-pow44.5%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)}}\right| \]
      8. fabs-sqr44.5%

        \[\leadsto -d \cdot \color{blue}{\left({\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)}\right)} \]
      9. sqr-pow44.5%

        \[\leadsto -d \cdot \color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{3}} \]
      10. rem-cube-cbrt45.0%

        \[\leadsto -d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      11. *-commutative45.0%

        \[\leadsto -\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot d} \]
    11. Simplified45.0%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if 9.4999999999999999e-303 < h

    1. Initial program 60.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified59.9%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(\frac{D}{\frac{2}{M} \cdot d}\right)}^{2} \cdot -0.5, 1\right)\right)} \]
    3. Taylor expanded in h around 0 38.8%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    4. Step-by-step derivation
      1. *-rgt-identity38.8%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. sqrt-prod32.8%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      3. expm1-log1p-u31.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)\right)} \]
      4. expm1-udef21.1%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)} - 1} \]
      5. frac-times16.6%

        \[\leadsto e^{\mathsf{log1p}\left(\sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}}\right)} - 1 \]
      6. sqrt-div20.7%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{d \cdot d}}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
      7. sqrt-unprod31.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
      8. add-sqr-sqrt31.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
    5. Applied egg-rr31.0%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)} - 1} \]
    6. Step-by-step derivation
      1. expm1-def42.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)\right)} \]
      2. expm1-log1p44.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Simplified44.9%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification44.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -1.65 \cdot 10^{+213}:\\ \;\;\;\;\sqrt{\frac{\frac{d}{h}}{\frac{\ell}{d}}}\\ \mathbf{elif}\;h \leq 9.5 \cdot 10^{-303}:\\ \;\;\;\;\frac{d}{-\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \end{array} \]

Alternative 19: 42.2% accurate, 3.1× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{h \cdot \ell}\\ \mathbf{if}\;d \leq 5.3 \cdot 10^{-241}:\\ \;\;\;\;\frac{d}{-t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{t_0}\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (let* ((t_0 (sqrt (* h l)))) (if (<= d 5.3e-241) (/ d (- t_0)) (/ d t_0))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double t_0 = sqrt((h * l));
	double tmp;
	if (d <= 5.3e-241) {
		tmp = d / -t_0;
	} else {
		tmp = d / t_0;
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((h * l))
    if (d <= 5.3d-241) then
        tmp = d / -t_0
    else
        tmp = d / t_0
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double t_0 = Math.sqrt((h * l));
	double tmp;
	if (d <= 5.3e-241) {
		tmp = d / -t_0;
	} else {
		tmp = d / t_0;
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	t_0 = math.sqrt((h * l))
	tmp = 0
	if d <= 5.3e-241:
		tmp = d / -t_0
	else:
		tmp = d / t_0
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	t_0 = sqrt(Float64(h * l))
	tmp = 0.0
	if (d <= 5.3e-241)
		tmp = Float64(d / Float64(-t_0));
	else
		tmp = Float64(d / t_0);
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	t_0 = sqrt((h * l));
	tmp = 0.0;
	if (d <= 5.3e-241)
		tmp = d / -t_0;
	else
		tmp = d / t_0;
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, 5.3e-241], N[(d / (-t$95$0)), $MachinePrecision], N[(d / t$95$0), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;d \leq 5.3 \cdot 10^{-241}:\\
\;\;\;\;\frac{d}{-t_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{t_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 5.2999999999999998e-241

    1. Initial program 56.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. Simplified56.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Step-by-step derivation
      1. add-sqr-sqrt56.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow256.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
    4. Applied egg-rr58.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    5. Step-by-step derivation
      1. associate-*r/59.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{\left(M \cdot 0.5\right) \cdot D}{d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. associate-*l*59.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{M \cdot \left(0.5 \cdot D\right)}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. *-commutative59.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{M \cdot \color{blue}{\left(D \cdot 0.5\right)}}{d} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. associate-*l/58.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{d} \cdot \left(D \cdot 0.5\right)\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. *-commutative58.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\left(D \cdot 0.5\right) \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. associate-*l*58.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-*l*58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
      8. metadata-eval58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(\color{blue}{\frac{1}{2}} \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      9. associate-/r/58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\frac{1}{\frac{2}{\frac{M}{d}}}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      10. associate-/l*57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{1}{\color{blue}{\frac{2 \cdot d}{M}}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      11. associate-/r/58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(\frac{1}{2 \cdot d} \cdot M\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      12. *-commutative58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(M \cdot \frac{1}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      13. associate-/r*58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      14. metadata-eval58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \frac{\color{blue}{0.5}}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    6. Simplified58.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\left(M \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    7. Step-by-step derivation
      1. clear-num58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      2. sqrt-div58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      3. metadata-eval58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    8. Applied egg-rr58.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(M \cdot \frac{0.5}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    9. Taylor expanded in d around -inf 37.5%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    10. Step-by-step derivation
      1. mul-1-neg37.5%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. unpow-137.5%

        \[\leadsto -d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      3. metadata-eval37.5%

        \[\leadsto -d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      4. pow-sqr37.5%

        \[\leadsto -d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      5. rem-sqrt-square36.8%

        \[\leadsto -d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      6. rem-cube-cbrt36.4%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{3}}\right| \]
      7. sqr-pow36.4%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)}}\right| \]
      8. fabs-sqr36.4%

        \[\leadsto -d \cdot \color{blue}{\left({\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{\left(\frac{3}{2}\right)}\right)} \]
      9. sqr-pow36.4%

        \[\leadsto -d \cdot \color{blue}{{\left(\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.5}}\right)}^{3}} \]
      10. rem-cube-cbrt36.8%

        \[\leadsto -d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      11. *-commutative36.8%

        \[\leadsto -\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot d} \]
    11. Simplified36.8%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if 5.2999999999999998e-241 < d

    1. Initial program 64.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. Simplified64.2%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(\frac{D}{\frac{2}{M} \cdot d}\right)}^{2} \cdot -0.5, 1\right)\right)} \]
    3. Taylor expanded in h around 0 42.0%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    4. Step-by-step derivation
      1. *-rgt-identity42.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. sqrt-prod35.5%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      3. expm1-log1p-u34.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)\right)} \]
      4. expm1-udef22.7%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)} - 1} \]
      5. frac-times17.8%

        \[\leadsto e^{\mathsf{log1p}\left(\sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}}\right)} - 1 \]
      6. sqrt-div22.3%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{d \cdot d}}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
      7. sqrt-unprod33.5%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
      8. add-sqr-sqrt33.5%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
    5. Applied egg-rr33.5%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)} - 1} \]
    6. Step-by-step derivation
      1. expm1-def46.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)\right)} \]
      2. expm1-log1p48.6%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Simplified48.6%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification42.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 5.3 \cdot 10^{-241}:\\ \;\;\;\;\frac{d}{-\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \end{array} \]

Alternative 20: 26.2% 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{h \cdot \ell}} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m) :precision binary64 (/ d (sqrt (* h l))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	return d / sqrt((h * l));
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_m
    code = d / sqrt((h * l))
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	return d / Math.sqrt((h * l));
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	return d / math.sqrt((h * l))
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	return Float64(d / sqrt(Float64(h * l)))
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp = code(d, h, l, M, D_m)
	tmp = d / sqrt((h * l));
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := N[(d / N[Sqrt[N[(h * 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])\\
\\
\frac{d}{\sqrt{h \cdot \ell}}
\end{array}
Derivation
  1. Initial program 60.0%

    \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  2. Simplified60.0%

    \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(\frac{D}{\frac{2}{M} \cdot d}\right)}^{2} \cdot -0.5, 1\right)\right)} \]
  3. Taylor expanded in h around 0 37.3%

    \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
  4. Step-by-step derivation
    1. *-rgt-identity37.3%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
    2. sqrt-prod31.5%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    3. expm1-log1p-u30.7%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)\right)} \]
    4. expm1-udef20.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right)} - 1} \]
    5. frac-times16.4%

      \[\leadsto e^{\mathsf{log1p}\left(\sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}}\right)} - 1 \]
    6. sqrt-div19.8%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{d \cdot d}}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
    7. sqrt-unprod15.0%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
    8. add-sqr-sqrt17.4%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
  5. Applied egg-rr17.4%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)} - 1} \]
  6. Step-by-step derivation
    1. expm1-def23.1%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)\right)} \]
    2. expm1-log1p26.5%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  7. Simplified26.5%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  8. Final simplification26.5%

    \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]

Reproduce

?
herbie shell --seed 2023314 
(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)))))