Henrywood and Agarwal, Equation (12)

Percentage Accurate: 67.8% → 80.0%
Time: 29.0s
Alternatives: 25
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 25 alternatives:

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

Initial Program: 67.8% accurate, 1.0× speedup?

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

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

Alternative 1: 80.0% accurate, 0.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -1.2999999999999999e-68

    1. Initial program 61.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.2999999999999999e-68 < h < -4.999999999999985e-310

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 77.4% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 65.8%

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 78.9% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 65.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 73.7% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 66.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.5000000000000003e-148 < l

    1. Initial program 73.6%

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

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

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

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

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

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

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

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

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

Alternative 5: 75.1% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 67.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.04999999999999998e-209 < l

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 73.7% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 66.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.1000000000000001e-148 < l

    1. Initial program 73.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 58.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -5.4 \cdot 10^{-211}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)\\ \mathbf{elif}\;\ell \leq 7.6 \cdot 10^{+104}:\\ \;\;\;\;\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}, 1\right) \cdot \frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -5.4e-211)
   (* (sqrt (/ d h)) (sqrt (/ d l)))
   (if (<= l -1e-310)
     (* d (log1p (expm1 (pow (* h l) -0.5))))
     (if (<= l 7.6e+104)
       (*
        (fma (/ h l) (* -0.5 (pow (* (/ M d) (/ D 2.0)) 2.0)) 1.0)
        (/ d (sqrt (* h l))))
       (/ d (* (sqrt h) (sqrt l)))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -5.4e-211) {
		tmp = sqrt((d / h)) * sqrt((d / l));
	} else if (l <= -1e-310) {
		tmp = d * log1p(expm1(pow((h * l), -0.5)));
	} else if (l <= 7.6e+104) {
		tmp = fma((h / l), (-0.5 * pow(((M / d) * (D / 2.0)), 2.0)), 1.0) * (d / sqrt((h * l)));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -5.4e-211)
		tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)));
	elseif (l <= -1e-310)
		tmp = Float64(d * log1p(expm1((Float64(h * l) ^ -0.5))));
	elseif (l <= 7.6e+104)
		tmp = Float64(fma(Float64(h / l), Float64(-0.5 * (Float64(Float64(M / d) * Float64(D / 2.0)) ^ 2.0)), 1.0) * Float64(d / sqrt(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, -5.4e-211], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1e-310], N[(d * N[Log[1 + N[(Exp[N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 7.6e+104], N[(N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(M / d), $MachinePrecision] * N[(D / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[Sqrt[N[(h * l), $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 -5.4 \cdot 10^{-211}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\

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

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

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


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

    1. Initial program 66.0%

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

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

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

    if -5.3999999999999998e-211 < l < -9.999999999999969e-311

    1. Initial program 65.1%

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Taylor expanded in d around 0 34.1%

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

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

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

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod33.9%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out33.9%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. distribute-rgt-neg-in33.9%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      7. metadata-eval33.9%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      8. exp-to-pow33.9%

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

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

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

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

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

    if -9.999999999999969e-311 < l < 7.59999999999999938e104

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.59999999999999938e104 < l

    1. Initial program 64.8%

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Taylor expanded in d around 0 56.3%

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

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

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

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod53.0%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out53.0%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. distribute-rgt-neg-in53.0%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      7. metadata-eval53.0%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      8. exp-to-pow56.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(d \cdot {\ell}^{-0.5}\right) \cdot \frac{\color{blue}{1}}{\sqrt{h}} \]
      9. un-div-inv72.4%

        \[\leadsto \color{blue}{\frac{d \cdot {\ell}^{-0.5}}{\sqrt{h}}} \]
      10. metadata-eval72.4%

        \[\leadsto \frac{d \cdot {\ell}^{\color{blue}{\left(-0.5\right)}}}{\sqrt{h}} \]
      11. pow-flip72.4%

        \[\leadsto \frac{d \cdot \color{blue}{\frac{1}{{\ell}^{0.5}}}}{\sqrt{h}} \]
      12. pow1/272.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5.4 \cdot 10^{-211}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)\\ \mathbf{elif}\;\ell \leq 7.6 \cdot 10^{+104}:\\ \;\;\;\;\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}, 1\right) \cdot \frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 8: 58.8% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 66.0%

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

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

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

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

    1. Initial program 65.1%

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Taylor expanded in d around 0 34.1%

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

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

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

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod33.9%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out33.9%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. distribute-rgt-neg-in33.9%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      7. metadata-eval33.9%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      8. exp-to-pow33.9%

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

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

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

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

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

    if -9.999999999999969e-311 < l < 9.5e104

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\color{blue}{\left(\frac{1 \cdot D}{\frac{d}{M} \cdot 2}\right)}}^{2}, 1\right) \cdot \frac{d}{\sqrt{\ell}}}{\sqrt{h}} \]
      8. *-un-lft-identity88.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.5e104 < l

    1. Initial program 64.8%

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Taylor expanded in d around 0 56.3%

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

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

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

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod53.0%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out53.0%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. distribute-rgt-neg-in53.0%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      7. metadata-eval53.0%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      8. exp-to-pow56.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(d \cdot {\ell}^{-0.5}\right) \cdot \frac{\color{blue}{1}}{\sqrt{h}} \]
      9. un-div-inv72.4%

        \[\leadsto \color{blue}{\frac{d \cdot {\ell}^{-0.5}}{\sqrt{h}}} \]
      10. metadata-eval72.4%

        \[\leadsto \frac{d \cdot {\ell}^{\color{blue}{\left(-0.5\right)}}}{\sqrt{h}} \]
      11. pow-flip72.4%

        \[\leadsto \frac{d \cdot \color{blue}{\frac{1}{{\ell}^{0.5}}}}{\sqrt{h}} \]
      12. pow1/272.4%

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

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

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

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

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

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

Alternative 9: 61.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.5 \cdot 10^{-210}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\

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

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


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

    1. Initial program 66.0%

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

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

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

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

    1. Initial program 65.1%

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Taylor expanded in d around 0 34.1%

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

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

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

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod33.9%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out33.9%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. distribute-rgt-neg-in33.9%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      7. metadata-eval33.9%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      8. exp-to-pow33.9%

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

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

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

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

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

    if -9.999999999999969e-311 < l

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 61.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.9 \cdot 10^{-210}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\

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

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


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

    1. Initial program 66.0%

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

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

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

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

    1. Initial program 65.1%

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Taylor expanded in d around 0 34.1%

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

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

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

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod33.9%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out33.9%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. distribute-rgt-neg-in33.9%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      7. metadata-eval33.9%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      8. exp-to-pow33.9%

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

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

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

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

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

    if -9.999999999999969e-311 < l

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 73.9% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 65.8%

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 73.9% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 65.8%

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 74.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 65.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 74.6% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 65.8%

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

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

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

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

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

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

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

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

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

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

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

    if 1.16e-307 < l

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 46.6% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -6 \cdot 10^{-211}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -6e-211)
   (* (sqrt (/ d h)) (sqrt (/ d l)))
   (if (<= l -1e-310)
     (* d (log1p (expm1 (pow (* h l) -0.5))))
     (* d (/ (pow l -0.5) (sqrt h))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -6e-211) {
		tmp = sqrt((d / h)) * sqrt((d / l));
	} else if (l <= -1e-310) {
		tmp = d * log1p(expm1(pow((h * l), -0.5)));
	} else {
		tmp = d * (pow(l, -0.5) / sqrt(h));
	}
	return tmp;
}
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -6e-211) {
		tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
	} else if (l <= -1e-310) {
		tmp = d * Math.log1p(Math.expm1(Math.pow((h * l), -0.5)));
	} else {
		tmp = d * (Math.pow(l, -0.5) / Math.sqrt(h));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if l <= -6e-211:
		tmp = math.sqrt((d / h)) * math.sqrt((d / l))
	elif l <= -1e-310:
		tmp = d * math.log1p(math.expm1(math.pow((h * l), -0.5)))
	else:
		tmp = d * (math.pow(l, -0.5) / math.sqrt(h))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -6e-211)
		tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)));
	elseif (l <= -1e-310)
		tmp = Float64(d * log1p(expm1((Float64(h * l) ^ -0.5))));
	else
		tmp = Float64(d * Float64((l ^ -0.5) / sqrt(h)));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -6e-211], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1e-310], N[(d * N[Log[1 + N[(Exp[N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6 \cdot 10^{-211}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\

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

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


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

    1. Initial program 66.0%

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

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

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

    if -6.00000000000000009e-211 < l < -9.999999999999969e-311

    1. Initial program 65.1%

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Taylor expanded in d around 0 34.1%

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

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

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

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod33.9%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out33.9%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. distribute-rgt-neg-in33.9%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      7. metadata-eval33.9%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      8. exp-to-pow33.9%

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

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

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

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

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

    if -9.999999999999969e-311 < l

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\frac{{\ell}^{-0.5}}{\sqrt{h}}} \]
    9. Simplified62.1%

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

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

Alternative 16: 38.8% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.6 \cdot 10^{-210}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\\

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

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


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

    1. Initial program 66.0%

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Taylor expanded in d around 0 7.9%

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

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      2. rem-exp-log7.9%

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

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod7.9%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out7.9%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. distribute-rgt-neg-in7.9%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      7. metadata-eval7.9%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      8. exp-to-pow7.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\left(\left({\ell}^{-0.5} \cdot {h}^{\color{blue}{-0.5}}\right) \cdot d\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      12. unpow-prod-down0.0%

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 65.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      7. pow-prod-down40.9%

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

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

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

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

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

    if -9.999999999999969e-311 < l

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\frac{{\ell}^{-0.5}}{\sqrt{h}}} \]
    9. Simplified62.1%

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

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

Alternative 17: 45.4% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2 \cdot 10^{-210}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\

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

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


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

    1. Initial program 66.0%

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

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

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

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

    1. Initial program 65.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      7. pow-prod-down40.9%

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

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

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

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

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

    if -9.999999999999969e-311 < l

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\frac{{\ell}^{-0.5}}{\sqrt{h}}} \]
    9. Simplified62.1%

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

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

Alternative 18: 36.6% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -9 \cdot 10^{-246}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq 2.6 \cdot 10^{-148}:\\ \;\;\;\;d \cdot \sqrt{\left(1 + \frac{\frac{1}{\ell}}{h}\right) + -1}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -9e-246)
   (sqrt (/ (pow d 2.0) (* h l)))
   (if (<= l 2.6e-148)
     (* d (sqrt (+ (+ 1.0 (/ (/ 1.0 l) h)) -1.0)))
     (* d (/ (pow l -0.5) (sqrt h))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -9e-246) {
		tmp = sqrt((pow(d, 2.0) / (h * l)));
	} else if (l <= 2.6e-148) {
		tmp = d * sqrt(((1.0 + ((1.0 / l) / h)) + -1.0));
	} else {
		tmp = d * (pow(l, -0.5) / sqrt(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 <= (-9d-246)) then
        tmp = sqrt(((d ** 2.0d0) / (h * l)))
    else if (l <= 2.6d-148) then
        tmp = d * sqrt(((1.0d0 + ((1.0d0 / l) / h)) + (-1.0d0)))
    else
        tmp = d * ((l ** (-0.5d0)) / sqrt(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 <= -9e-246) {
		tmp = Math.sqrt((Math.pow(d, 2.0) / (h * l)));
	} else if (l <= 2.6e-148) {
		tmp = d * Math.sqrt(((1.0 + ((1.0 / l) / h)) + -1.0));
	} else {
		tmp = d * (Math.pow(l, -0.5) / Math.sqrt(h));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if l <= -9e-246:
		tmp = math.sqrt((math.pow(d, 2.0) / (h * l)))
	elif l <= 2.6e-148:
		tmp = d * math.sqrt(((1.0 + ((1.0 / l) / h)) + -1.0))
	else:
		tmp = d * (math.pow(l, -0.5) / math.sqrt(h))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -9e-246)
		tmp = sqrt(Float64((d ^ 2.0) / Float64(h * l)));
	elseif (l <= 2.6e-148)
		tmp = Float64(d * sqrt(Float64(Float64(1.0 + Float64(Float64(1.0 / l) / h)) + -1.0)));
	else
		tmp = Float64(d * Float64((l ^ -0.5) / sqrt(h)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (l <= -9e-246)
		tmp = sqrt(((d ^ 2.0) / (h * l)));
	elseif (l <= 2.6e-148)
		tmp = d * sqrt(((1.0 + ((1.0 / l) / h)) + -1.0));
	else
		tmp = d * ((l ^ -0.5) / sqrt(h));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -9e-246], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, 2.6e-148], N[(d * N[Sqrt[N[(N[(1.0 + N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -9 \cdot 10^{-246}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\\

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

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


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

    1. Initial program 65.9%

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Taylor expanded in d around 0 8.3%

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

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      2. rem-exp-log8.3%

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

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod8.3%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out8.3%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. distribute-rgt-neg-in8.3%

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

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      8. exp-to-pow8.3%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)}} \]
      8. *-commutative0.0%

        \[\leadsto \sqrt{\color{blue}{\left(\left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right) \cdot d\right)} \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      9. inv-pow0.0%

        \[\leadsto \sqrt{\left(\left({\ell}^{-0.5} \cdot \sqrt{\color{blue}{{h}^{-1}}}\right) \cdot d\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      10. sqrt-pow10.0%

        \[\leadsto \sqrt{\left(\left({\ell}^{-0.5} \cdot \color{blue}{{h}^{\left(\frac{-1}{2}\right)}}\right) \cdot d\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      11. metadata-eval0.0%

        \[\leadsto \sqrt{\left(\left({\ell}^{-0.5} \cdot {h}^{\color{blue}{-0.5}}\right) \cdot d\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      12. unpow-prod-down0.0%

        \[\leadsto \sqrt{\left(\color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \cdot d\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      13. *-commutative0.0%

        \[\leadsto \sqrt{\left({\color{blue}{\left(h \cdot \ell\right)}}^{-0.5} \cdot d\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      14. metadata-eval0.0%

        \[\leadsto \sqrt{\left({\left(h \cdot \ell\right)}^{\color{blue}{\left(\frac{-1}{2}\right)}} \cdot d\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      15. sqrt-pow10.0%

        \[\leadsto \sqrt{\left(\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-1}}} \cdot d\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      16. inv-pow0.0%

        \[\leadsto \sqrt{\left(\sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \cdot d\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      17. *-commutative0.0%

        \[\leadsto \sqrt{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot d\right) \cdot \color{blue}{\left(\left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right) \cdot d\right)}} \]
    10. Applied egg-rr32.0%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h} \cdot {d}^{2}}} \]
    11. Step-by-step derivation
      1. associate-*l/32.0%

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot {d}^{2}}{\ell \cdot h}}} \]
      2. *-lft-identity32.0%

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{\ell \cdot h}} \]
      3. *-commutative32.0%

        \[\leadsto \sqrt{\frac{{d}^{2}}{\color{blue}{h \cdot \ell}}} \]
    12. Simplified32.0%

      \[\leadsto \color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}}} \]

    if -8.99999999999999998e-246 < l < 2.60000000000000008e-148

    1. Initial program 69.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified69.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Taylor expanded in d around inf 49.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative49.6%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*49.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified49.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u48.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{1}{\ell}}{h}\right)\right)}} \]
      2. expm1-udef49.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{\ell}}{h}\right)} - 1}} \]
      3. associate-/l/49.0%

        \[\leadsto d \cdot \sqrt{e^{\mathsf{log1p}\left(\color{blue}{\frac{1}{h \cdot \ell}}\right)} - 1} \]
    7. Applied egg-rr49.0%

      \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1}} \]
    8. Taylor expanded in h around inf 49.6%

      \[\leadsto d \cdot \sqrt{\color{blue}{\left(1 + \frac{1}{h \cdot \ell}\right)} - 1} \]
    9. Step-by-step derivation
      1. *-commutative49.6%

        \[\leadsto d \cdot \sqrt{\left(1 + \frac{1}{\color{blue}{\ell \cdot h}}\right) - 1} \]
      2. associate-/r*49.6%

        \[\leadsto d \cdot \sqrt{\left(1 + \color{blue}{\frac{\frac{1}{\ell}}{h}}\right) - 1} \]
    10. Simplified49.6%

      \[\leadsto d \cdot \sqrt{\color{blue}{\left(1 + \frac{\frac{1}{\ell}}{h}\right)} - 1} \]

    if 2.60000000000000008e-148 < l

    1. Initial program 73.6%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified74.5%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Taylor expanded in d around inf 55.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative55.2%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*56.2%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified56.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u54.7%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\right)} \]
      2. expm1-udef26.1%

        \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{\frac{1}{\ell}}{h}}\right)} - 1\right)} \]
      3. sqrt-div27.9%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}}\right)} - 1\right) \]
      4. inv-pow27.9%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{{\ell}^{-1}}}}{\sqrt{h}}\right)} - 1\right) \]
      5. sqrt-pow127.9%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{{\ell}^{\left(\frac{-1}{2}\right)}}}{\sqrt{h}}\right)} - 1\right) \]
      6. metadata-eval27.9%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\frac{{\ell}^{\color{blue}{-0.5}}}{\sqrt{h}}\right)} - 1\right) \]
    7. Applied egg-rr27.9%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{{\ell}^{-0.5}}{\sqrt{h}}\right)} - 1\right)} \]
    8. Step-by-step derivation
      1. expm1-def63.6%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{\ell}^{-0.5}}{\sqrt{h}}\right)\right)} \]
      2. expm1-log1p65.2%

        \[\leadsto d \cdot \color{blue}{\frac{{\ell}^{-0.5}}{\sqrt{h}}} \]
    9. Simplified65.2%

      \[\leadsto d \cdot \color{blue}{\frac{{\ell}^{-0.5}}{\sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification47.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9 \cdot 10^{-246}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq 2.6 \cdot 10^{-148}:\\ \;\;\;\;d \cdot \sqrt{\left(1 + \frac{\frac{1}{\ell}}{h}\right) + -1}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\ \end{array} \]

Alternative 19: 36.5% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -3.75 \cdot 10^{-246}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq 2.2 \cdot 10^{-134}:\\ \;\;\;\;d \cdot \sqrt{\left(1 + \frac{\frac{1}{\ell}}{h}\right) + -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -3.75e-246)
   (sqrt (/ (pow d 2.0) (* h l)))
   (if (<= l 2.2e-134)
     (* d (sqrt (+ (+ 1.0 (/ (/ 1.0 l) h)) -1.0)))
     (/ d (* (sqrt h) (sqrt l))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -3.75e-246) {
		tmp = sqrt((pow(d, 2.0) / (h * l)));
	} else if (l <= 2.2e-134) {
		tmp = d * sqrt(((1.0 + ((1.0 / l) / h)) + -1.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) :: tmp
    if (l <= (-3.75d-246)) then
        tmp = sqrt(((d ** 2.0d0) / (h * l)))
    else if (l <= 2.2d-134) then
        tmp = d * sqrt(((1.0d0 + ((1.0d0 / l) / h)) + (-1.0d0)))
    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 <= -3.75e-246) {
		tmp = Math.sqrt((Math.pow(d, 2.0) / (h * l)));
	} else if (l <= 2.2e-134) {
		tmp = d * Math.sqrt(((1.0 + ((1.0 / l) / h)) + -1.0));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if l <= -3.75e-246:
		tmp = math.sqrt((math.pow(d, 2.0) / (h * l)))
	elif l <= 2.2e-134:
		tmp = d * math.sqrt(((1.0 + ((1.0 / l) / h)) + -1.0))
	else:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -3.75e-246)
		tmp = sqrt(Float64((d ^ 2.0) / Float64(h * l)));
	elseif (l <= 2.2e-134)
		tmp = Float64(d * sqrt(Float64(Float64(1.0 + Float64(Float64(1.0 / l) / h)) + -1.0)));
	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 <= -3.75e-246)
		tmp = sqrt(((d ^ 2.0) / (h * l)));
	elseif (l <= 2.2e-134)
		tmp = d * sqrt(((1.0 + ((1.0 / l) / h)) + -1.0));
	else
		tmp = d / (sqrt(h) * sqrt(l));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -3.75e-246], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, 2.2e-134], N[(d * N[Sqrt[N[(N[(1.0 + N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision] + -1.0), $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 -3.75 \cdot 10^{-246}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\\

\mathbf{elif}\;\ell \leq 2.2 \cdot 10^{-134}:\\
\;\;\;\;d \cdot \sqrt{\left(1 + \frac{\frac{1}{\ell}}{h}\right) + -1}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -3.75000000000000025e-246

    1. Initial program 65.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified65.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Taylor expanded in d around inf 8.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative8.3%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*8.3%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified8.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Taylor expanded in d around 0 8.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. unpow1/28.3%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      2. rem-exp-log8.3%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      3. exp-neg8.3%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod8.3%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out8.3%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. distribute-rgt-neg-in8.3%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      7. metadata-eval8.3%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      8. exp-to-pow8.3%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Simplified8.3%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative8.3%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down0.0%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
      3. metadata-eval0.0%

        \[\leadsto d \cdot \left({\ell}^{-0.5} \cdot {h}^{\color{blue}{\left(\frac{-1}{2}\right)}}\right) \]
      4. sqrt-pow10.0%

        \[\leadsto d \cdot \left({\ell}^{-0.5} \cdot \color{blue}{\sqrt{{h}^{-1}}}\right) \]
      5. inv-pow0.0%

        \[\leadsto d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\color{blue}{\frac{1}{h}}}\right) \]
      6. add-sqr-sqrt0.0%

        \[\leadsto \color{blue}{\sqrt{d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)} \cdot \sqrt{d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)}} \]
      7. sqrt-unprod0.0%

        \[\leadsto \color{blue}{\sqrt{\left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)}} \]
      8. *-commutative0.0%

        \[\leadsto \sqrt{\color{blue}{\left(\left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right) \cdot d\right)} \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      9. inv-pow0.0%

        \[\leadsto \sqrt{\left(\left({\ell}^{-0.5} \cdot \sqrt{\color{blue}{{h}^{-1}}}\right) \cdot d\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      10. sqrt-pow10.0%

        \[\leadsto \sqrt{\left(\left({\ell}^{-0.5} \cdot \color{blue}{{h}^{\left(\frac{-1}{2}\right)}}\right) \cdot d\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      11. metadata-eval0.0%

        \[\leadsto \sqrt{\left(\left({\ell}^{-0.5} \cdot {h}^{\color{blue}{-0.5}}\right) \cdot d\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      12. unpow-prod-down0.0%

        \[\leadsto \sqrt{\left(\color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \cdot d\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      13. *-commutative0.0%

        \[\leadsto \sqrt{\left({\color{blue}{\left(h \cdot \ell\right)}}^{-0.5} \cdot d\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      14. metadata-eval0.0%

        \[\leadsto \sqrt{\left({\left(h \cdot \ell\right)}^{\color{blue}{\left(\frac{-1}{2}\right)}} \cdot d\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      15. sqrt-pow10.0%

        \[\leadsto \sqrt{\left(\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-1}}} \cdot d\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      16. inv-pow0.0%

        \[\leadsto \sqrt{\left(\sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \cdot d\right) \cdot \left(d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\right)} \]
      17. *-commutative0.0%

        \[\leadsto \sqrt{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot d\right) \cdot \color{blue}{\left(\left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right) \cdot d\right)}} \]
    10. Applied egg-rr32.0%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h} \cdot {d}^{2}}} \]
    11. Step-by-step derivation
      1. associate-*l/32.0%

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot {d}^{2}}{\ell \cdot h}}} \]
      2. *-lft-identity32.0%

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{\ell \cdot h}} \]
      3. *-commutative32.0%

        \[\leadsto \sqrt{\frac{{d}^{2}}{\color{blue}{h \cdot \ell}}} \]
    12. Simplified32.0%

      \[\leadsto \color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}}} \]

    if -3.75000000000000025e-246 < l < 2.2e-134

    1. Initial program 69.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified69.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Taylor expanded in d around inf 51.7%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative51.7%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*51.7%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified51.7%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u50.7%

        \[\leadsto d \cdot \sqrt{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{1}{\ell}}{h}\right)\right)}} \]
      2. expm1-udef50.7%

        \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{\ell}}{h}\right)} - 1}} \]
      3. associate-/l/50.7%

        \[\leadsto d \cdot \sqrt{e^{\mathsf{log1p}\left(\color{blue}{\frac{1}{h \cdot \ell}}\right)} - 1} \]
    7. Applied egg-rr50.7%

      \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1}} \]
    8. Taylor expanded in h around inf 51.8%

      \[\leadsto d \cdot \sqrt{\color{blue}{\left(1 + \frac{1}{h \cdot \ell}\right)} - 1} \]
    9. Step-by-step derivation
      1. *-commutative51.8%

        \[\leadsto d \cdot \sqrt{\left(1 + \frac{1}{\color{blue}{\ell \cdot h}}\right) - 1} \]
      2. associate-/r*51.8%

        \[\leadsto d \cdot \sqrt{\left(1 + \color{blue}{\frac{\frac{1}{\ell}}{h}}\right) - 1} \]
    10. Simplified51.8%

      \[\leadsto d \cdot \sqrt{\color{blue}{\left(1 + \frac{\frac{1}{\ell}}{h}\right)} - 1} \]

    if 2.2e-134 < l

    1. Initial program 73.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified74.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Taylor expanded in d around inf 54.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative54.4%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*55.5%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified55.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Taylor expanded in d around 0 54.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. unpow1/254.4%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      2. rem-exp-log50.9%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      3. exp-neg50.9%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod50.9%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out50.9%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. distribute-rgt-neg-in50.9%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      7. metadata-eval50.9%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      8. exp-to-pow54.4%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Simplified54.4%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative54.4%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down64.7%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
      3. metadata-eval64.7%

        \[\leadsto d \cdot \left({\ell}^{-0.5} \cdot {h}^{\color{blue}{\left(\frac{-1}{2}\right)}}\right) \]
      4. sqrt-pow164.7%

        \[\leadsto d \cdot \left({\ell}^{-0.5} \cdot \color{blue}{\sqrt{{h}^{-1}}}\right) \]
      5. inv-pow64.7%

        \[\leadsto d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\color{blue}{\frac{1}{h}}}\right) \]
      6. associate-*r*63.8%

        \[\leadsto \color{blue}{\left(d \cdot {\ell}^{-0.5}\right) \cdot \sqrt{\frac{1}{h}}} \]
      7. sqrt-div63.8%

        \[\leadsto \left(d \cdot {\ell}^{-0.5}\right) \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h}}} \]
      8. metadata-eval63.8%

        \[\leadsto \left(d \cdot {\ell}^{-0.5}\right) \cdot \frac{\color{blue}{1}}{\sqrt{h}} \]
      9. un-div-inv63.8%

        \[\leadsto \color{blue}{\frac{d \cdot {\ell}^{-0.5}}{\sqrt{h}}} \]
      10. metadata-eval63.8%

        \[\leadsto \frac{d \cdot {\ell}^{\color{blue}{\left(-0.5\right)}}}{\sqrt{h}} \]
      11. pow-flip63.8%

        \[\leadsto \frac{d \cdot \color{blue}{\frac{1}{{\ell}^{0.5}}}}{\sqrt{h}} \]
      12. pow1/263.8%

        \[\leadsto \frac{d \cdot \frac{1}{\color{blue}{\sqrt{\ell}}}}{\sqrt{h}} \]
      13. div-inv63.8%

        \[\leadsto \frac{\color{blue}{\frac{d}{\sqrt{\ell}}}}{\sqrt{h}} \]
    10. Applied egg-rr63.8%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    11. Step-by-step derivation
      1. associate-/l/64.8%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    12. Simplified64.8%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification47.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.75 \cdot 10^{-246}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq 2.2 \cdot 10^{-134}:\\ \;\;\;\;d \cdot \sqrt{\left(1 + \frac{\frac{1}{\ell}}{h}\right) + -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 20: 29.5% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;h \leq 1.25 \cdot 10^{-264}:\\ \;\;\;\;d \cdot \sqrt{\left(1 + \frac{\frac{1}{\ell}}{h}\right) + -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= h 1.25e-264)
   (* d (sqrt (+ (+ 1.0 (/ (/ 1.0 l) h)) -1.0)))
   (/ d (* (sqrt h) (sqrt l)))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= 1.25e-264) {
		tmp = d * sqrt(((1.0 + ((1.0 / l) / h)) + -1.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) :: tmp
    if (h <= 1.25d-264) then
        tmp = d * sqrt(((1.0d0 + ((1.0d0 / l) / h)) + (-1.0d0)))
    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 (h <= 1.25e-264) {
		tmp = d * Math.sqrt(((1.0 + ((1.0 / l) / h)) + -1.0));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if h <= 1.25e-264:
		tmp = d * math.sqrt(((1.0 + ((1.0 / l) / h)) + -1.0))
	else:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (h <= 1.25e-264)
		tmp = Float64(d * sqrt(Float64(Float64(1.0 + Float64(Float64(1.0 / l) / h)) + -1.0)));
	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 (h <= 1.25e-264)
		tmp = d * sqrt(((1.0 + ((1.0 / l) / h)) + -1.0));
	else
		tmp = d / (sqrt(h) * sqrt(l));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[h, 1.25e-264], N[(d * N[Sqrt[N[(N[(1.0 + N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;h \leq 1.25 \cdot 10^{-264}:\\
\;\;\;\;d \cdot \sqrt{\left(1 + \frac{\frac{1}{\ell}}{h}\right) + -1}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if h < 1.25e-264

    1. Initial program 65.5%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified65.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Taylor expanded in d around inf 16.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative16.5%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*16.5%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified16.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u16.3%

        \[\leadsto d \cdot \sqrt{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{1}{\ell}}{h}\right)\right)}} \]
      2. expm1-udef16.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{\ell}}{h}\right)} - 1}} \]
      3. associate-/l/16.4%

        \[\leadsto d \cdot \sqrt{e^{\mathsf{log1p}\left(\color{blue}{\frac{1}{h \cdot \ell}}\right)} - 1} \]
    7. Applied egg-rr16.4%

      \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1}} \]
    8. Taylor expanded in h around inf 16.6%

      \[\leadsto d \cdot \sqrt{\color{blue}{\left(1 + \frac{1}{h \cdot \ell}\right)} - 1} \]
    9. Step-by-step derivation
      1. *-commutative16.6%

        \[\leadsto d \cdot \sqrt{\left(1 + \frac{1}{\color{blue}{\ell \cdot h}}\right) - 1} \]
      2. associate-/r*16.6%

        \[\leadsto d \cdot \sqrt{\left(1 + \color{blue}{\frac{\frac{1}{\ell}}{h}}\right) - 1} \]
    10. Simplified16.6%

      \[\leadsto d \cdot \sqrt{\color{blue}{\left(1 + \frac{\frac{1}{\ell}}{h}\right)} - 1} \]

    if 1.25e-264 < h

    1. Initial program 73.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified74.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Taylor expanded in d around inf 53.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    4. Step-by-step derivation
      1. *-commutative53.1%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*54.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified54.0%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Taylor expanded in d around 0 53.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. unpow1/253.1%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      2. rem-exp-log50.2%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      3. exp-neg50.2%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod50.2%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out50.2%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. distribute-rgt-neg-in50.2%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      7. metadata-eval50.2%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      8. exp-to-pow53.1%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Simplified53.1%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative53.1%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down61.5%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
      3. metadata-eval61.5%

        \[\leadsto d \cdot \left({\ell}^{-0.5} \cdot {h}^{\color{blue}{\left(\frac{-1}{2}\right)}}\right) \]
      4. sqrt-pow161.4%

        \[\leadsto d \cdot \left({\ell}^{-0.5} \cdot \color{blue}{\sqrt{{h}^{-1}}}\right) \]
      5. inv-pow61.4%

        \[\leadsto d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\color{blue}{\frac{1}{h}}}\right) \]
      6. associate-*r*58.4%

        \[\leadsto \color{blue}{\left(d \cdot {\ell}^{-0.5}\right) \cdot \sqrt{\frac{1}{h}}} \]
      7. sqrt-div58.4%

        \[\leadsto \left(d \cdot {\ell}^{-0.5}\right) \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h}}} \]
      8. metadata-eval58.4%

        \[\leadsto \left(d \cdot {\ell}^{-0.5}\right) \cdot \frac{\color{blue}{1}}{\sqrt{h}} \]
      9. un-div-inv58.4%

        \[\leadsto \color{blue}{\frac{d \cdot {\ell}^{-0.5}}{\sqrt{h}}} \]
      10. metadata-eval58.4%

        \[\leadsto \frac{d \cdot {\ell}^{\color{blue}{\left(-0.5\right)}}}{\sqrt{h}} \]
      11. pow-flip58.4%

        \[\leadsto \frac{d \cdot \color{blue}{\frac{1}{{\ell}^{0.5}}}}{\sqrt{h}} \]
      12. pow1/258.4%

        \[\leadsto \frac{d \cdot \frac{1}{\color{blue}{\sqrt{\ell}}}}{\sqrt{h}} \]
      13. div-inv58.5%

        \[\leadsto \frac{\color{blue}{\frac{d}{\sqrt{\ell}}}}{\sqrt{h}} \]
    10. Applied egg-rr58.5%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    11. Step-by-step derivation
      1. associate-/l/61.6%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    12. Simplified61.6%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification37.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq 1.25 \cdot 10^{-264}:\\ \;\;\;\;d \cdot \sqrt{\left(1 + \frac{\frac{1}{\ell}}{h}\right) + -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]

Alternative 21: 26.5% accurate, 3.1× speedup?

\[\begin{array}{l} \\ d \cdot \sqrt{\frac{1}{h \cdot \ell}} \end{array} \]
(FPCore (d h l M D) :precision binary64 (* d (sqrt (/ 1.0 (* h l)))))
double code(double d, double h, double l, double M, double D) {
	return d * sqrt((1.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 * sqrt((1.0d0 / (h * l)))
end function
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.sqrt((1.0 / (h * l)));
}
def code(d, h, l, M, D):
	return d * math.sqrt((1.0 / (h * l)))
function code(d, h, l, M, D)
	return Float64(d * sqrt(Float64(1.0 / Float64(h * l))))
end
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt((1.0 / (h * l)));
end
code[d_, h_, l_, M_, D_] := N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
d \cdot \sqrt{\frac{1}{h \cdot \ell}}
\end{array}
Derivation
  1. Initial program 69.4%

    \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  2. Simplified69.8%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Taylor expanded in d around inf 33.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  4. Final simplification33.4%

    \[\leadsto d \cdot \sqrt{\frac{1}{h \cdot \ell}} \]

Alternative 22: 26.6% accurate, 3.1× speedup?

\[\begin{array}{l} \\ d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}} \end{array} \]
(FPCore (d h l M D) :precision binary64 (* d (sqrt (/ (/ 1.0 h) l))))
double code(double d, double h, double l, double M, double D) {
	return d * sqrt(((1.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 * sqrt(((1.0d0 / h) / l))
end function
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.sqrt(((1.0 / h) / l));
}
def code(d, h, l, M, D):
	return d * math.sqrt(((1.0 / h) / l))
function code(d, h, l, M, D)
	return Float64(d * sqrt(Float64(Float64(1.0 / h) / l)))
end
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt(((1.0 / h) / l));
end
code[d_, h_, l_, M_, D_] := N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}
\end{array}
Derivation
  1. Initial program 69.4%

    \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  2. Simplified69.8%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Taylor expanded in d around inf 33.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  4. Step-by-step derivation
    1. *-commutative33.4%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    2. associate-/r*33.8%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
  5. Simplified33.8%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
  6. Taylor expanded in d around 0 33.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  7. Step-by-step derivation
    1. associate-/r*33.7%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
  8. Simplified33.7%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  9. Final simplification33.7%

    \[\leadsto d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}} \]

Alternative 23: 26.6% accurate, 3.1× speedup?

\[\begin{array}{l} \\ d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}} \end{array} \]
(FPCore (d h l M D) :precision binary64 (* d (sqrt (/ (/ 1.0 l) h))))
double code(double d, double h, double l, double M, double D) {
	return d * sqrt(((1.0 / 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(((1.0d0 / l) / h))
end function
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.sqrt(((1.0 / l) / h));
}
def code(d, h, l, M, D):
	return d * math.sqrt(((1.0 / l) / h))
function code(d, h, l, M, D)
	return Float64(d * sqrt(Float64(Float64(1.0 / l) / h)))
end
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt(((1.0 / l) / h));
end
code[d_, h_, l_, M_, D_] := N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}
\end{array}
Derivation
  1. Initial program 69.4%

    \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  2. Simplified69.8%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Taylor expanded in d around inf 33.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  4. Step-by-step derivation
    1. *-commutative33.4%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    2. associate-/r*33.8%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
  5. Simplified33.8%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
  6. Final simplification33.8%

    \[\leadsto d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}} \]

Alternative 24: 26.4% accurate, 3.1× speedup?

\[\begin{array}{l} \\ d \cdot {\left(h \cdot \ell\right)}^{-0.5} \end{array} \]
(FPCore (d h l M D) :precision binary64 (* d (pow (* h l) -0.5)))
double code(double d, double h, double l, double M, double D) {
	return d * pow((h * l), -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 * ((h * l) ** (-0.5d0))
end function
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.pow((h * l), -0.5);
}
def code(d, h, l, M, D):
	return d * math.pow((h * l), -0.5)
function code(d, h, l, M, D)
	return Float64(d * (Float64(h * l) ^ -0.5))
end
function tmp = code(d, h, l, M, D)
	tmp = d * ((h * l) ^ -0.5);
end
code[d_, h_, l_, M_, D_] := N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
d \cdot {\left(h \cdot \ell\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 69.4%

    \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  2. Simplified69.8%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Taylor expanded in d around inf 33.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  4. Step-by-step derivation
    1. *-commutative33.4%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    2. associate-/r*33.8%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
  5. Simplified33.8%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
  6. Taylor expanded in d around 0 33.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  7. Step-by-step derivation
    1. unpow1/233.4%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    2. rem-exp-log31.9%

      \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
    3. exp-neg31.9%

      \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
    4. exp-prod31.9%

      \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
    5. distribute-lft-neg-out31.9%

      \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
    6. distribute-rgt-neg-in31.9%

      \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
    7. metadata-eval31.9%

      \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
    8. exp-to-pow33.3%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  8. Simplified33.3%

    \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
  9. Final simplification33.3%

    \[\leadsto d \cdot {\left(h \cdot \ell\right)}^{-0.5} \]

Alternative 25: 4.5% accurate, 3.2× speedup?

\[\begin{array}{l} \\ d \cdot \sqrt{0} \end{array} \]
(FPCore (d h l M D) :precision binary64 (* d (sqrt 0.0)))
double code(double d, double h, double l, double M, double D) {
	return d * sqrt(0.0);
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    code = d * sqrt(0.0d0)
end function
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.sqrt(0.0);
}
def code(d, h, l, M, D):
	return d * math.sqrt(0.0)
function code(d, h, l, M, D)
	return Float64(d * sqrt(0.0))
end
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt(0.0);
end
code[d_, h_, l_, M_, D_] := N[(d * N[Sqrt[0.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
d \cdot \sqrt{0}
\end{array}
Derivation
  1. Initial program 69.4%

    \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  2. Simplified69.8%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Taylor expanded in d around inf 33.4%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  4. Step-by-step derivation
    1. *-commutative33.4%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    2. associate-/r*33.8%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
  5. Simplified33.8%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
  6. Step-by-step derivation
    1. expm1-log1p-u33.1%

      \[\leadsto d \cdot \sqrt{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{1}{\ell}}{h}\right)\right)}} \]
    2. expm1-udef22.1%

      \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{\ell}}{h}\right)} - 1}} \]
    3. associate-/l/22.1%

      \[\leadsto d \cdot \sqrt{e^{\mathsf{log1p}\left(\color{blue}{\frac{1}{h \cdot \ell}}\right)} - 1} \]
  7. Applied egg-rr22.1%

    \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1}} \]
  8. Taylor expanded in h around inf 4.5%

    \[\leadsto d \cdot \sqrt{\color{blue}{1} - 1} \]
  9. Final simplification4.5%

    \[\leadsto d \cdot \sqrt{0} \]

Reproduce

?
herbie shell --seed 2023318 
(FPCore (d h l M D)
  :name "Henrywood and Agarwal, Equation (12)"
  :precision binary64
  (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))