Henrywood and Agarwal, Equation (12)

Percentage Accurate: 65.7% → 76.5%
Time: 34.1s
Alternatives: 21
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 21 alternatives:

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

Initial Program: 65.7% 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: 76.5% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;d \leq -1.3 \cdot 10^{-116}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq -1.55 \cdot 10^{-276}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;d \leq 5 \cdot 10^{+64}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -2.70000000000000004e131 or -1.3e-116 < d < -1.54999999999999995e-276

    1. Initial program 53.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. Simplified53.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-e^{\log d} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      4. rem-exp-log0.0%

        \[\leadsto \left(-e^{\log d} \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      5. rec-exp0.0%

        \[\leadsto \left(-e^{\log d} \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      6. exp-prod0.0%

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

        \[\leadsto \left(-e^{\log d} \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      8. *-commutative0.0%

        \[\leadsto \left(-e^{\log d} \cdot e^{-\color{blue}{0.5 \cdot \log \left(h \cdot \ell\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      9. distribute-lft-neg-in0.0%

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

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

        \[\leadsto \left(-e^{\log d} \cdot e^{\color{blue}{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      12. exp-sum0.0%

        \[\leadsto \left(-\color{blue}{e^{\log d + \log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      13. log-pow0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{-0.5 \cdot \log \left(h \cdot \ell\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      14. metadata-eval0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{\left(-0.5\right)} \cdot \log \left(h \cdot \ell\right)}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      15. distribute-lft-neg-in0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{\left(-0.5 \cdot \log \left(h \cdot \ell\right)\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      16. log-pow0.0%

        \[\leadsto \left(-e^{\log d + \left(-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}\right)}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      17. unpow1/20.0%

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

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

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

    if -2.70000000000000004e131 < d < -1.3e-116 or 1.90000000000000001e-51 < d < 5e64

    1. Initial program 82.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. Simplified82.1%

      \[\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. Add Preprocessing
    4. Step-by-step derivation
      1. associate-*l/92.3%

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

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

    if -1.54999999999999995e-276 < d < 1.90000000000000001e-51

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

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

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

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

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

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

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

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

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

    if 5e64 < d

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

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

      \[\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} \]
    5. Step-by-step derivation
      1. expm1-def66.2%

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

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

        \[\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}}} \]
    6. Simplified91.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.7 \cdot 10^{+131}:\\ \;\;\;\;\mathsf{fma}\left({\left(\frac{M \cdot 0.5}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \cdot \frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -1.3 \cdot 10^{-116}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h \cdot \left(-0.5 \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)}{\ell}\right)\right)\\ \mathbf{elif}\;d \leq -1.55 \cdot 10^{-276}:\\ \;\;\;\;\mathsf{fma}\left({\left(\frac{M \cdot 0.5}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \cdot \frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 1.9 \cdot 10^{-51}:\\ \;\;\;\;\frac{d \cdot \frac{\mathsf{fma}\left({\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)}{\sqrt{h}}}{\sqrt{\ell}}\\ \mathbf{elif}\;d \leq 5 \cdot 10^{+64}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h \cdot \left(-0.5 \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}, 1\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 74.9% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;d \leq -1.22 \cdot 10^{-119}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq -1.55 \cdot 10^{-276}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;d \leq 3 \cdot 10^{+65}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -2.7e132 or -1.22e-119 < d < -1.54999999999999995e-276

    1. Initial program 53.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. Simplified53.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-e^{\log d} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      4. rem-exp-log0.0%

        \[\leadsto \left(-e^{\log d} \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      5. rec-exp0.0%

        \[\leadsto \left(-e^{\log d} \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      6. exp-prod0.0%

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

        \[\leadsto \left(-e^{\log d} \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      8. *-commutative0.0%

        \[\leadsto \left(-e^{\log d} \cdot e^{-\color{blue}{0.5 \cdot \log \left(h \cdot \ell\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      9. distribute-lft-neg-in0.0%

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

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

        \[\leadsto \left(-e^{\log d} \cdot e^{\color{blue}{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      12. exp-sum0.0%

        \[\leadsto \left(-\color{blue}{e^{\log d + \log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      13. log-pow0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{-0.5 \cdot \log \left(h \cdot \ell\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      14. metadata-eval0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{\left(-0.5\right)} \cdot \log \left(h \cdot \ell\right)}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      15. distribute-lft-neg-in0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{\left(-0.5 \cdot \log \left(h \cdot \ell\right)\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      16. log-pow0.0%

        \[\leadsto \left(-e^{\log d + \left(-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}\right)}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      17. unpow1/20.0%

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

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

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

    if -2.7e132 < d < -1.22e-119 or 7.0000000000000001e-66 < d < 3.0000000000000002e65

    1. Initial program 82.3%

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

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

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

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

    if -1.54999999999999995e-276 < d < 7.0000000000000001e-66

    1. Initial program 46.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. Simplified44.8%

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

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

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

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

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

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

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

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

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

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

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

    if 3.0000000000000002e65 < d

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

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

      \[\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} \]
    5. Step-by-step derivation
      1. expm1-def66.2%

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

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

        \[\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}}} \]
    6. Simplified91.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.7 \cdot 10^{+132}:\\ \;\;\;\;\mathsf{fma}\left({\left(\frac{M \cdot 0.5}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \cdot \frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -1.22 \cdot 10^{-119}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h \cdot \left(-0.5 \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)}{\ell}\right)\right)\\ \mathbf{elif}\;d \leq -1.55 \cdot 10^{-276}:\\ \;\;\;\;\mathsf{fma}\left({\left(\frac{M \cdot 0.5}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \cdot \frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 7 \cdot 10^{-66}:\\ \;\;\;\;\frac{d \cdot \mathsf{fma}\left({\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)}{{\left(\ell \cdot h\right)}^{0.5}}\\ \mathbf{elif}\;d \leq 3 \cdot 10^{+65}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h \cdot \left(-0.5 \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}, 1\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 76.1% accurate, 0.8× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -1.32e-79

    1. Initial program 77.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. Simplified77.7%

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

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

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

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

    if -1.32e-79 < d < -1.54999999999999995e-276

    1. Initial program 49.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. Simplified49.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.54999999999999995e-276 < d < 9.1999999999999995e-58

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

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

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

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

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

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

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

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

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

    if 9.1999999999999995e-58 < d < 9.5000000000000003e62

    1. Initial program 73.8%

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

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

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

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

    if 9.5000000000000003e62 < d

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

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

      \[\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} \]
    5. Step-by-step derivation
      1. expm1-def66.2%

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

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

        \[\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}}} \]
    6. Simplified91.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.32 \cdot 10^{-79}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right)\right)\\ \mathbf{elif}\;d \leq -1.55 \cdot 10^{-276}:\\ \;\;\;\;\left(d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\right) \cdot \mathsf{fma}\left({\left(\frac{M \cdot 0.5}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)\\ \mathbf{elif}\;d \leq 9.2 \cdot 10^{-58}:\\ \;\;\;\;\frac{d \cdot \frac{\mathsf{fma}\left({\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)}{\sqrt{h}}}{\sqrt{\ell}}\\ \mathbf{elif}\;d \leq 9.5 \cdot 10^{+62}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h \cdot \left(-0.5 \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}, 1\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 78.5% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 66.4%

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

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

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

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

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

    if -1.85e-302 < l

    1. Initial program 65.3%

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

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

      \[\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} \]
    5. Simplified77.4%

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

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

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

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

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

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

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

Alternative 5: 74.7% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;d \leq -2.9 \cdot 10^{-118}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq -1.55 \cdot 10^{-276}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;d \leq 1.75 \cdot 10^{-66}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(t_2, t_1, 1\right)}{{\left(\ell \cdot h\right)}^{0.5}}\\

\mathbf{elif}\;d \leq 7.2 \cdot 10^{+62}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell}} \cdot \frac{1 + t_2 \cdot t_1}{\sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -2.30000000000000021e130 or -2.8999999999999998e-118 < d < -1.54999999999999995e-276

    1. Initial program 53.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. Simplified53.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-e^{\log d} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      4. rem-exp-log0.0%

        \[\leadsto \left(-e^{\log d} \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      5. rec-exp0.0%

        \[\leadsto \left(-e^{\log d} \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      6. exp-prod0.0%

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

        \[\leadsto \left(-e^{\log d} \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      8. *-commutative0.0%

        \[\leadsto \left(-e^{\log d} \cdot e^{-\color{blue}{0.5 \cdot \log \left(h \cdot \ell\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      9. distribute-lft-neg-in0.0%

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

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

        \[\leadsto \left(-e^{\log d} \cdot e^{\color{blue}{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      12. exp-sum0.0%

        \[\leadsto \left(-\color{blue}{e^{\log d + \log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      13. log-pow0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{-0.5 \cdot \log \left(h \cdot \ell\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      14. metadata-eval0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{\left(-0.5\right)} \cdot \log \left(h \cdot \ell\right)}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      15. distribute-lft-neg-in0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{\left(-0.5 \cdot \log \left(h \cdot \ell\right)\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      16. log-pow0.0%

        \[\leadsto \left(-e^{\log d + \left(-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}\right)}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      17. unpow1/20.0%

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

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

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

    if -2.30000000000000021e130 < d < -2.8999999999999998e-118 or 1.75e-66 < d < 7.2e62

    1. Initial program 82.3%

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

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

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

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

    if -1.54999999999999995e-276 < d < 1.75e-66

    1. Initial program 46.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. Simplified44.8%

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

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

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

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

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

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

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

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

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

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

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

    if 7.2e62 < d

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.3 \cdot 10^{+130}:\\ \;\;\;\;\mathsf{fma}\left({\left(\frac{M \cdot 0.5}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \cdot \frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -2.9 \cdot 10^{-118}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h \cdot \left(-0.5 \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)}{\ell}\right)\right)\\ \mathbf{elif}\;d \leq -1.55 \cdot 10^{-276}:\\ \;\;\;\;\mathsf{fma}\left({\left(\frac{M \cdot 0.5}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \cdot \frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 1.75 \cdot 10^{-66}:\\ \;\;\;\;\frac{d \cdot \mathsf{fma}\left({\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)}{{\left(\ell \cdot h\right)}^{0.5}}\\ \mathbf{elif}\;d \leq 7.2 \cdot 10^{+62}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h \cdot \left(-0.5 \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell}} \cdot \frac{1 + {\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right)}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 63.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;d \leq -4.4 \cdot 10^{+188}:\\ \;\;\;\;\left|\frac{d}{t_0}\right|\\ \mathbf{elif}\;d \leq -7.6 \cdot 10^{-221}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + {\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right)\right)\\ \mathbf{elif}\;d \leq 2.4 \cdot 10^{-293}:\\ \;\;\;\;d \cdot \log \left(e^{{\left(\ell \cdot h\right)}^{-0.5}}\right)\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{+127}:\\ \;\;\;\;\frac{d}{\frac{t_0}{\mathsf{fma}\left({\left(\frac{0.5}{\frac{\frac{d}{D}}{M}}\right)}^{2}, \frac{h \cdot -0.5}{\ell}, 1\right)}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (* l h))))
   (if (<= d -4.4e+188)
     (fabs (/ d t_0))
     (if (<= d -7.6e-221)
       (*
        (sqrt (* (/ d l) (/ d h)))
        (+ 1.0 (* (pow (* D (/ (* M 0.5) d)) 2.0) (* (/ h l) -0.5))))
       (if (<= d 2.4e-293)
         (* d (log (exp (pow (* l h) -0.5))))
         (if (<= d 1.7e+127)
           (/
            d
            (/ t_0 (fma (pow (/ 0.5 (/ (/ d D) M)) 2.0) (/ (* h -0.5) l) 1.0)))
           (* d (/ (pow l -0.5) (sqrt h)))))))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((l * h));
	double tmp;
	if (d <= -4.4e+188) {
		tmp = fabs((d / t_0));
	} else if (d <= -7.6e-221) {
		tmp = sqrt(((d / l) * (d / h))) * (1.0 + (pow((D * ((M * 0.5) / d)), 2.0) * ((h / l) * -0.5)));
	} else if (d <= 2.4e-293) {
		tmp = d * log(exp(pow((l * h), -0.5)));
	} else if (d <= 1.7e+127) {
		tmp = d / (t_0 / fma(pow((0.5 / ((d / D) / M)), 2.0), ((h * -0.5) / l), 1.0));
	} else {
		tmp = d * (pow(l, -0.5) / sqrt(h));
	}
	return tmp;
}
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(l * h))
	tmp = 0.0
	if (d <= -4.4e+188)
		tmp = abs(Float64(d / t_0));
	elseif (d <= -7.6e-221)
		tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 + Float64((Float64(D * Float64(Float64(M * 0.5) / d)) ^ 2.0) * Float64(Float64(h / l) * -0.5))));
	elseif (d <= 2.4e-293)
		tmp = Float64(d * log(exp((Float64(l * h) ^ -0.5))));
	elseif (d <= 1.7e+127)
		tmp = Float64(d / Float64(t_0 / fma((Float64(0.5 / Float64(Float64(d / D) / M)) ^ 2.0), Float64(Float64(h * -0.5) / l), 1.0)));
	else
		tmp = Float64(d * Float64((l ^ -0.5) / sqrt(h)));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -4.4e+188], N[Abs[N[(d / t$95$0), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -7.6e-221], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[Power[N[(D * N[(N[(M * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.4e-293], N[(d * N[Log[N[Exp[N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.7e+127], N[(d / N[(t$95$0 / N[(N[Power[N[(0.5 / N[(N[(d / D), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h * -0.5), $MachinePrecision] / l), $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}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;d \leq -4.4 \cdot 10^{+188}:\\
\;\;\;\;\left|\frac{d}{t_0}\right|\\

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

\mathbf{elif}\;d \leq 2.4 \cdot 10^{-293}:\\
\;\;\;\;d \cdot \log \left(e^{{\left(\ell \cdot h\right)}^{-0.5}}\right)\\

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

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


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

    1. Initial program 61.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. Simplified61.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt0.4%

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

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

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

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

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

        \[\leadsto \color{blue}{\left|d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      3. rem-exp-log0.4%

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

        \[\leadsto \left|e^{\color{blue}{\log d + \log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right| \]
      5. log-pow0.0%

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

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

        \[\leadsto \left|e^{\log d + \color{blue}{\left(-0.5 \cdot \log \left(h \cdot \ell\right)\right)}}\right| \]
      8. log-pow0.0%

        \[\leadsto \left|e^{\log d + \left(-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}\right)}\right| \]
      9. unpow1/20.0%

        \[\leadsto \left|e^{\log d + \left(-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}\right)}\right| \]
      10. sub-neg0.0%

        \[\leadsto \left|e^{\color{blue}{\log d - \log \left(\sqrt{h \cdot \ell}\right)}}\right| \]
      11. log-div0.4%

        \[\leadsto \left|e^{\color{blue}{\log \left(\frac{d}{\sqrt{h \cdot \ell}}\right)}}\right| \]
      12. rem-exp-log64.2%

        \[\leadsto \left|\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}}\right| \]
    13. Simplified64.2%

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

    if -4.39999999999999998e188 < d < -7.6000000000000002e-221

    1. Initial program 74.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. 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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. frac-times74.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.6000000000000002e-221 < d < 2.3999999999999999e-293

    1. Initial program 29.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. Simplified29.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Step-by-step derivation
      1. add-log-exp40.7%

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

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

    if 2.3999999999999999e-293 < d < 1.69999999999999989e127

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

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

      \[\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} \]
    5. Simplified73.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.69999999999999989e127 < d

    1. Initial program 74.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. Simplified77.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.4 \cdot 10^{+188}:\\ \;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\ \mathbf{elif}\;d \leq -7.6 \cdot 10^{-221}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + {\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right)\right)\\ \mathbf{elif}\;d \leq 2.4 \cdot 10^{-293}:\\ \;\;\;\;d \cdot \log \left(e^{{\left(\ell \cdot h\right)}^{-0.5}}\right)\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{+127}:\\ \;\;\;\;\frac{d}{\frac{\sqrt{\ell \cdot h}}{\mathsf{fma}\left({\left(\frac{0.5}{\frac{\frac{d}{D}}{M}}\right)}^{2}, \frac{h \cdot -0.5}{\ell}, 1\right)}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 75.2% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;d \leq -1.75 \cdot 10^{-79}:\\
\;\;\;\;\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) \cdot \sqrt{\frac{d}{h}}\\

\mathbf{elif}\;d \leq -1.55 \cdot 10^{-276}:\\
\;\;\;\;\left(d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\right) \cdot t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -3.8000000000000002e133

    1. Initial program 64.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. Simplified64.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-e^{\log d} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      4. rem-exp-log0.0%

        \[\leadsto \left(-e^{\log d} \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      5. rec-exp0.0%

        \[\leadsto \left(-e^{\log d} \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      6. exp-prod0.0%

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

        \[\leadsto \left(-e^{\log d} \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      8. *-commutative0.0%

        \[\leadsto \left(-e^{\log d} \cdot e^{-\color{blue}{0.5 \cdot \log \left(h \cdot \ell\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      9. distribute-lft-neg-in0.0%

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

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

        \[\leadsto \left(-e^{\log d} \cdot e^{\color{blue}{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      12. exp-sum0.0%

        \[\leadsto \left(-\color{blue}{e^{\log d + \log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      13. log-pow0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{-0.5 \cdot \log \left(h \cdot \ell\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      14. metadata-eval0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{\left(-0.5\right)} \cdot \log \left(h \cdot \ell\right)}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      15. distribute-lft-neg-in0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{\left(-0.5 \cdot \log \left(h \cdot \ell\right)\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      16. log-pow0.0%

        \[\leadsto \left(-e^{\log d + \left(-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}\right)}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      17. unpow1/20.0%

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

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

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

    if -3.8000000000000002e133 < d < -1.75000000000000015e-79

    1. Initial program 87.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. Simplified87.5%

      \[\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. Add Preprocessing

    if -1.75000000000000015e-79 < d < -1.54999999999999995e-276

    1. Initial program 49.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. Simplified49.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.54999999999999995e-276 < d

    1. Initial program 65.3%

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

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

      \[\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} \]
    5. Simplified77.4%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.8 \cdot 10^{+133}:\\ \;\;\;\;\mathsf{fma}\left({\left(\frac{M \cdot 0.5}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \cdot \frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -1.75 \cdot 10^{-79}:\\ \;\;\;\;\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) \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq -1.55 \cdot 10^{-276}:\\ \;\;\;\;\left(d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\right) \cdot \mathsf{fma}\left({\left(\frac{M \cdot 0.5}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell}} \cdot \frac{1 + {\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right)}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 70.1% accurate, 1.0× speedup?

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

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

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

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


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

    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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. frac-times65.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-e^{\log d} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      4. rem-exp-log0.0%

        \[\leadsto \left(-e^{\log d} \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      5. rec-exp0.0%

        \[\leadsto \left(-e^{\log d} \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      6. exp-prod0.0%

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

        \[\leadsto \left(-e^{\log d} \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      8. *-commutative0.0%

        \[\leadsto \left(-e^{\log d} \cdot e^{-\color{blue}{0.5 \cdot \log \left(h \cdot \ell\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      9. distribute-lft-neg-in0.0%

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

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

        \[\leadsto \left(-e^{\log d} \cdot e^{\color{blue}{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      12. exp-sum0.0%

        \[\leadsto \left(-\color{blue}{e^{\log d + \log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      13. log-pow0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{-0.5 \cdot \log \left(h \cdot \ell\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      14. metadata-eval0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{\left(-0.5\right)} \cdot \log \left(h \cdot \ell\right)}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      15. distribute-lft-neg-in0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{\left(-0.5 \cdot \log \left(h \cdot \ell\right)\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      16. log-pow0.0%

        \[\leadsto \left(-e^{\log d + \left(-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}\right)}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      17. unpow1/20.0%

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

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

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

    if -1.000000000000002e-309 < h < 2.0500000000000001e229

    1. Initial program 69.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.0500000000000001e229 < h

    1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 70.1% accurate, 1.0× speedup?

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

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

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


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

    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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. frac-times65.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-e^{\log d} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      4. rem-exp-log0.0%

        \[\leadsto \left(-e^{\log d} \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      5. rec-exp0.0%

        \[\leadsto \left(-e^{\log d} \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      6. exp-prod0.0%

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

        \[\leadsto \left(-e^{\log d} \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      8. *-commutative0.0%

        \[\leadsto \left(-e^{\log d} \cdot e^{-\color{blue}{0.5 \cdot \log \left(h \cdot \ell\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      9. distribute-lft-neg-in0.0%

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

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

        \[\leadsto \left(-e^{\log d} \cdot e^{\color{blue}{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      12. exp-sum0.0%

        \[\leadsto \left(-\color{blue}{e^{\log d + \log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      13. log-pow0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{-0.5 \cdot \log \left(h \cdot \ell\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      14. metadata-eval0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{\left(-0.5\right)} \cdot \log \left(h \cdot \ell\right)}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      15. distribute-lft-neg-in0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{\left(-0.5 \cdot \log \left(h \cdot \ell\right)\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      16. log-pow0.0%

        \[\leadsto \left(-e^{\log d + \left(-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}\right)}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      17. unpow1/20.0%

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

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

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

    if -1.000000000000002e-309 < h < 6.5000000000000006e222

    1. Initial program 69.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.5000000000000006e222 < h

    1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 75.3% accurate, 1.0× speedup?

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

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

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


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

    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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. frac-times65.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < h

    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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Applied egg-rr32.8%

      \[\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} \]
    5. Simplified78.1%

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

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

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

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

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

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

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

Alternative 11: 75.2% accurate, 1.0× speedup?

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

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

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


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

    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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. frac-times65.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-e^{\log d} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      4. rem-exp-log0.0%

        \[\leadsto \left(-e^{\log d} \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      5. rec-exp0.0%

        \[\leadsto \left(-e^{\log d} \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      6. exp-prod0.0%

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

        \[\leadsto \left(-e^{\log d} \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      8. *-commutative0.0%

        \[\leadsto \left(-e^{\log d} \cdot e^{-\color{blue}{0.5 \cdot \log \left(h \cdot \ell\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      9. distribute-lft-neg-in0.0%

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

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

        \[\leadsto \left(-e^{\log d} \cdot e^{\color{blue}{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      12. exp-sum0.0%

        \[\leadsto \left(-\color{blue}{e^{\log d + \log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      13. log-pow0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{-0.5 \cdot \log \left(h \cdot \ell\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      14. metadata-eval0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{\left(-0.5\right)} \cdot \log \left(h \cdot \ell\right)}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      15. distribute-lft-neg-in0.0%

        \[\leadsto \left(-e^{\log d + \color{blue}{\left(-0.5 \cdot \log \left(h \cdot \ell\right)\right)}}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      16. log-pow0.0%

        \[\leadsto \left(-e^{\log d + \left(-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}\right)}\right) \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      17. unpow1/20.0%

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

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

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

    if -1.000000000000002e-309 < h

    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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Applied egg-rr32.8%

      \[\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} \]
    5. Simplified78.1%

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

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

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

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

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

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

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

Alternative 12: 62.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{d}{\sqrt{\ell \cdot h}}\\ \mathbf{if}\;d \leq -2.4 \cdot 10^{+182}:\\ \;\;\;\;\left|t_0\right|\\ \mathbf{elif}\;d \leq -4 \cdot 10^{-220}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + {\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right)\right)\\ \mathbf{elif}\;d \leq 1.05 \cdot 10^{-281}:\\ \;\;\;\;d \cdot \log \left(e^{{\left(\ell \cdot h\right)}^{-0.5}}\right)\\ \mathbf{elif}\;d \leq 1.1 \cdot 10^{+127}:\\ \;\;\;\;t_0 \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{\frac{D}{2}}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (/ d (sqrt (* l h)))))
   (if (<= d -2.4e+182)
     (fabs t_0)
     (if (<= d -4e-220)
       (*
        (sqrt (* (/ d l) (/ d h)))
        (+ 1.0 (* (pow (* D (/ (* M 0.5) d)) 2.0) (* (/ h l) -0.5))))
       (if (<= d 1.05e-281)
         (* d (log (exp (pow (* l h) -0.5))))
         (if (<= d 1.1e+127)
           (* t_0 (+ 1.0 (* -0.5 (* (/ h l) (pow (* M (/ (/ D 2.0) d)) 2.0)))))
           (* d (/ (pow l -0.5) (sqrt h)))))))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = d / sqrt((l * h));
	double tmp;
	if (d <= -2.4e+182) {
		tmp = fabs(t_0);
	} else if (d <= -4e-220) {
		tmp = sqrt(((d / l) * (d / h))) * (1.0 + (pow((D * ((M * 0.5) / d)), 2.0) * ((h / l) * -0.5)));
	} else if (d <= 1.05e-281) {
		tmp = d * log(exp(pow((l * h), -0.5)));
	} else if (d <= 1.1e+127) {
		tmp = t_0 * (1.0 + (-0.5 * ((h / l) * pow((M * ((D / 2.0) / d)), 2.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) :: t_0
    real(8) :: tmp
    t_0 = d / sqrt((l * h))
    if (d <= (-2.4d+182)) then
        tmp = abs(t_0)
    else if (d <= (-4d-220)) then
        tmp = sqrt(((d / l) * (d / h))) * (1.0d0 + (((d_1 * ((m * 0.5d0) / d)) ** 2.0d0) * ((h / l) * (-0.5d0))))
    else if (d <= 1.05d-281) then
        tmp = d * log(exp(((l * h) ** (-0.5d0))))
    else if (d <= 1.1d+127) then
        tmp = t_0 * (1.0d0 + ((-0.5d0) * ((h / l) * ((m * ((d_1 / 2.0d0) / d)) ** 2.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 t_0 = d / Math.sqrt((l * h));
	double tmp;
	if (d <= -2.4e+182) {
		tmp = Math.abs(t_0);
	} else if (d <= -4e-220) {
		tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 + (Math.pow((D * ((M * 0.5) / d)), 2.0) * ((h / l) * -0.5)));
	} else if (d <= 1.05e-281) {
		tmp = d * Math.log(Math.exp(Math.pow((l * h), -0.5)));
	} else if (d <= 1.1e+127) {
		tmp = t_0 * (1.0 + (-0.5 * ((h / l) * Math.pow((M * ((D / 2.0) / d)), 2.0))));
	} else {
		tmp = d * (Math.pow(l, -0.5) / Math.sqrt(h));
	}
	return tmp;
}
def code(d, h, l, M, D):
	t_0 = d / math.sqrt((l * h))
	tmp = 0
	if d <= -2.4e+182:
		tmp = math.fabs(t_0)
	elif d <= -4e-220:
		tmp = math.sqrt(((d / l) * (d / h))) * (1.0 + (math.pow((D * ((M * 0.5) / d)), 2.0) * ((h / l) * -0.5)))
	elif d <= 1.05e-281:
		tmp = d * math.log(math.exp(math.pow((l * h), -0.5)))
	elif d <= 1.1e+127:
		tmp = t_0 * (1.0 + (-0.5 * ((h / l) * math.pow((M * ((D / 2.0) / d)), 2.0))))
	else:
		tmp = d * (math.pow(l, -0.5) / math.sqrt(h))
	return tmp
function code(d, h, l, M, D)
	t_0 = Float64(d / sqrt(Float64(l * h)))
	tmp = 0.0
	if (d <= -2.4e+182)
		tmp = abs(t_0);
	elseif (d <= -4e-220)
		tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 + Float64((Float64(D * Float64(Float64(M * 0.5) / d)) ^ 2.0) * Float64(Float64(h / l) * -0.5))));
	elseif (d <= 1.05e-281)
		tmp = Float64(d * log(exp((Float64(l * h) ^ -0.5))));
	elseif (d <= 1.1e+127)
		tmp = Float64(t_0 * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(Float64(D / 2.0) / d)) ^ 2.0)))));
	else
		tmp = Float64(d * Float64((l ^ -0.5) / sqrt(h)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	t_0 = d / sqrt((l * h));
	tmp = 0.0;
	if (d <= -2.4e+182)
		tmp = abs(t_0);
	elseif (d <= -4e-220)
		tmp = sqrt(((d / l) * (d / h))) * (1.0 + (((D * ((M * 0.5) / d)) ^ 2.0) * ((h / l) * -0.5)));
	elseif (d <= 1.05e-281)
		tmp = d * log(exp(((l * h) ^ -0.5)));
	elseif (d <= 1.1e+127)
		tmp = t_0 * (1.0 + (-0.5 * ((h / l) * ((M * ((D / 2.0) / d)) ^ 2.0))));
	else
		tmp = d * ((l ^ -0.5) / sqrt(h));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.4e+182], N[Abs[t$95$0], $MachinePrecision], If[LessEqual[d, -4e-220], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[Power[N[(D * N[(N[(M * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.05e-281], N[(d * N[Log[N[Exp[N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.1e+127], N[(t$95$0 * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(N[(D / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;d \leq -2.4 \cdot 10^{+182}:\\
\;\;\;\;\left|t_0\right|\\

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

\mathbf{elif}\;d \leq 1.05 \cdot 10^{-281}:\\
\;\;\;\;d \cdot \log \left(e^{{\left(\ell \cdot h\right)}^{-0.5}}\right)\\

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

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


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

    1. Initial program 61.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. Simplified61.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt0.4%

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

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

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

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

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

        \[\leadsto \color{blue}{\left|d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      3. rem-exp-log0.4%

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

        \[\leadsto \left|e^{\color{blue}{\log d + \log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right| \]
      5. log-pow0.0%

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

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

        \[\leadsto \left|e^{\log d + \color{blue}{\left(-0.5 \cdot \log \left(h \cdot \ell\right)\right)}}\right| \]
      8. log-pow0.0%

        \[\leadsto \left|e^{\log d + \left(-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}\right)}\right| \]
      9. unpow1/20.0%

        \[\leadsto \left|e^{\log d + \left(-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}\right)}\right| \]
      10. sub-neg0.0%

        \[\leadsto \left|e^{\color{blue}{\log d - \log \left(\sqrt{h \cdot \ell}\right)}}\right| \]
      11. log-div0.4%

        \[\leadsto \left|e^{\color{blue}{\log \left(\frac{d}{\sqrt{h \cdot \ell}}\right)}}\right| \]
      12. rem-exp-log64.2%

        \[\leadsto \left|\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}}\right| \]
    13. Simplified64.2%

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

    if -2.4000000000000001e182 < d < -3.99999999999999997e-220

    1. Initial program 74.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. 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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. frac-times74.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.99999999999999997e-220 < d < 1.0499999999999999e-281

    1. Initial program 26.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. Simplified27.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Step-by-step derivation
      1. add-log-exp37.4%

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

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

    if 1.0499999999999999e-281 < d < 1.1000000000000001e127

    1. Initial program 63.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. Simplified62.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.1000000000000001e127 < d

    1. Initial program 74.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. Simplified77.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.4 \cdot 10^{+182}:\\ \;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\ \mathbf{elif}\;d \leq -4 \cdot 10^{-220}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + {\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right)\right)\\ \mathbf{elif}\;d \leq 1.05 \cdot 10^{-281}:\\ \;\;\;\;d \cdot \log \left(e^{{\left(\ell \cdot h\right)}^{-0.5}}\right)\\ \mathbf{elif}\;d \leq 1.1 \cdot 10^{+127}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{\frac{D}{2}}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 62.4% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{d}{\sqrt{\ell \cdot h}}\\ \mathbf{if}\;d \leq -2.95 \cdot 10^{+181}:\\ \;\;\;\;\left|t_0\right|\\ \mathbf{elif}\;d \leq -1.46 \cdot 10^{-215}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + {\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right)\right)\\ \mathbf{elif}\;d \leq 1.05 \cdot 10^{-281}:\\ \;\;\;\;d \cdot e^{0.5 \cdot \left(-\mathsf{log1p}\left(\ell \cdot h + -1\right)\right)}\\ \mathbf{elif}\;d \leq 2 \cdot 10^{+127}:\\ \;\;\;\;t_0 \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{\frac{D}{2}}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (/ d (sqrt (* l h)))))
   (if (<= d -2.95e+181)
     (fabs t_0)
     (if (<= d -1.46e-215)
       (*
        (sqrt (* (/ d l) (/ d h)))
        (+ 1.0 (* (pow (* D (/ (* M 0.5) d)) 2.0) (* (/ h l) -0.5))))
       (if (<= d 1.05e-281)
         (* d (exp (* 0.5 (- (log1p (+ (* l h) -1.0))))))
         (if (<= d 2e+127)
           (* t_0 (+ 1.0 (* -0.5 (* (/ h l) (pow (* M (/ (/ D 2.0) d)) 2.0)))))
           (* d (/ (pow l -0.5) (sqrt h)))))))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = d / sqrt((l * h));
	double tmp;
	if (d <= -2.95e+181) {
		tmp = fabs(t_0);
	} else if (d <= -1.46e-215) {
		tmp = sqrt(((d / l) * (d / h))) * (1.0 + (pow((D * ((M * 0.5) / d)), 2.0) * ((h / l) * -0.5)));
	} else if (d <= 1.05e-281) {
		tmp = d * exp((0.5 * -log1p(((l * h) + -1.0))));
	} else if (d <= 2e+127) {
		tmp = t_0 * (1.0 + (-0.5 * ((h / l) * pow((M * ((D / 2.0) / d)), 2.0))));
	} 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 t_0 = d / Math.sqrt((l * h));
	double tmp;
	if (d <= -2.95e+181) {
		tmp = Math.abs(t_0);
	} else if (d <= -1.46e-215) {
		tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 + (Math.pow((D * ((M * 0.5) / d)), 2.0) * ((h / l) * -0.5)));
	} else if (d <= 1.05e-281) {
		tmp = d * Math.exp((0.5 * -Math.log1p(((l * h) + -1.0))));
	} else if (d <= 2e+127) {
		tmp = t_0 * (1.0 + (-0.5 * ((h / l) * Math.pow((M * ((D / 2.0) / d)), 2.0))));
	} else {
		tmp = d * (Math.pow(l, -0.5) / Math.sqrt(h));
	}
	return tmp;
}
def code(d, h, l, M, D):
	t_0 = d / math.sqrt((l * h))
	tmp = 0
	if d <= -2.95e+181:
		tmp = math.fabs(t_0)
	elif d <= -1.46e-215:
		tmp = math.sqrt(((d / l) * (d / h))) * (1.0 + (math.pow((D * ((M * 0.5) / d)), 2.0) * ((h / l) * -0.5)))
	elif d <= 1.05e-281:
		tmp = d * math.exp((0.5 * -math.log1p(((l * h) + -1.0))))
	elif d <= 2e+127:
		tmp = t_0 * (1.0 + (-0.5 * ((h / l) * math.pow((M * ((D / 2.0) / d)), 2.0))))
	else:
		tmp = d * (math.pow(l, -0.5) / math.sqrt(h))
	return tmp
function code(d, h, l, M, D)
	t_0 = Float64(d / sqrt(Float64(l * h)))
	tmp = 0.0
	if (d <= -2.95e+181)
		tmp = abs(t_0);
	elseif (d <= -1.46e-215)
		tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 + Float64((Float64(D * Float64(Float64(M * 0.5) / d)) ^ 2.0) * Float64(Float64(h / l) * -0.5))));
	elseif (d <= 1.05e-281)
		tmp = Float64(d * exp(Float64(0.5 * Float64(-log1p(Float64(Float64(l * h) + -1.0))))));
	elseif (d <= 2e+127)
		tmp = Float64(t_0 * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(Float64(D / 2.0) / d)) ^ 2.0)))));
	else
		tmp = Float64(d * Float64((l ^ -0.5) / sqrt(h)));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.95e+181], N[Abs[t$95$0], $MachinePrecision], If[LessEqual[d, -1.46e-215], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[Power[N[(D * N[(N[(M * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.05e-281], N[(d * N[Exp[N[(0.5 * (-N[Log[1 + N[(N[(l * h), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2e+127], N[(t$95$0 * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(N[(D / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;d \leq -2.95 \cdot 10^{+181}:\\
\;\;\;\;\left|t_0\right|\\

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

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

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

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


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

    1. Initial program 61.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. Simplified61.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt0.4%

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

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

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

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

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

        \[\leadsto \color{blue}{\left|d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      3. rem-exp-log0.4%

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

        \[\leadsto \left|e^{\color{blue}{\log d + \log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right| \]
      5. log-pow0.0%

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

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

        \[\leadsto \left|e^{\log d + \color{blue}{\left(-0.5 \cdot \log \left(h \cdot \ell\right)\right)}}\right| \]
      8. log-pow0.0%

        \[\leadsto \left|e^{\log d + \left(-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}\right)}\right| \]
      9. unpow1/20.0%

        \[\leadsto \left|e^{\log d + \left(-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}\right)}\right| \]
      10. sub-neg0.0%

        \[\leadsto \left|e^{\color{blue}{\log d - \log \left(\sqrt{h \cdot \ell}\right)}}\right| \]
      11. log-div0.4%

        \[\leadsto \left|e^{\color{blue}{\log \left(\frac{d}{\sqrt{h \cdot \ell}}\right)}}\right| \]
      12. rem-exp-log64.2%

        \[\leadsto \left|\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}}\right| \]
    13. Simplified64.2%

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

    if -2.9499999999999999e181 < d < -1.4600000000000001e-215

    1. Initial program 74.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. 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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. frac-times74.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.4600000000000001e-215 < d < 1.0499999999999999e-281

    1. Initial program 26.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. Simplified27.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.0499999999999999e-281 < d < 1.99999999999999991e127

    1. Initial program 63.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. Simplified62.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999999999999991e127 < d

    1. Initial program 74.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. Simplified77.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.95 \cdot 10^{+181}:\\ \;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\ \mathbf{elif}\;d \leq -1.46 \cdot 10^{-215}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + {\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right)\right)\\ \mathbf{elif}\;d \leq 1.05 \cdot 10^{-281}:\\ \;\;\;\;d \cdot e^{0.5 \cdot \left(-\mathsf{log1p}\left(\ell \cdot h + -1\right)\right)}\\ \mathbf{elif}\;d \leq 2 \cdot 10^{+127}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{\frac{D}{2}}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 58.2% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.42 \cdot 10^{-71}:\\
\;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}^{2}}} \]
    11. Applied egg-rr28.5%

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

        \[\leadsto \sqrt{\color{blue}{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      2. rem-sqrt-square46.6%

        \[\leadsto \color{blue}{\left|d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right|} \]
    13. Simplified46.6%

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

    if -1.4199999999999999e-71 < l < -4.999999999999985e-310

    1. Initial program 68.8%

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. 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}}} \]
    6. Simplified16.5%

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

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

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

        \[\leadsto d \cdot e^{\log \color{blue}{\left(\frac{1}{h \cdot \ell}\right)} \cdot 0.5} \]
      4. log-rec16.5%

        \[\leadsto d \cdot e^{\color{blue}{\left(-\log \left(h \cdot \ell\right)\right)} \cdot 0.5} \]
    8. Applied egg-rr16.5%

      \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
    9. Step-by-step derivation
      1. log1p-expm1-u44.1%

        \[\leadsto d \cdot e^{\left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(h \cdot \ell\right)\right)\right)}\right) \cdot 0.5} \]
      2. expm1-udef44.1%

        \[\leadsto d \cdot e^{\left(-\mathsf{log1p}\left(\color{blue}{e^{\log \left(h \cdot \ell\right)} - 1}\right)\right) \cdot 0.5} \]
      3. add-exp-log44.1%

        \[\leadsto d \cdot e^{\left(-\mathsf{log1p}\left(\color{blue}{h \cdot \ell} - 1\right)\right) \cdot 0.5} \]
    10. Applied egg-rr44.1%

      \[\leadsto d \cdot e^{\left(-\color{blue}{\mathsf{log1p}\left(h \cdot \ell - 1\right)}\right) \cdot 0.5} \]

    if -4.999999999999985e-310 < l < 7.09999999999999957e245

    1. Initial program 66.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. Simplified65.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. clear-num65.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\color{blue}{\frac{1}{\frac{2}{M}}} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. frac-times66.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\color{blue}{\left(\frac{1 \cdot D}{\frac{2}{M} \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      3. *-un-lft-identity66.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{\color{blue}{D}}{\frac{2}{M} \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. associate-*l/66.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{\color{blue}{\frac{2 \cdot d}{M}}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      5. *-un-lft-identity66.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{\frac{2 \cdot d}{\color{blue}{1 \cdot M}}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      6. times-frac66.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{\color{blue}{\frac{2}{1} \cdot \frac{d}{M}}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      7. metadata-eval66.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{\color{blue}{2} \cdot \frac{d}{M}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr66.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\color{blue}{\left(\frac{D}{2 \cdot \frac{d}{M}}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. expm1-log1p-u38.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2 \cdot \frac{d}{M}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)\right)} \]
      2. expm1-udef26.9%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{2 \cdot \frac{d}{M}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} - 1} \]
    7. Applied egg-rr26.0%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(1 + -0.5 \cdot \left({\left(\frac{\frac{D}{2}}{\frac{d}{M}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \frac{d}{\sqrt{h \cdot \ell}}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def36.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(1 + -0.5 \cdot \left({\left(\frac{\frac{D}{2}}{\frac{d}{M}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \frac{d}{\sqrt{h \cdot \ell}}\right)\right)} \]
      2. expm1-log1p69.3%

        \[\leadsto \color{blue}{\left(1 + -0.5 \cdot \left({\left(\frac{\frac{D}{2}}{\frac{d}{M}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \frac{d}{\sqrt{h \cdot \ell}}} \]
      3. associate-/r/68.4%

        \[\leadsto \left(1 + -0.5 \cdot \left({\color{blue}{\left(\frac{\frac{D}{2}}{d} \cdot M\right)}}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \frac{d}{\sqrt{h \cdot \ell}} \]
    9. Simplified68.4%

      \[\leadsto \color{blue}{\left(1 + -0.5 \cdot \left({\left(\frac{\frac{D}{2}}{d} \cdot M\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \frac{d}{\sqrt{h \cdot \ell}}} \]

    if 7.09999999999999957e245 < l

    1. Initial program 60.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified66.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Applied egg-rr45.3%

      \[\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} \]
    5. Simplified79.5%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell}} \cdot \frac{\mathsf{fma}\left({\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)}{\sqrt{h}}} \]
    6. Taylor expanded in D around 0 79.9%

      \[\leadsto \frac{d}{\sqrt{\ell}} \cdot \color{blue}{\sqrt{\frac{1}{h}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification56.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.42 \cdot 10^{-71}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot e^{0.5 \cdot \left(-\mathsf{log1p}\left(\ell \cdot h + -1\right)\right)}\\ \mathbf{elif}\;\ell \leq 7.1 \cdot 10^{+245}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{\frac{D}{2}}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell}} \cdot \sqrt{\frac{1}{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 47.5% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1.7 \cdot 10^{-71}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot e^{0.5 \cdot \left(-\mathsf{log1p}\left(\ell \cdot h + -1\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 -1.7e-71)
   (fabs (* d (pow (* l h) -0.5)))
   (if (<= l -5e-310)
     (* d (exp (* 0.5 (- (log1p (+ (* 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 <= -1.7e-71) {
		tmp = fabs((d * pow((l * h), -0.5)));
	} else if (l <= -5e-310) {
		tmp = d * exp((0.5 * -log1p(((l * h) + -1.0))));
	} 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 <= -1.7e-71) {
		tmp = Math.abs((d * Math.pow((l * h), -0.5)));
	} else if (l <= -5e-310) {
		tmp = d * Math.exp((0.5 * -Math.log1p(((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 <= -1.7e-71:
		tmp = math.fabs((d * math.pow((l * h), -0.5)))
	elif l <= -5e-310:
		tmp = d * math.exp((0.5 * -math.log1p(((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 <= -1.7e-71)
		tmp = abs(Float64(d * (Float64(l * h) ^ -0.5)));
	elseif (l <= -5e-310)
		tmp = Float64(d * exp(Float64(0.5 * Float64(-log1p(Float64(Float64(l * h) + -1.0))))));
	else
		tmp = Float64(d * Float64((l ^ -0.5) / sqrt(h)));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -1.7e-71], N[Abs[N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, -5e-310], N[(d * N[Exp[N[(0.5 * (-N[Log[1 + N[(N[(l * h), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision])), $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 -1.7 \cdot 10^{-71}:\\
\;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot e^{0.5 \cdot \left(-\mathsf{log1p}\left(\ell \cdot h + -1\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 < -1.70000000000000002e-71

    1. Initial program 64.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. Simplified64.0%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 3.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative3.8%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*3.8%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    6. Simplified3.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    7. Taylor expanded in d around 0 3.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. unpow1/23.8%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      2. rem-exp-log3.8%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      3. exp-neg3.8%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod3.8%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out3.8%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. distribute-rgt-neg-in3.8%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      7. metadata-eval3.8%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      8. exp-to-pow3.8%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Simplified3.8%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt1.9%

        \[\leadsto \color{blue}{\sqrt{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{d \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      2. sqrt-unprod28.5%

        \[\leadsto \color{blue}{\sqrt{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      3. pow228.5%

        \[\leadsto \sqrt{\color{blue}{{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}^{2}}} \]
    11. Applied egg-rr28.5%

      \[\leadsto \color{blue}{\sqrt{{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}^{2}}} \]
    12. Step-by-step derivation
      1. unpow228.5%

        \[\leadsto \sqrt{\color{blue}{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      2. rem-sqrt-square46.6%

        \[\leadsto \color{blue}{\left|d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right|} \]
    13. Simplified46.6%

      \[\leadsto \color{blue}{\left|d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right|} \]

    if -1.70000000000000002e-71 < l < -4.999999999999985e-310

    1. Initial program 68.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified68.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 16.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. 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}}} \]
    6. Simplified16.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    7. Step-by-step derivation
      1. pow1/216.5%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{\frac{1}{\ell}}{h}\right)}^{0.5}} \]
      2. pow-to-exp16.5%

        \[\leadsto d \cdot \color{blue}{e^{\log \left(\frac{\frac{1}{\ell}}{h}\right) \cdot 0.5}} \]
      3. associate-/l/16.5%

        \[\leadsto d \cdot e^{\log \color{blue}{\left(\frac{1}{h \cdot \ell}\right)} \cdot 0.5} \]
      4. log-rec16.5%

        \[\leadsto d \cdot e^{\color{blue}{\left(-\log \left(h \cdot \ell\right)\right)} \cdot 0.5} \]
    8. Applied egg-rr16.5%

      \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
    9. Step-by-step derivation
      1. log1p-expm1-u44.1%

        \[\leadsto d \cdot e^{\left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(h \cdot \ell\right)\right)\right)}\right) \cdot 0.5} \]
      2. expm1-udef44.1%

        \[\leadsto d \cdot e^{\left(-\mathsf{log1p}\left(\color{blue}{e^{\log \left(h \cdot \ell\right)} - 1}\right)\right) \cdot 0.5} \]
      3. add-exp-log44.1%

        \[\leadsto d \cdot e^{\left(-\mathsf{log1p}\left(\color{blue}{h \cdot \ell} - 1\right)\right) \cdot 0.5} \]
    10. Applied egg-rr44.1%

      \[\leadsto d \cdot e^{\left(-\color{blue}{\mathsf{log1p}\left(h \cdot \ell - 1\right)}\right) \cdot 0.5} \]

    if -4.999999999999985e-310 < l

    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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 40.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative40.4%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*40.8%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    6. Simplified40.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    7. Step-by-step derivation
      1. expm1-log1p-u39.9%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\right)} \]
      2. expm1-udef25.6%

        \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{\frac{1}{\ell}}{h}}\right)} - 1\right)} \]
      3. sqrt-div28.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}}\right)} - 1\right) \]
      4. pow1/228.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{{\left(\frac{1}{\ell}\right)}^{0.5}}}{\sqrt{h}}\right)} - 1\right) \]
      5. inv-pow28.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\frac{{\color{blue}{\left({\ell}^{-1}\right)}}^{0.5}}{\sqrt{h}}\right)} - 1\right) \]
      6. pow-pow28.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{{\ell}^{\left(-1 \cdot 0.5\right)}}}{\sqrt{h}}\right)} - 1\right) \]
      7. metadata-eval28.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\frac{{\ell}^{\color{blue}{-0.5}}}{\sqrt{h}}\right)} - 1\right) \]
    8. Applied egg-rr28.4%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{{\ell}^{-0.5}}{\sqrt{h}}\right)} - 1\right)} \]
    9. Step-by-step derivation
      1. expm1-def50.3%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{\ell}^{-0.5}}{\sqrt{h}}\right)\right)} \]
      2. expm1-log1p51.5%

        \[\leadsto d \cdot \color{blue}{\frac{{\ell}^{-0.5}}{\sqrt{h}}} \]
    10. Simplified51.5%

      \[\leadsto d \cdot \color{blue}{\frac{{\ell}^{-0.5}}{\sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification48.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.7 \cdot 10^{-71}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot e^{0.5 \cdot \left(-\mathsf{log1p}\left(\ell \cdot h + -1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 46.3% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;h \leq -1 \cdot 10^{-309}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= h -1e-309)
   (fabs (* d (pow (* l h) -0.5)))
   (* d (/ (pow l -0.5) (sqrt h)))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= -1e-309) {
		tmp = fabs((d * pow((l * h), -0.5)));
	} 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 (h <= (-1d-309)) then
        tmp = abs((d * ((l * h) ** (-0.5d0))))
    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 (h <= -1e-309) {
		tmp = Math.abs((d * Math.pow((l * h), -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 h <= -1e-309:
		tmp = math.fabs((d * math.pow((l * h), -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 (h <= -1e-309)
		tmp = abs(Float64(d * (Float64(l * h) ^ -0.5)));
	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 (h <= -1e-309)
		tmp = abs((d * ((l * h) ^ -0.5)));
	else
		tmp = d * ((l ^ -0.5) / sqrt(h));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[h, -1e-309], N[Abs[N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $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}\;h \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if h < -1.000000000000002e-309

    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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 8.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative8.9%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*8.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    6. Simplified8.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    7. Taylor expanded in d around 0 8.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. unpow1/28.9%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      2. rem-exp-log8.9%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      3. exp-neg8.9%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod8.9%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out8.9%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. distribute-rgt-neg-in8.9%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      7. metadata-eval8.9%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      8. exp-to-pow8.9%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Simplified8.9%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt1.2%

        \[\leadsto \color{blue}{\sqrt{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{d \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      2. sqrt-unprod24.3%

        \[\leadsto \color{blue}{\sqrt{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      3. pow224.3%

        \[\leadsto \sqrt{\color{blue}{{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}^{2}}} \]
    11. Applied egg-rr24.3%

      \[\leadsto \color{blue}{\sqrt{{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}^{2}}} \]
    12. Step-by-step derivation
      1. unpow224.3%

        \[\leadsto \sqrt{\color{blue}{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      2. rem-sqrt-square37.6%

        \[\leadsto \color{blue}{\left|d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right|} \]
    13. Simplified37.6%

      \[\leadsto \color{blue}{\left|d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right|} \]

    if -1.000000000000002e-309 < h

    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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 40.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative40.4%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*40.8%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    6. Simplified40.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    7. Step-by-step derivation
      1. expm1-log1p-u39.9%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\right)} \]
      2. expm1-udef25.6%

        \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{\frac{1}{\ell}}{h}}\right)} - 1\right)} \]
      3. sqrt-div28.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}}\right)} - 1\right) \]
      4. pow1/228.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{{\left(\frac{1}{\ell}\right)}^{0.5}}}{\sqrt{h}}\right)} - 1\right) \]
      5. inv-pow28.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\frac{{\color{blue}{\left({\ell}^{-1}\right)}}^{0.5}}{\sqrt{h}}\right)} - 1\right) \]
      6. pow-pow28.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{{\ell}^{\left(-1 \cdot 0.5\right)}}}{\sqrt{h}}\right)} - 1\right) \]
      7. metadata-eval28.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\frac{{\ell}^{\color{blue}{-0.5}}}{\sqrt{h}}\right)} - 1\right) \]
    8. Applied egg-rr28.4%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{{\ell}^{-0.5}}{\sqrt{h}}\right)} - 1\right)} \]
    9. Step-by-step derivation
      1. expm1-def50.3%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{\ell}^{-0.5}}{\sqrt{h}}\right)\right)} \]
      2. expm1-log1p51.5%

        \[\leadsto d \cdot \color{blue}{\frac{{\ell}^{-0.5}}{\sqrt{h}}} \]
    10. Simplified51.5%

      \[\leadsto d \cdot \color{blue}{\frac{{\ell}^{-0.5}}{\sqrt{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification44.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -1 \cdot 10^{-309}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 42.9% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right| \end{array} \]
(FPCore (d h l M D) :precision binary64 (fabs (* d (pow (* l h) -0.5))))
double code(double d, double h, double l, double M, double D) {
	return fabs((d * pow((l * h), -0.5)));
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    code = abs((d * ((l * h) ** (-0.5d0))))
end function
public static double code(double d, double h, double l, double M, double D) {
	return Math.abs((d * Math.pow((l * h), -0.5)));
}
def code(d, h, l, M, D):
	return math.fabs((d * math.pow((l * h), -0.5)))
function code(d, h, l, M, D)
	return abs(Float64(d * (Float64(l * h) ^ -0.5)))
end
function tmp = code(d, h, l, M, D)
	tmp = abs((d * ((l * h) ^ -0.5)));
end
code[d_, h_, l_, M_, D_] := N[Abs[N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|
\end{array}
Derivation
  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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in d around inf 23.3%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  5. Step-by-step derivation
    1. *-commutative23.3%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    2. associate-/r*23.5%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
  6. Simplified23.5%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
  7. Taylor expanded in d around 0 23.3%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  8. Step-by-step derivation
    1. unpow1/223.3%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    2. rem-exp-log22.4%

      \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
    3. exp-neg22.4%

      \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
    4. exp-prod22.7%

      \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
    5. distribute-lft-neg-out22.7%

      \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
    6. distribute-rgt-neg-in22.7%

      \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
    7. metadata-eval22.7%

      \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
    8. exp-to-pow23.6%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  9. Simplified23.6%

    \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
  10. Step-by-step derivation
    1. add-sqr-sqrt19.4%

      \[\leadsto \color{blue}{\sqrt{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{d \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
    2. sqrt-unprod27.1%

      \[\leadsto \color{blue}{\sqrt{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
    3. pow227.1%

      \[\leadsto \sqrt{\color{blue}{{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}^{2}}} \]
  11. Applied egg-rr27.1%

    \[\leadsto \color{blue}{\sqrt{{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}^{2}}} \]
  12. Step-by-step derivation
    1. unpow227.1%

      \[\leadsto \sqrt{\color{blue}{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
    2. rem-sqrt-square39.2%

      \[\leadsto \color{blue}{\left|d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right|} \]
  13. Simplified39.2%

    \[\leadsto \color{blue}{\left|d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right|} \]
  14. Final simplification39.2%

    \[\leadsto \left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right| \]
  15. Add Preprocessing

Alternative 18: 42.9% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \left|\frac{d}{\sqrt{\ell \cdot h}}\right| \end{array} \]
(FPCore (d h l M D) :precision binary64 (fabs (/ d (sqrt (* l h)))))
double code(double d, double h, double l, double M, double D) {
	return fabs((d / sqrt((l * h))));
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    code = abs((d / sqrt((l * h))))
end function
public static double code(double d, double h, double l, double M, double D) {
	return Math.abs((d / Math.sqrt((l * h))));
}
def code(d, h, l, M, D):
	return math.fabs((d / math.sqrt((l * h))))
function code(d, h, l, M, D)
	return abs(Float64(d / sqrt(Float64(l * h))))
end
function tmp = code(d, h, l, M, D)
	tmp = abs((d / sqrt((l * h))));
end
code[d_, h_, l_, M_, D_] := N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\left|\frac{d}{\sqrt{\ell \cdot h}}\right|
\end{array}
Derivation
  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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in d around inf 23.3%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  5. Step-by-step derivation
    1. *-commutative23.3%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    2. associate-/r*23.5%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
  6. Simplified23.5%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
  7. Taylor expanded in d around 0 23.3%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  8. Step-by-step derivation
    1. unpow1/223.3%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    2. rem-exp-log22.4%

      \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
    3. exp-neg22.4%

      \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
    4. exp-prod22.7%

      \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
    5. distribute-lft-neg-out22.7%

      \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
    6. distribute-rgt-neg-in22.7%

      \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
    7. metadata-eval22.7%

      \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
    8. exp-to-pow23.6%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  9. Simplified23.6%

    \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
  10. Step-by-step derivation
    1. add-sqr-sqrt19.4%

      \[\leadsto \color{blue}{\sqrt{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{d \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
    2. sqrt-unprod27.1%

      \[\leadsto \color{blue}{\sqrt{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
    3. pow227.1%

      \[\leadsto \sqrt{\color{blue}{{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}^{2}}} \]
  11. Applied egg-rr27.1%

    \[\leadsto \color{blue}{\sqrt{{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}^{2}}} \]
  12. Step-by-step derivation
    1. unpow227.1%

      \[\leadsto \sqrt{\color{blue}{\left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
    2. rem-sqrt-square39.2%

      \[\leadsto \color{blue}{\left|d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right|} \]
    3. rem-exp-log18.5%

      \[\leadsto \left|\color{blue}{e^{\log \left(d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right)}}\right| \]
    4. log-prod17.6%

      \[\leadsto \left|e^{\color{blue}{\log d + \log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}}\right| \]
    5. log-pow17.6%

      \[\leadsto \left|e^{\log d + \color{blue}{-0.5 \cdot \log \left(h \cdot \ell\right)}}\right| \]
    6. metadata-eval17.6%

      \[\leadsto \left|e^{\log d + \color{blue}{\left(-0.5\right)} \cdot \log \left(h \cdot \ell\right)}\right| \]
    7. distribute-lft-neg-in17.6%

      \[\leadsto \left|e^{\log d + \color{blue}{\left(-0.5 \cdot \log \left(h \cdot \ell\right)\right)}}\right| \]
    8. log-pow17.6%

      \[\leadsto \left|e^{\log d + \left(-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}\right)}\right| \]
    9. unpow1/217.6%

      \[\leadsto \left|e^{\log d + \left(-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}\right)}\right| \]
    10. sub-neg17.6%

      \[\leadsto \left|e^{\color{blue}{\log d - \log \left(\sqrt{h \cdot \ell}\right)}}\right| \]
    11. log-div18.5%

      \[\leadsto \left|e^{\color{blue}{\log \left(\frac{d}{\sqrt{h \cdot \ell}}\right)}}\right| \]
    12. rem-exp-log39.2%

      \[\leadsto \left|\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}}\right| \]
  13. Simplified39.2%

    \[\leadsto \color{blue}{\left|\frac{d}{\sqrt{h \cdot \ell}}\right|} \]
  14. Final simplification39.2%

    \[\leadsto \left|\frac{d}{\sqrt{\ell \cdot h}}\right| \]
  15. Add Preprocessing

Alternative 19: 37.9% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -2.25 \cdot 10^{-172}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= d -2.25e-172) (sqrt (* (/ d l) (/ d h))) (* d (pow (* l h) -0.5))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -2.25e-172) {
		tmp = sqrt(((d / l) * (d / h)));
	} else {
		tmp = d * pow((l * h), -0.5);
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (d <= (-2.25d-172)) then
        tmp = sqrt(((d / l) * (d / h)))
    else
        tmp = d * ((l * h) ** (-0.5d0))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -2.25e-172) {
		tmp = Math.sqrt(((d / l) * (d / h)));
	} else {
		tmp = d * Math.pow((l * h), -0.5);
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if d <= -2.25e-172:
		tmp = math.sqrt(((d / l) * (d / h)))
	else:
		tmp = d * math.pow((l * h), -0.5)
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= -2.25e-172)
		tmp = sqrt(Float64(Float64(d / l) * Float64(d / h)));
	else
		tmp = Float64(d * (Float64(l * h) ^ -0.5));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (d <= -2.25e-172)
		tmp = sqrt(((d / l) * (d / h)));
	else
		tmp = d * ((l * h) ^ -0.5);
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[d, -2.25e-172], N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.25 \cdot 10^{-172}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.25000000000000002e-172

    1. Initial program 74.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.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. frac-times74.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. associate-/r*74.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\color{blue}{\left(\frac{\frac{M \cdot D}{2}}{d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. Applied egg-rr74.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\color{blue}{\left(\frac{\frac{M \cdot D}{2}}{d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. Step-by-step derivation
      1. expm1-log1p-u39.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{\frac{M \cdot D}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)\right)} \]
      2. expm1-udef27.3%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{\frac{M \cdot D}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} - 1} \]
    7. Applied egg-rr21.7%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2}\right)\right)\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def29.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2}\right)\right)\right)\right)} \]
      2. expm1-log1p61.6%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2}\right)\right)} \]
      3. associate-*r*61.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2}}\right) \]
      4. *-commutative61.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot -0.5\right)} \cdot {\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2}\right) \]
      5. *-commutative61.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{{\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right)}\right) \]
      6. +-commutative61.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\left({\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right) + 1\right)} \]
      7. fma-def61.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{\mathsf{fma}\left({\left(D \cdot \frac{M \cdot 0.5}{d}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)} \]
      8. *-commutative61.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \mathsf{fma}\left({\color{blue}{\left(\frac{M \cdot 0.5}{d} \cdot D\right)}}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      9. associate-/r/62.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \mathsf{fma}\left({\color{blue}{\left(\frac{M \cdot 0.5}{\frac{d}{D}}\right)}}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
      10. *-commutative62.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(\frac{\color{blue}{0.5 \cdot M}}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \]
    9. Simplified62.7%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(\frac{0.5 \cdot M}{\frac{d}{D}}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right)} \]
    10. Taylor expanded in M around 0 32.9%

      \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \color{blue}{1} \]

    if -2.25000000000000002e-172 < d

    1. Initial program 59.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. Simplified59.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 34.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative34.3%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*34.7%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    6. Simplified34.7%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    7. Taylor expanded in d around 0 34.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. unpow1/234.3%

        \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
      2. rem-exp-log32.9%

        \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
      3. exp-neg32.9%

        \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
      4. exp-prod33.4%

        \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
      5. distribute-lft-neg-out33.4%

        \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
      6. distribute-rgt-neg-in33.4%

        \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
      7. metadata-eval33.4%

        \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
      8. exp-to-pow34.9%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Simplified34.9%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification34.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.25 \cdot 10^{-172}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 26.5% accurate, 3.1× speedup?

\[\begin{array}{l} \\ d \cdot {\left(\ell \cdot h\right)}^{-0.5} \end{array} \]
(FPCore (d h l M D) :precision binary64 (* d (pow (* l h) -0.5)))
double code(double d, double h, double l, double M, double D) {
	return d * pow((l * h), -0.5);
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    code = d * ((l * h) ** (-0.5d0))
end function
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.pow((l * h), -0.5);
}
def code(d, h, l, M, D):
	return d * math.pow((l * h), -0.5)
function code(d, h, l, M, D)
	return Float64(d * (Float64(l * h) ^ -0.5))
end
function tmp = code(d, h, l, M, D)
	tmp = d * ((l * h) ^ -0.5);
end
code[d_, h_, l_, M_, D_] := N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
d \cdot {\left(\ell \cdot h\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in d around inf 23.3%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  5. Step-by-step derivation
    1. *-commutative23.3%

      \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
    2. associate-/r*23.5%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
  6. Simplified23.5%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
  7. Taylor expanded in d around 0 23.3%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  8. Step-by-step derivation
    1. unpow1/223.3%

      \[\leadsto d \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    2. rem-exp-log22.4%

      \[\leadsto d \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
    3. exp-neg22.4%

      \[\leadsto d \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
    4. exp-prod22.7%

      \[\leadsto d \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
    5. distribute-lft-neg-out22.7%

      \[\leadsto d \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
    6. distribute-rgt-neg-in22.7%

      \[\leadsto d \cdot e^{\color{blue}{\log \left(h \cdot \ell\right) \cdot \left(-0.5\right)}} \]
    7. metadata-eval22.7%

      \[\leadsto d \cdot e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{-0.5}} \]
    8. exp-to-pow23.6%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  9. Simplified23.6%

    \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
  10. Final simplification23.6%

    \[\leadsto d \cdot {\left(\ell \cdot h\right)}^{-0.5} \]
  11. Add Preprocessing

Alternative 21: 26.5% accurate, 3.2× speedup?

\[\begin{array}{l} \\ \frac{d}{\sqrt{\ell \cdot h}} \end{array} \]
(FPCore (d h l M D) :precision binary64 (/ d (sqrt (* l h))))
double code(double d, double h, double l, double M, double D) {
	return d / sqrt((l * h));
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    code = d / sqrt((l * h))
end function
public static double code(double d, double h, double l, double M, double D) {
	return d / Math.sqrt((l * h));
}
def code(d, h, l, M, D):
	return d / math.sqrt((l * h))
function code(d, h, l, M, D)
	return Float64(d / sqrt(Float64(l * h)))
end
function tmp = code(d, h, l, M, D)
	tmp = d / sqrt((l * h));
end
code[d_, h_, l_, M_, D_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Derivation
  1. Initial program 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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. clear-num65.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\color{blue}{\frac{1}{\frac{2}{M}}} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    2. frac-times65.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\color{blue}{\left(\frac{1 \cdot D}{\frac{2}{M} \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    3. *-un-lft-identity65.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{\color{blue}{D}}{\frac{2}{M} \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    4. associate-*l/65.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{\color{blue}{\frac{2 \cdot d}{M}}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    5. *-un-lft-identity65.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{\frac{2 \cdot d}{\color{blue}{1 \cdot M}}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    6. times-frac65.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{\color{blue}{\frac{2}{1} \cdot \frac{d}{M}}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
    7. metadata-eval65.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{D}{\color{blue}{2} \cdot \frac{d}{M}}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
  5. Applied egg-rr65.5%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\color{blue}{\left(\frac{D}{2 \cdot \frac{d}{M}}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right) \]
  6. Taylor expanded in d around inf 23.3%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  7. Step-by-step derivation
    1. rem-exp-log17.5%

      \[\leadsto \color{blue}{e^{\log d}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
    2. unpow1/217.5%

      \[\leadsto e^{\log d} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}} \]
    3. rem-exp-log17.4%

      \[\leadsto e^{\log d} \cdot {\left(\frac{1}{\color{blue}{e^{\log \left(h \cdot \ell\right)}}}\right)}^{0.5} \]
    4. rec-exp17.4%

      \[\leadsto e^{\log d} \cdot {\color{blue}{\left(e^{-\log \left(h \cdot \ell\right)}\right)}}^{0.5} \]
    5. exp-prod17.7%

      \[\leadsto e^{\log d} \cdot \color{blue}{e^{\left(-\log \left(h \cdot \ell\right)\right) \cdot 0.5}} \]
    6. distribute-lft-neg-in17.7%

      \[\leadsto e^{\log d} \cdot e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}} \]
    7. *-commutative17.7%

      \[\leadsto e^{\log d} \cdot e^{-\color{blue}{0.5 \cdot \log \left(h \cdot \ell\right)}} \]
    8. distribute-lft-neg-in17.7%

      \[\leadsto e^{\log d} \cdot e^{\color{blue}{\left(-0.5\right) \cdot \log \left(h \cdot \ell\right)}} \]
    9. metadata-eval17.7%

      \[\leadsto e^{\log d} \cdot e^{\color{blue}{-0.5} \cdot \log \left(h \cdot \ell\right)} \]
    10. log-pow17.7%

      \[\leadsto e^{\log d} \cdot e^{\color{blue}{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
    11. exp-sum17.6%

      \[\leadsto \color{blue}{e^{\log d + \log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
    12. log-pow17.6%

      \[\leadsto e^{\log d + \color{blue}{-0.5 \cdot \log \left(h \cdot \ell\right)}} \]
    13. metadata-eval17.6%

      \[\leadsto e^{\log d + \color{blue}{\left(-0.5\right)} \cdot \log \left(h \cdot \ell\right)} \]
    14. distribute-lft-neg-in17.6%

      \[\leadsto e^{\log d + \color{blue}{\left(-0.5 \cdot \log \left(h \cdot \ell\right)\right)}} \]
    15. log-pow17.6%

      \[\leadsto e^{\log d + \left(-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}\right)} \]
    16. unpow1/217.6%

      \[\leadsto e^{\log d + \left(-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}\right)} \]
    17. sub-neg17.6%

      \[\leadsto e^{\color{blue}{\log d - \log \left(\sqrt{h \cdot \ell}\right)}} \]
    18. log-div18.5%

      \[\leadsto e^{\color{blue}{\log \left(\frac{d}{\sqrt{h \cdot \ell}}\right)}} \]
  8. Simplified23.6%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  9. Final simplification23.6%

    \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
  10. Add Preprocessing

Reproduce

?
herbie shell --seed 2024018 
(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)))))