Henrywood and Agarwal, Equation (12)

Percentage Accurate: 67.1% → 76.4%
Time: 20.2s
Alternatives: 14
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 14 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: 67.1% accurate, 1.0× speedup?

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

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

Alternative 1: 76.4% accurate, 1.0× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right)\\ \mathbf{if}\;h \leq -1.15 \cdot 10^{+56}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{h \cdot M}{\frac{\ell}{M}}\right) \cdot 0.25\right)\right)\right)\\ \mathbf{elif}\;h \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(-1 - t_0\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + t_0\right) \cdot \left(d \cdot \left({h}^{-0.5} \cdot {\ell}^{-0.5}\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
 (let* ((t_0 (* -0.5 (* (/ h l) (pow (* D (/ M (* d 2.0))) 2.0)))))
   (if (<= h -1.15e+56)
     (*
      (sqrt (/ d h))
      (*
       (sqrt (/ d l))
       (- 1.0 (* 0.5 (* (* (* (/ D d) (/ D d)) (/ (* h M) (/ l M))) 0.25)))))
     (if (<= h -2e-310)
       (* (* d (pow (* h l) -0.5)) (- -1.0 t_0))
       (* (+ 1.0 t_0) (* d (* (pow h -0.5) (pow l -0.5))))))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = -0.5 * ((h / l) * pow((D * (M / (d * 2.0))), 2.0));
	double tmp;
	if (h <= -1.15e+56) {
		tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - (0.5 * ((((D / d) * (D / d)) * ((h * M) / (l / M))) * 0.25))));
	} else if (h <= -2e-310) {
		tmp = (d * pow((h * l), -0.5)) * (-1.0 - t_0);
	} else {
		tmp = (1.0 + t_0) * (d * (pow(h, -0.5) * pow(l, -0.5)));
	}
	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 = (-0.5d0) * ((h / l) * ((d_1 * (m / (d * 2.0d0))) ** 2.0d0))
    if (h <= (-1.15d+56)) then
        tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0d0 - (0.5d0 * ((((d_1 / d) * (d_1 / d)) * ((h * m) / (l / m))) * 0.25d0))))
    else if (h <= (-2d-310)) then
        tmp = (d * ((h * l) ** (-0.5d0))) * ((-1.0d0) - t_0)
    else
        tmp = (1.0d0 + t_0) * (d * ((h ** (-0.5d0)) * (l ** (-0.5d0))))
    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 = -0.5 * ((h / l) * Math.pow((D * (M / (d * 2.0))), 2.0));
	double tmp;
	if (h <= -1.15e+56) {
		tmp = Math.sqrt((d / h)) * (Math.sqrt((d / l)) * (1.0 - (0.5 * ((((D / d) * (D / d)) * ((h * M) / (l / M))) * 0.25))));
	} else if (h <= -2e-310) {
		tmp = (d * Math.pow((h * l), -0.5)) * (-1.0 - t_0);
	} else {
		tmp = (1.0 + t_0) * (d * (Math.pow(h, -0.5) * Math.pow(l, -0.5)));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = -0.5 * ((h / l) * math.pow((D * (M / (d * 2.0))), 2.0))
	tmp = 0
	if h <= -1.15e+56:
		tmp = math.sqrt((d / h)) * (math.sqrt((d / l)) * (1.0 - (0.5 * ((((D / d) * (D / d)) * ((h * M) / (l / M))) * 0.25))))
	elif h <= -2e-310:
		tmp = (d * math.pow((h * l), -0.5)) * (-1.0 - t_0)
	else:
		tmp = (1.0 + t_0) * (d * (math.pow(h, -0.5) * math.pow(l, -0.5)))
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(-0.5 * Float64(Float64(h / l) * (Float64(D * Float64(M / Float64(d * 2.0))) ^ 2.0)))
	tmp = 0.0
	if (h <= -1.15e+56)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(0.5 * Float64(Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(Float64(h * M) / Float64(l / M))) * 0.25)))));
	elseif (h <= -2e-310)
		tmp = Float64(Float64(d * (Float64(h * l) ^ -0.5)) * Float64(-1.0 - t_0));
	else
		tmp = Float64(Float64(1.0 + t_0) * Float64(d * Float64((h ^ -0.5) * (l ^ -0.5))));
	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 = -0.5 * ((h / l) * ((D * (M / (d * 2.0))) ^ 2.0));
	tmp = 0.0;
	if (h <= -1.15e+56)
		tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - (0.5 * ((((D / d) * (D / d)) * ((h * M) / (l / M))) * 0.25))));
	elseif (h <= -2e-310)
		tmp = (d * ((h * l) ^ -0.5)) * (-1.0 - t_0);
	else
		tmp = (1.0 + t_0) * (d * ((h ^ -0.5) * (l ^ -0.5)));
	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[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(D * N[(M / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -1.15e+56], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(N[(h * M), $MachinePrecision] / N[(l / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -2e-310], N[(N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + t$95$0), $MachinePrecision] * N[(d * N[(N[Power[h, -0.5], $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\right)\\
\mathbf{if}\;h \leq -1.15 \cdot 10^{+56}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{h \cdot M}{\frac{\ell}{M}}\right) \cdot 0.25\right)\right)\right)\\

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

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


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

    1. Initial program 51.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. associate-*l*51.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\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)}{\ell \cdot {d}^{2}}\right)}\right)\right) \]
    5. Step-by-step derivation
      1. *-commutative36.8%

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

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

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

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

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

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

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

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

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

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

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

    if -1.15000000000000007e56 < h < -1.999999999999994e-310

    1. Initial program 69.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. expm1-log1p-u43.3%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 \frac{M}{2 \cdot d}\right)}^{2}\right)\right) \]
    7. Step-by-step derivation
      1. mul-1-neg80.4%

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < h

    1. Initial program 60.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. Step-by-step derivation
      1. expm1-log1p-u39.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 72.9% accurate, 1.4× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ t_1 := {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\\ \mathbf{if}\;h \leq -1.22 \cdot 10^{+57}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{h \cdot M}{\frac{\ell}{M}}\right) \cdot 0.25\right)\right)\right)\\ \mathbf{elif}\;h \leq -2 \cdot 10^{-310}:\\ \;\;\;\;t_0 \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot t_1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(1 + -0.5 \cdot \frac{h \cdot t_1}{\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
 (let* ((t_0 (* d (pow (* h l) -0.5))) (t_1 (pow (* D (/ M (* d 2.0))) 2.0)))
   (if (<= h -1.22e+57)
     (*
      (sqrt (/ d h))
      (*
       (sqrt (/ d l))
       (- 1.0 (* 0.5 (* (* (* (/ D d) (/ D d)) (/ (* h M) (/ l M))) 0.25)))))
     (if (<= h -2e-310)
       (* t_0 (- -1.0 (* -0.5 (* (/ h l) t_1))))
       (* t_0 (+ 1.0 (* -0.5 (/ (* h t_1) l))))))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = d * pow((h * l), -0.5);
	double t_1 = pow((D * (M / (d * 2.0))), 2.0);
	double tmp;
	if (h <= -1.22e+57) {
		tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - (0.5 * ((((D / d) * (D / d)) * ((h * M) / (l / M))) * 0.25))));
	} else if (h <= -2e-310) {
		tmp = t_0 * (-1.0 - (-0.5 * ((h / l) * t_1)));
	} else {
		tmp = t_0 * (1.0 + (-0.5 * ((h * t_1) / 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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = d * ((h * l) ** (-0.5d0))
    t_1 = (d_1 * (m / (d * 2.0d0))) ** 2.0d0
    if (h <= (-1.22d+57)) then
        tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0d0 - (0.5d0 * ((((d_1 / d) * (d_1 / d)) * ((h * m) / (l / m))) * 0.25d0))))
    else if (h <= (-2d-310)) then
        tmp = t_0 * ((-1.0d0) - ((-0.5d0) * ((h / l) * t_1)))
    else
        tmp = t_0 * (1.0d0 + ((-0.5d0) * ((h * t_1) / 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 t_0 = d * Math.pow((h * l), -0.5);
	double t_1 = Math.pow((D * (M / (d * 2.0))), 2.0);
	double tmp;
	if (h <= -1.22e+57) {
		tmp = Math.sqrt((d / h)) * (Math.sqrt((d / l)) * (1.0 - (0.5 * ((((D / d) * (D / d)) * ((h * M) / (l / M))) * 0.25))));
	} else if (h <= -2e-310) {
		tmp = t_0 * (-1.0 - (-0.5 * ((h / l) * t_1)));
	} else {
		tmp = t_0 * (1.0 + (-0.5 * ((h * t_1) / l)));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = d * math.pow((h * l), -0.5)
	t_1 = math.pow((D * (M / (d * 2.0))), 2.0)
	tmp = 0
	if h <= -1.22e+57:
		tmp = math.sqrt((d / h)) * (math.sqrt((d / l)) * (1.0 - (0.5 * ((((D / d) * (D / d)) * ((h * M) / (l / M))) * 0.25))))
	elif h <= -2e-310:
		tmp = t_0 * (-1.0 - (-0.5 * ((h / l) * t_1)))
	else:
		tmp = t_0 * (1.0 + (-0.5 * ((h * t_1) / l)))
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(d * (Float64(h * l) ^ -0.5))
	t_1 = Float64(D * Float64(M / Float64(d * 2.0))) ^ 2.0
	tmp = 0.0
	if (h <= -1.22e+57)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(0.5 * Float64(Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(Float64(h * M) / Float64(l / M))) * 0.25)))));
	elseif (h <= -2e-310)
		tmp = Float64(t_0 * Float64(-1.0 - Float64(-0.5 * Float64(Float64(h / l) * t_1))));
	else
		tmp = Float64(t_0 * Float64(1.0 + Float64(-0.5 * Float64(Float64(h * t_1) / 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)
	t_0 = d * ((h * l) ^ -0.5);
	t_1 = (D * (M / (d * 2.0))) ^ 2.0;
	tmp = 0.0;
	if (h <= -1.22e+57)
		tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - (0.5 * ((((D / d) * (D / d)) * ((h * M) / (l / M))) * 0.25))));
	elseif (h <= -2e-310)
		tmp = t_0 * (-1.0 - (-0.5 * ((h / l) * t_1)));
	else
		tmp = t_0 * (1.0 + (-0.5 * ((h * t_1) / 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_] := Block[{t$95$0 = N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(D * N[(M / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[h, -1.22e+57], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(N[(h * M), $MachinePrecision] / N[(l / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -2e-310], N[(t$95$0 * N[(-1.0 - N[(-0.5 * N[(N[(h / l), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 + N[(-0.5 * N[(N[(h * t$95$1), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\
t_1 := {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\\
\mathbf{if}\;h \leq -1.22 \cdot 10^{+57}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{h \cdot M}{\frac{\ell}{M}}\right) \cdot 0.25\right)\right)\right)\\

\mathbf{elif}\;h \leq -2 \cdot 10^{-310}:\\
\;\;\;\;t_0 \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot t_1\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(1 + -0.5 \cdot \frac{h \cdot t_1}{\ell}\right)\\


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

    1. Initial program 51.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. associate-*l*51.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\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)}{\ell \cdot {d}^{2}}\right)}\right)\right) \]
    5. Step-by-step derivation
      1. *-commutative36.8%

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

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

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

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

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

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

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

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

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

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

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

    if -1.22e57 < h < -1.999999999999994e-310

    1. Initial program 69.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. expm1-log1p-u43.3%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 \frac{M}{2 \cdot d}\right)}^{2}\right)\right) \]
    7. Step-by-step derivation
      1. mul-1-neg80.4%

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < h

    1. Initial program 60.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. Step-by-step derivation
      1. expm1-log1p-u39.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 54.9% accurate, 1.5× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \frac{1}{h \cdot \ell}\\ \mathbf{if}\;\ell \leq -7.4 \cdot 10^{-273}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\left(h \cdot \ell\right)}^{-0.5} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\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
 (let* ((t_0 (/ 1.0 (* h l))))
   (if (<= l -7.4e-273)
     (* (sqrt (/ d h)) (sqrt (/ d l)))
     (if (<= l -5e-310)
       (* d (sqrt (cbrt (* t_0 (* t_0 t_0)))))
       (*
        d
        (*
         (pow (* h l) -0.5)
         (+ 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 t_0 = 1.0 / (h * l);
	double tmp;
	if (l <= -7.4e-273) {
		tmp = sqrt((d / h)) * sqrt((d / l));
	} else if (l <= -5e-310) {
		tmp = d * sqrt(cbrt((t_0 * (t_0 * t_0))));
	} else {
		tmp = d * (pow((h * l), -0.5) * (1.0 + (-0.5 * ((h / l) * pow(((D / d) * (M / 2.0)), 2.0)))));
	}
	return tmp;
}
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 / (h * l);
	double tmp;
	if (l <= -7.4e-273) {
		tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
	} else if (l <= -5e-310) {
		tmp = d * Math.sqrt(Math.cbrt((t_0 * (t_0 * t_0))));
	} else {
		tmp = d * (Math.pow((h * l), -0.5) * (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)
	t_0 = Float64(1.0 / Float64(h * l))
	tmp = 0.0
	if (l <= -7.4e-273)
		tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)));
	elseif (l <= -5e-310)
		tmp = Float64(d * sqrt(cbrt(Float64(t_0 * Float64(t_0 * t_0)))));
	else
		tmp = Float64(d * Float64((Float64(h * l) ^ -0.5) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0))))));
	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[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -7.4e-273], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-310], N[(d * N[Sqrt[N[Power[N[(t$95$0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[N[(h * l), $MachinePrecision], -0.5], $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]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \frac{1}{h \cdot \ell}\\
\mathbf{if}\;\ell \leq -7.4 \cdot 10^{-273}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \sqrt{\sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)}}\\

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


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

    1. Initial program 61.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. Step-by-step derivation
      1. associate-*l*61.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.4000000000000007e-273 < l < -4.999999999999985e-310

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

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    3. Step-by-step derivation
      1. add-cbrt-cube65.2%

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

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

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

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 60.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. Step-by-step derivation
      1. expm1-log1p-u39.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 57.2% accurate, 1.5× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \frac{1}{h \cdot \ell}\\ \mathbf{if}\;\ell \leq -2.1 \cdot 10^{-272}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(1 + -0.5 \cdot \frac{h \cdot {\left(D \cdot \frac{M}{d \cdot 2}\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
 (let* ((t_0 (/ 1.0 (* h l))))
   (if (<= l -2.1e-272)
     (* (sqrt (/ d h)) (sqrt (/ d l)))
     (if (<= l -5e-310)
       (* d (sqrt (cbrt (* t_0 (* t_0 t_0)))))
       (*
        (* d (pow (* h l) -0.5))
        (+ 1.0 (* -0.5 (/ (* h (pow (* D (/ M (* d 2.0))) 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 t_0 = 1.0 / (h * l);
	double tmp;
	if (l <= -2.1e-272) {
		tmp = sqrt((d / h)) * sqrt((d / l));
	} else if (l <= -5e-310) {
		tmp = d * sqrt(cbrt((t_0 * (t_0 * t_0))));
	} else {
		tmp = (d * pow((h * l), -0.5)) * (1.0 + (-0.5 * ((h * pow((D * (M / (d * 2.0))), 2.0)) / l)));
	}
	return tmp;
}
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 / (h * l);
	double tmp;
	if (l <= -2.1e-272) {
		tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
	} else if (l <= -5e-310) {
		tmp = d * Math.sqrt(Math.cbrt((t_0 * (t_0 * t_0))));
	} else {
		tmp = (d * Math.pow((h * l), -0.5)) * (1.0 + (-0.5 * ((h * Math.pow((D * (M / (d * 2.0))), 2.0)) / l)));
	}
	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(h * l))
	tmp = 0.0
	if (l <= -2.1e-272)
		tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)));
	elseif (l <= -5e-310)
		tmp = Float64(d * sqrt(cbrt(Float64(t_0 * Float64(t_0 * t_0)))));
	else
		tmp = Float64(Float64(d * (Float64(h * l) ^ -0.5)) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h * (Float64(D * Float64(M / Float64(d * 2.0))) ^ 2.0)) / l))));
	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[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.1e-272], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-310], N[(d * N[Sqrt[N[Power[N[(t$95$0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h * N[Power[N[(D * N[(M / N[(d * 2.0), $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}
t_0 := \frac{1}{h \cdot \ell}\\
\mathbf{if}\;\ell \leq -2.1 \cdot 10^{-272}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \sqrt{\sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)}}\\

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


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

    1. Initial program 61.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. Step-by-step derivation
      1. associate-*l*61.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.09999999999999987e-272 < l < -4.999999999999985e-310

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

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    3. Step-by-step derivation
      1. add-cbrt-cube65.2%

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

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

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

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 60.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. Step-by-step derivation
      1. expm1-log1p-u39.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 63.6% accurate, 1.5× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\\ \mathbf{if}\;d \leq 3.7 \cdot 10^{-264}:\\ \;\;\;\;\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot t_0\right)\right) \cdot \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(1 + -0.5 \cdot \frac{h \cdot t_0}{\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
 (let* ((t_0 (pow (* D (/ M (* d 2.0))) 2.0)))
   (if (<= d 3.7e-264)
     (* (+ 1.0 (* -0.5 (* (/ h l) t_0))) (sqrt (* (/ d h) (/ d l))))
     (* (* d (pow (* h l) -0.5)) (+ 1.0 (* -0.5 (/ (* h t_0) l)))))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = pow((D * (M / (d * 2.0))), 2.0);
	double tmp;
	if (d <= 3.7e-264) {
		tmp = (1.0 + (-0.5 * ((h / l) * t_0))) * sqrt(((d / h) * (d / l)));
	} else {
		tmp = (d * pow((h * l), -0.5)) * (1.0 + (-0.5 * ((h * t_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) :: t_0
    real(8) :: tmp
    t_0 = (d_1 * (m / (d * 2.0d0))) ** 2.0d0
    if (d <= 3.7d-264) then
        tmp = (1.0d0 + ((-0.5d0) * ((h / l) * t_0))) * sqrt(((d / h) * (d / l)))
    else
        tmp = (d * ((h * l) ** (-0.5d0))) * (1.0d0 + ((-0.5d0) * ((h * t_0) / 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 t_0 = Math.pow((D * (M / (d * 2.0))), 2.0);
	double tmp;
	if (d <= 3.7e-264) {
		tmp = (1.0 + (-0.5 * ((h / l) * t_0))) * Math.sqrt(((d / h) * (d / l)));
	} else {
		tmp = (d * Math.pow((h * l), -0.5)) * (1.0 + (-0.5 * ((h * t_0) / l)));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.pow((D * (M / (d * 2.0))), 2.0)
	tmp = 0
	if d <= 3.7e-264:
		tmp = (1.0 + (-0.5 * ((h / l) * t_0))) * math.sqrt(((d / h) * (d / l)))
	else:
		tmp = (d * math.pow((h * l), -0.5)) * (1.0 + (-0.5 * ((h * t_0) / l)))
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(D * Float64(M / Float64(d * 2.0))) ^ 2.0
	tmp = 0.0
	if (d <= 3.7e-264)
		tmp = Float64(Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * t_0))) * sqrt(Float64(Float64(d / h) * Float64(d / l))));
	else
		tmp = Float64(Float64(d * (Float64(h * l) ^ -0.5)) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h * t_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)
	t_0 = (D * (M / (d * 2.0))) ^ 2.0;
	tmp = 0.0;
	if (d <= 3.7e-264)
		tmp = (1.0 + (-0.5 * ((h / l) * t_0))) * sqrt(((d / h) * (d / l)));
	else
		tmp = (d * ((h * l) ^ -0.5)) * (1.0 + (-0.5 * ((h * t_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_] := Block[{t$95$0 = N[Power[N[(D * N[(M / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[d, 3.7e-264], N[(N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h * t$95$0), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\\
\mathbf{if}\;d \leq 3.7 \cdot 10^{-264}:\\
\;\;\;\;\left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot t_0\right)\right) \cdot \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\

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


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

    1. Initial program 61.6%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. expm1-log1p-u39.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.69999999999999996e-264 < d

    1. Initial program 62.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. Step-by-step derivation
      1. expm1-log1p-u39.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 64.8% accurate, 1.5× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := 1 + -0.5 \cdot \frac{h \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\ell}\\ \mathbf{if}\;d \leq 3.7 \cdot 10^{-264}:\\ \;\;\;\;t_0 \cdot \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\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 (pow (* D (/ M (* d 2.0))) 2.0)) l)))))
   (if (<= d 3.7e-264)
     (* t_0 (sqrt (* (/ d h) (/ d l))))
     (* (* d (pow (* h l) -0.5)) 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 * pow((D * (M / (d * 2.0))), 2.0)) / l));
	double tmp;
	if (d <= 3.7e-264) {
		tmp = t_0 * sqrt(((d / h) * (d / l)));
	} else {
		tmp = (d * pow((h * l), -0.5)) * 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 * ((d_1 * (m / (d * 2.0d0))) ** 2.0d0)) / l))
    if (d <= 3.7d-264) then
        tmp = t_0 * sqrt(((d / h) * (d / l)))
    else
        tmp = (d * ((h * l) ** (-0.5d0))) * 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 * Math.pow((D * (M / (d * 2.0))), 2.0)) / l));
	double tmp;
	if (d <= 3.7e-264) {
		tmp = t_0 * Math.sqrt(((d / h) * (d / l)));
	} else {
		tmp = (d * Math.pow((h * l), -0.5)) * 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 * math.pow((D * (M / (d * 2.0))), 2.0)) / l))
	tmp = 0
	if d <= 3.7e-264:
		tmp = t_0 * math.sqrt(((d / h) * (d / l)))
	else:
		tmp = (d * math.pow((h * l), -0.5)) * 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 * (Float64(D * Float64(M / Float64(d * 2.0))) ^ 2.0)) / l)))
	tmp = 0.0
	if (d <= 3.7e-264)
		tmp = Float64(t_0 * sqrt(Float64(Float64(d / h) * Float64(d / l))));
	else
		tmp = Float64(Float64(d * (Float64(h * l) ^ -0.5)) * 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 * ((D * (M / (d * 2.0))) ^ 2.0)) / l));
	tmp = 0.0;
	if (d <= 3.7e-264)
		tmp = t_0 * sqrt(((d / h) * (d / l)));
	else
		tmp = (d * ((h * l) ^ -0.5)) * 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 * N[Power[N[(D * N[(M / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, 3.7e-264], N[(t$95$0 * N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $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 \frac{h \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\ell}\\
\mathbf{if}\;d \leq 3.7 \cdot 10^{-264}:\\
\;\;\;\;t_0 \cdot \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\

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


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

    1. Initial program 61.6%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. expm1-log1p-u39.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.69999999999999996e-264 < d

    1. Initial program 62.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. Step-by-step derivation
      1. expm1-log1p-u39.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 72.1% accurate, 1.5× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\\ t_1 := d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{if}\;h \leq -2 \cdot 10^{-310}:\\ \;\;\;\;t_1 \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot t_0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(1 + -0.5 \cdot \frac{h \cdot t_0}{\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
 (let* ((t_0 (pow (* D (/ M (* d 2.0))) 2.0)) (t_1 (* d (pow (* h l) -0.5))))
   (if (<= h -2e-310)
     (* t_1 (- -1.0 (* -0.5 (* (/ h l) t_0))))
     (* t_1 (+ 1.0 (* -0.5 (/ (* h t_0) l)))))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = pow((D * (M / (d * 2.0))), 2.0);
	double t_1 = d * pow((h * l), -0.5);
	double tmp;
	if (h <= -2e-310) {
		tmp = t_1 * (-1.0 - (-0.5 * ((h / l) * t_0)));
	} else {
		tmp = t_1 * (1.0 + (-0.5 * ((h * t_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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (d_1 * (m / (d * 2.0d0))) ** 2.0d0
    t_1 = d * ((h * l) ** (-0.5d0))
    if (h <= (-2d-310)) then
        tmp = t_1 * ((-1.0d0) - ((-0.5d0) * ((h / l) * t_0)))
    else
        tmp = t_1 * (1.0d0 + ((-0.5d0) * ((h * t_0) / 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 t_0 = Math.pow((D * (M / (d * 2.0))), 2.0);
	double t_1 = d * Math.pow((h * l), -0.5);
	double tmp;
	if (h <= -2e-310) {
		tmp = t_1 * (-1.0 - (-0.5 * ((h / l) * t_0)));
	} else {
		tmp = t_1 * (1.0 + (-0.5 * ((h * t_0) / l)));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.pow((D * (M / (d * 2.0))), 2.0)
	t_1 = d * math.pow((h * l), -0.5)
	tmp = 0
	if h <= -2e-310:
		tmp = t_1 * (-1.0 - (-0.5 * ((h / l) * t_0)))
	else:
		tmp = t_1 * (1.0 + (-0.5 * ((h * t_0) / l)))
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(D * Float64(M / Float64(d * 2.0))) ^ 2.0
	t_1 = Float64(d * (Float64(h * l) ^ -0.5))
	tmp = 0.0
	if (h <= -2e-310)
		tmp = Float64(t_1 * Float64(-1.0 - Float64(-0.5 * Float64(Float64(h / l) * t_0))));
	else
		tmp = Float64(t_1 * Float64(1.0 + Float64(-0.5 * Float64(Float64(h * t_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)
	t_0 = (D * (M / (d * 2.0))) ^ 2.0;
	t_1 = d * ((h * l) ^ -0.5);
	tmp = 0.0;
	if (h <= -2e-310)
		tmp = t_1 * (-1.0 - (-0.5 * ((h / l) * t_0)));
	else
		tmp = t_1 * (1.0 + (-0.5 * ((h * t_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_] := Block[{t$95$0 = N[Power[N[(D * N[(M / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -2e-310], N[(t$95$1 * N[(-1.0 - N[(-0.5 * N[(N[(h / l), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 + N[(-0.5 * N[(N[(h * t$95$0), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}\\
t_1 := d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\
\mathbf{if}\;h \leq -2 \cdot 10^{-310}:\\
\;\;\;\;t_1 \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot t_0\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(1 + -0.5 \cdot \frac{h \cdot t_0}{\ell}\right)\\


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

    1. Initial program 62.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. expm1-log1p-u39.4%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 \frac{M}{2 \cdot d}\right)}^{2}\right)\right) \]
    7. Step-by-step derivation
      1. mul-1-neg68.3%

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < h

    1. Initial program 60.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. Step-by-step derivation
      1. expm1-log1p-u39.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 45.1% accurate, 1.5× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \frac{1}{h \cdot \ell}\\ \mathbf{if}\;\ell \leq -2.9 \cdot 10^{-272}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\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
 (let* ((t_0 (/ 1.0 (* h l))))
   (if (<= l -2.9e-272)
     (* (sqrt (/ d h)) (sqrt (/ d l)))
     (if (<= l -5e-310)
       (* d (sqrt (cbrt (* t_0 (* t_0 t_0)))))
       (/ d (* (sqrt h) (sqrt l)))))))
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 / (h * l);
	double tmp;
	if (l <= -2.9e-272) {
		tmp = sqrt((d / h)) * sqrt((d / l));
	} else if (l <= -5e-310) {
		tmp = d * sqrt(cbrt((t_0 * (t_0 * t_0))));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
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 / (h * l);
	double tmp;
	if (l <= -2.9e-272) {
		tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
	} else if (l <= -5e-310) {
		tmp = d * Math.sqrt(Math.cbrt((t_0 * (t_0 * t_0))));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	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(h * l))
	tmp = 0.0
	if (l <= -2.9e-272)
		tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)));
	elseif (l <= -5e-310)
		tmp = Float64(d * sqrt(cbrt(Float64(t_0 * Float64(t_0 * t_0)))));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	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[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.9e-272], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-310], N[(d * N[Sqrt[N[Power[N[(t$95$0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \frac{1}{h \cdot \ell}\\
\mathbf{if}\;\ell \leq -2.9 \cdot 10^{-272}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \sqrt{\sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)}}\\

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


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

    1. Initial program 61.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. Step-by-step derivation
      1. associate-*l*61.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.89999999999999995e-272 < l < -4.999999999999985e-310

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

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    3. Step-by-step derivation
      1. add-cbrt-cube65.2%

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

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

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

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

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

    if -4.999999999999985e-310 < l

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 44.1% accurate, 1.6× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\ t_1 := t_0 \cdot \left(1 + \frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)}{\ell \cdot \left(d \cdot d\right)} \cdot -0.125\right)\\ \mathbf{if}\;\ell \leq -1.75 \cdot 10^{+79}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -1.55 \cdot 10^{-257}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq -1.45 \cdot 10^{-295}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq 1.25 \cdot 10^{-297}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\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
 (let* ((t_0 (sqrt (* (/ d h) (/ d l))))
        (t_1
         (*
          t_0
          (+ 1.0 (* (/ (* (* D D) (* h (* M M))) (* l (* d d))) -0.125)))))
   (if (<= l -1.75e+79)
     t_0
     (if (<= l -1.55e-257)
       t_1
       (if (<= l -1.45e-295)
         (/ d (sqrt (* h l)))
         (if (<= l 1.25e-297) t_1 (/ d (* (sqrt h) (sqrt l)))))))))
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 / h) * (d / l)));
	double t_1 = t_0 * (1.0 + ((((D * D) * (h * (M * M))) / (l * (d * d))) * -0.125));
	double tmp;
	if (l <= -1.75e+79) {
		tmp = t_0;
	} else if (l <= -1.55e-257) {
		tmp = t_1;
	} else if (l <= -1.45e-295) {
		tmp = d / sqrt((h * l));
	} else if (l <= 1.25e-297) {
		tmp = t_1;
	} else {
		tmp = d / (sqrt(h) * sqrt(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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = sqrt(((d / h) * (d / l)))
    t_1 = t_0 * (1.0d0 + ((((d_1 * d_1) * (h * (m * m))) / (l * (d * d))) * (-0.125d0)))
    if (l <= (-1.75d+79)) then
        tmp = t_0
    else if (l <= (-1.55d-257)) then
        tmp = t_1
    else if (l <= (-1.45d-295)) then
        tmp = d / sqrt((h * l))
    else if (l <= 1.25d-297) then
        tmp = t_1
    else
        tmp = d / (sqrt(h) * sqrt(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 t_0 = Math.sqrt(((d / h) * (d / l)));
	double t_1 = t_0 * (1.0 + ((((D * D) * (h * (M * M))) / (l * (d * d))) * -0.125));
	double tmp;
	if (l <= -1.75e+79) {
		tmp = t_0;
	} else if (l <= -1.55e-257) {
		tmp = t_1;
	} else if (l <= -1.45e-295) {
		tmp = d / Math.sqrt((h * l));
	} else if (l <= 1.25e-297) {
		tmp = t_1;
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	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 / h) * (d / l)))
	t_1 = t_0 * (1.0 + ((((D * D) * (h * (M * M))) / (l * (d * d))) * -0.125))
	tmp = 0
	if l <= -1.75e+79:
		tmp = t_0
	elif l <= -1.55e-257:
		tmp = t_1
	elif l <= -1.45e-295:
		tmp = d / math.sqrt((h * l))
	elif l <= 1.25e-297:
		tmp = t_1
	else:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	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 / h) * Float64(d / l)))
	t_1 = Float64(t_0 * Float64(1.0 + Float64(Float64(Float64(Float64(D * D) * Float64(h * Float64(M * M))) / Float64(l * Float64(d * d))) * -0.125)))
	tmp = 0.0
	if (l <= -1.75e+79)
		tmp = t_0;
	elseif (l <= -1.55e-257)
		tmp = t_1;
	elseif (l <= -1.45e-295)
		tmp = Float64(d / sqrt(Float64(h * l)));
	elseif (l <= 1.25e-297)
		tmp = t_1;
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(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)
	t_0 = sqrt(((d / h) * (d / l)));
	t_1 = t_0 * (1.0 + ((((D * D) * (h * (M * M))) / (l * (d * d))) * -0.125));
	tmp = 0.0;
	if (l <= -1.75e+79)
		tmp = t_0;
	elseif (l <= -1.55e-257)
		tmp = t_1;
	elseif (l <= -1.45e-295)
		tmp = d / sqrt((h * l));
	elseif (l <= 1.25e-297)
		tmp = t_1;
	else
		tmp = d / (sqrt(h) * sqrt(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_] := Block[{t$95$0 = N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(1.0 + N[(N[(N[(N[(D * D), $MachinePrecision] * N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.75e+79], t$95$0, If[LessEqual[l, -1.55e-257], t$95$1, If[LessEqual[l, -1.45e-295], N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.25e-297], t$95$1, N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\
t_1 := t_0 \cdot \left(1 + \frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)}{\ell \cdot \left(d \cdot d\right)} \cdot -0.125\right)\\
\mathbf{if}\;\ell \leq -1.75 \cdot 10^{+79}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -1.55 \cdot 10^{-257}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;\ell \leq 1.25 \cdot 10^{-297}:\\
\;\;\;\;t_1\\

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


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

    1. Initial program 58.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. Step-by-step derivation
      1. expm1-log1p-u49.4%

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

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

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

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

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

        \[\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 \frac{\frac{M}{d}}{2}\right)}^{2}\right)\right) \]
      4. *-commutative50.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.7499999999999999e79 < l < -1.55000000000000004e-257 or -1.45000000000000008e-295 < l < 1.25e-297

    1. Initial program 63.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. expm1-log1p-u33.8%

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

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

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

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

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

        \[\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 \frac{\frac{M}{d}}{2}\right)}^{2}\right)\right) \]
      4. *-commutative47.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.55000000000000004e-257 < l < -1.45000000000000008e-295

    1. Initial program 77.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.25e-297 < l

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.75 \cdot 10^{+79}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq -1.55 \cdot 10^{-257}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)}{\ell \cdot \left(d \cdot d\right)} \cdot -0.125\right)\\ \mathbf{elif}\;\ell \leq -1.45 \cdot 10^{-295}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq 1.25 \cdot 10^{-297}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)}{\ell \cdot \left(d \cdot d\right)} \cdot -0.125\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 10: 44.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 -4.8 \cdot 10^{-273}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\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.8e-273)
   (* (sqrt (/ d h)) (sqrt (/ d l)))
   (if (<= l -5e-310) (/ d (sqrt (* h l))) (/ d (* (sqrt h) (sqrt 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.8e-273) {
		tmp = sqrt((d / h)) * sqrt((d / l));
	} else if (l <= -5e-310) {
		tmp = d / sqrt((h * l));
	} else {
		tmp = d / (sqrt(h) * sqrt(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.8d-273)) then
        tmp = sqrt((d / h)) * sqrt((d / l))
    else if (l <= (-5d-310)) then
        tmp = d / sqrt((h * l))
    else
        tmp = d / (sqrt(h) * sqrt(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.8e-273) {
		tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
	} else if (l <= -5e-310) {
		tmp = d / Math.sqrt((h * l));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(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.8e-273:
		tmp = math.sqrt((d / h)) * math.sqrt((d / l))
	elif l <= -5e-310:
		tmp = d / math.sqrt((h * l))
	else:
		tmp = d / (math.sqrt(h) * math.sqrt(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.8e-273)
		tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)));
	elseif (l <= -5e-310)
		tmp = Float64(d / sqrt(Float64(h * l)));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(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.8e-273)
		tmp = sqrt((d / h)) * sqrt((d / l));
	elseif (l <= -5e-310)
		tmp = d / sqrt((h * l));
	else
		tmp = d / (sqrt(h) * sqrt(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.8e-273], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-310], N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.8 \cdot 10^{-273}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\

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

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


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

    1. Initial program 61.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. Step-by-step derivation
      1. associate-*l*61.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.79999999999999963e-273 < l < -4.999999999999985e-310

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.8 \cdot 10^{-273}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 11: 43.0% accurate, 2.5× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\ \mathbf{if}\;d \leq -3.4 \cdot 10^{+110}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -2.9 \cdot 10^{-220} \lor \neg \left(d \leq 3.6 \cdot 10^{-89}\right) \land d \leq 5.9 \cdot 10^{+85}:\\ \;\;\;\;t_0 \cdot \left(1 + \frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)}{\ell \cdot \left(d \cdot d\right)} \cdot -0.125\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\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
 (let* ((t_0 (sqrt (* (/ d h) (/ d l)))))
   (if (<= d -3.4e+110)
     t_0
     (if (or (<= d -2.9e-220) (and (not (<= d 3.6e-89)) (<= d 5.9e+85)))
       (* t_0 (+ 1.0 (* (/ (* (* D D) (* h (* M M))) (* l (* d d))) -0.125)))
       (* d (sqrt (/ (/ 1.0 h) l)))))))
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 / h) * (d / l)));
	double tmp;
	if (d <= -3.4e+110) {
		tmp = t_0;
	} else if ((d <= -2.9e-220) || (!(d <= 3.6e-89) && (d <= 5.9e+85))) {
		tmp = t_0 * (1.0 + ((((D * D) * (h * (M * M))) / (l * (d * d))) * -0.125));
	} else {
		tmp = d * sqrt(((1.0 / 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) :: t_0
    real(8) :: tmp
    t_0 = sqrt(((d / h) * (d / l)))
    if (d <= (-3.4d+110)) then
        tmp = t_0
    else if ((d <= (-2.9d-220)) .or. (.not. (d <= 3.6d-89)) .and. (d <= 5.9d+85)) then
        tmp = t_0 * (1.0d0 + ((((d_1 * d_1) * (h * (m * m))) / (l * (d * d))) * (-0.125d0)))
    else
        tmp = d * sqrt(((1.0d0 / 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 t_0 = Math.sqrt(((d / h) * (d / l)));
	double tmp;
	if (d <= -3.4e+110) {
		tmp = t_0;
	} else if ((d <= -2.9e-220) || (!(d <= 3.6e-89) && (d <= 5.9e+85))) {
		tmp = t_0 * (1.0 + ((((D * D) * (h * (M * M))) / (l * (d * d))) * -0.125));
	} else {
		tmp = d * Math.sqrt(((1.0 / h) / l));
	}
	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 / h) * (d / l)))
	tmp = 0
	if d <= -3.4e+110:
		tmp = t_0
	elif (d <= -2.9e-220) or (not (d <= 3.6e-89) and (d <= 5.9e+85)):
		tmp = t_0 * (1.0 + ((((D * D) * (h * (M * M))) / (l * (d * d))) * -0.125))
	else:
		tmp = d * math.sqrt(((1.0 / h) / l))
	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 / h) * Float64(d / l)))
	tmp = 0.0
	if (d <= -3.4e+110)
		tmp = t_0;
	elseif ((d <= -2.9e-220) || (!(d <= 3.6e-89) && (d <= 5.9e+85)))
		tmp = Float64(t_0 * Float64(1.0 + Float64(Float64(Float64(Float64(D * D) * Float64(h * Float64(M * M))) / Float64(l * Float64(d * d))) * -0.125)));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / 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)
	t_0 = sqrt(((d / h) * (d / l)));
	tmp = 0.0;
	if (d <= -3.4e+110)
		tmp = t_0;
	elseif ((d <= -2.9e-220) || (~((d <= 3.6e-89)) && (d <= 5.9e+85)))
		tmp = t_0 * (1.0 + ((((D * D) * (h * (M * M))) / (l * (d * d))) * -0.125));
	else
		tmp = d * sqrt(((1.0 / 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_] := Block[{t$95$0 = N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -3.4e+110], t$95$0, If[Or[LessEqual[d, -2.9e-220], And[N[Not[LessEqual[d, 3.6e-89]], $MachinePrecision], LessEqual[d, 5.9e+85]]], N[(t$95$0 * N[(1.0 + N[(N[(N[(N[(D * D), $MachinePrecision] * N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\
\mathbf{if}\;d \leq -3.4 \cdot 10^{+110}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq -2.9 \cdot 10^{-220} \lor \neg \left(d \leq 3.6 \cdot 10^{-89}\right) \land d \leq 5.9 \cdot 10^{+85}:\\
\;\;\;\;t_0 \cdot \left(1 + \frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)}{\ell \cdot \left(d \cdot d\right)} \cdot -0.125\right)\\

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


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

    1. Initial program 64.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. expm1-log1p-u53.3%

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

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

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

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

        \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)\right)} \]
      3. unpow1/252.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 \frac{\frac{M}{d}}{2}\right)}^{2}\right)\right) \]
      4. *-commutative52.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.4000000000000001e110 < d < -2.8999999999999998e-220 or 3.60000000000000007e-89 < d < 5.9e85

    1. Initial program 71.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. Step-by-step derivation
      1. expm1-log1p-u36.6%

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

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

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

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

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

        \[\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 \frac{\frac{M}{d}}{2}\right)}^{2}\right)\right) \]
      4. *-commutative57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.8999999999999998e-220 < d < 3.60000000000000007e-89 or 5.9e85 < d

    1. Initial program 51.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. Step-by-step derivation
      1. sqr-pow51.3%

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right)} - 1\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{0.25} \cdot {\left(\frac{d}{\ell}\right)}^{0.25}\right)\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. metadata-eval38.8%

        \[\leadsto \left(\left(e^{\mathsf{log1p}\left({\left(\frac{d}{h}\right)}^{\color{blue}{0.5}}\right)} - 1\right) \cdot \left({\left(\frac{d}{\ell}\right)}^{0.25} \cdot {\left(\frac{d}{\ell}\right)}^{0.25}\right)\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. pow1/238.8%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.4 \cdot 10^{+110}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\ \mathbf{elif}\;d \leq -2.9 \cdot 10^{-220} \lor \neg \left(d \leq 3.6 \cdot 10^{-89}\right) \land d \leq 5.9 \cdot 10^{+85}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)}{\ell \cdot \left(d \cdot d\right)} \cdot -0.125\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]

Alternative 12: 36.8% accurate, 2.5× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\ \mathbf{if}\;\ell \leq -3 \cdot 10^{-273}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{-199}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq 2.1 \cdot 10^{-118}:\\ \;\;\;\;t_0 \cdot \left(\frac{-0.125}{d \cdot d} \cdot \frac{D \cdot D}{\frac{\ell}{M \cdot \left(h \cdot M\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\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
 (let* ((t_0 (sqrt (* (/ d h) (/ d l)))))
   (if (<= l -3e-273)
     t_0
     (if (<= l 6e-199)
       (/ d (sqrt (* h l)))
       (if (<= l 2.1e-118)
         (* t_0 (* (/ -0.125 (* d d)) (/ (* D D) (/ l (* M (* h M))))))
         (* d (sqrt (/ (/ 1.0 h) l))))))))
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 / h) * (d / l)));
	double tmp;
	if (l <= -3e-273) {
		tmp = t_0;
	} else if (l <= 6e-199) {
		tmp = d / sqrt((h * l));
	} else if (l <= 2.1e-118) {
		tmp = t_0 * ((-0.125 / (d * d)) * ((D * D) / (l / (M * (h * M)))));
	} else {
		tmp = d * sqrt(((1.0 / 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) :: t_0
    real(8) :: tmp
    t_0 = sqrt(((d / h) * (d / l)))
    if (l <= (-3d-273)) then
        tmp = t_0
    else if (l <= 6d-199) then
        tmp = d / sqrt((h * l))
    else if (l <= 2.1d-118) then
        tmp = t_0 * (((-0.125d0) / (d * d)) * ((d_1 * d_1) / (l / (m * (h * m)))))
    else
        tmp = d * sqrt(((1.0d0 / 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 t_0 = Math.sqrt(((d / h) * (d / l)));
	double tmp;
	if (l <= -3e-273) {
		tmp = t_0;
	} else if (l <= 6e-199) {
		tmp = d / Math.sqrt((h * l));
	} else if (l <= 2.1e-118) {
		tmp = t_0 * ((-0.125 / (d * d)) * ((D * D) / (l / (M * (h * M)))));
	} else {
		tmp = d * Math.sqrt(((1.0 / h) / l));
	}
	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 / h) * (d / l)))
	tmp = 0
	if l <= -3e-273:
		tmp = t_0
	elif l <= 6e-199:
		tmp = d / math.sqrt((h * l))
	elif l <= 2.1e-118:
		tmp = t_0 * ((-0.125 / (d * d)) * ((D * D) / (l / (M * (h * M)))))
	else:
		tmp = d * math.sqrt(((1.0 / h) / l))
	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 / h) * Float64(d / l)))
	tmp = 0.0
	if (l <= -3e-273)
		tmp = t_0;
	elseif (l <= 6e-199)
		tmp = Float64(d / sqrt(Float64(h * l)));
	elseif (l <= 2.1e-118)
		tmp = Float64(t_0 * Float64(Float64(-0.125 / Float64(d * d)) * Float64(Float64(D * D) / Float64(l / Float64(M * Float64(h * M))))));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / 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)
	t_0 = sqrt(((d / h) * (d / l)));
	tmp = 0.0;
	if (l <= -3e-273)
		tmp = t_0;
	elseif (l <= 6e-199)
		tmp = d / sqrt((h * l));
	elseif (l <= 2.1e-118)
		tmp = t_0 * ((-0.125 / (d * d)) * ((D * D) / (l / (M * (h * M)))));
	else
		tmp = d * sqrt(((1.0 / 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_] := Block[{t$95$0 = N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -3e-273], t$95$0, If[LessEqual[l, 6e-199], N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.1e-118], N[(t$95$0 * N[(N[(-0.125 / N[(d * d), $MachinePrecision]), $MachinePrecision] * N[(N[(D * D), $MachinePrecision] / N[(l / N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\
\mathbf{if}\;\ell \leq -3 \cdot 10^{-273}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;\ell \leq 2.1 \cdot 10^{-118}:\\
\;\;\;\;t_0 \cdot \left(\frac{-0.125}{d \cdot d} \cdot \frac{D \cdot D}{\frac{\ell}{M \cdot \left(h \cdot M\right)}}\right)\\

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


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

    1. Initial program 61.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. Step-by-step derivation
      1. expm1-log1p-u43.2%

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

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

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

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

        \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)\right)} \]
      3. unpow1/248.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 \frac{\frac{M}{d}}{2}\right)}^{2}\right)\right) \]
      4. *-commutative48.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.99999999999999987e-273 < l < 5.99999999999999966e-199

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.99999999999999966e-199 < l < 2.1e-118

    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. Step-by-step derivation
      1. expm1-log1p-u30.0%

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

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

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

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

        \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)\right)} \]
      3. unpow1/258.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 \frac{\frac{M}{d}}{2}\right)}^{2}\right)\right) \]
      4. *-commutative58.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.1e-118 < l

    1. Initial program 63.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. sqr-pow63.2%

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right)} - 1\right)} \cdot \left({\left(\frac{d}{\ell}\right)}^{0.25} \cdot {\left(\frac{d}{\ell}\right)}^{0.25}\right)\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. metadata-eval45.6%

        \[\leadsto \left(\left(e^{\mathsf{log1p}\left({\left(\frac{d}{h}\right)}^{\color{blue}{0.5}}\right)} - 1\right) \cdot \left({\left(\frac{d}{\ell}\right)}^{0.25} \cdot {\left(\frac{d}{\ell}\right)}^{0.25}\right)\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. pow1/245.6%

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    10. Simplified60.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3 \cdot 10^{-273}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{-199}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq 2.1 \cdot 10^{-118}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(\frac{-0.125}{d \cdot d} \cdot \frac{D \cdot D}{\frac{\ell}{M \cdot \left(h \cdot M\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]

Alternative 13: 37.0% accurate, 3.0× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -3.6 \cdot 10^{-273}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\ \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 -3.6e-273) (sqrt (* (/ d h) (/ d 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 <= -3.6e-273) {
		tmp = sqrt(((d / h) * (d / 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 <= (-3.6d-273)) then
        tmp = sqrt(((d / h) * (d / 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 <= -3.6e-273) {
		tmp = Math.sqrt(((d / h) * (d / 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 <= -3.6e-273:
		tmp = math.sqrt(((d / h) * (d / 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 <= -3.6e-273)
		tmp = sqrt(Float64(Float64(d / h) * Float64(d / 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 <= -3.6e-273)
		tmp = sqrt(((d / h) * (d / 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, -3.6e-273], N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $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 -3.6 \cdot 10^{-273}:\\
\;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\

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


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

    1. Initial program 61.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. Step-by-step derivation
      1. expm1-log1p-u43.2%

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

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

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

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

        \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{0.5} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{\frac{M}{d}}{2}\right)}^{2}\right)\right)} \]
      3. unpow1/248.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 \frac{\frac{M}{d}}{2}\right)}^{2}\right)\right) \]
      4. *-commutative48.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.59999999999999993e-273 < l

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.6 \cdot 10^{-273}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \end{array} \]

Alternative 14: 25.4% 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 61.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  7. Final simplification32.0%

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

Reproduce

?
herbie shell --seed 2023257 
(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)))))