Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.9% → 82.3%
Time: 22.9s
Alternatives: 16
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 16 alternatives:

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

Initial Program: 66.9% accurate, 1.0× speedup?

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

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

Alternative 1: 82.3% accurate, 0.8× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

    if 9.999999999999969e-311 < l

    1. Initial program 70.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Add Preprocessing
    3. Applied egg-rr85.8%

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

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

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

Alternative 2: 79.0% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 59.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.00000000000000028e-33 < l < -4.999999999999985e-310

    1. Initial program 69.9%

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

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

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 70.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Add Preprocessing
    3. Applied egg-rr85.8%

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

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

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

Alternative 3: 77.9% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 65.3%

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

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

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

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

    if 3.59999999999999968e-272 < h

    1. Initial program 69.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Add Preprocessing
    3. Applied egg-rr85.2%

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

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

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

Alternative 4: 57.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;\ell \leq -4.5 \cdot 10^{-73}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(d \cdot \frac{1}{t\_0}\right)\right)\\

\mathbf{elif}\;\ell \leq 4.7 \cdot 10^{+204}:\\
\;\;\;\;\frac{d}{t\_0} \cdot \mathsf{fma}\left(h, \frac{-0.125}{\ell} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}, 1\right)\\

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


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

    1. Initial program 62.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. Add Preprocessing
    3. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.5e-73 < l < -4.999999999999985e-310

    1. Initial program 67.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. Add Preprocessing
    3. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{d} \]
      6. log1p-expm1-u41.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{d} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)\right) \]
      18. associate-/l/41.5%

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

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

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

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

    if -4.999999999999985e-310 < l < 4.7000000000000002e204

    1. Initial program 72.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. Add Preprocessing
    3. Applied egg-rr36.9%

      \[\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(0.25 \cdot {\left(\frac{M \cdot D}{d}\right)}^{2}\right)\right)\right)\right)} - 1} \]
    4. Simplified78.2%

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(-1 + \mathsf{fma}\left(\mathsf{fma}\left(h, -0.125 \cdot \frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, 1\right), \frac{d}{\sqrt{h \cdot \ell}}, 1\right)\right)} - 1} \]
    7. Step-by-step derivation
      1. sub-neg34.5%

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

        \[\leadsto e^{\color{blue}{\log \left(1 + \left(-1 + \mathsf{fma}\left(\mathsf{fma}\left(h, -0.125 \cdot \frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, 1\right), \frac{d}{\sqrt{h \cdot \ell}}, 1\right)\right)\right)}} + \left(-1\right) \]
      3. rem-exp-log73.7%

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

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

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

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

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

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

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

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

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

    if 4.7000000000000002e204 < l

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

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

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

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

Alternative 5: 60.2% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;t\_0 \cdot \left(t\_1 \cdot \left(h \cdot t\_2\right)\right)\\

\mathbf{elif}\;\ell \leq 1.48 \cdot 10^{+206}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \mathsf{fma}\left(h, t\_2, 1\right)\\

\mathbf{else}:\\
\;\;\;\;t\_1 \cdot t\_0\\


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

    1. Initial program 60.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. Add Preprocessing
    3. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.4999999999999999e-37 < l < -4.999999999999985e-310

    1. Initial program 69.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l < 1.47999999999999992e206

    1. Initial program 72.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. Add Preprocessing
    3. Applied egg-rr36.9%

      \[\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(0.25 \cdot {\left(\frac{M \cdot D}{d}\right)}^{2}\right)\right)\right)\right)} - 1} \]
    4. Simplified78.2%

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(-1 + \mathsf{fma}\left(\mathsf{fma}\left(h, -0.125 \cdot \frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, 1\right), \frac{d}{\sqrt{h \cdot \ell}}, 1\right)\right)} - 1} \]
    7. Step-by-step derivation
      1. sub-neg34.5%

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

        \[\leadsto e^{\color{blue}{\log \left(1 + \left(-1 + \mathsf{fma}\left(\mathsf{fma}\left(h, -0.125 \cdot \frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}, 1\right), \frac{d}{\sqrt{h \cdot \ell}}, 1\right)\right)\right)}} + \left(-1\right) \]
      3. rem-exp-log73.7%

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

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

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

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

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

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

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

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

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

    if 1.47999999999999992e206 < l

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

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

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

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

Alternative 6: 63.8% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 60.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. Add Preprocessing
    3. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.5000000000000002e-42 < l < -4.999999999999985e-310

    1. Initial program 69.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 70.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Add Preprocessing
    3. Applied egg-rr85.8%

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

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

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

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

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

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

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

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

Alternative 7: 72.9% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 65.3%

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

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

    if 3.59999999999999968e-272 < h

    1. Initial program 69.7%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Add Preprocessing
    3. Applied egg-rr85.2%

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

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

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

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

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

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

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

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

Alternative 8: 73.3% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 64.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.0500000000000002e-304 < h

    1. Initial program 70.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. Add Preprocessing
    3. Applied egg-rr85.1%

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

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

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

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

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

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

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

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

Alternative 9: 73.6% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 64.9%

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

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

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

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

    if 1.72e-227 < h

    1. Initial program 70.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. Add Preprocessing
    3. Applied egg-rr87.3%

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

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

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

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

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

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

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

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

Alternative 10: 41.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{-73}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

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

\mathbf{elif}\;\ell \leq 2.2 \cdot 10^{-249}:\\
\;\;\;\;d \cdot \left(-\sqrt{\log \left(e^{\frac{1}{\ell \cdot h}}\right)}\right)\\

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


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

    1. Initial program 62.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. Add Preprocessing
    3. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.9999999999999998e-73 < l < -4.999999999999985e-310

    1. Initial program 67.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. Add Preprocessing
    3. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{d} \]
      6. log1p-expm1-u41.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{d} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)\right) \]
      18. associate-/l/41.5%

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

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

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

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

    if -4.999999999999985e-310 < l < 2.2e-249

    1. Initial program 38.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. Add Preprocessing
    3. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

    if 2.2e-249 < l

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-73}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(d \cdot \frac{1}{\sqrt{\ell \cdot h}}\right)\right)\\ \mathbf{elif}\;\ell \leq 2.2 \cdot 10^{-249}:\\ \;\;\;\;d \cdot \left(-\sqrt{\log \left(e^{\frac{1}{\ell \cdot h}}\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 38.2% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;M \leq 4.4 \cdot 10^{+18}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(d \cdot \frac{1}{\sqrt{\ell \cdot h}}\right)\right)\\


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

    1. Initial program 66.9%

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

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

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

    if 4.4e18 < M

    1. Initial program 68.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(\sqrt{d} \cdot \sqrt{d}\right)} \]
      5. add-sqr-sqrt27.4%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{d} \]
      6. log1p-expm1-u24.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{d} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right)\right) \]
      18. associate-/l/24.5%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 4.4 \cdot 10^{+18}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(d \cdot \frac{1}{\sqrt{\ell \cdot h}}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 41.1% accurate, 1.6× speedup?

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

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

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


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

    1. Initial program 62.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. Add Preprocessing
    3. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.3e-249 < l

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

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

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

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

Alternative 13: 42.9% accurate, 2.9× speedup?

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

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

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


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

    1. Initial program 64.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.59999999999999985e-298 < l

    1. Initial program 70.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. Add Preprocessing
    3. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 42.9% accurate, 3.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3 \cdot 10^{-293}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

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


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

    1. Initial program 64.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.0000000000000002e-293 < l

    1. Initial program 70.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. Add Preprocessing
    3. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3 \cdot 10^{-293}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 42.9% accurate, 3.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_0}\\


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

    1. Initial program 64.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{0 - \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d} \]
      3. add-sqr-sqrt0.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - \color{blue}{d} \cdot \sqrt{\frac{\frac{1}{h}}{\ell}} \]
      14. associate-/l/38.6%

        \[\leadsto 0 - d \cdot \sqrt{\color{blue}{\frac{1}{\ell \cdot h}}} \]
      15. sqrt-div38.6%

        \[\leadsto 0 - d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\ell \cdot h}}} \]
      16. metadata-eval38.6%

        \[\leadsto 0 - d \cdot \frac{\color{blue}{1}}{\sqrt{\ell \cdot h}} \]
    7. Applied egg-rr38.6%

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

        \[\leadsto \color{blue}{-d \cdot \frac{1}{\sqrt{\ell \cdot h}}} \]
      2. distribute-lft-neg-in38.6%

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

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

        \[\leadsto \frac{\color{blue}{-d}}{\sqrt{\ell \cdot h}} \]
      5. distribute-neg-frac38.6%

        \[\leadsto \color{blue}{-\frac{d}{\sqrt{\ell \cdot h}}} \]
      6. distribute-neg-frac238.6%

        \[\leadsto \color{blue}{\frac{d}{-\sqrt{\ell \cdot h}}} \]
      7. *-commutative38.6%

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

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

    if -5.0000000000000003e-294 < l

    1. Initial program 70.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. Add Preprocessing
    3. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 26.6% accurate, 3.2× speedup?

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

\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Derivation
  1. Initial program 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. Add Preprocessing
  3. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  10. Final simplification25.3%

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

Reproduce

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