Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.8% → 76.8%
Time: 35.0s
Alternatives: 20
Speedup: 1.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 20 alternatives:

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

Initial Program: 66.8% accurate, 1.0× speedup?

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

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

Alternative 1: 76.8% accurate, 0.6× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(t_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\


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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(\left(M \cdot \color{blue}{0.5}\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}\right) \]
    4. Applied egg-rr68.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. pow1/268.8%

        \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \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. sqr-pow68.7%

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

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

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

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

      \[\leadsto \left({\color{blue}{\left(e^{0.25 \cdot \left(\log \left(\frac{-1}{h}\right) + -1 \cdot \log \left(\frac{-1}{d}\right)\right)}\right)}}^{2} \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) \]
    8. Step-by-step derivation
      1. distribute-lft-in77.0%

        \[\leadsto \left({\left(e^{\color{blue}{0.25 \cdot \log \left(\frac{-1}{h}\right) + 0.25 \cdot \left(-1 \cdot \log \left(\frac{-1}{d}\right)\right)}}\right)}^{2} \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. exp-sum77.3%

        \[\leadsto \left({\color{blue}{\left(e^{0.25 \cdot \log \left(\frac{-1}{h}\right)} \cdot e^{0.25 \cdot \left(-1 \cdot \log \left(\frac{-1}{d}\right)\right)}\right)}}^{2} \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. *-commutative77.3%

        \[\leadsto \left({\left(e^{\color{blue}{\log \left(\frac{-1}{h}\right) \cdot 0.25}} \cdot e^{0.25 \cdot \left(-1 \cdot \log \left(\frac{-1}{d}\right)\right)}\right)}^{2} \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) \]
      4. exp-to-pow77.9%

        \[\leadsto \left({\left(\color{blue}{{\left(\frac{-1}{h}\right)}^{0.25}} \cdot e^{0.25 \cdot \left(-1 \cdot \log \left(\frac{-1}{d}\right)\right)}\right)}^{2} \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) \]
      5. *-commutative77.9%

        \[\leadsto \left({\left({\left(\frac{-1}{h}\right)}^{0.25} \cdot e^{\color{blue}{\left(-1 \cdot \log \left(\frac{-1}{d}\right)\right) \cdot 0.25}}\right)}^{2} \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. *-commutative77.9%

        \[\leadsto \left({\left({\left(\frac{-1}{h}\right)}^{0.25} \cdot e^{\color{blue}{\left(\log \left(\frac{-1}{d}\right) \cdot -1\right)} \cdot 0.25}\right)}^{2} \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. associate-*l*77.9%

        \[\leadsto \left({\left({\left(\frac{-1}{h}\right)}^{0.25} \cdot e^{\color{blue}{\log \left(\frac{-1}{d}\right) \cdot \left(-1 \cdot 0.25\right)}}\right)}^{2} \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) \]
      8. metadata-eval77.9%

        \[\leadsto \left({\left({\left(\frac{-1}{h}\right)}^{0.25} \cdot e^{\log \left(\frac{-1}{d}\right) \cdot \color{blue}{-0.25}}\right)}^{2} \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) \]
      9. metadata-eval77.9%

        \[\leadsto \left({\left({\left(\frac{-1}{h}\right)}^{0.25} \cdot e^{\log \left(\frac{-1}{d}\right) \cdot \color{blue}{\frac{-0.5}{2}}}\right)}^{2} \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) \]
      10. metadata-eval77.9%

        \[\leadsto \left({\left({\left(\frac{-1}{h}\right)}^{0.25} \cdot e^{\log \left(\frac{-1}{d}\right) \cdot \frac{\color{blue}{\frac{-1}{2}}}{2}}\right)}^{2} \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) \]
      11. exp-to-pow80.3%

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

        \[\leadsto \left({\left({\left(\frac{-1}{h}\right)}^{0.25} \cdot {\left(\frac{-1}{d}\right)}^{\left(\frac{\color{blue}{-0.5}}{2}\right)}\right)}^{2} \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) \]
      13. metadata-eval80.3%

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

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

    if -4.9999999999999995e-309 < d < 2.5999999999999999e-207

    1. Initial program 52.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. Simplified52.2%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \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-cube-cbrt52.1%

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

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

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

      \[\leadsto \left(\color{blue}{\left({\left({\left(\sqrt[3]{\frac{d}{h}}\right)}^{2}\right)}^{0.5} \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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. Step-by-step derivation
      1. unpow1/252.1%

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

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

        \[\leadsto \left(\left(\color{blue}{\left|\sqrt[3]{\frac{d}{h}}\right|} \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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) \]
      4. rem-square-sqrt52.2%

        \[\leadsto \left(\left(\left|\color{blue}{\sqrt{\sqrt[3]{\frac{d}{h}}} \cdot \sqrt{\sqrt[3]{\frac{d}{h}}}}\right| \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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) \]
      5. unpow1/252.2%

        \[\leadsto \left(\left(\left|\color{blue}{{\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}} \cdot \sqrt{\sqrt[3]{\frac{d}{h}}}\right| \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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. unpow1/252.2%

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

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

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

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

        \[\leadsto \left(\left(\color{blue}{\sqrt[3]{\frac{d}{h}}} \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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) \]
      11. unpow1/252.1%

        \[\leadsto \left(\left(\sqrt[3]{\frac{d}{h}} \cdot \color{blue}{\sqrt{\sqrt[3]{\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) \]
    8. Simplified52.1%

      \[\leadsto \left(\color{blue}{\left(\sqrt[3]{\frac{d}{h}} \cdot \sqrt{\sqrt[3]{\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) \]
    9. Taylor expanded in d around 0 68.7%

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

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

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

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

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

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

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

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

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

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

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

    if 2.5999999999999999e-207 < d < 2.0000000000000001e-127

    1. Initial program 63.3%

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

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

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

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

    if 2.0000000000000001e-127 < d

    1. Initial program 74.4%

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

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

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

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

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

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

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

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

Alternative 2: 73.7% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;d \leq 5 \cdot 10^{-138}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot t_0\\

\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot t_0\\


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

    1. Initial program 68.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. Applied egg-rr26.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < d < 1.3e-206

    1. Initial program 52.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. Simplified52.2%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \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-cube-cbrt52.1%

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

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

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

      \[\leadsto \left(\color{blue}{\left({\left({\left(\sqrt[3]{\frac{d}{h}}\right)}^{2}\right)}^{0.5} \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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. Step-by-step derivation
      1. unpow1/252.1%

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

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

        \[\leadsto \left(\left(\color{blue}{\left|\sqrt[3]{\frac{d}{h}}\right|} \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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) \]
      4. rem-square-sqrt52.2%

        \[\leadsto \left(\left(\left|\color{blue}{\sqrt{\sqrt[3]{\frac{d}{h}}} \cdot \sqrt{\sqrt[3]{\frac{d}{h}}}}\right| \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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) \]
      5. unpow1/252.2%

        \[\leadsto \left(\left(\left|\color{blue}{{\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}} \cdot \sqrt{\sqrt[3]{\frac{d}{h}}}\right| \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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. unpow1/252.2%

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

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

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

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

        \[\leadsto \left(\left(\color{blue}{\sqrt[3]{\frac{d}{h}}} \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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) \]
      11. unpow1/252.1%

        \[\leadsto \left(\left(\sqrt[3]{\frac{d}{h}} \cdot \color{blue}{\sqrt{\sqrt[3]{\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) \]
    8. Simplified52.1%

      \[\leadsto \left(\color{blue}{\left(\sqrt[3]{\frac{d}{h}} \cdot \sqrt{\sqrt[3]{\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) \]
    9. Taylor expanded in d around 0 68.7%

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

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

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

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

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

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

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

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

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

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

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

    if 1.3e-206 < d < 4.99999999999999989e-138

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

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

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

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

    if 4.99999999999999989e-138 < d

    1. Initial program 74.4%

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

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

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

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

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

Alternative 3: 72.2% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 68.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. Applied egg-rr26.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < d < 2.59999999999999983e-204

    1. Initial program 52.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. Simplified52.2%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \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-cube-cbrt52.1%

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

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

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

      \[\leadsto \left(\color{blue}{\left({\left({\left(\sqrt[3]{\frac{d}{h}}\right)}^{2}\right)}^{0.5} \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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. Step-by-step derivation
      1. unpow1/252.1%

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

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

        \[\leadsto \left(\left(\color{blue}{\left|\sqrt[3]{\frac{d}{h}}\right|} \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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) \]
      4. rem-square-sqrt52.2%

        \[\leadsto \left(\left(\left|\color{blue}{\sqrt{\sqrt[3]{\frac{d}{h}}} \cdot \sqrt{\sqrt[3]{\frac{d}{h}}}}\right| \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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) \]
      5. unpow1/252.2%

        \[\leadsto \left(\left(\left|\color{blue}{{\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}} \cdot \sqrt{\sqrt[3]{\frac{d}{h}}}\right| \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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. unpow1/252.2%

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

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

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

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

        \[\leadsto \left(\left(\color{blue}{\sqrt[3]{\frac{d}{h}}} \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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) \]
      11. unpow1/252.1%

        \[\leadsto \left(\left(\sqrt[3]{\frac{d}{h}} \cdot \color{blue}{\sqrt{\sqrt[3]{\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) \]
    8. Simplified52.1%

      \[\leadsto \left(\color{blue}{\left(\sqrt[3]{\frac{d}{h}} \cdot \sqrt{\sqrt[3]{\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) \]
    9. Taylor expanded in d around 0 68.7%

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

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

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

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

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

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

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

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

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

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

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

    if 2.59999999999999983e-204 < d

    1. Initial program 72.3%

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

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

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

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

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

Alternative 4: 73.9% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 68.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. Applied egg-rr26.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < d < 2.3000000000000001e-207

    1. Initial program 52.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. Simplified52.2%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \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-cube-cbrt52.1%

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

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

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

      \[\leadsto \left(\color{blue}{\left({\left({\left(\sqrt[3]{\frac{d}{h}}\right)}^{2}\right)}^{0.5} \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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. Step-by-step derivation
      1. unpow1/252.1%

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

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

        \[\leadsto \left(\left(\color{blue}{\left|\sqrt[3]{\frac{d}{h}}\right|} \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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) \]
      4. rem-square-sqrt52.2%

        \[\leadsto \left(\left(\left|\color{blue}{\sqrt{\sqrt[3]{\frac{d}{h}}} \cdot \sqrt{\sqrt[3]{\frac{d}{h}}}}\right| \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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) \]
      5. unpow1/252.2%

        \[\leadsto \left(\left(\left|\color{blue}{{\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}} \cdot \sqrt{\sqrt[3]{\frac{d}{h}}}\right| \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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. unpow1/252.2%

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

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

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

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

        \[\leadsto \left(\left(\color{blue}{\sqrt[3]{\frac{d}{h}}} \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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) \]
      11. unpow1/252.1%

        \[\leadsto \left(\left(\sqrt[3]{\frac{d}{h}} \cdot \color{blue}{\sqrt{\sqrt[3]{\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) \]
    8. Simplified52.1%

      \[\leadsto \left(\color{blue}{\left(\sqrt[3]{\frac{d}{h}} \cdot \sqrt{\sqrt[3]{\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) \]
    9. Taylor expanded in d around 0 68.7%

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

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

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

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

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

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

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

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

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

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

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

    if 2.3000000000000001e-207 < d

    1. Initial program 72.3%

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

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

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

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

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

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

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

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

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

Alternative 5: 75.2% accurate, 0.8× speedup?

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

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


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

    1. Initial program 68.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. Applied egg-rr26.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 69.1%

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

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

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

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

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

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

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

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

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

Alternative 6: 71.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 68.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. Applied egg-rr26.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.8999999999999999e-308 < l < 5.20000000000000015e122

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

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

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

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

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

        \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \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. sqr-pow76.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.20000000000000015e122 < l

    1. Initial program 59.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. Taylor expanded in d around inf 53.8%

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

        \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      2. add-cbrt-cube40.1%

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

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      4. *-commutative40.1%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity54.0%

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

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

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

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

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

Alternative 7: 71.6% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 68.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. Applied egg-rr26.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.8999999999999999e-308 < l < 6.99999999999999965e117

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

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

    if 6.99999999999999965e117 < l

    1. Initial program 59.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. Taylor expanded in d around inf 53.8%

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

        \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      2. add-cbrt-cube40.1%

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

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      4. *-commutative40.1%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity54.0%

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

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

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

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

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

Alternative 8: 71.1% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 68.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. Applied egg-rr26.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < d < 2.79999999999999991e-205

    1. Initial program 52.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. Simplified52.2%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \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-cube-cbrt52.1%

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

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

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

      \[\leadsto \left(\color{blue}{\left({\left({\left(\sqrt[3]{\frac{d}{h}}\right)}^{2}\right)}^{0.5} \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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. Step-by-step derivation
      1. unpow1/252.1%

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

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

        \[\leadsto \left(\left(\color{blue}{\left|\sqrt[3]{\frac{d}{h}}\right|} \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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) \]
      4. rem-square-sqrt52.2%

        \[\leadsto \left(\left(\left|\color{blue}{\sqrt{\sqrt[3]{\frac{d}{h}}} \cdot \sqrt{\sqrt[3]{\frac{d}{h}}}}\right| \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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) \]
      5. unpow1/252.2%

        \[\leadsto \left(\left(\left|\color{blue}{{\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}} \cdot \sqrt{\sqrt[3]{\frac{d}{h}}}\right| \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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. unpow1/252.2%

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

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

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

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

        \[\leadsto \left(\left(\color{blue}{\sqrt[3]{\frac{d}{h}}} \cdot {\left(\sqrt[3]{\frac{d}{h}}\right)}^{0.5}\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) \]
      11. unpow1/252.1%

        \[\leadsto \left(\left(\sqrt[3]{\frac{d}{h}} \cdot \color{blue}{\sqrt{\sqrt[3]{\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) \]
    8. Simplified52.1%

      \[\leadsto \left(\color{blue}{\left(\sqrt[3]{\frac{d}{h}} \cdot \sqrt{\sqrt[3]{\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) \]
    9. Taylor expanded in d around 0 68.7%

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

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

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

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

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

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

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

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

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

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

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

    if 2.79999999999999991e-205 < d

    1. Initial program 72.3%

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

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

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

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

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

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

      \[\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-/l*73.3%

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

      \[\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}{\frac{d}{M}}\right)}}^{2} \cdot h}{\ell}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification76.2%

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

Alternative 9: 72.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 68.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. Applied egg-rr26.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.8999999999999999e-308 < l < 3.1500000000000001e153

    1. Initial program 73.4%

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

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

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

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

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

      \[\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 3.1500000000000001e153 < l

    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. Taylor expanded in d around inf 53.1%

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

        \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      2. add-cbrt-cube39.9%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}}} \]
      3. add-sqr-sqrt39.8%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      4. *-commutative39.8%

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 58.9% accurate, 1.4× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{if}\;\ell \leq -6.8 \cdot 10^{-23}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{1}{h \cdot \ell}}\right)\\ \mathbf{elif}\;\ell \leq 2.6 \cdot 10^{-122}:\\ \;\;\;\;t_0 \cdot \left(1 + -0.5 \cdot \left(h \cdot \frac{{\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{elif}\;\ell \leq 2.4 \cdot 10^{-68}:\\ \;\;\;\;-0.125 \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right)}{d}\\ \mathbf{elif}\;\ell \leq 3.5 \cdot 10^{-33}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq 6.9 \cdot 10^{+81}:\\ \;\;\;\;t_0 \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (* (/ d l) (/ d h)))))
   (if (<= l -6.8e-23)
     (* d (- (sqrt (/ 1.0 (* h l)))))
     (if (<= l 2.6e-122)
       (* t_0 (+ 1.0 (* -0.5 (* h (/ (pow (* (* 0.5 M) (/ D d)) 2.0) l)))))
       (if (<= l 2.4e-68)
         (* -0.125 (/ (* (sqrt (/ h (pow l 3.0))) (* (* M D) (* M D))) d))
         (if (<= l 3.5e-33)
           (/ d (sqrt (* h l)))
           (if (<= l 6.9e+81)
             (*
              t_0
              (+ 1.0 (* -0.5 (* (/ h l) (pow (* D (* 0.5 (/ M d))) 2.0)))))
             (/ d (* (sqrt l) (sqrt h))))))))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt(((d / l) * (d / h)));
	double tmp;
	if (l <= -6.8e-23) {
		tmp = d * -sqrt((1.0 / (h * l)));
	} else if (l <= 2.6e-122) {
		tmp = t_0 * (1.0 + (-0.5 * (h * (pow(((0.5 * M) * (D / d)), 2.0) / l))));
	} else if (l <= 2.4e-68) {
		tmp = -0.125 * ((sqrt((h / pow(l, 3.0))) * ((M * D) * (M * D))) / d);
	} else if (l <= 3.5e-33) {
		tmp = d / sqrt((h * l));
	} else if (l <= 6.9e+81) {
		tmp = t_0 * (1.0 + (-0.5 * ((h / l) * pow((D * (0.5 * (M / d))), 2.0))));
	} else {
		tmp = d / (sqrt(l) * sqrt(h));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt(((d / l) * (d / h)))
    if (l <= (-6.8d-23)) then
        tmp = d * -sqrt((1.0d0 / (h * l)))
    else if (l <= 2.6d-122) then
        tmp = t_0 * (1.0d0 + ((-0.5d0) * (h * ((((0.5d0 * m) * (d_1 / d)) ** 2.0d0) / l))))
    else if (l <= 2.4d-68) then
        tmp = (-0.125d0) * ((sqrt((h / (l ** 3.0d0))) * ((m * d_1) * (m * d_1))) / d)
    else if (l <= 3.5d-33) then
        tmp = d / sqrt((h * l))
    else if (l <= 6.9d+81) then
        tmp = t_0 * (1.0d0 + ((-0.5d0) * ((h / l) * ((d_1 * (0.5d0 * (m / d))) ** 2.0d0))))
    else
        tmp = d / (sqrt(l) * sqrt(h))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt(((d / l) * (d / h)));
	double tmp;
	if (l <= -6.8e-23) {
		tmp = d * -Math.sqrt((1.0 / (h * l)));
	} else if (l <= 2.6e-122) {
		tmp = t_0 * (1.0 + (-0.5 * (h * (Math.pow(((0.5 * M) * (D / d)), 2.0) / l))));
	} else if (l <= 2.4e-68) {
		tmp = -0.125 * ((Math.sqrt((h / Math.pow(l, 3.0))) * ((M * D) * (M * D))) / d);
	} else if (l <= 3.5e-33) {
		tmp = d / Math.sqrt((h * l));
	} else if (l <= 6.9e+81) {
		tmp = t_0 * (1.0 + (-0.5 * ((h / l) * Math.pow((D * (0.5 * (M / d))), 2.0))));
	} else {
		tmp = d / (Math.sqrt(l) * Math.sqrt(h));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt(((d / l) * (d / h)))
	tmp = 0
	if l <= -6.8e-23:
		tmp = d * -math.sqrt((1.0 / (h * l)))
	elif l <= 2.6e-122:
		tmp = t_0 * (1.0 + (-0.5 * (h * (math.pow(((0.5 * M) * (D / d)), 2.0) / l))))
	elif l <= 2.4e-68:
		tmp = -0.125 * ((math.sqrt((h / math.pow(l, 3.0))) * ((M * D) * (M * D))) / d)
	elif l <= 3.5e-33:
		tmp = d / math.sqrt((h * l))
	elif l <= 6.9e+81:
		tmp = t_0 * (1.0 + (-0.5 * ((h / l) * math.pow((D * (0.5 * (M / d))), 2.0))))
	else:
		tmp = d / (math.sqrt(l) * math.sqrt(h))
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(Float64(d / l) * Float64(d / h)))
	tmp = 0.0
	if (l <= -6.8e-23)
		tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(h * l)))));
	elseif (l <= 2.6e-122)
		tmp = Float64(t_0 * Float64(1.0 + Float64(-0.5 * Float64(h * Float64((Float64(Float64(0.5 * M) * Float64(D / d)) ^ 2.0) / l)))));
	elseif (l <= 2.4e-68)
		tmp = Float64(-0.125 * Float64(Float64(sqrt(Float64(h / (l ^ 3.0))) * Float64(Float64(M * D) * Float64(M * D))) / d));
	elseif (l <= 3.5e-33)
		tmp = Float64(d / sqrt(Float64(h * l)));
	elseif (l <= 6.9e+81)
		tmp = Float64(t_0 * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(D * Float64(0.5 * Float64(M / d))) ^ 2.0)))));
	else
		tmp = Float64(d / Float64(sqrt(l) * sqrt(h)));
	end
	return tmp
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt(((d / l) * (d / h)));
	tmp = 0.0;
	if (l <= -6.8e-23)
		tmp = d * -sqrt((1.0 / (h * l)));
	elseif (l <= 2.6e-122)
		tmp = t_0 * (1.0 + (-0.5 * (h * ((((0.5 * M) * (D / d)) ^ 2.0) / l))));
	elseif (l <= 2.4e-68)
		tmp = -0.125 * ((sqrt((h / (l ^ 3.0))) * ((M * D) * (M * D))) / d);
	elseif (l <= 3.5e-33)
		tmp = d / sqrt((h * l));
	elseif (l <= 6.9e+81)
		tmp = t_0 * (1.0 + (-0.5 * ((h / l) * ((D * (0.5 * (M / d))) ^ 2.0))));
	else
		tmp = d / (sqrt(l) * sqrt(h));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -6.8e-23], N[(d * (-N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[l, 2.6e-122], N[(t$95$0 * N[(1.0 + N[(-0.5 * N[(h * N[(N[Power[N[(N[(0.5 * M), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.4e-68], N[(-0.125 * N[(N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.5e-33], N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6.9e+81], N[(t$95$0 * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(D * N[(0.5 * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{if}\;\ell \leq -6.8 \cdot 10^{-23}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{h \cdot \ell}}\right)\\

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if l < -6.8000000000000001e-23

    1. Initial program 63.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.8000000000000001e-23 < l < 2.59999999999999975e-122

    1. Initial program 75.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.59999999999999975e-122 < l < 2.39999999999999991e-68

    1. Initial program 78.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Taylor expanded in d around 0 79.4%

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

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

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

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

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

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

    if 2.39999999999999991e-68 < l < 3.4999999999999999e-33

    1. Initial program 56.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. Taylor expanded in d around inf 88.7%

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

        \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      2. add-cbrt-cube44.3%

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

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      4. *-commutative44.3%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity88.9%

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

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

    if 3.4999999999999999e-33 < l < 6.8999999999999996e81

    1. Initial program 79.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.8999999999999996e81 < l

    1. Initial program 58.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Taylor expanded in d around inf 53.4%

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

        \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      2. add-cbrt-cube41.3%

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

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      4. *-commutative41.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -6.8 \cdot 10^{-23}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{1}{h \cdot \ell}}\right)\\ \mathbf{elif}\;\ell \leq 2.6 \cdot 10^{-122}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.5 \cdot \left(h \cdot \frac{{\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{elif}\;\ell \leq 2.4 \cdot 10^{-68}:\\ \;\;\;\;-0.125 \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right)}{d}\\ \mathbf{elif}\;\ell \leq 3.5 \cdot 10^{-33}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq 6.9 \cdot 10^{+81}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]

Alternative 11: 58.8% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 63.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.5999999999999994e-23 < l < 6.4999999999999996e81

    1. Initial program 75.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. Applied egg-rr19.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.4999999999999996e81 < l

    1. Initial program 58.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Taylor expanded in d around inf 53.4%

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

        \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      2. add-cbrt-cube41.3%

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

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      4. *-commutative41.3%

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 60.7% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 63.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.4999999999999998e-23 < l < 2.8e82

    1. Initial program 75.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. Applied egg-rr19.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.8e82 < l

    1. Initial program 58.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Taylor expanded in d around inf 53.4%

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

        \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      2. add-cbrt-cube41.3%

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

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      4. *-commutative41.3%

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 66.4% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 68.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. Applied egg-rr26.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.8999999999999999e-308 < l < 6.4999999999999996e81

    1. Initial program 76.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.4999999999999996e81 < l

    1. Initial program 58.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Taylor expanded in d around inf 53.4%

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

        \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      2. add-cbrt-cube41.3%

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

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      4. *-commutative41.3%

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 68.7% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 68.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. Applied egg-rr26.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.8999999999999999e-308 < l < 5.00000000000000015e82

    1. Initial program 76.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000000000000015e82 < l

    1. Initial program 58.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Taylor expanded in d around inf 53.4%

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

        \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      2. add-cbrt-cube41.3%

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

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      4. *-commutative41.3%

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 55.5% accurate, 1.6× speedup?

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

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

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


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

    1. Initial program 63.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
      3. distribute-rgt-neg-in56.3%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-d\right)} \]
      4. *-commutative56.3%

        \[\leadsto \sqrt{\frac{1}{\color{blue}{h \cdot \ell}}} \cdot \left(-d\right) \]
    9. Simplified56.3%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(-d\right)} \]

    if -1.15000000000000005e-23 < l < 2.9500000000000002e81

    1. Initial program 75.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. Applied egg-rr19.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    3. Step-by-step derivation
      1. expm1-def25.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p66.4%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. cancel-sign-sub-inv66.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left(1 + \left(-0.5\right) \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      4. metadata-eval66.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{-0.5} \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      5. *-commutative66.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(0.5 \cdot M\right)} \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      6. associate-*r*66.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}}^{2}\right)\right) \]
      7. *-commutative66.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot 0.5\right)}}^{2}\right)\right) \]
      8. associate-*r/67.1%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\frac{M \cdot D}{d}} \cdot 0.5\right)}^{2}\right)\right) \]
      9. associate-*l/66.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(\frac{M}{d} \cdot D\right)} \cdot 0.5\right)}^{2}\right)\right) \]
      10. *-commutative66.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d}\right)} \cdot 0.5\right)}^{2}\right)\right) \]
      11. associate-*l*66.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}}^{2}\right)\right) \]
    4. Simplified66.3%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    5. Step-by-step derivation
      1. associate-*l/67.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{h \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}}{\ell}}\right) \]
      2. *-commutative67.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \frac{h \cdot {\left(D \cdot \color{blue}{\left(0.5 \cdot \frac{M}{d}\right)}\right)}^{2}}{\ell}\right) \]
    6. Applied egg-rr67.9%

      \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{h \cdot {\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)}^{2}}{\ell}}\right) \]
    7. Taylor expanded in h around 0 43.1%

      \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(0.25 \cdot \frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{\ell \cdot {d}^{2}}\right)}\right) \]
    8. Step-by-step derivation
      1. associate-*r/43.1%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{0.25 \cdot \left({D}^{2} \cdot \left(h \cdot {M}^{2}\right)\right)}{\ell \cdot {d}^{2}}}\right) \]
      2. unpow243.1%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \frac{0.25 \cdot \left({D}^{2} \cdot \left(h \cdot \color{blue}{\left(M \cdot M\right)}\right)\right)}{\ell \cdot {d}^{2}}\right) \]
      3. *-commutative43.1%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \frac{0.25 \cdot \left({D}^{2} \cdot \color{blue}{\left(\left(M \cdot M\right) \cdot h\right)}\right)}{\ell \cdot {d}^{2}}\right) \]
      4. unpow243.1%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \frac{0.25 \cdot \left({D}^{2} \cdot \left(\color{blue}{{M}^{2}} \cdot h\right)\right)}{\ell \cdot {d}^{2}}\right) \]
      5. *-commutative43.1%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \frac{0.25 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{\color{blue}{{d}^{2} \cdot \ell}}\right) \]
      6. associate-*r/43.1%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
      7. times-frac44.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \color{blue}{\left(\frac{{D}^{2}}{{d}^{2}} \cdot \frac{{M}^{2} \cdot h}{\ell}\right)}\right)\right) \]
      8. unpow244.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\frac{\color{blue}{D \cdot D}}{{d}^{2}} \cdot \frac{{M}^{2} \cdot h}{\ell}\right)\right)\right) \]
      9. unpow244.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\frac{D \cdot D}{\color{blue}{d \cdot d}} \cdot \frac{{M}^{2} \cdot h}{\ell}\right)\right)\right) \]
      10. times-frac54.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)} \cdot \frac{{M}^{2} \cdot h}{\ell}\right)\right)\right) \]
      11. unpow254.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{\color{blue}{\left(M \cdot M\right)} \cdot h}{\ell}\right)\right)\right) \]
      12. *-commutative54.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{\color{blue}{h \cdot \left(M \cdot M\right)}}{\ell}\right)\right)\right) \]
      13. associate-/l*54.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \color{blue}{\frac{h}{\frac{\ell}{M \cdot M}}}\right)\right)\right) \]
    9. Simplified54.9%

      \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{h}{\frac{\ell}{M \cdot M}}\right)\right)}\right) \]

    if 2.9500000000000002e81 < l

    1. Initial program 58.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Taylor expanded in d around inf 53.4%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    3. Step-by-step derivation
      1. *-commutative53.4%

        \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      2. add-cbrt-cube41.3%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}}} \]
      3. add-sqr-sqrt41.3%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      4. *-commutative41.3%

        \[\leadsto d \cdot \sqrt[3]{\frac{1}{\color{blue}{h \cdot \ell}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      5. *-commutative41.3%

        \[\leadsto d \cdot \sqrt[3]{\frac{1}{h \cdot \ell} \cdot \sqrt{\frac{1}{\color{blue}{h \cdot \ell}}}} \]
      6. pow141.3%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt[3]{\frac{1}{h \cdot \ell} \cdot \sqrt{\frac{1}{h \cdot \ell}}}\right)}^{1}} \]
    4. Applied egg-rr53.4%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow153.4%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/53.5%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity53.5%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    6. Simplified53.5%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. sqrt-prod70.3%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Applied egg-rr70.3%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification58.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.15 \cdot 10^{-23}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{1}{h \cdot \ell}}\right)\\ \mathbf{elif}\;\ell \leq 2.95 \cdot 10^{+81}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{h}{\frac{\ell}{M \cdot M}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]

Alternative 16: 56.5% accurate, 1.6× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 7.2 \cdot 10^{-180}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{h}{\frac{\ell}{M \cdot M}}\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (if (<= M 7.2e-180)
   (* (sqrt (/ d l)) (sqrt (/ d h)))
   (*
    (sqrt (* (/ d l) (/ d h)))
    (+ 1.0 (* -0.5 (* 0.25 (* (* (/ D d) (/ D d)) (/ h (/ l (* M M))))))))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (M <= 7.2e-180) {
		tmp = sqrt((d / l)) * sqrt((d / h));
	} else {
		tmp = sqrt(((d / l) * (d / h))) * (1.0 + (-0.5 * (0.25 * (((D / d) * (D / d)) * (h / (l / (M * M)))))));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: tmp
    if (m <= 7.2d-180) then
        tmp = sqrt((d / l)) * sqrt((d / h))
    else
        tmp = sqrt(((d / l) * (d / h))) * (1.0d0 + ((-0.5d0) * (0.25d0 * (((d_1 / d) * (d_1 / d)) * (h / (l / (m * m)))))))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (M <= 7.2e-180) {
		tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
	} else {
		tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 + (-0.5 * (0.25 * (((D / d) * (D / d)) * (h / (l / (M * M)))))));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if M <= 7.2e-180:
		tmp = math.sqrt((d / l)) * math.sqrt((d / h))
	else:
		tmp = math.sqrt(((d / l) * (d / h))) * (1.0 + (-0.5 * (0.25 * (((D / d) * (D / d)) * (h / (l / (M * M)))))))
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (M <= 7.2e-180)
		tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h)));
	else
		tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 + Float64(-0.5 * Float64(0.25 * Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(h / Float64(l / Float64(M * M))))))));
	end
	return tmp
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (M <= 7.2e-180)
		tmp = sqrt((d / l)) * sqrt((d / h));
	else
		tmp = sqrt(((d / l) * (d / h))) * (1.0 + (-0.5 * (0.25 * (((D / d) * (D / d)) * (h / (l / (M * M)))))));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := If[LessEqual[M, 7.2e-180], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(0.25 * N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(h / N[(l / N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 7.2 \cdot 10^{-180}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{h}{\frac{\ell}{M \cdot M}}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 7.1999999999999998e-180

    1. Initial program 68.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified68.6%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Taylor expanded in M around 0 43.3%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{1}\right) \]

    if 7.1999999999999998e-180 < M

    1. Initial program 69.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Applied egg-rr21.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    3. Step-by-step derivation
      1. expm1-def27.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p55.2%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. cancel-sign-sub-inv55.2%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left(1 + \left(-0.5\right) \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      4. metadata-eval55.2%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{-0.5} \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      5. *-commutative55.2%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(0.5 \cdot M\right)} \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      6. associate-*r*55.2%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}}^{2}\right)\right) \]
      7. *-commutative55.2%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot 0.5\right)}}^{2}\right)\right) \]
      8. associate-*r/56.1%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\frac{M \cdot D}{d}} \cdot 0.5\right)}^{2}\right)\right) \]
      9. associate-*l/55.5%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(\frac{M}{d} \cdot D\right)} \cdot 0.5\right)}^{2}\right)\right) \]
      10. *-commutative55.5%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d}\right)} \cdot 0.5\right)}^{2}\right)\right) \]
      11. associate-*l*55.5%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}}^{2}\right)\right) \]
    4. Simplified55.5%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    5. Step-by-step derivation
      1. associate-*l/56.5%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{h \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}}{\ell}}\right) \]
      2. *-commutative56.5%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \frac{h \cdot {\left(D \cdot \color{blue}{\left(0.5 \cdot \frac{M}{d}\right)}\right)}^{2}}{\ell}\right) \]
    6. Applied egg-rr56.5%

      \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{h \cdot {\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)}^{2}}{\ell}}\right) \]
    7. Taylor expanded in h around 0 30.3%

      \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(0.25 \cdot \frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{\ell \cdot {d}^{2}}\right)}\right) \]
    8. Step-by-step derivation
      1. associate-*r/30.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{0.25 \cdot \left({D}^{2} \cdot \left(h \cdot {M}^{2}\right)\right)}{\ell \cdot {d}^{2}}}\right) \]
      2. unpow230.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \frac{0.25 \cdot \left({D}^{2} \cdot \left(h \cdot \color{blue}{\left(M \cdot M\right)}\right)\right)}{\ell \cdot {d}^{2}}\right) \]
      3. *-commutative30.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \frac{0.25 \cdot \left({D}^{2} \cdot \color{blue}{\left(\left(M \cdot M\right) \cdot h\right)}\right)}{\ell \cdot {d}^{2}}\right) \]
      4. unpow230.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \frac{0.25 \cdot \left({D}^{2} \cdot \left(\color{blue}{{M}^{2}} \cdot h\right)\right)}{\ell \cdot {d}^{2}}\right) \]
      5. *-commutative30.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \frac{0.25 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{\color{blue}{{d}^{2} \cdot \ell}}\right) \]
      6. associate-*r/30.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
      7. times-frac32.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \color{blue}{\left(\frac{{D}^{2}}{{d}^{2}} \cdot \frac{{M}^{2} \cdot h}{\ell}\right)}\right)\right) \]
      8. unpow232.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\frac{\color{blue}{D \cdot D}}{{d}^{2}} \cdot \frac{{M}^{2} \cdot h}{\ell}\right)\right)\right) \]
      9. unpow232.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\frac{D \cdot D}{\color{blue}{d \cdot d}} \cdot \frac{{M}^{2} \cdot h}{\ell}\right)\right)\right) \]
      10. times-frac42.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)} \cdot \frac{{M}^{2} \cdot h}{\ell}\right)\right)\right) \]
      11. unpow242.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{\color{blue}{\left(M \cdot M\right)} \cdot h}{\ell}\right)\right)\right) \]
      12. *-commutative42.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{\color{blue}{h \cdot \left(M \cdot M\right)}}{\ell}\right)\right)\right) \]
      13. associate-/l*42.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \color{blue}{\frac{h}{\frac{\ell}{M \cdot M}}}\right)\right)\right) \]
    9. Simplified42.3%

      \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{h}{\frac{\ell}{M \cdot M}}\right)\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification42.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 7.2 \cdot 10^{-180}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{h}{\frac{\ell}{M \cdot M}}\right)\right)\right)\\ \end{array} \]

Alternative 17: 52.7% accurate, 2.5× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -6.2 \cdot 10^{-23}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{1}{h \cdot \ell}}\right)\\ \mathbf{elif}\;\ell \leq 6.5 \cdot 10^{+168}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{h}{\frac{\ell}{M \cdot M}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -6.2e-23)
   (* d (- (sqrt (/ 1.0 (* h l)))))
   (if (<= l 6.5e+168)
     (*
      (sqrt (* (/ d l) (/ d h)))
      (+ 1.0 (* -0.5 (* 0.25 (* (* (/ D d) (/ D d)) (/ h (/ l (* M M))))))))
     (/ d (sqrt (* h l))))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -6.2e-23) {
		tmp = d * -sqrt((1.0 / (h * l)));
	} else if (l <= 6.5e+168) {
		tmp = sqrt(((d / l) * (d / h))) * (1.0 + (-0.5 * (0.25 * (((D / d) * (D / d)) * (h / (l / (M * M)))))));
	} else {
		tmp = d / sqrt((h * l));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: tmp
    if (l <= (-6.2d-23)) then
        tmp = d * -sqrt((1.0d0 / (h * l)))
    else if (l <= 6.5d+168) then
        tmp = sqrt(((d / l) * (d / h))) * (1.0d0 + ((-0.5d0) * (0.25d0 * (((d_1 / d) * (d_1 / d)) * (h / (l / (m * m)))))))
    else
        tmp = d / sqrt((h * l))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -6.2e-23) {
		tmp = d * -Math.sqrt((1.0 / (h * l)));
	} else if (l <= 6.5e+168) {
		tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 + (-0.5 * (0.25 * (((D / d) * (D / d)) * (h / (l / (M * M)))))));
	} else {
		tmp = d / Math.sqrt((h * l));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if l <= -6.2e-23:
		tmp = d * -math.sqrt((1.0 / (h * l)))
	elif l <= 6.5e+168:
		tmp = math.sqrt(((d / l) * (d / h))) * (1.0 + (-0.5 * (0.25 * (((D / d) * (D / d)) * (h / (l / (M * M)))))))
	else:
		tmp = d / math.sqrt((h * l))
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -6.2e-23)
		tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(h * l)))));
	elseif (l <= 6.5e+168)
		tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 + Float64(-0.5 * Float64(0.25 * Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(h / Float64(l / Float64(M * M))))))));
	else
		tmp = Float64(d / sqrt(Float64(h * l)));
	end
	return tmp
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (l <= -6.2e-23)
		tmp = d * -sqrt((1.0 / (h * l)));
	elseif (l <= 6.5e+168)
		tmp = sqrt(((d / l) * (d / h))) * (1.0 + (-0.5 * (0.25 * (((D / d) * (D / d)) * (h / (l / (M * M)))))));
	else
		tmp = d / sqrt((h * l));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -6.2e-23], N[(d * (-N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[l, 6.5e+168], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(0.25 * N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(h / N[(l / N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6.2 \cdot 10^{-23}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{h \cdot \ell}}\right)\\

\mathbf{elif}\;\ell \leq 6.5 \cdot 10^{+168}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{h}{\frac{\ell}{M \cdot M}}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -6.1999999999999998e-23

    1. Initial program 63.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Applied egg-rr29.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    3. Step-by-step derivation
      1. expm1-def40.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p48.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. cancel-sign-sub-inv48.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left(1 + \left(-0.5\right) \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      4. metadata-eval48.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{-0.5} \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      5. *-commutative48.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(0.5 \cdot M\right)} \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      6. associate-*r*48.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}}^{2}\right)\right) \]
      7. *-commutative48.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot 0.5\right)}}^{2}\right)\right) \]
      8. associate-*r/47.3%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\frac{M \cdot D}{d}} \cdot 0.5\right)}^{2}\right)\right) \]
      9. associate-*l/48.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(\frac{M}{d} \cdot D\right)} \cdot 0.5\right)}^{2}\right)\right) \]
      10. *-commutative48.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d}\right)} \cdot 0.5\right)}^{2}\right)\right) \]
      11. associate-*l*48.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}}^{2}\right)\right) \]
    4. Simplified48.9%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    5. Step-by-step derivation
      1. associate-*l/49.0%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{h \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}}{\ell}}\right) \]
      2. *-commutative49.0%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \frac{h \cdot {\left(D \cdot \color{blue}{\left(0.5 \cdot \frac{M}{d}\right)}\right)}^{2}}{\ell}\right) \]
    6. Applied egg-rr49.0%

      \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{h \cdot {\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)}^{2}}{\ell}}\right) \]
    7. Taylor expanded in d around -inf 56.3%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)} \]
    8. Step-by-step derivation
      1. mul-1-neg56.3%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      2. *-commutative56.3%

        \[\leadsto -\color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
      3. distribute-rgt-neg-in56.3%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-d\right)} \]
      4. *-commutative56.3%

        \[\leadsto \sqrt{\frac{1}{\color{blue}{h \cdot \ell}}} \cdot \left(-d\right) \]
    9. Simplified56.3%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(-d\right)} \]

    if -6.1999999999999998e-23 < l < 6.49999999999999999e168

    1. Initial program 73.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. Applied egg-rr21.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    3. Step-by-step derivation
      1. expm1-def27.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p64.7%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. cancel-sign-sub-inv64.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left(1 + \left(-0.5\right) \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      4. metadata-eval64.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{-0.5} \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      5. *-commutative64.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(0.5 \cdot M\right)} \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      6. associate-*r*64.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}}^{2}\right)\right) \]
      7. *-commutative64.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot 0.5\right)}}^{2}\right)\right) \]
      8. associate-*r/65.2%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\frac{M \cdot D}{d}} \cdot 0.5\right)}^{2}\right)\right) \]
      9. associate-*l/64.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(\frac{M}{d} \cdot D\right)} \cdot 0.5\right)}^{2}\right)\right) \]
      10. *-commutative64.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d}\right)} \cdot 0.5\right)}^{2}\right)\right) \]
      11. associate-*l*64.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}}^{2}\right)\right) \]
    4. Simplified64.6%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    5. Step-by-step derivation
      1. associate-*l/66.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{h \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}}{\ell}}\right) \]
      2. *-commutative66.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \frac{h \cdot {\left(D \cdot \color{blue}{\left(0.5 \cdot \frac{M}{d}\right)}\right)}^{2}}{\ell}\right) \]
    6. Applied egg-rr66.7%

      \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{h \cdot {\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)}^{2}}{\ell}}\right) \]
    7. Taylor expanded in h around 0 41.9%

      \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(0.25 \cdot \frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{\ell \cdot {d}^{2}}\right)}\right) \]
    8. Step-by-step derivation
      1. associate-*r/41.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{0.25 \cdot \left({D}^{2} \cdot \left(h \cdot {M}^{2}\right)\right)}{\ell \cdot {d}^{2}}}\right) \]
      2. unpow241.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \frac{0.25 \cdot \left({D}^{2} \cdot \left(h \cdot \color{blue}{\left(M \cdot M\right)}\right)\right)}{\ell \cdot {d}^{2}}\right) \]
      3. *-commutative41.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \frac{0.25 \cdot \left({D}^{2} \cdot \color{blue}{\left(\left(M \cdot M\right) \cdot h\right)}\right)}{\ell \cdot {d}^{2}}\right) \]
      4. unpow241.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \frac{0.25 \cdot \left({D}^{2} \cdot \left(\color{blue}{{M}^{2}} \cdot h\right)\right)}{\ell \cdot {d}^{2}}\right) \]
      5. *-commutative41.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \frac{0.25 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{\color{blue}{{d}^{2} \cdot \ell}}\right) \]
      6. associate-*r/41.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
      7. times-frac43.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \color{blue}{\left(\frac{{D}^{2}}{{d}^{2}} \cdot \frac{{M}^{2} \cdot h}{\ell}\right)}\right)\right) \]
      8. unpow243.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\frac{\color{blue}{D \cdot D}}{{d}^{2}} \cdot \frac{{M}^{2} \cdot h}{\ell}\right)\right)\right) \]
      9. unpow243.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\frac{D \cdot D}{\color{blue}{d \cdot d}} \cdot \frac{{M}^{2} \cdot h}{\ell}\right)\right)\right) \]
      10. times-frac53.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)} \cdot \frac{{M}^{2} \cdot h}{\ell}\right)\right)\right) \]
      11. unpow253.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{\color{blue}{\left(M \cdot M\right)} \cdot h}{\ell}\right)\right)\right) \]
      12. *-commutative53.9%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{\color{blue}{h \cdot \left(M \cdot M\right)}}{\ell}\right)\right)\right) \]
      13. associate-/l*55.1%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \color{blue}{\frac{h}{\frac{\ell}{M \cdot M}}}\right)\right)\right) \]
    9. Simplified55.1%

      \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{h}{\frac{\ell}{M \cdot M}}\right)\right)}\right) \]

    if 6.49999999999999999e168 < l

    1. Initial program 59.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. Taylor expanded in d around inf 54.9%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    3. Step-by-step derivation
      1. *-commutative54.9%

        \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      2. add-cbrt-cube42.6%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}}} \]
      3. add-sqr-sqrt42.6%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      4. *-commutative42.6%

        \[\leadsto d \cdot \sqrt[3]{\frac{1}{\color{blue}{h \cdot \ell}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      5. *-commutative42.6%

        \[\leadsto d \cdot \sqrt[3]{\frac{1}{h \cdot \ell} \cdot \sqrt{\frac{1}{\color{blue}{h \cdot \ell}}}} \]
      6. pow142.6%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt[3]{\frac{1}{h \cdot \ell} \cdot \sqrt{\frac{1}{h \cdot \ell}}}\right)}^{1}} \]
    4. Applied egg-rr54.9%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow154.9%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/55.0%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity55.0%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    6. Simplified55.0%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification55.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -6.2 \cdot 10^{-23}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{1}{h \cdot \ell}}\right)\\ \mathbf{elif}\;\ell \leq 6.5 \cdot 10^{+168}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{h}{\frac{\ell}{M \cdot M}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \end{array} \]

Alternative 18: 41.6% accurate, 3.0× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -4.5 \cdot 10^{-207}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{1}{h \cdot \ell}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -4.5e-207) (* d (- (sqrt (/ 1.0 (* h l))))) (/ d (sqrt (* h l)))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -4.5e-207) {
		tmp = d * -sqrt((1.0 / (h * l)));
	} else {
		tmp = d / sqrt((h * l));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: tmp
    if (l <= (-4.5d-207)) then
        tmp = d * -sqrt((1.0d0 / (h * l)))
    else
        tmp = d / sqrt((h * l))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -4.5e-207) {
		tmp = d * -Math.sqrt((1.0 / (h * l)));
	} else {
		tmp = d / Math.sqrt((h * l));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if l <= -4.5e-207:
		tmp = d * -math.sqrt((1.0 / (h * l)))
	else:
		tmp = d / math.sqrt((h * l))
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -4.5e-207)
		tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(h * l)))));
	else
		tmp = Float64(d / sqrt(Float64(h * l)));
	end
	return tmp
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (l <= -4.5e-207)
		tmp = d * -sqrt((1.0 / (h * l)));
	else
		tmp = d / sqrt((h * l));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -4.5e-207], N[(d * (-N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.5 \cdot 10^{-207}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{h \cdot \ell}}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -4.49999999999999992e-207

    1. Initial program 69.5%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Applied egg-rr29.7%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    3. Step-by-step derivation
      1. expm1-def36.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p55.4%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      3. cancel-sign-sub-inv55.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left(1 + \left(-0.5\right) \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)} \]
      4. metadata-eval55.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{-0.5} \cdot \left(\frac{h}{\ell} \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      5. *-commutative55.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(0.5 \cdot M\right)} \cdot \frac{D}{d}\right)}^{2}\right)\right) \]
      6. associate-*r*55.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}}^{2}\right)\right) \]
      7. *-commutative55.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot 0.5\right)}}^{2}\right)\right) \]
      8. associate-*r/54.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\frac{M \cdot D}{d}} \cdot 0.5\right)}^{2}\right)\right) \]
      9. associate-*l/55.5%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(\frac{M}{d} \cdot D\right)} \cdot 0.5\right)}^{2}\right)\right) \]
      10. *-commutative55.5%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\color{blue}{\left(D \cdot \frac{M}{d}\right)} \cdot 0.5\right)}^{2}\right)\right) \]
      11. associate-*l*55.5%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}}^{2}\right)\right) \]
    4. Simplified55.5%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}\right)\right)} \]
    5. Step-by-step derivation
      1. associate-*l/55.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{h \cdot {\left(D \cdot \left(\frac{M}{d} \cdot 0.5\right)\right)}^{2}}{\ell}}\right) \]
      2. *-commutative55.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \frac{h \cdot {\left(D \cdot \color{blue}{\left(0.5 \cdot \frac{M}{d}\right)}\right)}^{2}}{\ell}\right) \]
    6. Applied egg-rr55.7%

      \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\frac{h \cdot {\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right)}^{2}}{\ell}}\right) \]
    7. Taylor expanded in d around -inf 51.2%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)} \]
    8. Step-by-step derivation
      1. mul-1-neg51.2%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      2. *-commutative51.2%

        \[\leadsto -\color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
      3. distribute-rgt-neg-in51.2%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-d\right)} \]
      4. *-commutative51.2%

        \[\leadsto \sqrt{\frac{1}{\color{blue}{h \cdot \ell}}} \cdot \left(-d\right) \]
    9. Simplified51.2%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(-d\right)} \]

    if -4.49999999999999992e-207 < l

    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. Taylor expanded in d around inf 41.1%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    3. Step-by-step derivation
      1. *-commutative41.1%

        \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      2. add-cbrt-cube32.1%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}}} \]
      3. add-sqr-sqrt32.1%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      4. *-commutative32.1%

        \[\leadsto d \cdot \sqrt[3]{\frac{1}{\color{blue}{h \cdot \ell}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      5. *-commutative32.1%

        \[\leadsto d \cdot \sqrt[3]{\frac{1}{h \cdot \ell} \cdot \sqrt{\frac{1}{\color{blue}{h \cdot \ell}}}} \]
      6. pow132.1%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt[3]{\frac{1}{h \cdot \ell} \cdot \sqrt{\frac{1}{h \cdot \ell}}}\right)}^{1}} \]
    4. Applied egg-rr41.1%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow141.1%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/41.1%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity41.1%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    6. Simplified41.1%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification45.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.5 \cdot 10^{-207}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{1}{h \cdot \ell}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \end{array} \]

Alternative 19: 36.6% accurate, 3.0× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2.8 \cdot 10^{-182}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -2.8e-182) (sqrt (* (/ d l) (/ d h))) (/ d (sqrt (* h l)))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -2.8e-182) {
		tmp = sqrt(((d / l) * (d / h)));
	} else {
		tmp = d / sqrt((h * l));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: tmp
    if (l <= (-2.8d-182)) then
        tmp = sqrt(((d / l) * (d / h)))
    else
        tmp = d / sqrt((h * l))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -2.8e-182) {
		tmp = Math.sqrt(((d / l) * (d / h)));
	} else {
		tmp = d / Math.sqrt((h * l));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if l <= -2.8e-182:
		tmp = math.sqrt(((d / l) * (d / h)))
	else:
		tmp = d / math.sqrt((h * l))
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -2.8e-182)
		tmp = sqrt(Float64(Float64(d / l) * Float64(d / h)));
	else
		tmp = Float64(d / sqrt(Float64(h * l)));
	end
	return tmp
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (l <= -2.8e-182)
		tmp = sqrt(((d / l) * (d / h)));
	else
		tmp = d / sqrt((h * l));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -2.8e-182], N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.8 \cdot 10^{-182}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.79999999999999993e-182

    1. Initial program 70.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. Simplified70.0%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \frac{M}{\frac{d}{D}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Taylor expanded in M around 0 46.8%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{1}\right) \]
    4. Step-by-step derivation
      1. *-rgt-identity46.8%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}} \]
      2. *-commutative46.8%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} \]
      3. sqrt-prod39.1%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
      4. pow1/239.1%

        \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5}} \]
    5. Applied egg-rr39.1%

      \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5}} \]
    6. Step-by-step derivation
      1. unpow1/239.1%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]
    7. Simplified39.1%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \]

    if -2.79999999999999993e-182 < l

    1. Initial program 68.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Taylor expanded in d around inf 40.4%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    3. Step-by-step derivation
      1. *-commutative40.4%

        \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      2. add-cbrt-cube32.3%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}}} \]
      3. add-sqr-sqrt32.3%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      4. *-commutative32.3%

        \[\leadsto d \cdot \sqrt[3]{\frac{1}{\color{blue}{h \cdot \ell}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
      5. *-commutative32.3%

        \[\leadsto d \cdot \sqrt[3]{\frac{1}{h \cdot \ell} \cdot \sqrt{\frac{1}{\color{blue}{h \cdot \ell}}}} \]
      6. pow132.3%

        \[\leadsto \color{blue}{{\left(d \cdot \sqrt[3]{\frac{1}{h \cdot \ell} \cdot \sqrt{\frac{1}{h \cdot \ell}}}\right)}^{1}} \]
    4. Applied egg-rr40.4%

      \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow140.4%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. associate-*r/40.5%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      3. *-rgt-identity40.5%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    6. Simplified40.5%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification39.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.8 \cdot 10^{-182}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \end{array} \]

Alternative 20: 25.9% accurate, 3.2× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \frac{d}{\sqrt{h \cdot \ell}} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D) :precision binary64 (/ d (sqrt (* h l))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d / sqrt((h * l));
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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 / sqrt((h * l))
end function
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return d / Math.sqrt((h * l));
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d / math.sqrt((h * l))
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d / sqrt(Float64(h * l)))
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d / sqrt((h * l));
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\frac{d}{\sqrt{h \cdot \ell}}
\end{array}
Derivation
  1. Initial program 68.9%

    \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  2. Taylor expanded in d around inf 28.3%

    \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
  3. Step-by-step derivation
    1. *-commutative28.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    2. add-cbrt-cube24.1%

      \[\leadsto d \cdot \color{blue}{\sqrt[3]{\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}}} \]
    3. add-sqr-sqrt24.0%

      \[\leadsto d \cdot \sqrt[3]{\color{blue}{\frac{1}{\ell \cdot h}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    4. *-commutative24.0%

      \[\leadsto d \cdot \sqrt[3]{\frac{1}{\color{blue}{h \cdot \ell}} \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
    5. *-commutative24.0%

      \[\leadsto d \cdot \sqrt[3]{\frac{1}{h \cdot \ell} \cdot \sqrt{\frac{1}{\color{blue}{h \cdot \ell}}}} \]
    6. pow124.0%

      \[\leadsto \color{blue}{{\left(d \cdot \sqrt[3]{\frac{1}{h \cdot \ell} \cdot \sqrt{\frac{1}{h \cdot \ell}}}\right)}^{1}} \]
  4. Applied egg-rr28.0%

    \[\leadsto \color{blue}{{\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)}^{1}} \]
  5. Step-by-step derivation
    1. unpow128.0%

      \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
    2. associate-*r/28.0%

      \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
    3. *-rgt-identity28.0%

      \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
  6. Simplified28.0%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  7. Final simplification28.0%

    \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]

Reproduce

?
herbie shell --seed 2023275 
(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)))))