Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.0% → 79.1%
Time: 25.9s
Alternatives: 17
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 17 alternatives:

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

Initial Program: 66.0% accurate, 1.0× speedup?

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

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

Alternative 1: 79.1% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -1 \cdot 10^{-309}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot -0.5\right)\right) \cdot \sqrt{\frac{d}{\ell}}\right)\\ \mathbf{elif}\;d \leq 5.5 \cdot 10^{-252}:\\ \;\;\;\;{\left(\sqrt[3]{\frac{d \cdot \mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot {\left(\frac{D \cdot \left(M \cdot 0.5\right)}{d}\right)}^{2}, 1\right)}{\sqrt{h \cdot \ell}}}\right)}^{3}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(M \cdot \frac{D}{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
 (if (<= d -1e-309)
   (*
    (/ (sqrt (- d)) (sqrt (- h)))
    (*
     (+ 1.0 (* (/ h l) (* (pow (* (/ M 2.0) (/ D d)) 2.0) -0.5)))
     (sqrt (/ d l))))
   (if (<= d 5.5e-252)
     (pow
      (cbrt
       (/
        (* d (fma -0.5 (* (/ h l) (pow (/ (* D (* M 0.5)) d) 2.0)) 1.0))
        (sqrt (* h l))))
      3.0)
     (*
      (fma (/ h l) (* -0.5 (pow (* M (/ D (* 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 tmp;
	if (d <= -1e-309) {
		tmp = (sqrt(-d) / sqrt(-h)) * ((1.0 + ((h / l) * (pow(((M / 2.0) * (D / d)), 2.0) * -0.5))) * sqrt((d / l)));
	} else if (d <= 5.5e-252) {
		tmp = pow(cbrt(((d * fma(-0.5, ((h / l) * pow(((D * (M * 0.5)) / d), 2.0)), 1.0)) / sqrt((h * l)))), 3.0);
	} else {
		tmp = fma((h / l), (-0.5 * pow((M * (D / (d * 2.0))), 2.0)), 1.0) * (d / (sqrt(h) * sqrt(l)));
	}
	return tmp;
}
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= -1e-309)
		tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(M / 2.0) * Float64(D / d)) ^ 2.0) * -0.5))) * sqrt(Float64(d / l))));
	elseif (d <= 5.5e-252)
		tmp = cbrt(Float64(Float64(d * fma(-0.5, Float64(Float64(h / l) * (Float64(Float64(D * Float64(M * 0.5)) / d) ^ 2.0)), 1.0)) / sqrt(Float64(h * l)))) ^ 3.0;
	else
		tmp = Float64(fma(Float64(h / l), Float64(-0.5 * (Float64(M * Float64(D / 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_] := If[LessEqual[d, -1e-309], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(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] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.5e-252], N[Power[N[Power[N[(N[(d * N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D * N[(M * 0.5), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision], N[(N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(M * N[(D / 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}
\mathbf{if}\;d \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot -0.5\right)\right) \cdot \sqrt{\frac{d}{\ell}}\right)\\

\mathbf{elif}\;d \leq 5.5 \cdot 10^{-252}:\\
\;\;\;\;{\left(\sqrt[3]{\frac{d \cdot \mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot {\left(\frac{D \cdot \left(M \cdot 0.5\right)}{d}\right)}^{2}, 1\right)}{\sqrt{h \cdot \ell}}}\right)}^{3}\\

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


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

    1. Initial program 70.7%

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

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

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

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

      \[\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.000000000000002e-309 < d < 5.5e-252

    1. Initial program 17.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. Simplified15.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. add-cube-cbrt15.9%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\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)} \cdot \sqrt[3]{\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)}\right) \cdot \sqrt[3]{\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)}} \]
      2. pow315.9%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{\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)}\right)}^{3}} \]
    5. Applied egg-rr16.6%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \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)}^{3}} \]
    6. Step-by-step derivation
      1. associate-*l/40.0%

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

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

    if 5.5e-252 < d

    1. Initial program 72.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified72.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. Step-by-step derivation
      1. expm1-log1p-u41.5%

        \[\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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)\right)} \]
      2. expm1-udef24.5%

        \[\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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} - 1} \]
    5. Applied egg-rr33.2%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \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} \]
    6. Step-by-step derivation
      1. expm1-def54.3%

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

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

        \[\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{h} \cdot \sqrt{\ell}}} \]
    7. Simplified88.8%

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

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

Alternative 2: 75.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h}}\\ \mathbf{if}\;h \leq -2 \cdot 10^{+32}:\\ \;\;\;\;t_0 \cdot \left(\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) \cdot \sqrt{\frac{d}{\ell}}\right)\\ \mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\ \;\;\;\;t_0 \cdot \left(\left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot -0.5\right)\right) \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(M \cdot \frac{D}{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))))
   (if (<= h -2e+32)
     (*
      t_0
      (*
       (+ 1.0 (/ (* h (* -0.5 (pow (* (/ D d) (* M 0.5)) 2.0))) l))
       (sqrt (/ d l))))
     (if (<= h -5e-310)
       (*
        t_0
        (*
         (+ 1.0 (* (/ h l) (* (pow (* (/ M 2.0) (/ D d)) 2.0) -0.5)))
         (/ (sqrt (- d)) (sqrt (- l)))))
       (*
        (fma (/ h l) (* -0.5 (pow (* M (/ D (* 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 tmp;
	if (h <= -2e+32) {
		tmp = t_0 * ((1.0 + ((h * (-0.5 * pow(((D / d) * (M * 0.5)), 2.0))) / l)) * sqrt((d / l)));
	} else if (h <= -5e-310) {
		tmp = t_0 * ((1.0 + ((h / l) * (pow(((M / 2.0) * (D / d)), 2.0) * -0.5))) * (sqrt(-d) / sqrt(-l)));
	} else {
		tmp = fma((h / l), (-0.5 * pow((M * (D / (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))
	tmp = 0.0
	if (h <= -2e+32)
		tmp = Float64(t_0 * Float64(Float64(1.0 + Float64(Float64(h * Float64(-0.5 * (Float64(Float64(D / d) * Float64(M * 0.5)) ^ 2.0))) / l)) * sqrt(Float64(d / l))));
	elseif (h <= -5e-310)
		tmp = Float64(t_0 * Float64(Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(M / 2.0) * Float64(D / d)) ^ 2.0) * -0.5))) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-l)))));
	else
		tmp = Float64(fma(Float64(h / l), Float64(-0.5 * (Float64(M * Float64(D / 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]}, If[LessEqual[h, -2e+32], N[(t$95$0 * N[(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] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -5e-310], N[(t$95$0 * N[(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] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(M * N[(D / 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}}\\
\mathbf{if}\;h \leq -2 \cdot 10^{+32}:\\
\;\;\;\;t_0 \cdot \left(\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) \cdot \sqrt{\frac{d}{\ell}}\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -2.00000000000000011e32

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

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

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

      \[\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 -2.00000000000000011e32 < h < -4.999999999999985e-310

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 66.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. Simplified66.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. expm1-log1p-u38.1%

        \[\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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)\right)} \]
      2. expm1-udef22.8%

        \[\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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} - 1} \]
    5. Applied egg-rr30.6%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \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} \]
    6. Step-by-step derivation
      1. expm1-def49.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \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-log1p81.5%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \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. *-commutative81.5%

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

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

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

Alternative 3: 78.5% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2.85 \cdot 10^{-308}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot -0.5\right)\right) \cdot \sqrt{\frac{d}{\ell}}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(M \cdot \frac{D}{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
 (if (<= l -2.85e-308)
   (*
    (/ (sqrt (- d)) (sqrt (- h)))
    (*
     (+ 1.0 (* (/ h l) (* (pow (* (/ M 2.0) (/ D d)) 2.0) -0.5)))
     (sqrt (/ d l))))
   (*
    (fma (/ h l) (* -0.5 (pow (* M (/ D (* 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 tmp;
	if (l <= -2.85e-308) {
		tmp = (sqrt(-d) / sqrt(-h)) * ((1.0 + ((h / l) * (pow(((M / 2.0) * (D / d)), 2.0) * -0.5))) * sqrt((d / l)));
	} else {
		tmp = fma((h / l), (-0.5 * pow((M * (D / (d * 2.0))), 2.0)), 1.0) * (d / (sqrt(h) * sqrt(l)));
	}
	return tmp;
}
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -2.85e-308)
		tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(M / 2.0) * Float64(D / d)) ^ 2.0) * -0.5))) * sqrt(Float64(d / l))));
	else
		tmp = Float64(fma(Float64(h / l), Float64(-0.5 * (Float64(M * Float64(D / 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_] := If[LessEqual[l, -2.85e-308], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(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] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(M * N[(D / 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}
\mathbf{if}\;\ell \leq -2.85 \cdot 10^{-308}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot -0.5\right)\right) \cdot \sqrt{\frac{d}{\ell}}\right)\\

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


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

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

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

      \[\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 -2.85000000000000019e-308 < l

    1. Initial program 66.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. Simplified66.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. expm1-log1p-u37.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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)\right)} \]
      2. expm1-udef22.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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} - 1} \]
    5. Applied egg-rr30.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \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} \]
    6. Step-by-step derivation
      1. expm1-def49.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \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-log1p80.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \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. *-commutative80.9%

        \[\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{h} \cdot \sqrt{\ell}}} \]
    7. Simplified80.9%

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

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

Alternative 4: 73.7% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;h \leq 1.65 \cdot 10^{-295}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\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) \cdot \sqrt{\frac{d}{\ell}}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(M \cdot \frac{D}{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
 (if (<= h 1.65e-295)
   (*
    (sqrt (/ d h))
    (*
     (+ 1.0 (/ (* h (* -0.5 (pow (* (/ D d) (* M 0.5)) 2.0))) l))
     (sqrt (/ d l))))
   (*
    (fma (/ h l) (* -0.5 (pow (* M (/ D (* 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 tmp;
	if (h <= 1.65e-295) {
		tmp = sqrt((d / h)) * ((1.0 + ((h * (-0.5 * pow(((D / d) * (M * 0.5)), 2.0))) / l)) * sqrt((d / l)));
	} else {
		tmp = fma((h / l), (-0.5 * pow((M * (D / (d * 2.0))), 2.0)), 1.0) * (d / (sqrt(h) * sqrt(l)));
	}
	return tmp;
}
function code(d, h, l, M, D)
	tmp = 0.0
	if (h <= 1.65e-295)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(1.0 + Float64(Float64(h * Float64(-0.5 * (Float64(Float64(D / d) * Float64(M * 0.5)) ^ 2.0))) / l)) * sqrt(Float64(d / l))));
	else
		tmp = Float64(fma(Float64(h / l), Float64(-0.5 * (Float64(M * Float64(D / 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_] := If[LessEqual[h, 1.65e-295], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(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] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(M * N[(D / 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}
\mathbf{if}\;h \leq 1.65 \cdot 10^{-295}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\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) \cdot \sqrt{\frac{d}{\ell}}\right)\\

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


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

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

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot -0.5\right)\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-*l/74.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-rr74.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.6499999999999999e-295 < h

    1. Initial program 66.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. Simplified66.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. expm1-log1p-u38.3%

        \[\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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)\right)} \]
      2. expm1-udef22.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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} - 1} \]
    5. Applied egg-rr30.7%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \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} \]
    6. Step-by-step derivation
      1. expm1-def50.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \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-log1p81.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \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. *-commutative81.9%

        \[\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{h} \cdot \sqrt{\ell}}} \]
    7. Simplified81.9%

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

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

Alternative 5: 47.2% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;\ell \leq 2.25 \cdot 10^{-165}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\ell \leq 1.06 \cdot 10^{-85}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;\ell \leq 4.1 \cdot 10^{-67}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;\ell \leq 1.4 \cdot 10^{+41}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_2\\


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

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

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

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

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

        \[\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) \]
    6. Applied egg-rr55.8%

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

    if -4.999999999999985e-310 < l < 2.24999999999999996e-165 or 1.0599999999999999e-85 < l < 4.0999999999999997e-67 or 1.9999999999999999e-36 < l < 1.4e41

    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}{\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 0 52.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\sqrt{h \cdot {\ell}^{-3}} \cdot \color{blue}{\left(\left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right) \cdot -0.125\right)}\right)} - 1 \]
      7. associate-*l/0.1%

        \[\leadsto e^{\mathsf{log1p}\left(\sqrt{h \cdot {\ell}^{-3}} \cdot \left(\color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{d}} \cdot -0.125\right)\right)} - 1 \]
      8. pow-prod-down1.4%

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

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

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

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

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

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

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

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

    if 2.24999999999999996e-165 < l < 1.0599999999999999e-85 or 1.4e41 < l

    1. Initial program 56.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. Simplified56.6%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. sqrt-div60.9%

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

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

    if 4.0999999999999997e-67 < l < 1.9999999999999999e-36

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. pow1/281.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq 2.25 \cdot 10^{-165}:\\ \;\;\;\;\sqrt{h \cdot {\ell}^{-3}} \cdot \left(-0.125 \cdot \frac{{\left(M \cdot D\right)}^{2}}{d}\right)\\ \mathbf{elif}\;\ell \leq 1.06 \cdot 10^{-85}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{d}}{\sqrt{h}}\\ \mathbf{elif}\;\ell \leq 4.1 \cdot 10^{-67}:\\ \;\;\;\;\sqrt{h \cdot {\ell}^{-3}} \cdot \left(-0.125 \cdot \frac{{\left(M \cdot D\right)}^{2}}{d}\right)\\ \mathbf{elif}\;\ell \leq 2 \cdot 10^{-36}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{d} \cdot \sqrt{\frac{1}{\ell}}\right)\\ \mathbf{elif}\;\ell \leq 1.4 \cdot 10^{+41}:\\ \;\;\;\;\sqrt{h \cdot {\ell}^{-3}} \cdot \left(-0.125 \cdot \frac{{\left(M \cdot D\right)}^{2}}{d}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{d}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 66.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;\ell \leq -8 \cdot 10^{+197}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -7.9999999999999996e197

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

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

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

        \[\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-div70.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) \]
    6. Applied egg-rr71.8%

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

    if -7.9999999999999996e197 < l < 1.56000000000000009e60

    1. Initial program 75.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. Simplified74.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.56000000000000009e60 < l

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. sqrt-div62.9%

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

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

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

Alternative 7: 68.3% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;\ell \leq -1.4 \cdot 10^{+198}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t_0\\

\mathbf{elif}\;\ell \leq 1.05 \cdot 10^{+60}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\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) \cdot t_0\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1.4e198

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

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

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

        \[\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-div70.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) \]
    6. Applied egg-rr71.8%

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

    if -1.4e198 < l < 1.0500000000000001e60

    1. Initial program 75.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. Simplified74.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
    4. Step-by-step derivation
      1. associate-*l/78.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-rr78.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.0500000000000001e60 < l

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. sqrt-div62.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.4 \cdot 10^{+198}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq 1.05 \cdot 10^{+60}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\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) \cdot \sqrt{\frac{d}{\ell}}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{d}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 59.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;\ell \leq -2.3 \cdot 10^{+93}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t_0\\

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

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


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

    1. Initial program 67.2%

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

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

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

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

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

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

    if -2.3000000000000002e93 < l < 4.4000000000000003e42

    1. Initial program 75.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. Simplified74.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. add-cbrt-cube67.7%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt[3]{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{\ell}}\right) \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) \]
      2. pow1/366.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \sqrt{\frac{d}{\ell}}\right)}^{0.3333333333333333}}\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-sqr-sqrt66.4%

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(\color{blue}{{\left(\frac{d}{\ell}\right)}^{1}} \cdot \sqrt{\frac{d}{\ell}}\right)}^{0.3333333333333333}\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. pow1/266.4%

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left({\left(\frac{d}{\ell}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333}\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-rr66.4%

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

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

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

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

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

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

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

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

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

    if 4.4000000000000003e42 < l

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

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

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

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

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

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

Alternative 9: 65.9% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 9.80000000000000015e59

    1. Initial program 73.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. Simplified72.7%

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

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

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

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

    if 9.80000000000000015e59 < l

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. sqrt-div62.9%

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

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

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

Alternative 10: 42.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;h \leq 1.4 \cdot 10^{-271}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{1}{\sqrt{\frac{h}{d}}}\\ \mathbf{elif}\;h \leq 1.45 \cdot 10^{-227}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= h 1.4e-271)
   (* (sqrt (/ d l)) (/ 1.0 (sqrt (/ h d))))
   (if (<= h 1.45e-227)
     (* d (sqrt (/ 1.0 (* h l))))
     (* (sqrt (/ d h)) (/ (sqrt d) (sqrt l))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= 1.4e-271) {
		tmp = sqrt((d / l)) * (1.0 / sqrt((h / d)));
	} else if (h <= 1.45e-227) {
		tmp = d * sqrt((1.0 / (h * l)));
	} else {
		tmp = sqrt((d / h)) * (sqrt(d) / sqrt(l));
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (h <= 1.4d-271) then
        tmp = sqrt((d / l)) * (1.0d0 / sqrt((h / d)))
    else if (h <= 1.45d-227) then
        tmp = d * sqrt((1.0d0 / (h * l)))
    else
        tmp = sqrt((d / h)) * (sqrt(d) / sqrt(l))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= 1.4e-271) {
		tmp = Math.sqrt((d / l)) * (1.0 / Math.sqrt((h / d)));
	} else if (h <= 1.45e-227) {
		tmp = d * Math.sqrt((1.0 / (h * l)));
	} else {
		tmp = Math.sqrt((d / h)) * (Math.sqrt(d) / Math.sqrt(l));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if h <= 1.4e-271:
		tmp = math.sqrt((d / l)) * (1.0 / math.sqrt((h / d)))
	elif h <= 1.45e-227:
		tmp = d * math.sqrt((1.0 / (h * l)))
	else:
		tmp = math.sqrt((d / h)) * (math.sqrt(d) / math.sqrt(l))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (h <= 1.4e-271)
		tmp = Float64(sqrt(Float64(d / l)) * Float64(1.0 / sqrt(Float64(h / d))));
	elseif (h <= 1.45e-227)
		tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * l))));
	else
		tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(d) / sqrt(l)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (h <= 1.4e-271)
		tmp = sqrt((d / l)) * (1.0 / sqrt((h / d)));
	elseif (h <= 1.45e-227)
		tmp = d * sqrt((1.0 / (h * l)));
	else
		tmp = sqrt((d / h)) * (sqrt(d) / sqrt(l));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[h, 1.4e-271], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 1.45e-227], N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;h \leq 1.45 \cdot 10^{-227}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\

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


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

    1. Initial program 70.1%

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. clear-num46.9%

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

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

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

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

    if 1.3999999999999999e-271 < h < 1.45000000000000005e-227

    1. Initial program 42.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. Simplified43.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. Taylor expanded in d around inf 74.1%

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

    if 1.45000000000000005e-227 < h

    1. Initial program 70.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. Simplified70.5%

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. sqrt-div44.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq 1.4 \cdot 10^{-271}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{1}{\sqrt{\frac{h}{d}}}\\ \mathbf{elif}\;h \leq 1.45 \cdot 10^{-227}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 45.2% accurate, 1.1× speedup?

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

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

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


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

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

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

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

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

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

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

    if -1.000000000000002e-309 < d

    1. Initial program 66.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. Simplified65.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1 \cdot 10^{-309}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{d}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 45.8% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;d \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t_0\\

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


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

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

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

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

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

        \[\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) \]
    6. Applied egg-rr55.8%

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

    if -1.000000000000002e-309 < d

    1. Initial program 66.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. Simplified65.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1 \cdot 10^{-309}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{d}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 42.6% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;d \leq 5 \cdot 10^{-68}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot t_0\\

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


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

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

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

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

    if 4.99999999999999971e-68 < d

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right) \]
    6. Applied egg-rr59.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 5 \cdot 10^{-68}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{d}}{\sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 38.6% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq 0.165:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{1}{\sqrt{\frac{h}{d}}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= M 0.165)
   (* (sqrt (/ d l)) (/ 1.0 (sqrt (/ h d))))
   (* d (sqrt (/ (/ 1.0 l) h)))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (M <= 0.165) {
		tmp = sqrt((d / l)) * (1.0 / sqrt((h / d)));
	} else {
		tmp = d * sqrt(((1.0 / l) / h));
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (m <= 0.165d0) then
        tmp = sqrt((d / l)) * (1.0d0 / sqrt((h / d)))
    else
        tmp = d * sqrt(((1.0d0 / l) / h))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (M <= 0.165) {
		tmp = Math.sqrt((d / l)) * (1.0 / Math.sqrt((h / d)));
	} else {
		tmp = d * Math.sqrt(((1.0 / l) / h));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if M <= 0.165:
		tmp = math.sqrt((d / l)) * (1.0 / math.sqrt((h / d)))
	else:
		tmp = d * math.sqrt(((1.0 / l) / h))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (M <= 0.165)
		tmp = Float64(sqrt(Float64(d / l)) * Float64(1.0 / sqrt(Float64(h / d))));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / l) / h)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (M <= 0.165)
		tmp = sqrt((d / l)) * (1.0 / sqrt((h / d)));
	else
		tmp = d * sqrt(((1.0 / l) / h));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[M, 0.165], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;M \leq 0.165:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{1}{\sqrt{\frac{h}{d}}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 0.165000000000000008

    1. Initial program 69.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. Simplified68.1%

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

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

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

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

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

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

    if 0.165000000000000008 < M

    1. Initial program 67.3%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 0.165:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{1}{\sqrt{\frac{h}{d}}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 38.4% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq 0.066:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= M 0.066)
   (* (sqrt (/ d h)) (sqrt (/ d l)))
   (* d (sqrt (/ (/ 1.0 l) h)))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (M <= 0.066) {
		tmp = sqrt((d / h)) * sqrt((d / l));
	} else {
		tmp = d * sqrt(((1.0 / l) / h));
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (m <= 0.066d0) then
        tmp = sqrt((d / h)) * sqrt((d / l))
    else
        tmp = d * sqrt(((1.0d0 / l) / h))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (M <= 0.066) {
		tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
	} else {
		tmp = d * Math.sqrt(((1.0 / l) / h));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if M <= 0.066:
		tmp = math.sqrt((d / h)) * math.sqrt((d / l))
	else:
		tmp = d * math.sqrt(((1.0 / l) / h))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (M <= 0.066)
		tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / l) / h)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (M <= 0.066)
		tmp = sqrt((d / h)) * sqrt((d / l));
	else
		tmp = d * sqrt(((1.0 / l) / h));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[M, 0.066], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;M \leq 0.066:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 0.066000000000000003

    1. Initial program 69.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. Simplified68.1%

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

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

    if 0.066000000000000003 < M

    1. Initial program 67.3%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 0.066:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 37.9% accurate, 3.0× speedup?

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

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

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


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

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. pow1/249.6%

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\color{blue}{\left(1.5 \cdot 0.3333333333333333\right)}} \]
      4. pow-pow35.6%

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt[3]{{\left(\frac{d}{\ell}\right)}^{1.5}}} \]
      6. expm1-log1p-u36.2%

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left({\left(\frac{d}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}}\right)} - 1 \]
      9. pow-pow30.8%

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}}\right)} - 1 \]
      12. *-rgt-identity30.8%

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot 1\right) \cdot \sqrt{\frac{d}{h}}}\right)} - 1 \]
      14. *-rgt-identity30.8%

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

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

        \[\leadsto e^{\mathsf{log1p}\left({\left(\frac{d}{\ell}\right)}^{0.5} \cdot \color{blue}{{\left(\frac{d}{h}\right)}^{0.5}}\right)} - 1 \]
      17. pow-prod-down26.7%

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

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

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

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

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

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

    if -3.3999999999999999e-304 < h

    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}{\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 37.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -3.4 \cdot 10^{-304}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 33.0% accurate, 3.1× speedup?

\[\begin{array}{l} \\ \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \end{array} \]
(FPCore (d h l M D) :precision binary64 (sqrt (* (/ d l) (/ d h))))
double code(double d, double h, double l, double M, double D) {
	return sqrt(((d / l) * (d / 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 = sqrt(((d / l) * (d / h)))
end function
public static double code(double d, double h, double l, double M, double D) {
	return Math.sqrt(((d / l) * (d / h)));
}
def code(d, h, l, M, D):
	return math.sqrt(((d / l) * (d / h)))
function code(d, h, l, M, D)
	return sqrt(Float64(Float64(d / l) * Float64(d / h)))
end
function tmp = code(d, h, l, M, D)
	tmp = sqrt(((d / l) * (d / h)));
end
code[d_, h_, l_, M_, D_] := N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}
\end{array}
Derivation
  1. Initial program 68.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. Simplified68.0%

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
    2. pow1/242.9%

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt[3]{{\left(\frac{d}{\ell}\right)}^{1.5}}} \]
    6. expm1-log1p-u31.9%

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

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

      \[\leadsto e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left({\left(\frac{d}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}}\right)} - 1 \]
    9. pow-pow26.8%

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

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

      \[\leadsto e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}}\right)} - 1 \]
    12. *-rgt-identity26.8%

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

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot 1\right) \cdot \sqrt{\frac{d}{h}}}\right)} - 1 \]
    14. *-rgt-identity26.8%

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

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

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

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

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

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

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

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

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

    \[\leadsto \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \]
  10. Add Preprocessing

Reproduce

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