Henrywood and Agarwal, Equation (12)

Percentage Accurate: 67.8% → 81.6%
Time: 31.2s
Alternatives: 26
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

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

Alternative 1: 81.6% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 55.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.2000000000000001e198 < h < -4.999999999999985e-310

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 73.1%

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

        \[\leadsto \color{blue}{{\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-rr87.1%

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

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

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

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

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

Alternative 2: 81.6% accurate, 0.8× speedup?

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

\mathbf{elif}\;h \leq -2.1 \cdot 10^{-70}:\\
\;\;\;\;\frac{t_0}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot t_1\right)\right)\right)\\

\mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -1.70000000000000008e197 or -2.1000000000000001e-70 < h < -4.999999999999985e-310

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

      \[\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)} \]
    3. Step-by-step derivation
      1. frac-2neg71.9%

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

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

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

    if -1.70000000000000008e197 < h < -2.1000000000000001e-70

    1. Initial program 63.5%

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 73.1%

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

        \[\leadsto \color{blue}{{\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-rr87.1%

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

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

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

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

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

Alternative 3: 81.2% accurate, 0.8× speedup?

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

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


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

    1. Initial program 66.4%

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

      \[\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)} \]
    3. Step-by-step derivation
      1. frac-2neg70.7%

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

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

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

    if -3.5e-308 < d

    1. Initial program 72.6%

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

        \[\leadsto \color{blue}{{\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-rr86.4%

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

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

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

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

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

Alternative 4: 80.2% accurate, 0.8× speedup?

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

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


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

    1. Initial program 65.8%

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

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

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

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

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

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

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

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

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

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

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

    if -9.999999999999969e-311 < l

    1. Initial program 73.1%

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

        \[\leadsto \color{blue}{{\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-rr87.1%

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

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

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

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

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

Alternative 5: 80.2% accurate, 0.8× speedup?

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

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


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

    1. Initial program 65.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.999999999999969e-311 < l

    1. Initial program 73.1%

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

        \[\leadsto \color{blue}{{\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-rr87.1%

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

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

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

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

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

Alternative 6: 73.6% accurate, 0.8× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.2000000000000003e-148 < l

    1. Initial program 73.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. Simplified74.5%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 73.5% accurate, 1.0× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.99999999999999974e-148 < l

    1. Initial program 73.6%

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

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

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

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

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

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

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

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

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

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

Alternative 8: 76.6% accurate, 1.0× speedup?

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

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


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

    1. Initial program 66.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.5e-307 < l

    1. Initial program 72.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. pow172.9%

        \[\leadsto \color{blue}{{\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-rr87.7%

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

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

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

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

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

Alternative 9: 73.9% accurate, 1.0× speedup?

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

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


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

    1. Initial program 66.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.0000000000000001e-191 < l

    1. Initial program 73.6%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 73.5% accurate, 1.0× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.8000000000000001e-148 < l

    1. Initial program 73.6%

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

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

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

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

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

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

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

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

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

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

Alternative 11: 73.5% accurate, 1.0× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.95000000000000008e-148 < l

    1. Initial program 73.6%

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

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

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

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

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

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

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

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

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

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

Alternative 12: 69.8% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 1.27999999999999994e70

    1. Initial program 69.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.27999999999999994e70 < l

    1. Initial program 70.2%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    5. Applied egg-rr76.7%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Step-by-step derivation
      1. associate-/l/78.8%

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

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

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

Alternative 13: 73.5% accurate, 1.0× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.9999999999999999e-148 < l

    1. Initial program 73.6%

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

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

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

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

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

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

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

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

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

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

Alternative 14: 67.3% accurate, 1.0× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(M \cdot \frac{D}{d}\right)}^{2} \cdot -0.125\right)\right)\right) \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (*
  (sqrt (/ d l))
  (* (sqrt (/ d h)) (+ 1.0 (* (/ h l) (* (pow (* M (/ D d)) 2.0) -0.125))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return sqrt((d / l)) * (sqrt((d / h)) * (1.0 + ((h / l) * (pow((M * (D / d)), 2.0) * -0.125))));
}
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 = sqrt((d / l)) * (sqrt((d / h)) * (1.0d0 + ((h / l) * (((m * (d_1 / d)) ** 2.0d0) * (-0.125d0)))))
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return Math.sqrt((d / l)) * (Math.sqrt((d / h)) * (1.0 + ((h / l) * (Math.pow((M * (D / d)), 2.0) * -0.125))));
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return math.sqrt((d / l)) * (math.sqrt((d / h)) * (1.0 + ((h / l) * (math.pow((M * (D / d)), 2.0) * -0.125))))
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(M * Float64(D / d)) ^ 2.0) * -0.125)))))
end
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + ((h / l) * (((M * (D / d)) ^ 2.0) * -0.125))));
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(M \cdot \frac{D}{d}\right)}^{2} \cdot -0.125\right)\right)\right)
\end{array}
Derivation
  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. Simplified69.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 46.5% accurate, 1.6× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2 \cdot 10^{-210}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\ \;\;\;\;d \cdot e^{0.5 \cdot \left(-\mathsf{log1p}\left(h \cdot \ell + -1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -2e-210)
   (* (sqrt (/ d h)) (sqrt (/ d l)))
   (if (<= l -1e-310)
     (* d (exp (* 0.5 (- (log1p (+ (* h l) -1.0))))))
     (/ d (* (sqrt l) (sqrt h))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -2e-210) {
		tmp = sqrt((d / h)) * sqrt((d / l));
	} else if (l <= -1e-310) {
		tmp = d * exp((0.5 * -log1p(((h * l) + -1.0))));
	} else {
		tmp = d / (sqrt(l) * sqrt(h));
	}
	return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -2e-210) {
		tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
	} else if (l <= -1e-310) {
		tmp = d * Math.exp((0.5 * -Math.log1p(((h * l) + -1.0))));
	} else {
		tmp = d / (Math.sqrt(l) * Math.sqrt(h));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if l <= -2e-210:
		tmp = math.sqrt((d / h)) * math.sqrt((d / l))
	elif l <= -1e-310:
		tmp = d * math.exp((0.5 * -math.log1p(((h * l) + -1.0))))
	else:
		tmp = d / (math.sqrt(l) * math.sqrt(h))
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -2e-210)
		tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)));
	elseif (l <= -1e-310)
		tmp = Float64(d * exp(Float64(0.5 * Float64(-log1p(Float64(Float64(h * l) + -1.0))))));
	else
		tmp = Float64(d / Float64(sqrt(l) * sqrt(h)));
	end
	return tmp
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -2e-210], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1e-310], N[(d * N[Exp[N[(0.5 * (-N[Log[1 + N[(N[(h * l), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2 \cdot 10^{-210}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\

\mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;d \cdot e^{0.5 \cdot \left(-\mathsf{log1p}\left(h \cdot \ell + -1\right)\right)}\\

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


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

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

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

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

    if -2.0000000000000001e-210 < l < -9.999999999999969e-311

    1. Initial program 65.1%

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow1/234.1%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      2. pow-to-exp34.1%

        \[\leadsto d \cdot \color{blue}{e^{\log \left(\frac{1}{h \cdot \ell}\right) \cdot 0.5}} \]
      3. log-rec33.9%

        \[\leadsto d \cdot e^{\color{blue}{\left(-\log \left(h \cdot \ell\right)\right)} \cdot 0.5} \]
    5. Applied egg-rr33.9%

      \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
    6. Step-by-step derivation
      1. log1p-expm1-u54.3%

        \[\leadsto d \cdot e^{\left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(h \cdot \ell\right)\right)\right)}\right) \cdot 0.5} \]
      2. expm1-udef54.3%

        \[\leadsto d \cdot e^{\left(-\mathsf{log1p}\left(\color{blue}{e^{\log \left(h \cdot \ell\right)} - 1}\right)\right) \cdot 0.5} \]
      3. add-exp-log54.3%

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

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

    if -9.999999999999969e-311 < l

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    5. Applied egg-rr59.2%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Step-by-step derivation
      1. associate-/l/62.1%

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

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

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

Alternative 16: 46.7% accurate, 1.6× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -4.5 \cdot 10^{-210}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{1}{\sqrt{\frac{h}{d}}}\\ \mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\ \;\;\;\;d \cdot e^{0.5 \cdot \left(-\mathsf{log1p}\left(h \cdot \ell + -1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -4.5e-210)
   (* (sqrt (/ d l)) (/ 1.0 (sqrt (/ h d))))
   (if (<= l -1e-310)
     (* d (exp (* 0.5 (- (log1p (+ (* h l) -1.0))))))
     (/ d (* (sqrt l) (sqrt h))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -4.5e-210) {
		tmp = sqrt((d / l)) * (1.0 / sqrt((h / d)));
	} else if (l <= -1e-310) {
		tmp = d * exp((0.5 * -log1p(((h * l) + -1.0))));
	} else {
		tmp = d / (sqrt(l) * sqrt(h));
	}
	return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -4.5e-210) {
		tmp = Math.sqrt((d / l)) * (1.0 / Math.sqrt((h / d)));
	} else if (l <= -1e-310) {
		tmp = d * Math.exp((0.5 * -Math.log1p(((h * l) + -1.0))));
	} else {
		tmp = d / (Math.sqrt(l) * Math.sqrt(h));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if l <= -4.5e-210:
		tmp = math.sqrt((d / l)) * (1.0 / math.sqrt((h / d)))
	elif l <= -1e-310:
		tmp = d * math.exp((0.5 * -math.log1p(((h * l) + -1.0))))
	else:
		tmp = d / (math.sqrt(l) * math.sqrt(h))
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -4.5e-210)
		tmp = Float64(sqrt(Float64(d / l)) * Float64(1.0 / sqrt(Float64(h / d))));
	elseif (l <= -1e-310)
		tmp = Float64(d * exp(Float64(0.5 * Float64(-log1p(Float64(Float64(h * l) + -1.0))))));
	else
		tmp = Float64(d / Float64(sqrt(l) * sqrt(h)));
	end
	return tmp
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -4.5e-210], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1e-310], N[(d * N[Exp[N[(0.5 * (-N[Log[1 + N[(N[(h * l), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.5 \cdot 10^{-210}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{1}{\sqrt{\frac{h}{d}}}\\

\mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;d \cdot e^{0.5 \cdot \left(-\mathsf{log1p}\left(h \cdot \ell + -1\right)\right)}\\

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


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

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

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

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

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

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

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

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

    if -4.5000000000000002e-210 < l < -9.999999999999969e-311

    1. Initial program 65.1%

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. pow1/234.1%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      2. pow-to-exp34.1%

        \[\leadsto d \cdot \color{blue}{e^{\log \left(\frac{1}{h \cdot \ell}\right) \cdot 0.5}} \]
      3. log-rec33.9%

        \[\leadsto d \cdot e^{\color{blue}{\left(-\log \left(h \cdot \ell\right)\right)} \cdot 0.5} \]
    5. Applied egg-rr33.9%

      \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
    6. Step-by-step derivation
      1. log1p-expm1-u54.3%

        \[\leadsto d \cdot e^{\left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(h \cdot \ell\right)\right)\right)}\right) \cdot 0.5} \]
      2. expm1-udef54.3%

        \[\leadsto d \cdot e^{\left(-\mathsf{log1p}\left(\color{blue}{e^{\log \left(h \cdot \ell\right)} - 1}\right)\right) \cdot 0.5} \]
      3. add-exp-log54.3%

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

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

    if -9.999999999999969e-311 < l

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    5. Applied egg-rr59.2%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Step-by-step derivation
      1. associate-/l/62.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.5 \cdot 10^{-210}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{1}{\sqrt{\frac{h}{d}}}\\ \mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\ \;\;\;\;d \cdot e^{0.5 \cdot \left(-\mathsf{log1p}\left(h \cdot \ell + -1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]

Alternative 17: 36.6% accurate, 1.6× speedup?

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

\mathbf{elif}\;\ell \leq 2.2 \cdot 10^{-134}:\\
\;\;\;\;d \cdot \sqrt{\left(1 + \frac{1}{h \cdot \ell}\right) + -1}\\

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


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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. add-sqr-sqrt0.0%

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot d}{\left(\sqrt{\ell} \cdot \sqrt{h}\right) \cdot \left(\sqrt{\ell} \cdot \sqrt{h}\right)}}} \]
      9. pow20.0%

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

        \[\leadsto \sqrt{\frac{{d}^{2}}{\color{blue}{\sqrt{\ell \cdot h}} \cdot \left(\sqrt{\ell} \cdot \sqrt{h}\right)}} \]
      11. sqrt-unprod31.9%

        \[\leadsto \sqrt{\frac{{d}^{2}}{\sqrt{\ell \cdot h} \cdot \color{blue}{\sqrt{\ell \cdot h}}}} \]
      12. add-sqr-sqrt32.0%

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

        \[\leadsto \sqrt{\frac{{d}^{2}}{\color{blue}{h \cdot \ell}}} \]
    5. Applied egg-rr32.0%

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

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{{d}^{2}}{h}}{\ell}}} \]
    7. Simplified33.4%

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

    if -9.2000000000000001e-248 < l < 2.2e-134

    1. Initial program 69.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. Simplified69.7%

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

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

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

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

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

      \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{h}}{\ell}\right)} - 1}} \]
    6. Taylor expanded in h around inf 51.8%

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

    if 2.2e-134 < l

    1. Initial program 73.4%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Step-by-step derivation
      1. associate-/l/64.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9.2 \cdot 10^{-248}:\\ \;\;\;\;\sqrt{\frac{\frac{{d}^{2}}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq 2.2 \cdot 10^{-134}:\\ \;\;\;\;d \cdot \sqrt{\left(1 + \frac{1}{h \cdot \ell}\right) + -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]

Alternative 18: 43.4% accurate, 1.6× speedup?

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

\mathbf{elif}\;\ell \leq 3.8 \cdot 10^{-134}:\\
\;\;\;\;d \cdot \sqrt{\left(1 + \frac{1}{h \cdot \ell}\right) + -1}\\

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


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

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

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

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

    if -1.16e-246 < l < 3.80000000000000003e-134

    1. Initial program 69.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. Simplified69.7%

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

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

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

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

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

      \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{h}}{\ell}\right)} - 1}} \]
    6. Taylor expanded in h around inf 51.8%

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

    if 3.80000000000000003e-134 < l

    1. Initial program 73.4%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Step-by-step derivation
      1. associate-/l/64.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.16 \cdot 10^{-246}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq 3.8 \cdot 10^{-134}:\\ \;\;\;\;d \cdot \sqrt{\left(1 + \frac{1}{h \cdot \ell}\right) + -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]

Alternative 19: 29.5% accurate, 1.6× speedup?

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

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


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

    1. Initial program 65.5%

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

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

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

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

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

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

      \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{h}}{\ell}\right)} - 1}} \]
    6. Taylor expanded in h around inf 16.6%

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

    if 1.25e-264 < h

    1. Initial program 73.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. Simplified74.8%

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

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

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

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

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

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv61.6%

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

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

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Step-by-step derivation
      1. associate-/l/61.6%

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

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

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

Alternative 20: 26.5% accurate, 3.1× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ d \cdot \sqrt{\frac{1}{h \cdot \ell}} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D) :precision binary64 (* d (sqrt (/ 1.0 (* h l)))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d * sqrt((1.0 / (h * l)));
}
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((1.0d0 / (h * l)))
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.sqrt((1.0 / (h * l)));
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * math.sqrt((1.0 / (h * l)))
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d * sqrt(Float64(1.0 / Float64(h * l))))
end
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt((1.0 / (h * l)));
end
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[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot \sqrt{\frac{1}{h \cdot \ell}}
\end{array}
Derivation
  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. Simplified69.8%

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

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  4. Final simplification33.4%

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

Alternative 21: 26.6% accurate, 3.1× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D) :precision binary64 (* d (sqrt (/ (/ 1.0 h) l))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d * sqrt(((1.0 / h) / l));
}
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(((1.0d0 / h) / l))
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.sqrt(((1.0 / h) / l));
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * math.sqrt(((1.0 / h) / l))
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d * sqrt(Float64(Float64(1.0 / h) / l)))
end
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt(((1.0 / h) / l));
end
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[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}
\end{array}
Derivation
  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. Simplified69.8%

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

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

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

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

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

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

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

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

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

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

Alternative 22: 26.6% accurate, 3.1× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D) :precision binary64 (* d (sqrt (/ (/ 1.0 l) h))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d * sqrt(((1.0 / l) / h));
}
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(((1.0d0 / l) / h))
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.sqrt(((1.0 / l) / h));
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * math.sqrt(((1.0 / l) / h))
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d * sqrt(Float64(Float64(1.0 / l) / h)))
end
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt(((1.0 / l) / h));
end
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[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}
\end{array}
Derivation
  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. Simplified69.8%

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

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

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

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

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

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

Alternative 23: 26.4% accurate, 3.1× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ d \cdot {\left(h \cdot \ell\right)}^{-0.5} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D) :precision binary64 (* d (pow (* h l) -0.5)))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d * pow((h * l), -0.5);
}
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 * ((h * l) ** (-0.5d0))
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.pow((h * l), -0.5);
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * math.pow((h * l), -0.5)
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d * (Float64(h * l) ^ -0.5))
end
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d * ((h * l) ^ -0.5);
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot {\left(h \cdot \ell\right)}^{-0.5}
\end{array}
Derivation
  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. Simplified69.8%

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

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

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

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

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

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

      \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
  5. Applied egg-rr22.0%

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

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

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

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

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

Alternative 24: 26.4% accurate, 3.2× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \frac{d}{\sqrt{h \cdot \ell}} \end{array} \]
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))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d / sqrt((h * l));
}
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
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return d / Math.sqrt((h * l));
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d / math.sqrt((h * l))
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d / sqrt(Float64(h * l)))
end
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d / sqrt((h * l));
end
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, D] = \mathsf{sort}([M, D])\\
\\
\frac{d}{\sqrt{h \cdot \ell}}
\end{array}
Derivation
  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. Simplified69.8%

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

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

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

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

      \[\leadsto d \cdot {\left(\color{blue}{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{0.3333333333333333} \]
    4. pow129.8%

      \[\leadsto d \cdot {\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{1}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{0.3333333333333333} \]
    5. pow1/229.8%

      \[\leadsto d \cdot {\left({\left(\frac{1}{h \cdot \ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)}^{0.3333333333333333} \]
    6. pow-prod-up29.8%

      \[\leadsto d \cdot {\color{blue}{\left({\left(\frac{1}{h \cdot \ell}\right)}^{\left(1 + 0.5\right)}\right)}}^{0.3333333333333333} \]
    7. associate-/r*29.8%

      \[\leadsto d \cdot {\left({\color{blue}{\left(\frac{\frac{1}{h}}{\ell}\right)}}^{\left(1 + 0.5\right)}\right)}^{0.3333333333333333} \]
    8. metadata-eval29.8%

      \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
  5. Applied egg-rr29.8%

    \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
  6. Step-by-step derivation
    1. unpow1/331.1%

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

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

      \[\leadsto d \cdot \sqrt[3]{{\color{blue}{\left(\frac{\frac{1}{\ell}}{h}\right)}}^{1.5}} \]
  7. Simplified31.1%

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

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    2. associate-/l/29.8%

      \[\leadsto d \cdot {\left({\color{blue}{\left(\frac{1}{h \cdot \ell}\right)}}^{1.5}\right)}^{0.3333333333333333} \]
    3. pow-pow33.4%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}} \]
    4. metadata-eval33.4%

      \[\leadsto d \cdot {\left(\frac{1}{h \cdot \ell}\right)}^{\color{blue}{0.5}} \]
    5. pow1/233.4%

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

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
    7. metadata-eval33.3%

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

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

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

    \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell \cdot h}}} \]
  10. Final simplification33.3%

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

Alternative 25: 0.0% accurate, 3.2× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ d \cdot \sqrt{-1} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D) :precision binary64 (* d (sqrt -1.0)))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d * sqrt(-1.0);
}
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((-1.0d0))
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.sqrt(-1.0);
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * math.sqrt(-1.0)
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d * sqrt(-1.0))
end
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt(-1.0);
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := N[(d * N[Sqrt[-1.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot \sqrt{-1}
\end{array}
Derivation
  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. Simplified69.8%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto d \cdot \sqrt{\color{blue}{{\left(\sqrt[3]{1 + \frac{1}{h \cdot \ell}}\right)}^{3}} - 1} \]
  8. Taylor expanded in h around 0 0.0%

    \[\leadsto d \cdot \sqrt{\color{blue}{-1}} \]
  9. Final simplification0.0%

    \[\leadsto d \cdot \sqrt{-1} \]

Alternative 26: 4.5% accurate, 3.2× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ d \cdot \sqrt{0} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D) :precision binary64 (* d (sqrt 0.0)))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d * sqrt(0.0);
}
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(0.0d0)
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.sqrt(0.0);
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * math.sqrt(0.0)
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d * sqrt(0.0))
end
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt(0.0);
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := N[(d * N[Sqrt[0.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot \sqrt{0}
\end{array}
Derivation
  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. Simplified69.8%

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

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

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

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

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

    \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{h}}{\ell}\right)} - 1}} \]
  6. Taylor expanded in h around inf 4.5%

    \[\leadsto d \cdot \sqrt{\color{blue}{1} - 1} \]
  7. Final simplification4.5%

    \[\leadsto d \cdot \sqrt{0} \]

Reproduce

?
herbie shell --seed 2023318 
(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)))))