Henrywood and Agarwal, Equation (12)

Percentage Accurate: 65.8% → 83.7%
Time: 25.7s
Alternatives: 21
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 21 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: 65.8% accurate, 1.0× speedup?

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

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

Alternative 1: 83.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - h \cdot \left(0.125 \cdot \frac{{\left(\frac{M \cdot D}{d}\right)}^{2}}{\ell}\right)\\ t_1 := \sqrt{-d}\\ \mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{t\_1}{\sqrt{-h}} \cdot \left(\frac{t\_1}{\sqrt{-\ell}} \cdot t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(t\_0 \cdot \sqrt{\frac{d}{\ell}}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (- 1.0 (* h (* 0.125 (/ (pow (/ (* M D) d) 2.0) l)))))
        (t_1 (sqrt (- d))))
   (if (<= l -2e-310)
     (* (/ t_1 (sqrt (- h))) (* (/ t_1 (sqrt (- l))) t_0))
     (* (/ (sqrt d) (sqrt h)) (* t_0 (sqrt (/ d l)))))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = 1.0 - (h * (0.125 * (pow(((M * D) / d), 2.0) / l)));
	double t_1 = sqrt(-d);
	double tmp;
	if (l <= -2e-310) {
		tmp = (t_1 / sqrt(-h)) * ((t_1 / sqrt(-l)) * t_0);
	} else {
		tmp = (sqrt(d) / sqrt(h)) * (t_0 * sqrt((d / l)));
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 1.0d0 - (h * (0.125d0 * ((((m * d_1) / d) ** 2.0d0) / l)))
    t_1 = sqrt(-d)
    if (l <= (-2d-310)) then
        tmp = (t_1 / sqrt(-h)) * ((t_1 / sqrt(-l)) * t_0)
    else
        tmp = (sqrt(d) / sqrt(h)) * (t_0 * sqrt((d / l)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = 1.0 - (h * (0.125 * (Math.pow(((M * D) / d), 2.0) / l)));
	double t_1 = Math.sqrt(-d);
	double tmp;
	if (l <= -2e-310) {
		tmp = (t_1 / Math.sqrt(-h)) * ((t_1 / Math.sqrt(-l)) * t_0);
	} else {
		tmp = (Math.sqrt(d) / Math.sqrt(h)) * (t_0 * Math.sqrt((d / l)));
	}
	return tmp;
}
def code(d, h, l, M, D):
	t_0 = 1.0 - (h * (0.125 * (math.pow(((M * D) / d), 2.0) / l)))
	t_1 = math.sqrt(-d)
	tmp = 0
	if l <= -2e-310:
		tmp = (t_1 / math.sqrt(-h)) * ((t_1 / math.sqrt(-l)) * t_0)
	else:
		tmp = (math.sqrt(d) / math.sqrt(h)) * (t_0 * math.sqrt((d / l)))
	return tmp
function code(d, h, l, M, D)
	t_0 = Float64(1.0 - Float64(h * Float64(0.125 * Float64((Float64(Float64(M * D) / d) ^ 2.0) / l))))
	t_1 = sqrt(Float64(-d))
	tmp = 0.0
	if (l <= -2e-310)
		tmp = Float64(Float64(t_1 / sqrt(Float64(-h))) * Float64(Float64(t_1 / sqrt(Float64(-l))) * t_0));
	else
		tmp = Float64(Float64(sqrt(d) / sqrt(h)) * Float64(t_0 * sqrt(Float64(d / l))));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	t_0 = 1.0 - (h * (0.125 * ((((M * D) / d) ^ 2.0) / l)));
	t_1 = sqrt(-d);
	tmp = 0.0;
	if (l <= -2e-310)
		tmp = (t_1 / sqrt(-h)) * ((t_1 / sqrt(-l)) * t_0);
	else
		tmp = (sqrt(d) / sqrt(h)) * (t_0 * sqrt((d / l)));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(1.0 - N[(h * N[(0.125 * N[(N[Power[N[(N[(M * D), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[l, -2e-310], N[(N[(t$95$1 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[(t$95$1 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 - h \cdot \left(0.125 \cdot \frac{{\left(\frac{M \cdot D}{d}\right)}^{2}}{\ell}\right)\\
t_1 := \sqrt{-d}\\
\mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{t\_1}{\sqrt{-h}} \cdot \left(\frac{t\_1}{\sqrt{-\ell}} \cdot t\_0\right)\\

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


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

    1. Initial program 62.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. Simplified61.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < l

    1. Initial program 66.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 83.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{-d}\\ \mathbf{if}\;h \leq -5 \cdot 10^{-312}:\\ \;\;\;\;\frac{t\_0}{\sqrt{-h}} \cdot \left(\frac{t\_0}{\sqrt{-\ell}} \cdot \left(1 - h \cdot \left(0.125 \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(\left(1 - h \cdot \left(0.125 \cdot \frac{{\left(\frac{M \cdot D}{d}\right)}^{2}}{\ell}\right)\right) \cdot \sqrt{\frac{d}{\ell}}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (- d))))
   (if (<= h -5e-312)
     (*
      (/ t_0 (sqrt (- h)))
      (*
       (/ t_0 (sqrt (- l)))
       (- 1.0 (* h (* 0.125 (/ (pow (* M (/ D d)) 2.0) l))))))
     (*
      (/ (sqrt d) (sqrt h))
      (*
       (- 1.0 (* h (* 0.125 (/ (pow (/ (* M D) d) 2.0) l))))
       (sqrt (/ d l)))))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt(-d);
	double tmp;
	if (h <= -5e-312) {
		tmp = (t_0 / sqrt(-h)) * ((t_0 / sqrt(-l)) * (1.0 - (h * (0.125 * (pow((M * (D / d)), 2.0) / l)))));
	} else {
		tmp = (sqrt(d) / sqrt(h)) * ((1.0 - (h * (0.125 * (pow(((M * D) / d), 2.0) / l)))) * sqrt((d / l)));
	}
	return tmp;
}
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)
    if (h <= (-5d-312)) then
        tmp = (t_0 / sqrt(-h)) * ((t_0 / sqrt(-l)) * (1.0d0 - (h * (0.125d0 * (((m * (d_1 / d)) ** 2.0d0) / l)))))
    else
        tmp = (sqrt(d) / sqrt(h)) * ((1.0d0 - (h * (0.125d0 * ((((m * d_1) / d) ** 2.0d0) / l)))) * sqrt((d / l)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt(-d);
	double tmp;
	if (h <= -5e-312) {
		tmp = (t_0 / Math.sqrt(-h)) * ((t_0 / Math.sqrt(-l)) * (1.0 - (h * (0.125 * (Math.pow((M * (D / d)), 2.0) / l)))));
	} else {
		tmp = (Math.sqrt(d) / Math.sqrt(h)) * ((1.0 - (h * (0.125 * (Math.pow(((M * D) / d), 2.0) / l)))) * Math.sqrt((d / l)));
	}
	return tmp;
}
def code(d, h, l, M, D):
	t_0 = math.sqrt(-d)
	tmp = 0
	if h <= -5e-312:
		tmp = (t_0 / math.sqrt(-h)) * ((t_0 / math.sqrt(-l)) * (1.0 - (h * (0.125 * (math.pow((M * (D / d)), 2.0) / l)))))
	else:
		tmp = (math.sqrt(d) / math.sqrt(h)) * ((1.0 - (h * (0.125 * (math.pow(((M * D) / d), 2.0) / l)))) * math.sqrt((d / l)))
	return tmp
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(-d))
	tmp = 0.0
	if (h <= -5e-312)
		tmp = Float64(Float64(t_0 / sqrt(Float64(-h))) * Float64(Float64(t_0 / sqrt(Float64(-l))) * Float64(1.0 - Float64(h * Float64(0.125 * Float64((Float64(M * Float64(D / d)) ^ 2.0) / l))))));
	else
		tmp = Float64(Float64(sqrt(d) / sqrt(h)) * Float64(Float64(1.0 - Float64(h * Float64(0.125 * Float64((Float64(Float64(M * D) / d) ^ 2.0) / l)))) * sqrt(Float64(d / l))));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt(-d);
	tmp = 0.0;
	if (h <= -5e-312)
		tmp = (t_0 / sqrt(-h)) * ((t_0 / sqrt(-l)) * (1.0 - (h * (0.125 * (((M * (D / d)) ^ 2.0) / l)))));
	else
		tmp = (sqrt(d) / sqrt(h)) * ((1.0 - (h * (0.125 * ((((M * D) / d) ^ 2.0) / l)))) * sqrt((d / l)));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[h, -5e-312], N[(N[(t$95$0 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[(t$95$0 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(h * N[(0.125 * N[(N[Power[N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 - N[(h * N[(0.125 * N[(N[Power[N[(N[(M * D), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{-d}\\
\mathbf{if}\;h \leq -5 \cdot 10^{-312}:\\
\;\;\;\;\frac{t\_0}{\sqrt{-h}} \cdot \left(\frac{t\_0}{\sqrt{-\ell}} \cdot \left(1 - h \cdot \left(0.125 \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\right)\right)\\

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


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

    1. Initial program 62.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. Simplified61.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.0000000000022e-312 < h

    1. Initial program 66.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 80.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{\ell}}\\ t_1 := M \cdot \frac{D}{d}\\ \mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(t\_0 \cdot \left(1 - h \cdot \left(0.125 \cdot \left(t\_1 \cdot \frac{t\_1}{\ell}\right)\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 8.2 \cdot 10^{+238}:\\ \;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(t\_0 \cdot \left(1 - h \cdot \left(0.125 \cdot \frac{{t\_1}^{2}}{\ell}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (/ d l))) (t_1 (* M (/ D d))))
   (if (<= l -2e-310)
     (*
      (/ (sqrt (- d)) (sqrt (- h)))
      (* t_0 (- 1.0 (* h (* 0.125 (* t_1 (/ t_1 l)))))))
     (if (<= l 8.2e+238)
       (*
        (/ (sqrt d) (sqrt h))
        (* t_0 (- 1.0 (* h (* 0.125 (/ (pow t_1 2.0) l))))))
       (/ d (* (sqrt h) (sqrt l)))))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / l));
	double t_1 = M * (D / d);
	double tmp;
	if (l <= -2e-310) {
		tmp = (sqrt(-d) / sqrt(-h)) * (t_0 * (1.0 - (h * (0.125 * (t_1 * (t_1 / l))))));
	} else if (l <= 8.2e+238) {
		tmp = (sqrt(d) / sqrt(h)) * (t_0 * (1.0 - (h * (0.125 * (pow(t_1, 2.0) / l)))));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = sqrt((d / l))
    t_1 = m * (d_1 / d)
    if (l <= (-2d-310)) then
        tmp = (sqrt(-d) / sqrt(-h)) * (t_0 * (1.0d0 - (h * (0.125d0 * (t_1 * (t_1 / l))))))
    else if (l <= 8.2d+238) then
        tmp = (sqrt(d) / sqrt(h)) * (t_0 * (1.0d0 - (h * (0.125d0 * ((t_1 ** 2.0d0) / l)))))
    else
        tmp = d / (sqrt(h) * sqrt(l))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt((d / l));
	double t_1 = M * (D / d);
	double tmp;
	if (l <= -2e-310) {
		tmp = (Math.sqrt(-d) / Math.sqrt(-h)) * (t_0 * (1.0 - (h * (0.125 * (t_1 * (t_1 / l))))));
	} else if (l <= 8.2e+238) {
		tmp = (Math.sqrt(d) / Math.sqrt(h)) * (t_0 * (1.0 - (h * (0.125 * (Math.pow(t_1, 2.0) / l)))));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
def code(d, h, l, M, D):
	t_0 = math.sqrt((d / l))
	t_1 = M * (D / d)
	tmp = 0
	if l <= -2e-310:
		tmp = (math.sqrt(-d) / math.sqrt(-h)) * (t_0 * (1.0 - (h * (0.125 * (t_1 * (t_1 / l))))))
	elif l <= 8.2e+238:
		tmp = (math.sqrt(d) / math.sqrt(h)) * (t_0 * (1.0 - (h * (0.125 * (math.pow(t_1, 2.0) / l)))))
	else:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	return tmp
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(d / l))
	t_1 = Float64(M * Float64(D / d))
	tmp = 0.0
	if (l <= -2e-310)
		tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(t_0 * Float64(1.0 - Float64(h * Float64(0.125 * Float64(t_1 * Float64(t_1 / l)))))));
	elseif (l <= 8.2e+238)
		tmp = Float64(Float64(sqrt(d) / sqrt(h)) * Float64(t_0 * Float64(1.0 - Float64(h * Float64(0.125 * Float64((t_1 ^ 2.0) / l))))));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt((d / l));
	t_1 = M * (D / d);
	tmp = 0.0;
	if (l <= -2e-310)
		tmp = (sqrt(-d) / sqrt(-h)) * (t_0 * (1.0 - (h * (0.125 * (t_1 * (t_1 / l))))));
	elseif (l <= 8.2e+238)
		tmp = (sqrt(d) / sqrt(h)) * (t_0 * (1.0 - (h * (0.125 * ((t_1 ^ 2.0) / l)))));
	else
		tmp = d / (sqrt(h) * sqrt(l));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2e-310], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * N[(1.0 - N[(h * N[(0.125 * N[(t$95$1 * N[(t$95$1 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 8.2e+238], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * N[(1.0 - N[(h * N[(0.125 * N[(N[Power[t$95$1, 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := M \cdot \frac{D}{d}\\
\mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(t\_0 \cdot \left(1 - h \cdot \left(0.125 \cdot \left(t\_1 \cdot \frac{t\_1}{\ell}\right)\right)\right)\right)\\

\mathbf{elif}\;\ell \leq 8.2 \cdot 10^{+238}:\\
\;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(t\_0 \cdot \left(1 - h \cdot \left(0.125 \cdot \frac{{t\_1}^{2}}{\ell}\right)\right)\right)\\

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


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

    1. Initial program 62.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. Simplified61.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < l < 8.1999999999999998e238

    1. Initial program 68.9%

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

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

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

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

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

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

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

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

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

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

    if 8.1999999999999998e238 < l

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified50.2%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. sqrt-div50.1%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      2. metadata-eval50.1%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}} \]
      3. un-div-inv50.1%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      4. +-commutative50.1%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{fma}\left(h, \ell, 1\right) + -1}}} \]
      5. fma-undefine50.1%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(h \cdot \ell + 1\right)} + -1}} \]
      6. associate-+l+50.1%

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

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell + \color{blue}{0}}} \]
    10. Applied egg-rr50.1%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell + 0}}} \]
    11. Step-by-step derivation
      1. +-rgt-identity50.1%

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

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

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

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

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

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

Alternative 4: 79.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 - h \cdot \left(0.125 \cdot \frac{{\left(\frac{M \cdot D}{d}\right)}^{2}}{\ell}\right)\right) \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{if}\;h \leq -5 \cdot 10^{-312}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot t\_0\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0
         (*
          (- 1.0 (* h (* 0.125 (/ (pow (/ (* M D) d) 2.0) l))))
          (sqrt (/ d l)))))
   (if (<= h -5e-312)
     (* (/ (sqrt (- d)) (sqrt (- h))) t_0)
     (* (/ (sqrt d) (sqrt h)) t_0))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = (1.0 - (h * (0.125 * (pow(((M * D) / d), 2.0) / l)))) * sqrt((d / l));
	double tmp;
	if (h <= -5e-312) {
		tmp = (sqrt(-d) / sqrt(-h)) * t_0;
	} else {
		tmp = (sqrt(d) / sqrt(h)) * t_0;
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (1.0d0 - (h * (0.125d0 * ((((m * d_1) / d) ** 2.0d0) / l)))) * sqrt((d / l))
    if (h <= (-5d-312)) then
        tmp = (sqrt(-d) / sqrt(-h)) * t_0
    else
        tmp = (sqrt(d) / sqrt(h)) * t_0
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = (1.0 - (h * (0.125 * (Math.pow(((M * D) / d), 2.0) / l)))) * Math.sqrt((d / l));
	double tmp;
	if (h <= -5e-312) {
		tmp = (Math.sqrt(-d) / Math.sqrt(-h)) * t_0;
	} else {
		tmp = (Math.sqrt(d) / Math.sqrt(h)) * t_0;
	}
	return tmp;
}
def code(d, h, l, M, D):
	t_0 = (1.0 - (h * (0.125 * (math.pow(((M * D) / d), 2.0) / l)))) * math.sqrt((d / l))
	tmp = 0
	if h <= -5e-312:
		tmp = (math.sqrt(-d) / math.sqrt(-h)) * t_0
	else:
		tmp = (math.sqrt(d) / math.sqrt(h)) * t_0
	return tmp
function code(d, h, l, M, D)
	t_0 = Float64(Float64(1.0 - Float64(h * Float64(0.125 * Float64((Float64(Float64(M * D) / d) ^ 2.0) / l)))) * sqrt(Float64(d / l)))
	tmp = 0.0
	if (h <= -5e-312)
		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
function tmp_2 = code(d, h, l, M, D)
	t_0 = (1.0 - (h * (0.125 * ((((M * D) / d) ^ 2.0) / l)))) * sqrt((d / l));
	tmp = 0.0;
	if (h <= -5e-312)
		tmp = (sqrt(-d) / sqrt(-h)) * t_0;
	else
		tmp = (sqrt(d) / sqrt(h)) * t_0;
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(1.0 - N[(h * N[(0.125 * N[(N[Power[N[(N[(M * D), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -5e-312], 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}

\\
\begin{array}{l}
t_0 := \left(1 - h \cdot \left(0.125 \cdot \frac{{\left(\frac{M \cdot D}{d}\right)}^{2}}{\ell}\right)\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;h \leq -5 \cdot 10^{-312}:\\
\;\;\;\;\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 h < -5.0000000000022e-312

    1. Initial program 62.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. Simplified61.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.0000000000022e-312 < h

    1. Initial program 66.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 80.0% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{\ell}}\\ t_1 := M \cdot \frac{D}{d}\\ \mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(t\_0 \cdot \left(1 - h \cdot \left(0.125 \cdot \left(t\_1 \cdot \frac{t\_1}{\ell}\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(\left(1 - h \cdot \left(0.125 \cdot \frac{{\left(\frac{M \cdot D}{d}\right)}^{2}}{\ell}\right)\right) \cdot t\_0\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (/ d l))) (t_1 (* M (/ D d))))
   (if (<= l -2e-310)
     (*
      (/ (sqrt (- d)) (sqrt (- h)))
      (* t_0 (- 1.0 (* h (* 0.125 (* t_1 (/ t_1 l)))))))
     (*
      (/ (sqrt d) (sqrt h))
      (* (- 1.0 (* h (* 0.125 (/ (pow (/ (* M D) d) 2.0) l)))) t_0)))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / l));
	double t_1 = M * (D / d);
	double tmp;
	if (l <= -2e-310) {
		tmp = (sqrt(-d) / sqrt(-h)) * (t_0 * (1.0 - (h * (0.125 * (t_1 * (t_1 / l))))));
	} else {
		tmp = (sqrt(d) / sqrt(h)) * ((1.0 - (h * (0.125 * (pow(((M * D) / d), 2.0) / l)))) * t_0);
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = sqrt((d / l))
    t_1 = m * (d_1 / d)
    if (l <= (-2d-310)) then
        tmp = (sqrt(-d) / sqrt(-h)) * (t_0 * (1.0d0 - (h * (0.125d0 * (t_1 * (t_1 / l))))))
    else
        tmp = (sqrt(d) / sqrt(h)) * ((1.0d0 - (h * (0.125d0 * ((((m * d_1) / d) ** 2.0d0) / l)))) * t_0)
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt((d / l));
	double t_1 = M * (D / d);
	double tmp;
	if (l <= -2e-310) {
		tmp = (Math.sqrt(-d) / Math.sqrt(-h)) * (t_0 * (1.0 - (h * (0.125 * (t_1 * (t_1 / l))))));
	} else {
		tmp = (Math.sqrt(d) / Math.sqrt(h)) * ((1.0 - (h * (0.125 * (Math.pow(((M * D) / d), 2.0) / l)))) * t_0);
	}
	return tmp;
}
def code(d, h, l, M, D):
	t_0 = math.sqrt((d / l))
	t_1 = M * (D / d)
	tmp = 0
	if l <= -2e-310:
		tmp = (math.sqrt(-d) / math.sqrt(-h)) * (t_0 * (1.0 - (h * (0.125 * (t_1 * (t_1 / l))))))
	else:
		tmp = (math.sqrt(d) / math.sqrt(h)) * ((1.0 - (h * (0.125 * (math.pow(((M * D) / d), 2.0) / l)))) * t_0)
	return tmp
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(d / l))
	t_1 = Float64(M * Float64(D / d))
	tmp = 0.0
	if (l <= -2e-310)
		tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(t_0 * Float64(1.0 - Float64(h * Float64(0.125 * Float64(t_1 * Float64(t_1 / l)))))));
	else
		tmp = Float64(Float64(sqrt(d) / sqrt(h)) * Float64(Float64(1.0 - Float64(h * Float64(0.125 * Float64((Float64(Float64(M * D) / d) ^ 2.0) / l)))) * t_0));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt((d / l));
	t_1 = M * (D / d);
	tmp = 0.0;
	if (l <= -2e-310)
		tmp = (sqrt(-d) / sqrt(-h)) * (t_0 * (1.0 - (h * (0.125 * (t_1 * (t_1 / l))))));
	else
		tmp = (sqrt(d) / sqrt(h)) * ((1.0 - (h * (0.125 * ((((M * D) / d) ^ 2.0) / l)))) * t_0);
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2e-310], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * N[(1.0 - N[(h * N[(0.125 * N[(t$95$1 * N[(t$95$1 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 - N[(h * N[(0.125 * N[(N[Power[N[(N[(M * D), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := M \cdot \frac{D}{d}\\
\mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(t\_0 \cdot \left(1 - h \cdot \left(0.125 \cdot \left(t\_1 \cdot \frac{t\_1}{\ell}\right)\right)\right)\right)\\

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


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

    1. Initial program 62.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. Simplified61.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < l

    1. Initial program 66.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 77.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := M \cdot \frac{D}{d}\\ \mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - h \cdot \left(0.125 \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 3.1 \cdot 10^{+184}:\\ \;\;\;\;\left(d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (* M (/ D d))))
   (if (<= l -2e-310)
     (*
      (/ (sqrt (- d)) (sqrt (- h)))
      (* (sqrt (/ d l)) (- 1.0 (* h (* 0.125 (* t_0 (/ t_0 l)))))))
     (if (<= l 3.1e+184)
       (*
        (* d (pow (* l h) -0.5))
        (- 1.0 (* 0.5 (* (pow (* (/ D d) (/ M 2.0)) 2.0) (/ h l)))))
       (/ d (* (sqrt h) (sqrt l)))))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = M * (D / d);
	double tmp;
	if (l <= -2e-310) {
		tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0 - (h * (0.125 * (t_0 * (t_0 / l))))));
	} else if (l <= 3.1e+184) {
		tmp = (d * pow((l * h), -0.5)) * (1.0 - (0.5 * (pow(((D / d) * (M / 2.0)), 2.0) * (h / l))));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = m * (d_1 / d)
    if (l <= (-2d-310)) then
        tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0d0 - (h * (0.125d0 * (t_0 * (t_0 / l))))))
    else if (l <= 3.1d+184) then
        tmp = (d * ((l * h) ** (-0.5d0))) * (1.0d0 - (0.5d0 * ((((d_1 / d) * (m / 2.0d0)) ** 2.0d0) * (h / l))))
    else
        tmp = d / (sqrt(h) * sqrt(l))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = M * (D / d);
	double tmp;
	if (l <= -2e-310) {
		tmp = (Math.sqrt(-d) / Math.sqrt(-h)) * (Math.sqrt((d / l)) * (1.0 - (h * (0.125 * (t_0 * (t_0 / l))))));
	} else if (l <= 3.1e+184) {
		tmp = (d * Math.pow((l * h), -0.5)) * (1.0 - (0.5 * (Math.pow(((D / d) * (M / 2.0)), 2.0) * (h / l))));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
def code(d, h, l, M, D):
	t_0 = M * (D / d)
	tmp = 0
	if l <= -2e-310:
		tmp = (math.sqrt(-d) / math.sqrt(-h)) * (math.sqrt((d / l)) * (1.0 - (h * (0.125 * (t_0 * (t_0 / l))))))
	elif l <= 3.1e+184:
		tmp = (d * math.pow((l * h), -0.5)) * (1.0 - (0.5 * (math.pow(((D / d) * (M / 2.0)), 2.0) * (h / l))))
	else:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	return tmp
function code(d, h, l, M, D)
	t_0 = Float64(M * Float64(D / d))
	tmp = 0.0
	if (l <= -2e-310)
		tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(h * Float64(0.125 * Float64(t_0 * Float64(t_0 / l)))))));
	elseif (l <= 3.1e+184)
		tmp = Float64(Float64(d * (Float64(l * h) ^ -0.5)) * Float64(1.0 - Float64(0.5 * Float64((Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0) * Float64(h / l)))));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	t_0 = M * (D / d);
	tmp = 0.0;
	if (l <= -2e-310)
		tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0 - (h * (0.125 * (t_0 * (t_0 / l))))));
	elseif (l <= 3.1e+184)
		tmp = (d * ((l * h) ^ -0.5)) * (1.0 - (0.5 * ((((D / d) * (M / 2.0)) ^ 2.0) * (h / l))));
	else
		tmp = d / (sqrt(h) * sqrt(l));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2e-310], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(h * N[(0.125 * N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.1e+184], N[(N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := M \cdot \frac{D}{d}\\
\mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - h \cdot \left(0.125 \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)\right)\right)\right)\\

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

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


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

    1. Initial program 62.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. Simplified61.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < l < 3.0999999999999998e184

    1. Initial program 71.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.0999999999999998e184 < l

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified39.4%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. sqrt-div39.4%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      2. metadata-eval39.4%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}} \]
      3. un-div-inv39.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      4. +-commutative39.4%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{fma}\left(h, \ell, 1\right) + -1}}} \]
      5. fma-undefine39.4%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(h \cdot \ell + 1\right)} + -1}} \]
      6. associate-+l+40.2%

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

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell + \color{blue}{0}}} \]
    10. Applied egg-rr40.2%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell + 0}}} \]
    11. Step-by-step derivation
      1. +-rgt-identity40.2%

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

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

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

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    14. Applied egg-rr69.1%

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

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

Alternative 7: 65.1% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - 0.5 \cdot \left({\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2} \cdot \frac{h}{\ell}\right)\\ \mathbf{if}\;\ell \leq -4.4 \cdot 10^{+93}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{elif}\;\ell \leq 2 \cdot 10^{-306}:\\ \;\;\;\;t\_0 \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{elif}\;\ell \leq 2.7 \cdot 10^{+181}:\\ \;\;\;\;\left(d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right) \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (- 1.0 (* 0.5 (* (pow (* (/ D d) (/ M 2.0)) 2.0) (/ h l))))))
   (if (<= l -4.4e+93)
     (* (- d) (sqrt (/ (/ 1.0 l) h)))
     (if (<= l 2e-306)
       (* t_0 (sqrt (* (/ d l) (/ d h))))
       (if (<= l 2.7e+181)
         (* (* d (pow (* l h) -0.5)) t_0)
         (/ d (* (sqrt h) (sqrt l))))))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = 1.0 - (0.5 * (pow(((D / d) * (M / 2.0)), 2.0) * (h / l)));
	double tmp;
	if (l <= -4.4e+93) {
		tmp = -d * sqrt(((1.0 / l) / h));
	} else if (l <= 2e-306) {
		tmp = t_0 * sqrt(((d / l) * (d / h)));
	} else if (l <= 2.7e+181) {
		tmp = (d * pow((l * h), -0.5)) * t_0;
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 - (0.5d0 * ((((d_1 / d) * (m / 2.0d0)) ** 2.0d0) * (h / l)))
    if (l <= (-4.4d+93)) then
        tmp = -d * sqrt(((1.0d0 / l) / h))
    else if (l <= 2d-306) then
        tmp = t_0 * sqrt(((d / l) * (d / h)))
    else if (l <= 2.7d+181) then
        tmp = (d * ((l * h) ** (-0.5d0))) * t_0
    else
        tmp = d / (sqrt(h) * sqrt(l))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = 1.0 - (0.5 * (Math.pow(((D / d) * (M / 2.0)), 2.0) * (h / l)));
	double tmp;
	if (l <= -4.4e+93) {
		tmp = -d * Math.sqrt(((1.0 / l) / h));
	} else if (l <= 2e-306) {
		tmp = t_0 * Math.sqrt(((d / l) * (d / h)));
	} else if (l <= 2.7e+181) {
		tmp = (d * Math.pow((l * h), -0.5)) * t_0;
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
def code(d, h, l, M, D):
	t_0 = 1.0 - (0.5 * (math.pow(((D / d) * (M / 2.0)), 2.0) * (h / l)))
	tmp = 0
	if l <= -4.4e+93:
		tmp = -d * math.sqrt(((1.0 / l) / h))
	elif l <= 2e-306:
		tmp = t_0 * math.sqrt(((d / l) * (d / h)))
	elif l <= 2.7e+181:
		tmp = (d * math.pow((l * h), -0.5)) * t_0
	else:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	return tmp
function code(d, h, l, M, D)
	t_0 = Float64(1.0 - Float64(0.5 * Float64((Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0) * Float64(h / l))))
	tmp = 0.0
	if (l <= -4.4e+93)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / l) / h)));
	elseif (l <= 2e-306)
		tmp = Float64(t_0 * sqrt(Float64(Float64(d / l) * Float64(d / h))));
	elseif (l <= 2.7e+181)
		tmp = Float64(Float64(d * (Float64(l * h) ^ -0.5)) * t_0);
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	t_0 = 1.0 - (0.5 * ((((D / d) * (M / 2.0)) ^ 2.0) * (h / l)));
	tmp = 0.0;
	if (l <= -4.4e+93)
		tmp = -d * sqrt(((1.0 / l) / h));
	elseif (l <= 2e-306)
		tmp = t_0 * sqrt(((d / l) * (d / h)));
	elseif (l <= 2.7e+181)
		tmp = (d * ((l * h) ^ -0.5)) * t_0;
	else
		tmp = d / (sqrt(h) * sqrt(l));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(1.0 - N[(0.5 * N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4.4e+93], N[((-d) * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2e-306], N[(t$95$0 * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.7e+181], N[(N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 - 0.5 \cdot \left({\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2} \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;\ell \leq -4.4 \cdot 10^{+93}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\

\mathbf{elif}\;\ell \leq 2 \cdot 10^{-306}:\\
\;\;\;\;t\_0 \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\

\mathbf{elif}\;\ell \leq 2.7 \cdot 10^{+181}:\\
\;\;\;\;\left(d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right) \cdot t\_0\\

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


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

    1. Initial program 51.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. Simplified50.9%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

    if -4.40000000000000042e93 < l < 2.00000000000000006e-306

    1. Initial program 68.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. Simplified67.3%

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \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) \]
    7. Simplified57.0%

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

    if 2.00000000000000006e-306 < l < 2.70000000000000007e181

    1. Initial program 71.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.70000000000000007e181 < l

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified39.4%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. sqrt-div39.4%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      2. metadata-eval39.4%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}} \]
      3. un-div-inv39.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      4. +-commutative39.4%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{fma}\left(h, \ell, 1\right) + -1}}} \]
      5. fma-undefine39.4%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(h \cdot \ell + 1\right)} + -1}} \]
      6. associate-+l+40.2%

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

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell + \color{blue}{0}}} \]
    10. Applied egg-rr40.2%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell + 0}}} \]
    11. Step-by-step derivation
      1. +-rgt-identity40.2%

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

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

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

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    14. Applied egg-rr69.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.4 \cdot 10^{+93}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{elif}\;\ell \leq 2 \cdot 10^{-306}:\\ \;\;\;\;\left(1 - 0.5 \cdot \left({\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{elif}\;\ell \leq 2.7 \cdot 10^{+181}:\\ \;\;\;\;\left(d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 59.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1.5 \cdot 10^{-172}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}\\ \mathbf{elif}\;\ell \leq 3.2 \cdot 10^{+182}:\\ \;\;\;\;\left(d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -1.5e-172)
   (* (- d) (sqrt (/ (/ 1.0 l) h)))
   (if (<= l -2e-310)
     (/ d (sqrt (+ -1.0 (fma h l 1.0))))
     (if (<= l 3.2e+182)
       (*
        (* d (pow (* l h) -0.5))
        (- 1.0 (* 0.5 (* (pow (* (/ D d) (/ M 2.0)) 2.0) (/ h l)))))
       (/ d (* (sqrt h) (sqrt l)))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -1.5e-172) {
		tmp = -d * sqrt(((1.0 / l) / h));
	} else if (l <= -2e-310) {
		tmp = d / sqrt((-1.0 + fma(h, l, 1.0)));
	} else if (l <= 3.2e+182) {
		tmp = (d * pow((l * h), -0.5)) * (1.0 - (0.5 * (pow(((D / d) * (M / 2.0)), 2.0) * (h / l))));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -1.5e-172)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / l) / h)));
	elseif (l <= -2e-310)
		tmp = Float64(d / sqrt(Float64(-1.0 + fma(h, l, 1.0))));
	elseif (l <= 3.2e+182)
		tmp = Float64(Float64(d * (Float64(l * h) ^ -0.5)) * Float64(1.0 - Float64(0.5 * Float64((Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0) * Float64(h / l)))));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -1.5e-172], N[((-d) * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -2e-310], N[(d / N[Sqrt[N[(-1.0 + N[(h * l + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.2e+182], N[(N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.5 \cdot 10^{-172}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\

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

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

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


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

    1. Initial program 55.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. Simplified54.3%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

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

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

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

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot d \]
      4. rem-square-sqrt54.0%

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(-1 \cdot d\right)} \]
      7. *-commutative54.0%

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

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

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

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

    if -1.49999999999999992e-172 < l < -1.999999999999994e-310

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified47.9%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. sqrt-div47.9%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      2. metadata-eval47.9%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}} \]
      3. un-div-inv47.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      4. +-commutative47.9%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{fma}\left(h, \ell, 1\right) + -1}}} \]
      5. fma-undefine47.9%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(h \cdot \ell + 1\right)} + -1}} \]
      6. associate-+l+28.8%

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

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell + 0}}} \]
    11. Step-by-step derivation
      1. +-rgt-identity28.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    16. Simplified47.9%

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

    if -1.999999999999994e-310 < l < 3.1999999999999997e182

    1. Initial program 71.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.1999999999999997e182 < l

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified39.4%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. sqrt-div39.4%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      2. metadata-eval39.4%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}} \]
      3. un-div-inv39.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      4. +-commutative39.4%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{fma}\left(h, \ell, 1\right) + -1}}} \]
      5. fma-undefine39.4%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(h \cdot \ell + 1\right)} + -1}} \]
      6. associate-+l+40.2%

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

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell + \color{blue}{0}}} \]
    10. Applied egg-rr40.2%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell + 0}}} \]
    11. Step-by-step derivation
      1. +-rgt-identity40.2%

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

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

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

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    14. Applied egg-rr69.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.5 \cdot 10^{-172}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}\\ \mathbf{elif}\;\ell \leq 3.2 \cdot 10^{+182}:\\ \;\;\;\;\left(d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 50.9% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -5.6 \cdot 10^{-174}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{elif}\;\ell \leq 1.95 \cdot 10^{-301}:\\ \;\;\;\;\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}\\ \mathbf{elif}\;\ell \leq 2.45 \cdot 10^{-65}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(-0.125 \cdot \left(h \cdot \frac{{\left(\frac{D}{\frac{d}{M}}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -5.6e-174)
   (* (- d) (sqrt (/ (/ 1.0 l) h)))
   (if (<= l 1.95e-301)
     (/ d (sqrt (+ -1.0 (fma h l 1.0))))
     (if (<= l 2.45e-65)
       (* (/ d (sqrt (* l h))) (* -0.125 (* h (/ (pow (/ D (/ d M)) 2.0) l))))
       (* d (* (pow l -0.5) (pow h -0.5)))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -5.6e-174) {
		tmp = -d * sqrt(((1.0 / l) / h));
	} else if (l <= 1.95e-301) {
		tmp = d / sqrt((-1.0 + fma(h, l, 1.0)));
	} else if (l <= 2.45e-65) {
		tmp = (d / sqrt((l * h))) * (-0.125 * (h * (pow((D / (d / M)), 2.0) / l)));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -5.6e-174)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / l) / h)));
	elseif (l <= 1.95e-301)
		tmp = Float64(d / sqrt(Float64(-1.0 + fma(h, l, 1.0))));
	elseif (l <= 2.45e-65)
		tmp = Float64(Float64(d / sqrt(Float64(l * h))) * Float64(-0.125 * Float64(h * Float64((Float64(D / Float64(d / M)) ^ 2.0) / l))));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -5.6e-174], N[((-d) * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.95e-301], N[(d / N[Sqrt[N[(-1.0 + N[(h * l + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.45e-65], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.125 * N[(h * N[(N[Power[N[(D / N[(d / M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5.6 \cdot 10^{-174}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\

\mathbf{elif}\;\ell \leq 1.95 \cdot 10^{-301}:\\
\;\;\;\;\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}\\

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

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


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

    1. Initial program 55.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. Simplified54.3%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

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

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

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

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot d \]
      4. rem-square-sqrt54.0%

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(-1 \cdot d\right)} \]
      7. *-commutative54.0%

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

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

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

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

    if -5.59999999999999998e-174 < l < 1.9500000000000001e-301

    1. Initial program 76.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. Simplified76.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified49.1%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. sqrt-div49.1%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      2. metadata-eval49.1%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}} \]
      3. un-div-inv49.1%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      4. +-commutative49.1%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{fma}\left(h, \ell, 1\right) + -1}}} \]
      5. fma-undefine49.1%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(h \cdot \ell + 1\right)} + -1}} \]
      6. associate-+l+30.5%

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

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell + \color{blue}{0}}} \]
    10. Applied egg-rr30.5%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell + 0}}} \]
    11. Step-by-step derivation
      1. +-rgt-identity30.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    16. Simplified49.1%

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

    if 1.9500000000000001e-301 < l < 2.44999999999999982e-65

    1. Initial program 70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.44999999999999982e-65 < l

    1. Initial program 64.5%

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

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

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

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

        \[\leadsto d \cdot \left(1 \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right) \]
      3. inv-pow48.0%

        \[\leadsto d \cdot \left(1 \cdot {\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right) \]
      4. pow-pow48.1%

        \[\leadsto d \cdot \left(1 \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right) \]
      5. metadata-eval48.1%

        \[\leadsto d \cdot \left(1 \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right) \]
    6. Applied egg-rr48.1%

      \[\leadsto d \cdot \color{blue}{\left(1 \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    7. Step-by-step derivation
      1. *-lft-identity48.1%

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

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative48.1%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down60.4%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr60.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5.6 \cdot 10^{-174}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{elif}\;\ell \leq 1.95 \cdot 10^{-301}:\\ \;\;\;\;\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}\\ \mathbf{elif}\;\ell \leq 2.45 \cdot 10^{-65}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(-0.125 \cdot \left(h \cdot \frac{{\left(\frac{D}{\frac{d}{M}}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 71.0% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left({\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2} \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;\ell \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(t\_0 + -1\right)\\

\mathbf{elif}\;\ell \leq 3.2 \cdot 10^{+182}:\\
\;\;\;\;\left(d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right) \cdot \left(1 - t\_0\right)\\

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


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

    1. Initial program 62.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. Simplified61.4%

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

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

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

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

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

    if -1.999999999999994e-310 < l < 3.1999999999999997e182

    1. Initial program 71.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.1999999999999997e182 < l

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified39.4%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. sqrt-div39.4%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      2. metadata-eval39.4%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}} \]
      3. un-div-inv39.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      4. +-commutative39.4%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{fma}\left(h, \ell, 1\right) + -1}}} \]
      5. fma-undefine39.4%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(h \cdot \ell + 1\right)} + -1}} \]
      6. associate-+l+40.2%

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

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell + \color{blue}{0}}} \]
    10. Applied egg-rr40.2%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell + 0}}} \]
    11. Step-by-step derivation
      1. +-rgt-identity40.2%

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

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

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

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    14. Applied egg-rr69.1%

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

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

Alternative 11: 47.2% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1.42 \cdot 10^{-162}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{elif}\;\ell \leq 3.5 \cdot 10^{-301}:\\ \;\;\;\;\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}\\ \mathbf{elif}\;\ell \leq 8.5 \cdot 10^{-254}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{{\left(\frac{d}{\ell}\right)}^{1.5}}{\frac{d}{-\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -1.42e-162)
   (* (- d) (sqrt (/ (/ 1.0 l) h)))
   (if (<= l 3.5e-301)
     (/ d (sqrt (+ -1.0 (fma h l 1.0))))
     (if (<= l 8.5e-254)
       (* (sqrt (/ d h)) (/ (pow (/ d l) 1.5) (/ d (- l))))
       (* d (* (pow l -0.5) (pow h -0.5)))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -1.42e-162) {
		tmp = -d * sqrt(((1.0 / l) / h));
	} else if (l <= 3.5e-301) {
		tmp = d / sqrt((-1.0 + fma(h, l, 1.0)));
	} else if (l <= 8.5e-254) {
		tmp = sqrt((d / h)) * (pow((d / l), 1.5) / (d / -l));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -1.42e-162)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / l) / h)));
	elseif (l <= 3.5e-301)
		tmp = Float64(d / sqrt(Float64(-1.0 + fma(h, l, 1.0))));
	elseif (l <= 8.5e-254)
		tmp = Float64(sqrt(Float64(d / h)) * Float64((Float64(d / l) ^ 1.5) / Float64(d / Float64(-l))));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -1.42e-162], N[((-d) * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.5e-301], N[(d / N[Sqrt[N[(-1.0 + N[(h * l + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 8.5e-254], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Power[N[(d / l), $MachinePrecision], 1.5], $MachinePrecision] / N[(d / (-l)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.42 \cdot 10^{-162}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\

\mathbf{elif}\;\ell \leq 3.5 \cdot 10^{-301}:\\
\;\;\;\;\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}\\

\mathbf{elif}\;\ell \leq 8.5 \cdot 10^{-254}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{{\left(\frac{d}{\ell}\right)}^{1.5}}{\frac{d}{-\ell}}\\

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


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

    1. Initial program 55.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. Simplified54.3%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

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

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

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

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot d \]
      4. rem-square-sqrt54.0%

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(-1 \cdot d\right)} \]
      7. *-commutative54.0%

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

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

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

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

    if -1.41999999999999989e-162 < l < 3.49999999999999992e-301

    1. Initial program 76.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. Simplified76.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified49.1%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. sqrt-div49.1%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      2. metadata-eval49.1%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}} \]
      3. un-div-inv49.1%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      4. +-commutative49.1%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{fma}\left(h, \ell, 1\right) + -1}}} \]
      5. fma-undefine49.1%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(h \cdot \ell + 1\right)} + -1}} \]
      6. associate-+l+30.5%

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

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell + \color{blue}{0}}} \]
    10. Applied egg-rr30.5%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell + 0}}} \]
    11. Step-by-step derivation
      1. +-rgt-identity30.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    16. Simplified49.1%

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

    if 3.49999999999999992e-301 < l < 8.49999999999999963e-254

    1. Initial program 85.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. Simplified85.7%

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{{0}^{3} - {\left(\sqrt{\frac{d}{\ell}}\right)}^{3}}{0 \cdot 0 + \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{\ell}} + 0 \cdot \sqrt{\frac{d}{\ell}}\right)}} \]
      3. metadata-eval71.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{0} - {\left(\sqrt{\frac{d}{\ell}}\right)}^{3}}{0 \cdot 0 + \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{\ell}} + 0 \cdot \sqrt{\frac{d}{\ell}}\right)} \]
      4. pow371.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \frac{0 - \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \sqrt{\frac{d}{\ell}}}}{0 \cdot 0 + \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{\ell}} + 0 \cdot \sqrt{\frac{d}{\ell}}\right)} \]
      5. add-sqr-sqrt71.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \frac{0 - \color{blue}{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{\ell}}}{0 \cdot 0 + \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{\ell}} + 0 \cdot \sqrt{\frac{d}{\ell}}\right)} \]
      6. pow171.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \frac{0 - \color{blue}{{\left(\frac{d}{\ell}\right)}^{1}} \cdot \sqrt{\frac{d}{\ell}}}{0 \cdot 0 + \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{\ell}} + 0 \cdot \sqrt{\frac{d}{\ell}}\right)} \]
      7. pow1/271.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \frac{0 - {\left(\frac{d}{\ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}}{0 \cdot 0 + \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{\ell}} + 0 \cdot \sqrt{\frac{d}{\ell}}\right)} \]
      8. pow-prod-up71.7%

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \frac{0 - {\left(\frac{d}{\ell}\right)}^{\color{blue}{1.5}}}{0 \cdot 0 + \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{\ell}} + 0 \cdot \sqrt{\frac{d}{\ell}}\right)} \]
      10. metadata-eval71.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \frac{0 - {\left(\frac{d}{\ell}\right)}^{1.5}}{\color{blue}{0} + \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{\ell}} + 0 \cdot \sqrt{\frac{d}{\ell}}\right)} \]
      11. add-sqr-sqrt71.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \frac{0 - {\left(\frac{d}{\ell}\right)}^{1.5}}{0 + \left(\color{blue}{\frac{d}{\ell}} + 0 \cdot \sqrt{\frac{d}{\ell}}\right)} \]
    8. Applied egg-rr71.7%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{0 - {\left(\frac{d}{\ell}\right)}^{1.5}}{0 + \left(\frac{d}{\ell} + 0 \cdot \sqrt{\frac{d}{\ell}}\right)}} \]
    9. Step-by-step derivation
      1. sub0-neg71.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{-{\left(\frac{d}{\ell}\right)}^{1.5}}}{0 + \left(\frac{d}{\ell} + 0 \cdot \sqrt{\frac{d}{\ell}}\right)} \]
      2. +-lft-identity71.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \frac{-{\left(\frac{d}{\ell}\right)}^{1.5}}{\color{blue}{\frac{d}{\ell} + 0 \cdot \sqrt{\frac{d}{\ell}}}} \]
      3. mul0-lft71.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \frac{-{\left(\frac{d}{\ell}\right)}^{1.5}}{\frac{d}{\ell} + \color{blue}{0}} \]
      4. +-rgt-identity71.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \frac{-{\left(\frac{d}{\ell}\right)}^{1.5}}{\color{blue}{\frac{d}{\ell}}} \]
    10. Simplified71.7%

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

    if 8.49999999999999963e-254 < l

    1. Initial program 65.5%

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

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

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

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

        \[\leadsto d \cdot \left(1 \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right) \]
      3. inv-pow42.4%

        \[\leadsto d \cdot \left(1 \cdot {\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right) \]
      4. pow-pow42.9%

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

        \[\leadsto d \cdot \left(1 \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right) \]
    6. Applied egg-rr42.9%

      \[\leadsto d \cdot \color{blue}{\left(1 \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    7. Step-by-step derivation
      1. *-lft-identity42.9%

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

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative42.9%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down53.1%

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

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification53.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.42 \cdot 10^{-162}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{elif}\;\ell \leq 3.5 \cdot 10^{-301}:\\ \;\;\;\;\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}\\ \mathbf{elif}\;\ell \leq 8.5 \cdot 10^{-254}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{{\left(\frac{d}{\ell}\right)}^{1.5}}{\frac{d}{-\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 48.4% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -3 \cdot 10^{-174}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -3e-174)
   (* (- d) (sqrt (/ (/ 1.0 l) h)))
   (if (<= l -2e-310)
     (/ d (sqrt (+ -1.0 (fma h l 1.0))))
     (* d (* (pow l -0.5) (pow h -0.5))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -3e-174) {
		tmp = -d * sqrt(((1.0 / l) / h));
	} else if (l <= -2e-310) {
		tmp = d / sqrt((-1.0 + fma(h, l, 1.0)));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -3e-174)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / l) / h)));
	elseif (l <= -2e-310)
		tmp = Float64(d / sqrt(Float64(-1.0 + fma(h, l, 1.0))));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -3e-174], N[((-d) * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -2e-310], N[(d / N[Sqrt[N[(-1.0 + N[(h * l + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3 \cdot 10^{-174}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\

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

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


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

    1. Initial program 55.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. Simplified54.3%

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

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

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

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

        \[\leadsto \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot d \]
      4. rem-square-sqrt54.0%

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(-1 \cdot d\right)} \]
      7. *-commutative54.0%

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

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

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

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

    if -3.00000000000000021e-174 < l < -1.999999999999994e-310

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified47.9%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. sqrt-div47.9%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      2. metadata-eval47.9%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}} \]
      3. un-div-inv47.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      4. +-commutative47.9%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{fma}\left(h, \ell, 1\right) + -1}}} \]
      5. fma-undefine47.9%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(h \cdot \ell + 1\right)} + -1}} \]
      6. associate-+l+28.8%

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

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell + 0}}} \]
    11. Step-by-step derivation
      1. +-rgt-identity28.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    16. Simplified47.9%

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

    if -1.999999999999994e-310 < l

    1. Initial program 66.8%

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

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

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

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

        \[\leadsto d \cdot \left(1 \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right) \]
      3. inv-pow40.6%

        \[\leadsto d \cdot \left(1 \cdot {\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right) \]
      4. pow-pow41.0%

        \[\leadsto d \cdot \left(1 \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right) \]
      5. metadata-eval41.0%

        \[\leadsto d \cdot \left(1 \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right) \]
    6. Applied egg-rr41.0%

      \[\leadsto d \cdot \color{blue}{\left(1 \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    7. Step-by-step derivation
      1. *-lft-identity41.0%

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

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative41.0%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down50.6%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr50.6%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification51.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3 \cdot 10^{-174}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 46.8% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -8.2 \cdot 10^{-185}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -8.2e-185)
   (* (- d) (sqrt (/ (/ 1.0 l) h)))
   (if (<= l -2e-310)
     (/ d (cbrt (pow (* l h) 1.5)))
     (* d (* (pow l -0.5) (pow h -0.5))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -8.2e-185) {
		tmp = -d * sqrt(((1.0 / l) / h));
	} else if (l <= -2e-310) {
		tmp = d / cbrt(pow((l * h), 1.5));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -8.2e-185) {
		tmp = -d * Math.sqrt(((1.0 / l) / h));
	} else if (l <= -2e-310) {
		tmp = d / Math.cbrt(Math.pow((l * h), 1.5));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -8.2e-185)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / l) / h)));
	elseif (l <= -2e-310)
		tmp = Float64(d / cbrt((Float64(l * h) ^ 1.5)));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -8.2e-185], N[((-d) * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -2e-310], 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[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -8.2 \cdot 10^{-185}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\

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

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


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

    1. Initial program 57.0%

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

    if -8.2e-185 < l < -1.999999999999994e-310

    1. Initial program 74.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified48.8%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. sqrt-div48.8%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      2. metadata-eval48.8%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}} \]
      3. un-div-inv48.8%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      4. +-commutative48.8%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{fma}\left(h, \ell, 1\right) + -1}}} \]
      5. fma-undefine48.8%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(h \cdot \ell + 1\right)} + -1}} \]
      6. associate-+l+30.8%

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

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell + 0}}} \]
    11. Step-by-step derivation
      1. +-rgt-identity30.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\color{blue}{\sqrt[3]{{\left(h \cdot \ell\right)}^{1.5}}}} \]
    16. Simplified38.5%

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

    if -1.999999999999994e-310 < l

    1. Initial program 66.8%

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

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

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

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

        \[\leadsto d \cdot \left(1 \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right) \]
      3. inv-pow40.6%

        \[\leadsto d \cdot \left(1 \cdot {\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right) \]
      4. pow-pow41.0%

        \[\leadsto d \cdot \left(1 \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right) \]
      5. metadata-eval41.0%

        \[\leadsto d \cdot \left(1 \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right) \]
    6. Applied egg-rr41.0%

      \[\leadsto d \cdot \color{blue}{\left(1 \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    7. Step-by-step derivation
      1. *-lft-identity41.0%

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

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative41.0%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down50.6%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr50.6%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification50.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -8.2 \cdot 10^{-185}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 46.8% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1.7 \cdot 10^{-180}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -1.7e-180)
   (* (- d) (sqrt (/ (/ 1.0 l) h)))
   (if (<= l -2e-310)
     (/ d (cbrt (pow (* l h) 1.5)))
     (/ d (* (sqrt h) (sqrt l))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -1.7e-180) {
		tmp = -d * sqrt(((1.0 / l) / h));
	} else if (l <= -2e-310) {
		tmp = d / cbrt(pow((l * h), 1.5));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -1.7e-180) {
		tmp = -d * Math.sqrt(((1.0 / l) / h));
	} else if (l <= -2e-310) {
		tmp = d / Math.cbrt(Math.pow((l * h), 1.5));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -1.7e-180)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / l) / h)));
	elseif (l <= -2e-310)
		tmp = Float64(d / cbrt((Float64(l * h) ^ 1.5)));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -1.7e-180], N[((-d) * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -2e-310], N[(d / N[Power[N[Power[N[(l * h), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.7 \cdot 10^{-180}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\

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

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


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

    1. Initial program 57.0%

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

    if -1.69999999999999991e-180 < l < -1.999999999999994e-310

    1. Initial program 74.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified48.8%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. sqrt-div48.8%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      2. metadata-eval48.8%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}} \]
      3. un-div-inv48.8%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      4. +-commutative48.8%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{fma}\left(h, \ell, 1\right) + -1}}} \]
      5. fma-undefine48.8%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(h \cdot \ell + 1\right)} + -1}} \]
      6. associate-+l+30.8%

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

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell + 0}}} \]
    11. Step-by-step derivation
      1. +-rgt-identity30.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\color{blue}{\sqrt[3]{{\left(h \cdot \ell\right)}^{1.5}}}} \]
    16. Simplified38.5%

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

    if -1.999999999999994e-310 < l

    1. Initial program 66.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\left(h \cdot \ell + 1\right)}}} \]
      7. fma-define26.0%

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified26.0%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. sqrt-div26.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      2. metadata-eval26.0%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}} \]
      3. un-div-inv26.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      4. +-commutative26.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{fma}\left(h, \ell, 1\right) + -1}}} \]
      5. fma-undefine26.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(h \cdot \ell + 1\right)} + -1}} \]
      6. associate-+l+41.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell + \left(1 + -1\right)}}} \]
      7. metadata-eval41.0%

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell + 0}}} \]
    11. Step-by-step derivation
      1. +-rgt-identity41.0%

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

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

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

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    14. Applied egg-rr50.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.7 \cdot 10^{-180}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 46.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1.7 \cdot 10^{-185}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -1.7e-185)
   (* (- d) (sqrt (/ (/ 1.0 l) h)))
   (if (<= l -2e-310)
     (* d (sqrt (/ 1.0 (* l h))))
     (/ d (* (sqrt h) (sqrt l))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -1.7e-185) {
		tmp = -d * sqrt(((1.0 / l) / h));
	} else if (l <= -2e-310) {
		tmp = d * sqrt((1.0 / (l * h)));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (l <= (-1.7d-185)) then
        tmp = -d * sqrt(((1.0d0 / l) / h))
    else if (l <= (-2d-310)) then
        tmp = d * sqrt((1.0d0 / (l * h)))
    else
        tmp = d / (sqrt(h) * sqrt(l))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -1.7e-185) {
		tmp = -d * Math.sqrt(((1.0 / l) / h));
	} else if (l <= -2e-310) {
		tmp = d * Math.sqrt((1.0 / (l * h)));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if l <= -1.7e-185:
		tmp = -d * math.sqrt(((1.0 / l) / h))
	elif l <= -2e-310:
		tmp = d * math.sqrt((1.0 / (l * h)))
	else:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -1.7e-185)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / l) / h)));
	elseif (l <= -2e-310)
		tmp = Float64(d * sqrt(Float64(1.0 / Float64(l * h))));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (l <= -1.7e-185)
		tmp = -d * sqrt(((1.0 / l) / h));
	elseif (l <= -2e-310)
		tmp = d * sqrt((1.0 / (l * h)));
	else
		tmp = d / (sqrt(h) * sqrt(l));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -1.7e-185], N[((-d) * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -2e-310], N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.7 \cdot 10^{-185}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\

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

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


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

    1. Initial program 57.0%

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

    if -1.6999999999999999e-185 < l < -1.999999999999994e-310

    1. Initial program 74.2%

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

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

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

    if -1.999999999999994e-310 < l

    1. Initial program 66.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\left(h \cdot \ell + 1\right)}}} \]
      7. fma-define26.0%

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified26.0%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. sqrt-div26.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      2. metadata-eval26.0%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}} \]
      3. un-div-inv26.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      4. +-commutative26.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{fma}\left(h, \ell, 1\right) + -1}}} \]
      5. fma-undefine26.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(h \cdot \ell + 1\right)} + -1}} \]
      6. associate-+l+41.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell + \left(1 + -1\right)}}} \]
      7. metadata-eval41.0%

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell + 0}}} \]
    11. Step-by-step derivation
      1. +-rgt-identity41.0%

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

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

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

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    14. Applied egg-rr50.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.7 \cdot 10^{-185}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 42.5% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{if}\;\ell \leq -3.1 \cdot 10^{-183}:\\ \;\;\;\;\left(-d\right) \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot t\_0\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (/ (/ 1.0 l) h))))
   (if (<= l -3.1e-183) (* (- d) t_0) (* d t_0))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt(((1.0 / l) / h));
	double tmp;
	if (l <= -3.1e-183) {
		tmp = -d * t_0;
	} else {
		tmp = d * t_0;
	}
	return tmp;
}
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(((1.0d0 / l) / h))
    if (l <= (-3.1d-183)) then
        tmp = -d * t_0
    else
        tmp = d * t_0
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt(((1.0 / l) / h));
	double tmp;
	if (l <= -3.1e-183) {
		tmp = -d * t_0;
	} else {
		tmp = d * t_0;
	}
	return tmp;
}
def code(d, h, l, M, D):
	t_0 = math.sqrt(((1.0 / l) / h))
	tmp = 0
	if l <= -3.1e-183:
		tmp = -d * t_0
	else:
		tmp = d * t_0
	return tmp
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(Float64(1.0 / l) / h))
	tmp = 0.0
	if (l <= -3.1e-183)
		tmp = Float64(Float64(-d) * t_0);
	else
		tmp = Float64(d * t_0);
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt(((1.0 / l) / h));
	tmp = 0.0;
	if (l <= -3.1e-183)
		tmp = -d * t_0;
	else
		tmp = d * t_0;
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -3.1e-183], N[((-d) * t$95$0), $MachinePrecision], N[(d * t$95$0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\frac{\frac{1}{\ell}}{h}}\\
\mathbf{if}\;\ell \leq -3.1 \cdot 10^{-183}:\\
\;\;\;\;\left(-d\right) \cdot t\_0\\

\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\


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

    1. Initial program 57.0%

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Taylor expanded in h around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

    if -3.1e-183 < l

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{1 \cdot \frac{1}{h \cdot \ell}}} \]
    6. Applied egg-rr39.6%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.1 \cdot 10^{-183}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 42.4% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1.55 \cdot 10^{-185}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -1.55e-185) (/ d (- (sqrt (* l h)))) (* d (sqrt (/ (/ 1.0 l) h)))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -1.55e-185) {
		tmp = d / -sqrt((l * h));
	} else {
		tmp = d * sqrt(((1.0 / l) / h));
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (l <= (-1.55d-185)) then
        tmp = d / -sqrt((l * h))
    else
        tmp = d * sqrt(((1.0d0 / l) / h))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -1.55e-185) {
		tmp = d / -Math.sqrt((l * h));
	} else {
		tmp = d * Math.sqrt(((1.0 / l) / h));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if l <= -1.55e-185:
		tmp = d / -math.sqrt((l * h))
	else:
		tmp = d * math.sqrt(((1.0 / l) / h))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -1.55e-185)
		tmp = Float64(d / Float64(-sqrt(Float64(l * h))));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / l) / h)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (l <= -1.55e-185)
		tmp = d / -sqrt((l * h));
	else
		tmp = d * sqrt(((1.0 / l) / h));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -1.55e-185], N[(d / (-N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.55 \cdot 10^{-185}:\\
\;\;\;\;\frac{d}{-\sqrt{\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 l < -1.5499999999999998e-185

    1. Initial program 57.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\left(h \cdot \ell + 1\right)}}} \]
      7. fma-define7.0%

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified7.0%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. sqrt-div7.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      2. metadata-eval7.0%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}} \]
      3. un-div-inv7.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      4. +-commutative7.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{fma}\left(h, \ell, 1\right) + -1}}} \]
      5. fma-undefine7.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(h \cdot \ell + 1\right)} + -1}} \]
      6. associate-+l+2.8%

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

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell + 0}}} \]
    11. Step-by-step derivation
      1. +-rgt-identity2.8%

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    13. 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. frac-times0.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. sqrt-div37.6%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\left(-\sqrt{\frac{d}{\ell}}\right) \cdot \left(-\sqrt{\frac{d}{\ell}}\right)}} \]
      8. sqrt-unprod0.6%

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\left(-\sqrt{\frac{d}{\ell}}\right)} \]
      10. distribute-rgt-neg-out3.8%

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

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

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

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

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

        \[\leadsto -\frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      16. neg-sub053.4%

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

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

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

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

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

    if -1.5499999999999998e-185 < l

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{1 \cdot \frac{1}{h \cdot \ell}}} \]
    6. Applied egg-rr39.6%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.55 \cdot 10^{-185}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 42.3% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -5.2 \cdot 10^{-185}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -5.2e-185) (/ d (- (sqrt (* l h)))) (* d (sqrt (/ 1.0 (* l h))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -5.2e-185) {
		tmp = d / -sqrt((l * h));
	} else {
		tmp = d * sqrt((1.0 / (l * h)));
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (l <= (-5.2d-185)) then
        tmp = d / -sqrt((l * h))
    else
        tmp = d * sqrt((1.0d0 / (l * h)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -5.2e-185) {
		tmp = d / -Math.sqrt((l * h));
	} else {
		tmp = d * Math.sqrt((1.0 / (l * h)));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if l <= -5.2e-185:
		tmp = d / -math.sqrt((l * h))
	else:
		tmp = d * math.sqrt((1.0 / (l * h)))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -5.2e-185)
		tmp = Float64(d / Float64(-sqrt(Float64(l * h))));
	else
		tmp = Float64(d * sqrt(Float64(1.0 / Float64(l * h))));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (l <= -5.2e-185)
		tmp = d / -sqrt((l * h));
	else
		tmp = d * sqrt((1.0 / (l * h)));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -5.2e-185], N[(d / (-N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5.2 \cdot 10^{-185}:\\
\;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\

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


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

    1. Initial program 57.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\left(h \cdot \ell + 1\right)}}} \]
      7. fma-define7.0%

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified7.0%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. sqrt-div7.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      2. metadata-eval7.0%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}} \]
      3. un-div-inv7.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      4. +-commutative7.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{fma}\left(h, \ell, 1\right) + -1}}} \]
      5. fma-undefine7.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(h \cdot \ell + 1\right)} + -1}} \]
      6. associate-+l+2.8%

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

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell + 0}}} \]
    11. Step-by-step derivation
      1. +-rgt-identity2.8%

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    13. 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. frac-times0.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. sqrt-div37.6%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\left(-\sqrt{\frac{d}{\ell}}\right) \cdot \left(-\sqrt{\frac{d}{\ell}}\right)}} \]
      8. sqrt-unprod0.6%

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\left(-\sqrt{\frac{d}{\ell}}\right)} \]
      10. distribute-rgt-neg-out3.8%

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

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

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

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

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

        \[\leadsto -\frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      16. neg-sub053.4%

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

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

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

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

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

    if -5.1999999999999997e-185 < l

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5.2 \cdot 10^{-185}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 42.3% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2.35 \cdot 10^{-185}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -2.35e-185) (/ d (- (sqrt (* l h)))) (* d (pow (* l h) -0.5))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -2.35e-185) {
		tmp = d / -sqrt((l * h));
	} else {
		tmp = d * pow((l * h), -0.5);
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (l <= (-2.35d-185)) then
        tmp = d / -sqrt((l * h))
    else
        tmp = d * ((l * h) ** (-0.5d0))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -2.35e-185) {
		tmp = d / -Math.sqrt((l * h));
	} else {
		tmp = d * Math.pow((l * h), -0.5);
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if l <= -2.35e-185:
		tmp = d / -math.sqrt((l * h))
	else:
		tmp = d * math.pow((l * h), -0.5)
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -2.35e-185)
		tmp = Float64(d / Float64(-sqrt(Float64(l * h))));
	else
		tmp = Float64(d * (Float64(l * h) ^ -0.5));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (l <= -2.35e-185)
		tmp = d / -sqrt((l * h));
	else
		tmp = d * ((l * h) ^ -0.5);
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -2.35e-185], N[(d / (-N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.35 \cdot 10^{-185}:\\
\;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\

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


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

    1. Initial program 57.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\left(h \cdot \ell + 1\right)}}} \]
      7. fma-define7.0%

        \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
    8. Simplified7.0%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    9. Step-by-step derivation
      1. sqrt-div7.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      2. metadata-eval7.0%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}} \]
      3. un-div-inv7.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
      4. +-commutative7.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{fma}\left(h, \ell, 1\right) + -1}}} \]
      5. fma-undefine7.0%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(h \cdot \ell + 1\right)} + -1}} \]
      6. associate-+l+2.8%

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

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell + 0}}} \]
    11. Step-by-step derivation
      1. +-rgt-identity2.8%

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    13. 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. frac-times0.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. sqrt-div37.6%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\left(-\sqrt{\frac{d}{\ell}}\right) \cdot \left(-\sqrt{\frac{d}{\ell}}\right)}} \]
      8. sqrt-unprod0.6%

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\left(-\sqrt{\frac{d}{\ell}}\right)} \]
      10. distribute-rgt-neg-out3.8%

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

        \[\leadsto -\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}} \]
      12. sqrt-div0.0%

        \[\leadsto -\frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \]
      13. frac-times0.0%

        \[\leadsto -\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      14. add-sqr-sqrt0.0%

        \[\leadsto -\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}} \]
      15. sqrt-prod53.4%

        \[\leadsto -\frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      16. neg-sub053.4%

        \[\leadsto \color{blue}{0 - \frac{d}{\sqrt{h \cdot \ell}}} \]
    14. Applied egg-rr53.4%

      \[\leadsto \color{blue}{0 - \frac{d}{\sqrt{h \cdot \ell}}} \]
    15. Step-by-step derivation
      1. neg-sub053.4%

        \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]
      2. distribute-frac-neg253.4%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]
    16. Simplified53.4%

      \[\leadsto \color{blue}{\frac{d}{-\sqrt{h \cdot \ell}}} \]

    if -2.3500000000000001e-185 < l

    1. Initial program 68.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. Simplified68.0%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 39.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-un-lft-identity39.6%

        \[\leadsto d \cdot \color{blue}{\left(1 \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. pow1/239.6%

        \[\leadsto d \cdot \left(1 \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right) \]
      3. inv-pow39.6%

        \[\leadsto d \cdot \left(1 \cdot {\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right) \]
      4. pow-pow38.7%

        \[\leadsto d \cdot \left(1 \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right) \]
      5. metadata-eval38.7%

        \[\leadsto d \cdot \left(1 \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right) \]
    6. Applied egg-rr38.7%

      \[\leadsto d \cdot \color{blue}{\left(1 \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    7. Step-by-step derivation
      1. *-lft-identity38.7%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Simplified38.7%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification43.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.35 \cdot 10^{-185}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 26.8% accurate, 3.1× speedup?

\[\begin{array}{l} \\ d \cdot {\left(\ell \cdot h\right)}^{-0.5} \end{array} \]
(FPCore (d h l M D) :precision binary64 (* d (pow (* l h) -0.5)))
double code(double d, double h, double l, double M, double D) {
	return d * pow((l * h), -0.5);
}
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 * ((l * h) ** (-0.5d0))
end function
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.pow((l * h), -0.5);
}
def code(d, h, l, M, D):
	return d * math.pow((l * h), -0.5)
function code(d, h, l, M, D)
	return Float64(d * (Float64(l * h) ^ -0.5))
end
function tmp = code(d, h, l, M, D)
	tmp = d * ((l * h) ^ -0.5);
end
code[d_, h_, l_, M_, D_] := N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
d \cdot {\left(\ell \cdot h\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 64.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. Simplified63.8%

    \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in d around inf 27.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  5. Step-by-step derivation
    1. *-un-lft-identity27.4%

      \[\leadsto d \cdot \color{blue}{\left(1 \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    2. pow1/227.4%

      \[\leadsto d \cdot \left(1 \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right) \]
    3. inv-pow27.4%

      \[\leadsto d \cdot \left(1 \cdot {\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right) \]
    4. pow-pow26.5%

      \[\leadsto d \cdot \left(1 \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right) \]
    5. metadata-eval26.5%

      \[\leadsto d \cdot \left(1 \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right) \]
  6. Applied egg-rr26.5%

    \[\leadsto d \cdot \color{blue}{\left(1 \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)} \]
  7. Step-by-step derivation
    1. *-lft-identity26.5%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  8. Simplified26.5%

    \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  9. Final simplification26.5%

    \[\leadsto d \cdot {\left(\ell \cdot h\right)}^{-0.5} \]
  10. Add Preprocessing

Alternative 21: 26.8% accurate, 3.2× speedup?

\[\begin{array}{l} \\ \frac{d}{\sqrt{\ell \cdot h}} \end{array} \]
(FPCore (d h l M D) :precision binary64 (/ d (sqrt (* l h))))
double code(double d, double h, double l, double M, double D) {
	return d / sqrt((l * h));
}
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
public static double code(double d, double h, double l, double M, double D) {
	return d / Math.sqrt((l * h));
}
def code(d, h, l, M, D):
	return d / math.sqrt((l * h))
function code(d, h, l, M, D)
	return Float64(d / sqrt(Float64(l * h)))
end
function tmp = code(d, h, l, M, D)
	tmp = d / sqrt((l * h));
end
code[d_, h_, l_, M_, D_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Derivation
  1. Initial program 64.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. Simplified63.8%

    \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in d around inf 27.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  5. Step-by-step derivation
    1. expm1-log1p-u26.8%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(h \cdot \ell\right)\right)}}} \]
    2. expm1-undefine22.3%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{e^{\mathsf{log1p}\left(h \cdot \ell\right)} - 1}}} \]
  6. Applied egg-rr22.3%

    \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{e^{\mathsf{log1p}\left(h \cdot \ell\right)} - 1}}} \]
  7. Step-by-step derivation
    1. sub-neg22.3%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{e^{\mathsf{log1p}\left(h \cdot \ell\right)} + \left(-1\right)}}} \]
    2. metadata-eval22.3%

      \[\leadsto d \cdot \sqrt{\frac{1}{e^{\mathsf{log1p}\left(h \cdot \ell\right)} + \color{blue}{-1}}} \]
    3. +-commutative22.3%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + e^{\mathsf{log1p}\left(h \cdot \ell\right)}}}} \]
    4. log1p-undefine22.3%

      \[\leadsto d \cdot \sqrt{\frac{1}{-1 + e^{\color{blue}{\log \left(1 + h \cdot \ell\right)}}}} \]
    5. rem-exp-log23.0%

      \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\left(1 + h \cdot \ell\right)}}} \]
    6. +-commutative23.0%

      \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\left(h \cdot \ell + 1\right)}}} \]
    7. fma-define23.0%

      \[\leadsto d \cdot \sqrt{\frac{1}{-1 + \color{blue}{\mathsf{fma}\left(h, \ell, 1\right)}}} \]
  8. Simplified23.0%

    \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
  9. Step-by-step derivation
    1. sqrt-div22.9%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    2. metadata-eval22.9%

      \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}} \]
    3. un-div-inv22.9%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{-1 + \mathsf{fma}\left(h, \ell, 1\right)}}} \]
    4. +-commutative22.9%

      \[\leadsto \frac{d}{\sqrt{\color{blue}{\mathsf{fma}\left(h, \ell, 1\right) + -1}}} \]
    5. fma-undefine22.9%

      \[\leadsto \frac{d}{\sqrt{\color{blue}{\left(h \cdot \ell + 1\right)} + -1}} \]
    6. associate-+l+26.5%

      \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell + \left(1 + -1\right)}}} \]
    7. metadata-eval26.5%

      \[\leadsto \frac{d}{\sqrt{h \cdot \ell + \color{blue}{0}}} \]
  10. Applied egg-rr26.5%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell + 0}}} \]
  11. Step-by-step derivation
    1. +-rgt-identity26.5%

      \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \]
  12. Simplified26.5%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  13. Final simplification26.5%

    \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
  14. Add Preprocessing

Reproduce

?
herbie shell --seed 2024137 
(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)))))