Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.6% → 77.3%
Time: 15.1s
Alternatives: 5
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 5 alternatives:

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

Initial Program: 66.6% 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: 77.3% accurate, 0.8× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

Alternative 2: 75.6% accurate, 0.8× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

Alternative 3: 71.4% accurate, 0.8× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.19999999999999954e-182 < h

    1. Initial program 74.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. Simplified74.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 72.6% accurate, 0.8× speedup?

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

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


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

    1. Initial program 60.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.0999999999999998e-305 < l

    1. Initial program 71.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. Simplified71.7%

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

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

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

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

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

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

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

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

Alternative 5: 69.1% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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