Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.9% → 79.1%
Time: 30.5s
Alternatives: 23
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 23 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.9% accurate, 1.0× speedup?

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

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

Alternative 1: 79.1% accurate, 0.6× speedup?

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

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


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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left({\left(\frac{d}{h}\right)}^{0.25}\right)}^{2}} \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) \]
    5. Step-by-step derivation
      1. associate-*r/71.1%

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 66.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. Simplified65.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. sqrt-div67.4%

        \[\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) \]
    4. Applied egg-rr67.4%

      \[\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) \]
    5. Step-by-step derivation
      1. sqrt-div81.5%

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

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

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

Alternative 2: 75.5% accurate, 0.3× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right)\\ t_1 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;t_0 \leq 2 \cdot 10^{+287}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{\frac{M \cdot D}{2}}{d}\right)}^{2}\right)\right)\right)\\ \mathbf{elif}\;t_0 \leq \infty:\\ \;\;\;\;\left|\frac{d}{t_1} \cdot \mathsf{fma}\left(0.5, \frac{h}{\ell} \cdot \left(-{\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\right), 1\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\sqrt{{\left(d \cdot \frac{1}{t_1}\right)}^{2}}\\ \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 (/ d h) 0.5) (pow (/ d l) 0.5))
          (- 1.0 (* (/ h l) (* 0.5 (pow (/ (* M D) (* d 2.0)) 2.0))))))
        (t_1 (sqrt (* l h))))
   (if (<= t_0 2e+287)
     (*
      (sqrt (/ d l))
      (*
       (sqrt (/ d h))
       (+ 1.0 (* (/ h l) (* -0.5 (pow (/ (/ (* M D) 2.0) d) 2.0))))))
     (if (<= t_0 INFINITY)
       (fabs
        (*
         (/ d t_1)
         (fma 0.5 (* (/ h l) (- (pow (* M (/ (* 0.5 D) d)) 2.0))) 1.0)))
       (sqrt (pow (* d (/ 1.0 t_1)) 2.0))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = (pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * pow(((M * D) / (d * 2.0)), 2.0))));
	double t_1 = sqrt((l * h));
	double tmp;
	if (t_0 <= 2e+287) {
		tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * pow((((M * D) / 2.0) / d), 2.0)))));
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = fabs(((d / t_1) * fma(0.5, ((h / l) * -pow((M * ((0.5 * D) / d)), 2.0)), 1.0)));
	} else {
		tmp = sqrt(pow((d * (1.0 / t_1)), 2.0));
	}
	return tmp;
}
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.5 * (Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0)))))
	t_1 = sqrt(Float64(l * h))
	tmp = 0.0
	if (t_0 <= 2e+287)
		tmp = Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(Float64(Float64(M * D) / 2.0) / d) ^ 2.0))))));
	elseif (t_0 <= Inf)
		tmp = abs(Float64(Float64(d / t_1) * fma(0.5, Float64(Float64(h / l) * Float64(-(Float64(M * Float64(Float64(0.5 * D) / d)) ^ 2.0))), 1.0)));
	else
		tmp = sqrt((Float64(d * Float64(1.0 / t_1)) ^ 2.0));
	end
	return 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[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.5 * N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 2e+287], 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[(-0.5 * N[Power[N[(N[(N[(M * D), $MachinePrecision] / 2.0), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[Abs[N[(N[(d / t$95$1), $MachinePrecision] * N[(0.5 * N[(N[(h / l), $MachinePrecision] * (-N[Power[N[(M * N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision])), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[Power[N[(d * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right)\\
t_1 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{+287}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{\frac{M \cdot D}{2}}{d}\right)}^{2}\right)\right)\right)\\

\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;\left|\frac{d}{t_1} \cdot \mathsf{fma}\left(0.5, \frac{h}{\ell} \cdot \left(-{\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\right), 1\right)\right|\\

\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(d \cdot \frac{1}{t_1}\right)}^{2}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < 2.0000000000000002e287

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

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

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

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

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

    if 2.0000000000000002e287 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < +inf.0

    1. Initial program 56.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l))))

    1. Initial program 0.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. Simplified0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 76.0% accurate, 0.3× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ t_1 := \left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right)\\ \mathbf{if}\;t_1 \leq 2 \cdot 10^{+287}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot {\left(\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\right)\\ \mathbf{elif}\;t_1 \leq \infty:\\ \;\;\;\;\left|\frac{d}{t_0} \cdot \mathsf{fma}\left(0.5, \frac{h}{\ell} \cdot \left(-{\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\right), 1\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\sqrt{{\left(d \cdot \frac{1}{t_0}\right)}^{2}}\\ \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 (* l h)))
        (t_1
         (*
          (* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
          (- 1.0 (* (/ h l) (* 0.5 (pow (/ (* M D) (* d 2.0)) 2.0)))))))
   (if (<= t_1 2e+287)
     (*
      (sqrt (/ d h))
      (*
       (sqrt (/ d l))
       (- 1.0 (* 0.5 (pow (* (* (* 0.5 M) (/ D d)) (sqrt (/ h l))) 2.0)))))
     (if (<= t_1 INFINITY)
       (fabs
        (*
         (/ d t_0)
         (fma 0.5 (* (/ h l) (- (pow (* M (/ (* 0.5 D) d)) 2.0))) 1.0)))
       (sqrt (pow (* d (/ 1.0 t_0)) 2.0))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((l * h));
	double t_1 = (pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * pow(((M * D) / (d * 2.0)), 2.0))));
	double tmp;
	if (t_1 <= 2e+287) {
		tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - (0.5 * pow((((0.5 * M) * (D / d)) * sqrt((h / l))), 2.0))));
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = fabs(((d / t_0) * fma(0.5, ((h / l) * -pow((M * ((0.5 * D) / d)), 2.0)), 1.0)));
	} else {
		tmp = sqrt(pow((d * (1.0 / t_0)), 2.0));
	}
	return tmp;
}
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(l * h))
	t_1 = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.5 * (Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0)))))
	tmp = 0.0
	if (t_1 <= 2e+287)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(0.5 * (Float64(Float64(Float64(0.5 * M) * Float64(D / d)) * sqrt(Float64(h / l))) ^ 2.0)))));
	elseif (t_1 <= Inf)
		tmp = abs(Float64(Float64(d / t_0) * fma(0.5, Float64(Float64(h / l) * Float64(-(Float64(M * Float64(Float64(0.5 * D) / d)) ^ 2.0))), 1.0)));
	else
		tmp = sqrt((Float64(d * Float64(1.0 / t_0)) ^ 2.0));
	end
	return 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[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.5 * N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 2e+287], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(0.5 * N[Power[N[(N[(N[(0.5 * M), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[Abs[N[(N[(d / t$95$0), $MachinePrecision] * N[(0.5 * N[(N[(h / l), $MachinePrecision] * (-N[Power[N[(M * N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision])), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[Power[N[(d * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := \left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right)\\
\mathbf{if}\;t_1 \leq 2 \cdot 10^{+287}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot {\left(\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\right)\\

\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\left|\frac{d}{t_0} \cdot \mathsf{fma}\left(0.5, \frac{h}{\ell} \cdot \left(-{\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\right), 1\right)\right|\\

\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(d \cdot \frac{1}{t_0}\right)}^{2}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < 2.0000000000000002e287

    1. Initial program 87.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. Simplified86.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. add-sqr-sqrt86.3%

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

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

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

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

        \[\leadsto \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)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\right) \]
      6. pow188.4%

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

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

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

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

    if 2.0000000000000002e287 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < +inf.0

    1. Initial program 56.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l))))

    1. Initial program 0.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. Simplified0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 79.8% accurate, 0.6× speedup?

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

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


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

    1. Initial program 71.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. Simplified70.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-2neg70.3%

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

        \[\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) \]
    4. Applied egg-rr76.5%

      \[\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 -9.5000000000000007e-300 < d

    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.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. sqrt-div66.4%

        \[\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) \]
    4. Applied egg-rr66.4%

      \[\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) \]
    5. Step-by-step derivation
      1. sqrt-div80.3%

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

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

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

Alternative 5: 76.9% accurate, 0.8× speedup?

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

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


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

    1. Initial program 71.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. Simplified70.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-2neg70.3%

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

        \[\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) \]
    4. Applied egg-rr76.5%

      \[\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 -9.5000000000000007e-300 < d

    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.6%

      \[\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. sqrt-div80.3%

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

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

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

Alternative 6: 59.0% accurate, 1.0× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ t_1 := {\left(\frac{d}{h}\right)}^{0.25}\\ t_2 := \sqrt{\frac{d}{\ell}}\\ \mathbf{if}\;d \leq -1.9 \cdot 10^{+125}:\\ \;\;\;\;t_1 \cdot \left(t_1 \cdot t_2\right)\\ \mathbf{elif}\;d \leq -1.85 \cdot 10^{+73}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{d}{t_0}\right)\right)\\ \mathbf{elif}\;d \leq -9.2 \cdot 10^{-17}:\\ \;\;\;\;t_2 \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\ \;\;\;\;\frac{d}{e^{\mathsf{log1p}\left(t_0\right)} + -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \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
 (let* ((t_0 (sqrt (* l h))) (t_1 (pow (/ d h) 0.25)) (t_2 (sqrt (/ d l))))
   (if (<= d -1.9e+125)
     (* t_1 (* t_1 t_2))
     (if (<= d -1.85e+73)
       (log1p (expm1 (/ d t_0)))
       (if (<= d -9.2e-17)
         (* t_2 (sqrt (/ d h)))
         (if (<= d 4.05e-299)
           (/ d (+ (exp (log1p t_0)) -1.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 t_0 = sqrt((l * h));
	double t_1 = pow((d / h), 0.25);
	double t_2 = sqrt((d / l));
	double tmp;
	if (d <= -1.9e+125) {
		tmp = t_1 * (t_1 * t_2);
	} else if (d <= -1.85e+73) {
		tmp = log1p(expm1((d / t_0)));
	} else if (d <= -9.2e-17) {
		tmp = t_2 * sqrt((d / h));
	} else if (d <= 4.05e-299) {
		tmp = d / (exp(log1p(t_0)) + -1.0);
	} else {
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * pow((M * (0.5 * (D / d))), 2.0))));
	}
	return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt((l * h));
	double t_1 = Math.pow((d / h), 0.25);
	double t_2 = Math.sqrt((d / l));
	double tmp;
	if (d <= -1.9e+125) {
		tmp = t_1 * (t_1 * t_2);
	} else if (d <= -1.85e+73) {
		tmp = Math.log1p(Math.expm1((d / t_0)));
	} else if (d <= -9.2e-17) {
		tmp = t_2 * Math.sqrt((d / h));
	} else if (d <= 4.05e-299) {
		tmp = d / (Math.exp(Math.log1p(t_0)) + -1.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):
	t_0 = math.sqrt((l * h))
	t_1 = math.pow((d / h), 0.25)
	t_2 = math.sqrt((d / l))
	tmp = 0
	if d <= -1.9e+125:
		tmp = t_1 * (t_1 * t_2)
	elif d <= -1.85e+73:
		tmp = math.log1p(math.expm1((d / t_0)))
	elif d <= -9.2e-17:
		tmp = t_2 * math.sqrt((d / h))
	elif d <= 4.05e-299:
		tmp = d / (math.exp(math.log1p(t_0)) + -1.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)
	t_0 = sqrt(Float64(l * h))
	t_1 = Float64(d / h) ^ 0.25
	t_2 = sqrt(Float64(d / l))
	tmp = 0.0
	if (d <= -1.9e+125)
		tmp = Float64(t_1 * Float64(t_1 * t_2));
	elseif (d <= -1.85e+73)
		tmp = log1p(expm1(Float64(d / t_0)));
	elseif (d <= -9.2e-17)
		tmp = Float64(t_2 * sqrt(Float64(d / h)));
	elseif (d <= 4.05e-299)
		tmp = Float64(d / Float64(exp(log1p(t_0)) + -1.0));
	else
		tmp = Float64(Float64(d / Float64(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
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(d / h), $MachinePrecision], 0.25], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -1.9e+125], N[(t$95$1 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.85e+73], N[Log[1 + N[(Exp[N[(d / t$95$0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -9.2e-17], N[(t$95$2 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.05e-299], N[(d / N[(N[Exp[N[Log[1 + t$95$0], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $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}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := {\left(\frac{d}{h}\right)}^{0.25}\\
t_2 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;d \leq -1.9 \cdot 10^{+125}:\\
\;\;\;\;t_1 \cdot \left(t_1 \cdot t_2\right)\\

\mathbf{elif}\;d \leq -1.85 \cdot 10^{+73}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{d}{t_0}\right)\right)\\

\mathbf{elif}\;d \leq -9.2 \cdot 10^{-17}:\\
\;\;\;\;t_2 \cdot \sqrt{\frac{d}{h}}\\

\mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\
\;\;\;\;\frac{d}{e^{\mathsf{log1p}\left(t_0\right)} + -1}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \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 5 regimes
  2. if d < -1.90000000000000001e125

    1. Initial program 75.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. Simplified75.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 4.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      5. unpow1/20.0%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      6. metadata-eval0.0%

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

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

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

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(\sqrt{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}} \cdot \sqrt{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}}\right)} \]
      10. associate-*r*62.9%

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{0.25}\right) \cdot \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}} \]
      15. metadata-eval62.9%

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{0.25}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{\color{blue}{0.5}}{2}\right)} \]
      16. metadata-eval62.9%

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

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

    if -1.90000000000000001e125 < d < -1.84999999999999987e73

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.84999999999999987e73 < d < -9.20000000000000035e-17

    1. Initial program 81.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. Simplified81.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 3.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      5. unpow1/20.0%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      6. metadata-eval0.0%

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

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

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

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \]
      10. unpow1/264.5%

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

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

    if -9.20000000000000035e-17 < d < 4.0499999999999998e-299

    1. Initial program 58.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified58.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 19.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0499999999999998e-299 < d

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.9 \cdot 10^{+125}:\\ \;\;\;\;{\left(\frac{d}{h}\right)}^{0.25} \cdot \left({\left(\frac{d}{h}\right)}^{0.25} \cdot \sqrt{\frac{d}{\ell}}\right)\\ \mathbf{elif}\;d \leq -1.85 \cdot 10^{+73}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{d}{\sqrt{\ell \cdot h}}\right)\right)\\ \mathbf{elif}\;d \leq -9.2 \cdot 10^{-17}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\ \;\;\;\;\frac{d}{e^{\mathsf{log1p}\left(\sqrt{\ell \cdot h}\right)} + -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \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 7: 64.9% accurate, 1.0× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := {\left(\frac{d}{\ell}\right)}^{0.25}\\ \mathbf{if}\;d \leq -7.5 \cdot 10^{+170}:\\ \;\;\;\;t_0 \cdot \left(\sqrt{\frac{d}{h}} \cdot t_0\right)\\ \mathbf{elif}\;d \leq -2.25 \cdot 10^{-104}:\\ \;\;\;\;\left(1 - {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2} \cdot \left(0.5 \cdot \frac{h}{\ell}\right)\right) \cdot \sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\ \;\;\;\;\frac{d}{e^{\mathsf{log1p}\left(\sqrt{\ell \cdot h}\right)} + -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \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
 (let* ((t_0 (pow (/ d l) 0.25)))
   (if (<= d -7.5e+170)
     (* t_0 (* (sqrt (/ d h)) t_0))
     (if (<= d -2.25e-104)
       (*
        (- 1.0 (* (pow (* (/ D d) (/ M 2.0)) 2.0) (* 0.5 (/ h l))))
        (sqrt (/ (pow d 2.0) (* l h))))
       (if (<= d 4.05e-299)
         (/ d (+ (exp (log1p (sqrt (* l h)))) -1.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 t_0 = pow((d / l), 0.25);
	double tmp;
	if (d <= -7.5e+170) {
		tmp = t_0 * (sqrt((d / h)) * t_0);
	} else if (d <= -2.25e-104) {
		tmp = (1.0 - (pow(((D / d) * (M / 2.0)), 2.0) * (0.5 * (h / l)))) * sqrt((pow(d, 2.0) / (l * h)));
	} else if (d <= 4.05e-299) {
		tmp = d / (exp(log1p(sqrt((l * h)))) + -1.0);
	} else {
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * pow((M * (0.5 * (D / d))), 2.0))));
	}
	return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.pow((d / l), 0.25);
	double tmp;
	if (d <= -7.5e+170) {
		tmp = t_0 * (Math.sqrt((d / h)) * t_0);
	} else if (d <= -2.25e-104) {
		tmp = (1.0 - (Math.pow(((D / d) * (M / 2.0)), 2.0) * (0.5 * (h / l)))) * Math.sqrt((Math.pow(d, 2.0) / (l * h)));
	} else if (d <= 4.05e-299) {
		tmp = d / (Math.exp(Math.log1p(Math.sqrt((l * h)))) + -1.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):
	t_0 = math.pow((d / l), 0.25)
	tmp = 0
	if d <= -7.5e+170:
		tmp = t_0 * (math.sqrt((d / h)) * t_0)
	elif d <= -2.25e-104:
		tmp = (1.0 - (math.pow(((D / d) * (M / 2.0)), 2.0) * (0.5 * (h / l)))) * math.sqrt((math.pow(d, 2.0) / (l * h)))
	elif d <= 4.05e-299:
		tmp = d / (math.exp(math.log1p(math.sqrt((l * h)))) + -1.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)
	t_0 = Float64(d / l) ^ 0.25
	tmp = 0.0
	if (d <= -7.5e+170)
		tmp = Float64(t_0 * Float64(sqrt(Float64(d / h)) * t_0));
	elseif (d <= -2.25e-104)
		tmp = Float64(Float64(1.0 - Float64((Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0) * Float64(0.5 * Float64(h / l)))) * sqrt(Float64((d ^ 2.0) / Float64(l * h))));
	elseif (d <= 4.05e-299)
		tmp = Float64(d / Float64(exp(log1p(sqrt(Float64(l * h)))) + -1.0));
	else
		tmp = Float64(Float64(d / Float64(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
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Power[N[(d / l), $MachinePrecision], 0.25], $MachinePrecision]}, If[LessEqual[d, -7.5e+170], N[(t$95$0 * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.25e-104], N[(N[(1.0 - N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.05e-299], N[(d / N[(N[Exp[N[Log[1 + N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $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}
t_0 := {\left(\frac{d}{\ell}\right)}^{0.25}\\
\mathbf{if}\;d \leq -7.5 \cdot 10^{+170}:\\
\;\;\;\;t_0 \cdot \left(\sqrt{\frac{d}{h}} \cdot t_0\right)\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \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 4 regimes
  2. if d < -7.5000000000000002e170

    1. Initial program 79.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. Simplified79.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 1.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      5. unpow1/20.0%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      6. metadata-eval0.0%

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

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

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

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

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \cdot \sqrt{\sqrt{\frac{d}{\ell}}}\right) \cdot \sqrt{\sqrt{\frac{d}{\ell}}} \]
      11. unpow1/272.9%

        \[\leadsto \left(\color{blue}{\sqrt{\frac{d}{h}}} \cdot \sqrt{\sqrt{\frac{d}{\ell}}}\right) \cdot \sqrt{\sqrt{\frac{d}{\ell}}} \]
      12. pow1/272.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}}\right) \cdot \sqrt{\sqrt{\frac{d}{\ell}}} \]
      13. metadata-eval72.9%

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{0.25}}\right) \cdot \sqrt{\sqrt{\frac{d}{\ell}}} \]
      17. pow1/272.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(\frac{d}{\ell}\right)}^{0.25}\right) \cdot \sqrt{\color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}} \]
      18. metadata-eval72.9%

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

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

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

    if -7.5000000000000002e170 < d < -2.2499999999999999e-104

    1. Initial program 77.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. add-sqr-sqrt77.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.2499999999999999e-104 < d < 4.0499999999999998e-299

    1. Initial program 47.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. Simplified47.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 20.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0499999999999998e-299 < d

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.5 \cdot 10^{+170}:\\ \;\;\;\;{\left(\frac{d}{\ell}\right)}^{0.25} \cdot \left(\sqrt{\frac{d}{h}} \cdot {\left(\frac{d}{\ell}\right)}^{0.25}\right)\\ \mathbf{elif}\;d \leq -2.25 \cdot 10^{-104}:\\ \;\;\;\;\left(1 - {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2} \cdot \left(0.5 \cdot \frac{h}{\ell}\right)\right) \cdot \sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\ \;\;\;\;\frac{d}{e^{\mathsf{log1p}\left(\sqrt{\ell \cdot h}\right)} + -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \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: 72.9% accurate, 1.0× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \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 d < -9.5000000000000007e-300

    1. Initial program 71.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. Simplified70.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)} \]

    if -9.5000000000000007e-300 < d

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9.5 \cdot 10^{-300}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\right) \cdot \sqrt{\frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \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 9: 73.0% accurate, 1.0× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \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 d < -9.5000000000000007e-300

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

      \[\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)} \]

    if -9.5000000000000007e-300 < d

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9.5 \cdot 10^{-300}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2} \cdot -0.5\right)\right) \cdot \sqrt{\frac{d}{h}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \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: 72.4% accurate, 1.0× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \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 d < 1.02000000000000006e-231

    1. Initial program 68.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.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. frac-times68.8%

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

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

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

    if 1.02000000000000006e-231 < d

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 1.02 \cdot 10^{-231}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{\frac{M \cdot D}{2}}{d}\right)}^{2}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \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: 72.6% accurate, 1.0× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \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 < 2e-31

    1. Initial program 73.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. Simplified72.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/75.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-sqrt46.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-sqrt75.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-inv75.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-eval75.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-rr75.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) \]

    if 2e-31 < l

    1. Initial program 52.9%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 2 \cdot 10^{-31}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h \cdot \left({\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2} \cdot -0.5\right)}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \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: 53.5% accurate, 1.1× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ t_1 := \frac{d}{t_0}\\ t_2 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{if}\;d \leq -3.9 \cdot 10^{+128}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;d \leq -1.75 \cdot 10^{+73}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(t_1\right)\right)\\ \mathbf{elif}\;d \leq -3.5 \cdot 10^{-17}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\ \;\;\;\;\frac{d}{e^{\mathsf{log1p}\left(t_0\right)} + -1}\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(1 - \left(0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\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
 (let* ((t_0 (sqrt (* l h)))
        (t_1 (/ d t_0))
        (t_2 (* (sqrt (/ d l)) (sqrt (/ d h)))))
   (if (<= d -3.9e+128)
     t_2
     (if (<= d -1.75e+73)
       (log1p (expm1 t_1))
       (if (<= d -3.5e-17)
         t_2
         (if (<= d 4.05e-299)
           (/ d (+ (exp (log1p t_0)) -1.0))
           (*
            t_1
            (- 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 t_0 = sqrt((l * h));
	double t_1 = d / t_0;
	double t_2 = sqrt((d / l)) * sqrt((d / h));
	double tmp;
	if (d <= -3.9e+128) {
		tmp = t_2;
	} else if (d <= -1.75e+73) {
		tmp = log1p(expm1(t_1));
	} else if (d <= -3.5e-17) {
		tmp = t_2;
	} else if (d <= 4.05e-299) {
		tmp = d / (exp(log1p(t_0)) + -1.0);
	} else {
		tmp = t_1 * (1.0 - ((0.5 * (h / l)) * pow((M * ((0.5 * D) / d)), 2.0)));
	}
	return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt((l * h));
	double t_1 = d / t_0;
	double t_2 = Math.sqrt((d / l)) * Math.sqrt((d / h));
	double tmp;
	if (d <= -3.9e+128) {
		tmp = t_2;
	} else if (d <= -1.75e+73) {
		tmp = Math.log1p(Math.expm1(t_1));
	} else if (d <= -3.5e-17) {
		tmp = t_2;
	} else if (d <= 4.05e-299) {
		tmp = d / (Math.exp(Math.log1p(t_0)) + -1.0);
	} else {
		tmp = t_1 * (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):
	t_0 = math.sqrt((l * h))
	t_1 = d / t_0
	t_2 = math.sqrt((d / l)) * math.sqrt((d / h))
	tmp = 0
	if d <= -3.9e+128:
		tmp = t_2
	elif d <= -1.75e+73:
		tmp = math.log1p(math.expm1(t_1))
	elif d <= -3.5e-17:
		tmp = t_2
	elif d <= 4.05e-299:
		tmp = d / (math.exp(math.log1p(t_0)) + -1.0)
	else:
		tmp = t_1 * (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)
	t_0 = sqrt(Float64(l * h))
	t_1 = Float64(d / t_0)
	t_2 = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h)))
	tmp = 0.0
	if (d <= -3.9e+128)
		tmp = t_2;
	elseif (d <= -1.75e+73)
		tmp = log1p(expm1(t_1));
	elseif (d <= -3.5e-17)
		tmp = t_2;
	elseif (d <= 4.05e-299)
		tmp = Float64(d / Float64(exp(log1p(t_0)) + -1.0));
	else
		tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(0.5 * Float64(h / l)) * (Float64(M * Float64(Float64(0.5 * D) / d)) ^ 2.0))));
	end
	return 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[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(d / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.9e+128], t$95$2, If[LessEqual[d, -1.75e+73], N[Log[1 + N[(Exp[t$95$1] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -3.5e-17], t$95$2, If[LessEqual[d, 4.05e-299], N[(d / N[(N[Exp[N[Log[1 + t$95$0], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 - N[(N[(0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(M * N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := \frac{d}{t_0}\\
t_2 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{if}\;d \leq -3.9 \cdot 10^{+128}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;d \leq -1.75 \cdot 10^{+73}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(t_1\right)\right)\\

\mathbf{elif}\;d \leq -3.5 \cdot 10^{-17}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\
\;\;\;\;\frac{d}{e^{\mathsf{log1p}\left(t_0\right)} + -1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -3.8999999999999997e128 or -1.75000000000000001e73 < d < -3.5000000000000002e-17

    1. Initial program 77.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified77.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 3.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      5. unpow1/20.0%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      6. metadata-eval0.0%

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

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

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

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \]
      10. unpow1/263.4%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}} \]
    11. Applied egg-rr63.4%

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

    if -3.8999999999999997e128 < d < -1.75000000000000001e73

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.5000000000000002e-17 < d < 4.0499999999999998e-299

    1. Initial program 58.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified58.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 19.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0499999999999998e-299 < d

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.9 \cdot 10^{+128}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -1.75 \cdot 10^{+73}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{d}{\sqrt{\ell \cdot h}}\right)\right)\\ \mathbf{elif}\;d \leq -3.5 \cdot 10^{-17}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\ \;\;\;\;\frac{d}{e^{\mathsf{log1p}\left(\sqrt{\ell \cdot h}\right)} + -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\right)\\ \end{array} \]

Alternative 13: 53.6% accurate, 1.1× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ t_1 := \frac{d}{t_0}\\ t_2 := {\left(\frac{d}{h}\right)}^{0.25}\\ t_3 := \sqrt{\frac{d}{\ell}}\\ \mathbf{if}\;d \leq -6 \cdot 10^{+126}:\\ \;\;\;\;t_2 \cdot \left(t_2 \cdot t_3\right)\\ \mathbf{elif}\;d \leq -1.85 \cdot 10^{+73}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(t_1\right)\right)\\ \mathbf{elif}\;d \leq -1.26 \cdot 10^{-17}:\\ \;\;\;\;t_3 \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\ \;\;\;\;\frac{d}{e^{\mathsf{log1p}\left(t_0\right)} + -1}\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(1 - \left(0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\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
 (let* ((t_0 (sqrt (* l h)))
        (t_1 (/ d t_0))
        (t_2 (pow (/ d h) 0.25))
        (t_3 (sqrt (/ d l))))
   (if (<= d -6e+126)
     (* t_2 (* t_2 t_3))
     (if (<= d -1.85e+73)
       (log1p (expm1 t_1))
       (if (<= d -1.26e-17)
         (* t_3 (sqrt (/ d h)))
         (if (<= d 4.05e-299)
           (/ d (+ (exp (log1p t_0)) -1.0))
           (*
            t_1
            (- 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 t_0 = sqrt((l * h));
	double t_1 = d / t_0;
	double t_2 = pow((d / h), 0.25);
	double t_3 = sqrt((d / l));
	double tmp;
	if (d <= -6e+126) {
		tmp = t_2 * (t_2 * t_3);
	} else if (d <= -1.85e+73) {
		tmp = log1p(expm1(t_1));
	} else if (d <= -1.26e-17) {
		tmp = t_3 * sqrt((d / h));
	} else if (d <= 4.05e-299) {
		tmp = d / (exp(log1p(t_0)) + -1.0);
	} else {
		tmp = t_1 * (1.0 - ((0.5 * (h / l)) * pow((M * ((0.5 * D) / d)), 2.0)));
	}
	return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt((l * h));
	double t_1 = d / t_0;
	double t_2 = Math.pow((d / h), 0.25);
	double t_3 = Math.sqrt((d / l));
	double tmp;
	if (d <= -6e+126) {
		tmp = t_2 * (t_2 * t_3);
	} else if (d <= -1.85e+73) {
		tmp = Math.log1p(Math.expm1(t_1));
	} else if (d <= -1.26e-17) {
		tmp = t_3 * Math.sqrt((d / h));
	} else if (d <= 4.05e-299) {
		tmp = d / (Math.exp(Math.log1p(t_0)) + -1.0);
	} else {
		tmp = t_1 * (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):
	t_0 = math.sqrt((l * h))
	t_1 = d / t_0
	t_2 = math.pow((d / h), 0.25)
	t_3 = math.sqrt((d / l))
	tmp = 0
	if d <= -6e+126:
		tmp = t_2 * (t_2 * t_3)
	elif d <= -1.85e+73:
		tmp = math.log1p(math.expm1(t_1))
	elif d <= -1.26e-17:
		tmp = t_3 * math.sqrt((d / h))
	elif d <= 4.05e-299:
		tmp = d / (math.exp(math.log1p(t_0)) + -1.0)
	else:
		tmp = t_1 * (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)
	t_0 = sqrt(Float64(l * h))
	t_1 = Float64(d / t_0)
	t_2 = Float64(d / h) ^ 0.25
	t_3 = sqrt(Float64(d / l))
	tmp = 0.0
	if (d <= -6e+126)
		tmp = Float64(t_2 * Float64(t_2 * t_3));
	elseif (d <= -1.85e+73)
		tmp = log1p(expm1(t_1));
	elseif (d <= -1.26e-17)
		tmp = Float64(t_3 * sqrt(Float64(d / h)));
	elseif (d <= 4.05e-299)
		tmp = Float64(d / Float64(exp(log1p(t_0)) + -1.0));
	else
		tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(0.5 * Float64(h / l)) * (Float64(M * Float64(Float64(0.5 * D) / d)) ^ 2.0))));
	end
	return 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[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(d / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(d / h), $MachinePrecision], 0.25], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -6e+126], N[(t$95$2 * N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.85e+73], N[Log[1 + N[(Exp[t$95$1] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -1.26e-17], N[(t$95$3 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.05e-299], N[(d / N[(N[Exp[N[Log[1 + t$95$0], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 - N[(N[(0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(M * N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := \frac{d}{t_0}\\
t_2 := {\left(\frac{d}{h}\right)}^{0.25}\\
t_3 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;d \leq -6 \cdot 10^{+126}:\\
\;\;\;\;t_2 \cdot \left(t_2 \cdot t_3\right)\\

\mathbf{elif}\;d \leq -1.85 \cdot 10^{+73}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(t_1\right)\right)\\

\mathbf{elif}\;d \leq -1.26 \cdot 10^{-17}:\\
\;\;\;\;t_3 \cdot \sqrt{\frac{d}{h}}\\

\mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\
\;\;\;\;\frac{d}{e^{\mathsf{log1p}\left(t_0\right)} + -1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -6.0000000000000005e126

    1. Initial program 75.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. Simplified75.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 4.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      5. unpow1/20.0%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      6. metadata-eval0.0%

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

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

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

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \color{blue}{\left(\sqrt{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}} \cdot \sqrt{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}}\right)} \]
      10. associate-*r*62.9%

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{0.25}\right) \cdot \color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}} \]
      15. metadata-eval62.9%

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{0.25}\right) \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{\color{blue}{0.5}}{2}\right)} \]
      16. metadata-eval62.9%

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

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

    if -6.0000000000000005e126 < d < -1.84999999999999987e73

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.84999999999999987e73 < d < -1.2600000000000001e-17

    1. Initial program 81.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. Simplified81.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 3.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      5. unpow1/20.0%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      6. metadata-eval0.0%

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

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

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

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \]
      10. unpow1/264.5%

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

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

    if -1.2600000000000001e-17 < d < 4.0499999999999998e-299

    1. Initial program 58.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified58.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 19.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0499999999999998e-299 < d

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6 \cdot 10^{+126}:\\ \;\;\;\;{\left(\frac{d}{h}\right)}^{0.25} \cdot \left({\left(\frac{d}{h}\right)}^{0.25} \cdot \sqrt{\frac{d}{\ell}}\right)\\ \mathbf{elif}\;d \leq -1.85 \cdot 10^{+73}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{d}{\sqrt{\ell \cdot h}}\right)\right)\\ \mathbf{elif}\;d \leq -1.26 \cdot 10^{-17}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\ \;\;\;\;\frac{d}{e^{\mathsf{log1p}\left(\sqrt{\ell \cdot h}\right)} + -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\right)\\ \end{array} \]

Alternative 14: 53.6% accurate, 1.1× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ t_1 := \frac{d}{t_0}\\ t_2 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{if}\;d \leq -1.66 \cdot 10^{+125}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;d \leq -3.15 \cdot 10^{+72}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(t_1\right)\right)\\ \mathbf{elif}\;d \leq -1.3 \cdot 10^{-17}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\ \;\;\;\;\frac{d}{\log \left(e^{t_0}\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(1 - \left(0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\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
 (let* ((t_0 (sqrt (* l h)))
        (t_1 (/ d t_0))
        (t_2 (* (sqrt (/ d l)) (sqrt (/ d h)))))
   (if (<= d -1.66e+125)
     t_2
     (if (<= d -3.15e+72)
       (log1p (expm1 t_1))
       (if (<= d -1.3e-17)
         t_2
         (if (<= d 4.05e-299)
           (/ d (log (exp t_0)))
           (*
            t_1
            (- 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 t_0 = sqrt((l * h));
	double t_1 = d / t_0;
	double t_2 = sqrt((d / l)) * sqrt((d / h));
	double tmp;
	if (d <= -1.66e+125) {
		tmp = t_2;
	} else if (d <= -3.15e+72) {
		tmp = log1p(expm1(t_1));
	} else if (d <= -1.3e-17) {
		tmp = t_2;
	} else if (d <= 4.05e-299) {
		tmp = d / log(exp(t_0));
	} else {
		tmp = t_1 * (1.0 - ((0.5 * (h / l)) * pow((M * ((0.5 * D) / d)), 2.0)));
	}
	return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt((l * h));
	double t_1 = d / t_0;
	double t_2 = Math.sqrt((d / l)) * Math.sqrt((d / h));
	double tmp;
	if (d <= -1.66e+125) {
		tmp = t_2;
	} else if (d <= -3.15e+72) {
		tmp = Math.log1p(Math.expm1(t_1));
	} else if (d <= -1.3e-17) {
		tmp = t_2;
	} else if (d <= 4.05e-299) {
		tmp = d / Math.log(Math.exp(t_0));
	} else {
		tmp = t_1 * (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):
	t_0 = math.sqrt((l * h))
	t_1 = d / t_0
	t_2 = math.sqrt((d / l)) * math.sqrt((d / h))
	tmp = 0
	if d <= -1.66e+125:
		tmp = t_2
	elif d <= -3.15e+72:
		tmp = math.log1p(math.expm1(t_1))
	elif d <= -1.3e-17:
		tmp = t_2
	elif d <= 4.05e-299:
		tmp = d / math.log(math.exp(t_0))
	else:
		tmp = t_1 * (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)
	t_0 = sqrt(Float64(l * h))
	t_1 = Float64(d / t_0)
	t_2 = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h)))
	tmp = 0.0
	if (d <= -1.66e+125)
		tmp = t_2;
	elseif (d <= -3.15e+72)
		tmp = log1p(expm1(t_1));
	elseif (d <= -1.3e-17)
		tmp = t_2;
	elseif (d <= 4.05e-299)
		tmp = Float64(d / log(exp(t_0)));
	else
		tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(0.5 * Float64(h / l)) * (Float64(M * Float64(Float64(0.5 * D) / d)) ^ 2.0))));
	end
	return 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[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(d / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.66e+125], t$95$2, If[LessEqual[d, -3.15e+72], N[Log[1 + N[(Exp[t$95$1] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -1.3e-17], t$95$2, If[LessEqual[d, 4.05e-299], N[(d / N[Log[N[Exp[t$95$0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 - N[(N[(0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(M * N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := \frac{d}{t_0}\\
t_2 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{if}\;d \leq -1.66 \cdot 10^{+125}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;d \leq -3.15 \cdot 10^{+72}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(t_1\right)\right)\\

\mathbf{elif}\;d \leq -1.3 \cdot 10^{-17}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\
\;\;\;\;\frac{d}{\log \left(e^{t_0}\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.66000000000000005e125 or -3.14999999999999981e72 < d < -1.30000000000000002e-17

    1. Initial program 77.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified77.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 3.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      5. unpow1/20.0%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      6. metadata-eval0.0%

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

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

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

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \]
      10. unpow1/263.4%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}} \]
    11. Applied egg-rr63.4%

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

    if -1.66000000000000005e125 < d < -3.14999999999999981e72

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.30000000000000002e-17 < d < 4.0499999999999998e-299

    1. Initial program 58.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified58.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 19.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    10. Step-by-step derivation
      1. add-log-exp40.7%

        \[\leadsto \frac{d}{\color{blue}{\log \left(e^{\sqrt{h \cdot \ell}}\right)}} \]
    11. Applied egg-rr40.7%

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

    if 4.0499999999999998e-299 < d

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.66 \cdot 10^{+125}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -3.15 \cdot 10^{+72}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{d}{\sqrt{\ell \cdot h}}\right)\right)\\ \mathbf{elif}\;d \leq -1.3 \cdot 10^{-17}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\ \;\;\;\;\frac{d}{\log \left(e^{\sqrt{\ell \cdot h}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\right)\\ \end{array} \]

Alternative 15: 53.5% accurate, 1.1× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \frac{d}{\sqrt{\ell \cdot h}}\\ t_1 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{if}\;d \leq -1 \cdot 10^{+125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -4.6 \cdot 10^{+67}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(t_0\right)\right)\\ \mathbf{elif}\;d \leq -6 \cdot 10^{-140}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\ \;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(1 - \left(0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\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
 (let* ((t_0 (/ d (sqrt (* l h)))) (t_1 (* (sqrt (/ d l)) (sqrt (/ d h)))))
   (if (<= d -1e+125)
     t_1
     (if (<= d -4.6e+67)
       (log1p (expm1 t_0))
       (if (<= d -6e-140)
         t_1
         (if (<= d 4.05e-299)
           (/ d (cbrt (pow (* l h) 1.5)))
           (*
            t_0
            (- 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 t_0 = d / sqrt((l * h));
	double t_1 = sqrt((d / l)) * sqrt((d / h));
	double tmp;
	if (d <= -1e+125) {
		tmp = t_1;
	} else if (d <= -4.6e+67) {
		tmp = log1p(expm1(t_0));
	} else if (d <= -6e-140) {
		tmp = t_1;
	} else if (d <= 4.05e-299) {
		tmp = d / cbrt(pow((l * h), 1.5));
	} else {
		tmp = t_0 * (1.0 - ((0.5 * (h / l)) * pow((M * ((0.5 * D) / d)), 2.0)));
	}
	return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = d / Math.sqrt((l * h));
	double t_1 = Math.sqrt((d / l)) * Math.sqrt((d / h));
	double tmp;
	if (d <= -1e+125) {
		tmp = t_1;
	} else if (d <= -4.6e+67) {
		tmp = Math.log1p(Math.expm1(t_0));
	} else if (d <= -6e-140) {
		tmp = t_1;
	} else if (d <= 4.05e-299) {
		tmp = d / Math.cbrt(Math.pow((l * h), 1.5));
	} else {
		tmp = t_0 * (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)
	t_0 = Float64(d / sqrt(Float64(l * h)))
	t_1 = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h)))
	tmp = 0.0
	if (d <= -1e+125)
		tmp = t_1;
	elseif (d <= -4.6e+67)
		tmp = log1p(expm1(t_0));
	elseif (d <= -6e-140)
		tmp = t_1;
	elseif (d <= 4.05e-299)
		tmp = Float64(d / cbrt((Float64(l * h) ^ 1.5)));
	else
		tmp = Float64(t_0 * Float64(1.0 - Float64(Float64(0.5 * Float64(h / l)) * (Float64(M * Float64(Float64(0.5 * D) / d)) ^ 2.0))));
	end
	return 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[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1e+125], t$95$1, If[LessEqual[d, -4.6e+67], N[Log[1 + N[(Exp[t$95$0] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -6e-140], t$95$1, If[LessEqual[d, 4.05e-299], N[(d / N[Power[N[Power[N[(l * h), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 - N[(N[(0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(M * N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \frac{d}{\sqrt{\ell \cdot h}}\\
t_1 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{if}\;d \leq -1 \cdot 10^{+125}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;d \leq -4.6 \cdot 10^{+67}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(t_0\right)\right)\\

\mathbf{elif}\;d \leq -6 \cdot 10^{-140}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\
\;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -9.9999999999999992e124 or -4.5999999999999997e67 < d < -6.00000000000000037e-140

    1. Initial program 77.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified77.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 7.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      5. unpow1/20.0%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      6. metadata-eval0.0%

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

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

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

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \]
      10. unpow1/251.1%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}} \]
    11. Applied egg-rr51.1%

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

    if -9.9999999999999992e124 < d < -4.5999999999999997e67

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.00000000000000037e-140 < d < 4.0499999999999998e-299

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{{\left({\left(h \cdot \ell\right)}^{1} \cdot {\left(h \cdot \ell\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right)}^{0.3333333333333333}} \]
      7. pow-prod-up38.2%

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

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

        \[\leadsto \frac{d}{{\left({\left(h \cdot \ell\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333}} \]
    11. Applied egg-rr38.2%

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

        \[\leadsto \frac{d}{\color{blue}{\sqrt[3]{{\left(h \cdot \ell\right)}^{1.5}}}} \]
    13. Simplified38.2%

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

    if 4.0499999999999998e-299 < d

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1 \cdot 10^{+125}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -4.6 \cdot 10^{+67}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{d}{\sqrt{\ell \cdot h}}\right)\right)\\ \mathbf{elif}\;d \leq -6 \cdot 10^{-140}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\ \;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\right)\\ \end{array} \]

Alternative 16: 54.9% accurate, 1.5× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -2.8 \cdot 10^{-139}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\ \;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\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 (<= d -2.8e-139)
   (* (sqrt (/ d l)) (sqrt (/ d h)))
   (if (<= d 4.05e-299)
     (/ d (cbrt (pow (* l h) 1.5)))
     (*
      (/ d (sqrt (* l 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 (d <= -2.8e-139) {
		tmp = sqrt((d / l)) * sqrt((d / h));
	} else if (d <= 4.05e-299) {
		tmp = d / cbrt(pow((l * h), 1.5));
	} else {
		tmp = (d / sqrt((l * h))) * (1.0 - ((0.5 * (h / l)) * pow((M * ((0.5 * D) / d)), 2.0)));
	}
	return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -2.8e-139) {
		tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
	} else if (d <= 4.05e-299) {
		tmp = d / Math.cbrt(Math.pow((l * h), 1.5));
	} else {
		tmp = (d / Math.sqrt((l * 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 (d <= -2.8e-139)
		tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h)));
	elseif (d <= 4.05e-299)
		tmp = Float64(d / cbrt((Float64(l * h) ^ 1.5)));
	else
		tmp = Float64(Float64(d / sqrt(Float64(l * h))) * Float64(1.0 - Float64(Float64(0.5 * Float64(h / l)) * (Float64(M * Float64(Float64(0.5 * D) / d)) ^ 2.0))));
	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[d, -2.8e-139], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.05e-299], N[(d / N[Power[N[Power[N[(l * h), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(M * N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.8 \cdot 10^{-139}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\

\mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\
\;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\

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


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

    1. Initial program 77.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified77.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 7.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      5. unpow1/20.0%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      6. metadata-eval0.0%

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

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

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

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \]
      10. unpow1/246.3%

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

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

    if -2.7999999999999999e-139 < d < 4.0499999999999998e-299

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\color{blue}{{\left(\left(\sqrt{h \cdot \ell} \cdot \sqrt{h \cdot \ell}\right) \cdot \sqrt{h \cdot \ell}\right)}^{0.3333333333333333}}} \]
      3. add-sqr-sqrt38.2%

        \[\leadsto \frac{d}{{\left(\color{blue}{\left(h \cdot \ell\right)} \cdot \sqrt{h \cdot \ell}\right)}^{0.3333333333333333}} \]
      4. pow138.2%

        \[\leadsto \frac{d}{{\left(\color{blue}{{\left(h \cdot \ell\right)}^{1}} \cdot \sqrt{h \cdot \ell}\right)}^{0.3333333333333333}} \]
      5. pow1/238.2%

        \[\leadsto \frac{d}{{\left({\left(h \cdot \ell\right)}^{1} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{0.5}}\right)}^{0.3333333333333333}} \]
      6. metadata-eval38.2%

        \[\leadsto \frac{d}{{\left({\left(h \cdot \ell\right)}^{1} \cdot {\left(h \cdot \ell\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right)}^{0.3333333333333333}} \]
      7. pow-prod-up38.2%

        \[\leadsto \frac{d}{{\color{blue}{\left({\left(h \cdot \ell\right)}^{\left(1 + \frac{1}{2}\right)}\right)}}^{0.3333333333333333}} \]
      8. metadata-eval38.2%

        \[\leadsto \frac{d}{{\left({\left(h \cdot \ell\right)}^{\left(1 + \color{blue}{0.5}\right)}\right)}^{0.3333333333333333}} \]
      9. metadata-eval38.2%

        \[\leadsto \frac{d}{{\left({\left(h \cdot \ell\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333}} \]
    11. Applied egg-rr38.2%

      \[\leadsto \frac{d}{\color{blue}{{\left({\left(h \cdot \ell\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
    12. Step-by-step derivation
      1. unpow1/338.2%

        \[\leadsto \frac{d}{\color{blue}{\sqrt[3]{{\left(h \cdot \ell\right)}^{1.5}}}} \]
    13. Simplified38.2%

      \[\leadsto \frac{d}{\color{blue}{\sqrt[3]{{\left(h \cdot \ell\right)}^{1.5}}}} \]

    if 4.0499999999999998e-299 < d

    1. Initial program 67.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. add-sqr-sqrt67.3%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{\sqrt{\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}} \cdot \sqrt{\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}}}\right) \]
      2. pow267.3%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{{\left(\sqrt{\left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod67.3%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - {\color{blue}{\left(\sqrt{\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. *-commutative67.3%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - {\left(\sqrt{\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{1}{2}}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. frac-times66.5%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - {\left(\sqrt{{\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{1}{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. sqrt-prod66.5%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - {\left(\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{1}{2}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. sqrt-pow169.8%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - {\left(\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. metadata-eval69.8%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - {\left(\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. pow169.8%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - {\left(\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      10. div-inv69.8%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - {\left(\left(\left(\color{blue}{\left(M \cdot \frac{1}{2}\right)} \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      11. metadata-eval69.8%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - {\left(\left(\left(\left(M \cdot \color{blue}{0.5}\right) \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      12. metadata-eval69.8%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - {\left(\left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \sqrt{\color{blue}{0.5}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    3. Applied egg-rr69.8%

      \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \color{blue}{{\left(\left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    4. Step-by-step derivation
      1. expm1-log1p-u68.9%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)\right)}\right) \cdot \left(1 - {\left(\left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. expm1-udef45.4%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} - 1\right)}\right) \cdot \left(1 - {\left(\left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. metadata-eval45.4%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left(e^{\mathsf{log1p}\left({\left(\frac{d}{\ell}\right)}^{\color{blue}{0.5}}\right)} - 1\right)\right) \cdot \left(1 - {\left(\left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. unpow1/245.4%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\sqrt{\frac{d}{\ell}}}\right)} - 1\right)\right) \cdot \left(1 - {\left(\left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr45.4%

      \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{d}{\ell}}\right)} - 1\right)}\right) \cdot \left(1 - {\left(\left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    6. Step-by-step derivation
      1. expm1-def68.9%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{\ell}}\right)\right)}\right) \cdot \left(1 - {\left(\left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. expm1-log1p69.8%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}}\right) \cdot \left(1 - {\left(\left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    7. Simplified69.8%

      \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}}\right) \cdot \left(1 - {\left(\left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    8. Applied egg-rr62.8%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}} + \left(\left(0.5 \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right) \cdot \left(-\frac{h}{\ell}\right)\right) \cdot \frac{d}{\sqrt{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. *-lft-identity62.8%

        \[\leadsto \color{blue}{1 \cdot \frac{d}{\sqrt{h \cdot \ell}}} + \left(\left(0.5 \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right) \cdot \left(-\frac{h}{\ell}\right)\right) \cdot \frac{d}{\sqrt{h \cdot \ell}} \]
      2. distribute-rgt-in71.6%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + \left(0.5 \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right) \cdot \left(-\frac{h}{\ell}\right)\right)} \]
      3. *-commutative71.6%

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + \color{blue}{\left(-\frac{h}{\ell}\right) \cdot \left(0.5 \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)}\right) \]
      4. cancel-sign-sub-inv71.6%

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \cdot \color{blue}{\left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)} \]
      5. associate-*r*71.6%

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 - \color{blue}{\left(\frac{h}{\ell} \cdot 0.5\right) \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}\right) \]
      6. associate-*r/71.6%

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 - \left(\frac{h}{\ell} \cdot 0.5\right) \cdot {\left(M \cdot \color{blue}{\frac{0.5 \cdot D}{d}}\right)}^{2}\right) \]
    10. Simplified71.6%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 - \left(\frac{h}{\ell} \cdot 0.5\right) \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification57.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.8 \cdot 10^{-139}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\ \;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\right)\\ \end{array} \]

Alternative 17: 38.5% accurate, 1.6× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -1.42 \cdot 10^{-142}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 3.8 \cdot 10^{-66}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\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 -1.42e-142)
   (sqrt (/ (pow d 2.0) (* l h)))
   (if (<= d 3.8e-66)
     (* d (sqrt (/ (/ 1.0 l) h)))
     (* d (/ (pow l -0.5) (sqrt h))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -1.42e-142) {
		tmp = sqrt((pow(d, 2.0) / (l * h)));
	} else if (d <= 3.8e-66) {
		tmp = d * sqrt(((1.0 / l) / h));
	} else {
		tmp = d * (pow(l, -0.5) / 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 <= (-1.42d-142)) then
        tmp = sqrt(((d ** 2.0d0) / (l * h)))
    else if (d <= 3.8d-66) then
        tmp = d * sqrt(((1.0d0 / l) / h))
    else
        tmp = d * ((l ** (-0.5d0)) / 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 <= -1.42e-142) {
		tmp = Math.sqrt((Math.pow(d, 2.0) / (l * h)));
	} else if (d <= 3.8e-66) {
		tmp = d * Math.sqrt(((1.0 / l) / h));
	} else {
		tmp = d * (Math.pow(l, -0.5) / Math.sqrt(h));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if d <= -1.42e-142:
		tmp = math.sqrt((math.pow(d, 2.0) / (l * h)))
	elif d <= 3.8e-66:
		tmp = d * math.sqrt(((1.0 / l) / h))
	else:
		tmp = d * (math.pow(l, -0.5) / math.sqrt(h))
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= -1.42e-142)
		tmp = sqrt(Float64((d ^ 2.0) / Float64(l * h)));
	elseif (d <= 3.8e-66)
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / l) / h)));
	else
		tmp = Float64(d * Float64((l ^ -0.5) / 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 <= -1.42e-142)
		tmp = sqrt(((d ^ 2.0) / (l * h)));
	elseif (d <= 3.8e-66)
		tmp = d * sqrt(((1.0 / l) / h));
	else
		tmp = d * ((l ^ -0.5) / 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, -1.42e-142], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, 3.8e-66], N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.42 \cdot 10^{-142}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\

\mathbf{elif}\;d \leq 3.8 \cdot 10^{-66}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.42000000000000007e-142

    1. Initial program 77.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified77.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 7.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative7.4%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*7.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified7.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u1.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)\right)} \]
      2. expm1-udef1.1%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)} - 1} \]
      3. associate-/l/1.1%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}}\right)} - 1 \]
      4. sqrt-div1.1%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
      5. metadata-eval1.1%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
    7. Applied egg-rr1.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def1.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)\right)} \]
      2. expm1-log1p7.4%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      3. associate-*r/7.4%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      4. *-rgt-identity7.4%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    9. Simplified7.4%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}} \]
      2. sqrt-prod0.0%

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. times-frac0.0%

        \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{h}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}} \]
      4. sqrt-div0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      5. unpow1/20.0%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      6. metadata-eval0.0%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      7. sqrt-div46.3%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      8. pow1/246.3%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}} \]
      9. metadata-eval46.3%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}} \]
      10. pow-prod-down35.4%

        \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \]
    11. Applied egg-rr29.1%

      \[\leadsto \color{blue}{{\left(\frac{{d}^{2}}{h \cdot \ell}\right)}^{0.5}} \]
    12. Step-by-step derivation
      1. unpow1/229.1%

        \[\leadsto \color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}}} \]
    13. Simplified29.1%

      \[\leadsto \color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}}} \]

    if -1.42000000000000007e-142 < d < 3.7999999999999998e-66

    1. Initial program 48.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. Simplified47.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 22.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative22.4%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*23.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified23.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]

    if 3.7999999999999998e-66 < d

    1. Initial program 78.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. Simplified78.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 52.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative52.5%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*53.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified53.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Step-by-step derivation
      1. sqrt-div58.9%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
      2. inv-pow58.9%

        \[\leadsto d \cdot \frac{\sqrt{\color{blue}{{\ell}^{-1}}}}{\sqrt{h}} \]
      3. sqrt-pow158.9%

        \[\leadsto d \cdot \frac{\color{blue}{{\ell}^{\left(\frac{-1}{2}\right)}}}{\sqrt{h}} \]
      4. metadata-eval58.9%

        \[\leadsto d \cdot \frac{{\ell}^{\color{blue}{-0.5}}}{\sqrt{h}} \]
    7. Applied egg-rr58.9%

      \[\leadsto d \cdot \color{blue}{\frac{{\ell}^{-0.5}}{\sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification35.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.42 \cdot 10^{-142}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 3.8 \cdot 10^{-66}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\ \end{array} \]

Alternative 18: 39.5% accurate, 1.6× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -9 \cdot 10^{-140}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 7.8 \cdot 10^{-266}:\\ \;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\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 -9e-140)
   (sqrt (/ (pow d 2.0) (* l h)))
   (if (<= d 7.8e-266)
     (/ d (cbrt (pow (* l h) 1.5)))
     (* d (/ (pow l -0.5) (sqrt h))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -9e-140) {
		tmp = sqrt((pow(d, 2.0) / (l * h)));
	} else if (d <= 7.8e-266) {
		tmp = d / cbrt(pow((l * h), 1.5));
	} else {
		tmp = d * (pow(l, -0.5) / sqrt(h));
	}
	return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -9e-140) {
		tmp = Math.sqrt((Math.pow(d, 2.0) / (l * h)));
	} else if (d <= 7.8e-266) {
		tmp = d / Math.cbrt(Math.pow((l * h), 1.5));
	} else {
		tmp = d * (Math.pow(l, -0.5) / Math.sqrt(h));
	}
	return tmp;
}
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= -9e-140)
		tmp = sqrt(Float64((d ^ 2.0) / Float64(l * h)));
	elseif (d <= 7.8e-266)
		tmp = Float64(d / cbrt((Float64(l * h) ^ 1.5)));
	else
		tmp = Float64(d * Float64((l ^ -0.5) / 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[d, -9e-140], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, 7.8e-266], N[(d / N[Power[N[Power[N[(l * h), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9 \cdot 10^{-140}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\

\mathbf{elif}\;d \leq 7.8 \cdot 10^{-266}:\\
\;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -9.00000000000000008e-140

    1. Initial program 77.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified77.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 7.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative7.4%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*7.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified7.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u1.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)\right)} \]
      2. expm1-udef1.1%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)} - 1} \]
      3. associate-/l/1.1%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}}\right)} - 1 \]
      4. sqrt-div1.1%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
      5. metadata-eval1.1%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
    7. Applied egg-rr1.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def1.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)\right)} \]
      2. expm1-log1p7.4%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      3. associate-*r/7.4%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      4. *-rgt-identity7.4%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    9. Simplified7.4%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}} \]
      2. sqrt-prod0.0%

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. times-frac0.0%

        \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{h}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}} \]
      4. sqrt-div0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      5. unpow1/20.0%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      6. metadata-eval0.0%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      7. sqrt-div46.3%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      8. pow1/246.3%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}} \]
      9. metadata-eval46.3%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}} \]
      10. pow-prod-down35.4%

        \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \]
    11. Applied egg-rr29.1%

      \[\leadsto \color{blue}{{\left(\frac{{d}^{2}}{h \cdot \ell}\right)}^{0.5}} \]
    12. Step-by-step derivation
      1. unpow1/229.1%

        \[\leadsto \color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}}} \]
    13. Simplified29.1%

      \[\leadsto \color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}}} \]

    if -9.00000000000000008e-140 < d < 7.80000000000000057e-266

    1. Initial program 44.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. Simplified44.2%

      \[\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 23.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative23.6%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*23.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified23.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u12.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)\right)} \]
      2. expm1-udef10.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)} - 1} \]
      3. associate-/l/10.0%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}}\right)} - 1 \]
      4. sqrt-div10.0%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
      5. metadata-eval10.0%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
    7. Applied egg-rr10.0%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def12.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)\right)} \]
      2. expm1-log1p23.6%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      3. associate-*r/23.6%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      4. *-rgt-identity23.6%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    9. Simplified23.6%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    10. Step-by-step derivation
      1. add-cbrt-cube36.9%

        \[\leadsto \frac{d}{\color{blue}{\sqrt[3]{\left(\sqrt{h \cdot \ell} \cdot \sqrt{h \cdot \ell}\right) \cdot \sqrt{h \cdot \ell}}}} \]
      2. pow1/336.7%

        \[\leadsto \frac{d}{\color{blue}{{\left(\left(\sqrt{h \cdot \ell} \cdot \sqrt{h \cdot \ell}\right) \cdot \sqrt{h \cdot \ell}\right)}^{0.3333333333333333}}} \]
      3. add-sqr-sqrt36.7%

        \[\leadsto \frac{d}{{\left(\color{blue}{\left(h \cdot \ell\right)} \cdot \sqrt{h \cdot \ell}\right)}^{0.3333333333333333}} \]
      4. pow136.7%

        \[\leadsto \frac{d}{{\left(\color{blue}{{\left(h \cdot \ell\right)}^{1}} \cdot \sqrt{h \cdot \ell}\right)}^{0.3333333333333333}} \]
      5. pow1/236.7%

        \[\leadsto \frac{d}{{\left({\left(h \cdot \ell\right)}^{1} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{0.5}}\right)}^{0.3333333333333333}} \]
      6. metadata-eval36.7%

        \[\leadsto \frac{d}{{\left({\left(h \cdot \ell\right)}^{1} \cdot {\left(h \cdot \ell\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right)}^{0.3333333333333333}} \]
      7. pow-prod-up36.7%

        \[\leadsto \frac{d}{{\color{blue}{\left({\left(h \cdot \ell\right)}^{\left(1 + \frac{1}{2}\right)}\right)}}^{0.3333333333333333}} \]
      8. metadata-eval36.7%

        \[\leadsto \frac{d}{{\left({\left(h \cdot \ell\right)}^{\left(1 + \color{blue}{0.5}\right)}\right)}^{0.3333333333333333}} \]
      9. metadata-eval36.7%

        \[\leadsto \frac{d}{{\left({\left(h \cdot \ell\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333}} \]
    11. Applied egg-rr36.7%

      \[\leadsto \frac{d}{\color{blue}{{\left({\left(h \cdot \ell\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
    12. Step-by-step derivation
      1. unpow1/336.9%

        \[\leadsto \frac{d}{\color{blue}{\sqrt[3]{{\left(h \cdot \ell\right)}^{1.5}}}} \]
    13. Simplified36.9%

      \[\leadsto \frac{d}{\color{blue}{\sqrt[3]{{\left(h \cdot \ell\right)}^{1.5}}}} \]

    if 7.80000000000000057e-266 < d

    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. Simplified67.0%

      \[\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 39.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative39.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*41.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified41.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Step-by-step derivation
      1. sqrt-div44.4%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
      2. inv-pow44.4%

        \[\leadsto d \cdot \frac{\sqrt{\color{blue}{{\ell}^{-1}}}}{\sqrt{h}} \]
      3. sqrt-pow144.4%

        \[\leadsto d \cdot \frac{\color{blue}{{\ell}^{\left(\frac{-1}{2}\right)}}}{\sqrt{h}} \]
      4. metadata-eval44.4%

        \[\leadsto d \cdot \frac{{\ell}^{\color{blue}{-0.5}}}{\sqrt{h}} \]
    7. Applied egg-rr44.4%

      \[\leadsto d \cdot \color{blue}{\frac{{\ell}^{-0.5}}{\sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification37.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9 \cdot 10^{-140}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 7.8 \cdot 10^{-266}:\\ \;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\ \end{array} \]

Alternative 19: 45.6% accurate, 1.6× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -2.45 \cdot 10^{-139}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 7.8 \cdot 10^{-266}:\\ \;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\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 -2.45e-139)
   (* (sqrt (/ d l)) (sqrt (/ d h)))
   (if (<= d 7.8e-266)
     (/ d (cbrt (pow (* l h) 1.5)))
     (* d (/ (pow l -0.5) (sqrt h))))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -2.45e-139) {
		tmp = sqrt((d / l)) * sqrt((d / h));
	} else if (d <= 7.8e-266) {
		tmp = d / cbrt(pow((l * h), 1.5));
	} else {
		tmp = d * (pow(l, -0.5) / sqrt(h));
	}
	return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -2.45e-139) {
		tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
	} else if (d <= 7.8e-266) {
		tmp = d / Math.cbrt(Math.pow((l * h), 1.5));
	} else {
		tmp = d * (Math.pow(l, -0.5) / Math.sqrt(h));
	}
	return tmp;
}
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= -2.45e-139)
		tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h)));
	elseif (d <= 7.8e-266)
		tmp = Float64(d / cbrt((Float64(l * h) ^ 1.5)));
	else
		tmp = Float64(d * Float64((l ^ -0.5) / 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[d, -2.45e-139], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.8e-266], N[(d / N[Power[N[Power[N[(l * h), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.45 \cdot 10^{-139}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\

\mathbf{elif}\;d \leq 7.8 \cdot 10^{-266}:\\
\;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.45000000000000016e-139

    1. Initial program 77.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified77.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 7.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative7.4%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*7.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified7.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u1.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)\right)} \]
      2. expm1-udef1.1%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)} - 1} \]
      3. associate-/l/1.1%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}}\right)} - 1 \]
      4. sqrt-div1.1%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
      5. metadata-eval1.1%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
    7. Applied egg-rr1.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def1.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)\right)} \]
      2. expm1-log1p7.4%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      3. associate-*r/7.4%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      4. *-rgt-identity7.4%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    9. Simplified7.4%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}} \]
      2. sqrt-prod0.0%

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. times-frac0.0%

        \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{h}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}} \]
      4. sqrt-div0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      5. unpow1/20.0%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      6. metadata-eval0.0%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      7. sqrt-div46.3%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      8. *-commutative46.3%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}} \]
      9. metadata-eval46.3%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{0.5}} \]
      10. unpow1/246.3%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}} \]
    11. Applied egg-rr46.3%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}} \]

    if -2.45000000000000016e-139 < d < 7.80000000000000057e-266

    1. Initial program 44.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. Simplified44.2%

      \[\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 23.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative23.6%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*23.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified23.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u12.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)\right)} \]
      2. expm1-udef10.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)} - 1} \]
      3. associate-/l/10.0%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}}\right)} - 1 \]
      4. sqrt-div10.0%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
      5. metadata-eval10.0%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
    7. Applied egg-rr10.0%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def12.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)\right)} \]
      2. expm1-log1p23.6%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      3. associate-*r/23.6%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      4. *-rgt-identity23.6%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    9. Simplified23.6%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    10. Step-by-step derivation
      1. add-cbrt-cube36.9%

        \[\leadsto \frac{d}{\color{blue}{\sqrt[3]{\left(\sqrt{h \cdot \ell} \cdot \sqrt{h \cdot \ell}\right) \cdot \sqrt{h \cdot \ell}}}} \]
      2. pow1/336.7%

        \[\leadsto \frac{d}{\color{blue}{{\left(\left(\sqrt{h \cdot \ell} \cdot \sqrt{h \cdot \ell}\right) \cdot \sqrt{h \cdot \ell}\right)}^{0.3333333333333333}}} \]
      3. add-sqr-sqrt36.7%

        \[\leadsto \frac{d}{{\left(\color{blue}{\left(h \cdot \ell\right)} \cdot \sqrt{h \cdot \ell}\right)}^{0.3333333333333333}} \]
      4. pow136.7%

        \[\leadsto \frac{d}{{\left(\color{blue}{{\left(h \cdot \ell\right)}^{1}} \cdot \sqrt{h \cdot \ell}\right)}^{0.3333333333333333}} \]
      5. pow1/236.7%

        \[\leadsto \frac{d}{{\left({\left(h \cdot \ell\right)}^{1} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{0.5}}\right)}^{0.3333333333333333}} \]
      6. metadata-eval36.7%

        \[\leadsto \frac{d}{{\left({\left(h \cdot \ell\right)}^{1} \cdot {\left(h \cdot \ell\right)}^{\color{blue}{\left(\frac{1}{2}\right)}}\right)}^{0.3333333333333333}} \]
      7. pow-prod-up36.7%

        \[\leadsto \frac{d}{{\color{blue}{\left({\left(h \cdot \ell\right)}^{\left(1 + \frac{1}{2}\right)}\right)}}^{0.3333333333333333}} \]
      8. metadata-eval36.7%

        \[\leadsto \frac{d}{{\left({\left(h \cdot \ell\right)}^{\left(1 + \color{blue}{0.5}\right)}\right)}^{0.3333333333333333}} \]
      9. metadata-eval36.7%

        \[\leadsto \frac{d}{{\left({\left(h \cdot \ell\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333}} \]
    11. Applied egg-rr36.7%

      \[\leadsto \frac{d}{\color{blue}{{\left({\left(h \cdot \ell\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
    12. Step-by-step derivation
      1. unpow1/336.9%

        \[\leadsto \frac{d}{\color{blue}{\sqrt[3]{{\left(h \cdot \ell\right)}^{1.5}}}} \]
    13. Simplified36.9%

      \[\leadsto \frac{d}{\color{blue}{\sqrt[3]{{\left(h \cdot \ell\right)}^{1.5}}}} \]

    if 7.80000000000000057e-266 < d

    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. Simplified67.0%

      \[\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 39.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative39.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*41.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified41.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Step-by-step derivation
      1. sqrt-div44.4%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}} \]
      2. inv-pow44.4%

        \[\leadsto d \cdot \frac{\sqrt{\color{blue}{{\ell}^{-1}}}}{\sqrt{h}} \]
      3. sqrt-pow144.4%

        \[\leadsto d \cdot \frac{\color{blue}{{\ell}^{\left(\frac{-1}{2}\right)}}}{\sqrt{h}} \]
      4. metadata-eval44.4%

        \[\leadsto d \cdot \frac{{\ell}^{\color{blue}{-0.5}}}{\sqrt{h}} \]
    7. Applied egg-rr44.4%

      \[\leadsto d \cdot \color{blue}{\frac{{\ell}^{-0.5}}{\sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification44.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.45 \cdot 10^{-139}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 7.8 \cdot 10^{-266}:\\ \;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\ \end{array} \]

Alternative 20: 35.3% accurate, 1.6× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -2.85 \cdot 10^{-140}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{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 -2.85e-140)
   (sqrt (/ (pow d 2.0) (* l h)))
   (* d (sqrt (/ (/ 1.0 l) h)))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -2.85e-140) {
		tmp = sqrt((pow(d, 2.0) / (l * h)));
	} else {
		tmp = d * sqrt(((1.0 / l) / 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 <= (-2.85d-140)) then
        tmp = sqrt(((d ** 2.0d0) / (l * h)))
    else
        tmp = d * sqrt(((1.0d0 / l) / 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 <= -2.85e-140) {
		tmp = Math.sqrt((Math.pow(d, 2.0) / (l * h)));
	} else {
		tmp = d * Math.sqrt(((1.0 / l) / h));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if d <= -2.85e-140:
		tmp = math.sqrt((math.pow(d, 2.0) / (l * h)))
	else:
		tmp = d * math.sqrt(((1.0 / l) / h))
	return tmp
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= -2.85e-140)
		tmp = sqrt(Float64((d ^ 2.0) / Float64(l * h)));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / l) / 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 <= -2.85e-140)
		tmp = sqrt(((d ^ 2.0) / (l * h)));
	else
		tmp = d * sqrt(((1.0 / l) / 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, -2.85e-140], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.85 \cdot 10^{-140}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.85e-140

    1. Initial program 77.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified77.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 7.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative7.4%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*7.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified7.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u1.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)\right)} \]
      2. expm1-udef1.1%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)} - 1} \]
      3. associate-/l/1.1%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}}\right)} - 1 \]
      4. sqrt-div1.1%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
      5. metadata-eval1.1%

        \[\leadsto e^{\mathsf{log1p}\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
    7. Applied egg-rr1.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def1.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)\right)} \]
      2. expm1-log1p7.4%

        \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      3. associate-*r/7.4%

        \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
      4. *-rgt-identity7.4%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
    9. Simplified7.4%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}} \]
      2. sqrt-prod0.0%

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. times-frac0.0%

        \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{h}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}} \]
      4. sqrt-div0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      5. unpow1/20.0%

        \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{0.5}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      6. metadata-eval0.0%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}} \]
      7. sqrt-div46.3%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      8. pow1/246.3%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}} \]
      9. metadata-eval46.3%

        \[\leadsto {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}} \]
      10. pow-prod-down35.4%

        \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \]
    11. Applied egg-rr29.1%

      \[\leadsto \color{blue}{{\left(\frac{{d}^{2}}{h \cdot \ell}\right)}^{0.5}} \]
    12. Step-by-step derivation
      1. unpow1/229.1%

        \[\leadsto \color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}}} \]
    13. Simplified29.1%

      \[\leadsto \color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}}} \]

    if -2.85e-140 < d

    1. Initial program 62.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. Simplified61.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 36.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative36.1%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*37.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified37.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification34.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.85 \cdot 10^{-140}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \]

Alternative 21: 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 68.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. Simplified67.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 25.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  4. Step-by-step derivation
    1. *-commutative25.4%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    2. associate-/r*26.0%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
  5. Simplified26.0%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
  6. Final simplification26.0%

    \[\leadsto d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}} \]

Alternative 22: 26.3% accurate, 3.2× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \frac{d}{\sqrt{\ell \cdot 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 (* l h))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d / sqrt((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((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((l * h));
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d / math.sqrt((l * h))
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d / sqrt(Float64(l * h)))
end
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d / sqrt((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[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Derivation
  1. Initial program 68.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. Simplified67.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 25.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  4. Step-by-step derivation
    1. *-commutative25.4%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    2. associate-/r*26.0%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
  5. Simplified26.0%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
  6. Step-by-step derivation
    1. expm1-log1p-u21.3%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)\right)} \]
    2. expm1-udef15.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)} - 1} \]
    3. associate-/l/14.8%

      \[\leadsto e^{\mathsf{log1p}\left(d \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}}\right)} - 1 \]
    4. sqrt-div14.8%

      \[\leadsto e^{\mathsf{log1p}\left(d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
    5. metadata-eval14.8%

      \[\leadsto e^{\mathsf{log1p}\left(d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)} - 1 \]
  7. Applied egg-rr14.8%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)} - 1} \]
  8. Step-by-step derivation
    1. expm1-def20.7%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \frac{1}{\sqrt{h \cdot \ell}}\right)\right)} \]
    2. expm1-log1p25.3%

      \[\leadsto \color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
    3. associate-*r/25.4%

      \[\leadsto \color{blue}{\frac{d \cdot 1}{\sqrt{h \cdot \ell}}} \]
    4. *-rgt-identity25.4%

      \[\leadsto \frac{\color{blue}{d}}{\sqrt{h \cdot \ell}} \]
  9. Simplified25.4%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  10. Final simplification25.4%

    \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]

Alternative 23: 4.6% accurate, 110.7× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ d \cdot 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 0.0))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d * 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 * 0.0d0
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return d * 0.0;
}
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * 0.0
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d * 0.0)
end
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d * 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 * 0.0), $MachinePrecision]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot 0
\end{array}
Derivation
  1. Initial program 68.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. Simplified67.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 25.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  4. Step-by-step derivation
    1. *-commutative25.4%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    2. associate-/r*26.0%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
  5. Simplified26.0%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
  6. Step-by-step derivation
    1. expm1-log1p-u25.6%

      \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\right)} \]
    2. expm1-udef18.1%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{\frac{1}{\ell}}{h}}\right)} - 1\right)} \]
    3. associate-/l/18.1%

      \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\sqrt{\color{blue}{\frac{1}{h \cdot \ell}}}\right)} - 1\right) \]
    4. sqrt-div18.1%

      \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}}\right)} - 1\right) \]
    5. metadata-eval18.1%

      \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{1}}{\sqrt{h \cdot \ell}}\right)} - 1\right) \]
  7. Applied egg-rr18.1%

    \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{1}{\sqrt{h \cdot \ell}}\right)} - 1\right)} \]
  8. Taylor expanded in h around inf 3.5%

    \[\leadsto d \cdot \left(\color{blue}{1} - 1\right) \]
  9. Final simplification3.5%

    \[\leadsto d \cdot 0 \]

Reproduce

?
herbie shell --seed 2023312 
(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)))))