Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.4% → 81.9%
Time: 40.3s
Alternatives: 23
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 23 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.4% 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: 81.9% accurate, 0.6× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} t_0 := 1 + \frac{h \cdot \left({\left(\left(M \cdot 0.5\right) \cdot \frac{D_m}{d}\right)}^{2} \cdot -0.5\right)}{\ell}\\ \mathbf{if}\;d \leq -9.6 \cdot 10^{-300}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot t_0\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(t_0 \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right)\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (let* ((t_0 (+ 1.0 (/ (* h (* (pow (* (* M 0.5) (/ D_m d)) 2.0) -0.5)) l))))
   (if (<= d -9.6e-300)
     (* (/ (sqrt (- d)) (sqrt (- h))) (* (sqrt (/ d l)) t_0))
     (* (/ (sqrt d) (sqrt h)) (* t_0 (/ (sqrt d) (sqrt l)))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double t_0 = 1.0 + ((h * (pow(((M * 0.5) * (D_m / d)), 2.0) * -0.5)) / l);
	double tmp;
	if (d <= -9.6e-300) {
		tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * t_0);
	} else {
		tmp = (sqrt(d) / sqrt(h)) * (t_0 * (sqrt(d) / sqrt(l)));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 + ((h * ((((m * 0.5d0) * (d_m / d)) ** 2.0d0) * (-0.5d0))) / l)
    if (d <= (-9.6d-300)) then
        tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * t_0)
    else
        tmp = (sqrt(d) / sqrt(h)) * (t_0 * (sqrt(d) / sqrt(l)))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double t_0 = 1.0 + ((h * (Math.pow(((M * 0.5) * (D_m / d)), 2.0) * -0.5)) / l);
	double tmp;
	if (d <= -9.6e-300) {
		tmp = (Math.sqrt(-d) / Math.sqrt(-h)) * (Math.sqrt((d / l)) * t_0);
	} else {
		tmp = (Math.sqrt(d) / Math.sqrt(h)) * (t_0 * (Math.sqrt(d) / Math.sqrt(l)));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	t_0 = 1.0 + ((h * (math.pow(((M * 0.5) * (D_m / d)), 2.0) * -0.5)) / l)
	tmp = 0
	if d <= -9.6e-300:
		tmp = (math.sqrt(-d) / math.sqrt(-h)) * (math.sqrt((d / l)) * t_0)
	else:
		tmp = (math.sqrt(d) / math.sqrt(h)) * (t_0 * (math.sqrt(d) / math.sqrt(l)))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	t_0 = Float64(1.0 + Float64(Float64(h * Float64((Float64(Float64(M * 0.5) * Float64(D_m / d)) ^ 2.0) * -0.5)) / l))
	tmp = 0.0
	if (d <= -9.6e-300)
		tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(sqrt(Float64(d / l)) * t_0));
	else
		tmp = Float64(Float64(sqrt(d) / sqrt(h)) * Float64(t_0 * Float64(sqrt(d) / sqrt(l))));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	t_0 = 1.0 + ((h * ((((M * 0.5) * (D_m / d)) ^ 2.0) * -0.5)) / l);
	tmp = 0.0;
	if (d <= -9.6e-300)
		tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * t_0);
	else
		tmp = (sqrt(d) / sqrt(h)) * (t_0 * (sqrt(d) / sqrt(l)));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(1.0 + N[(N[(h * N[(N[Power[N[(N[(M * 0.5), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -9.6e-300], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := 1 + \frac{h \cdot \left({\left(\left(M \cdot 0.5\right) \cdot \frac{D_m}{d}\right)}^{2} \cdot -0.5\right)}{\ell}\\
\mathbf{if}\;d \leq -9.6 \cdot 10^{-300}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot t_0\right)\\

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


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

    1. Initial program 65.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.59999999999999998e-300 < d

    1. Initial program 68.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 77.1% accurate, 0.4× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{M \cdot D_m}{d \cdot 2}\right)}^{2}\right)\right) \leq 10^{+242}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{D_m \cdot \left(0.5 \cdot \frac{M}{d}\right)}{\sqrt{\frac{\ell}{h}}}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{d}{\sqrt{h \cdot \ell}}\right|\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (if (<=
      (*
       (* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
       (- 1.0 (* (/ h l) (* 0.5 (pow (/ (* M D_m) (* d 2.0)) 2.0)))))
      1e+242)
   (*
    (* (sqrt (/ d l)) (sqrt (/ d h)))
    (- 1.0 (* 0.5 (pow (/ (* D_m (* 0.5 (/ M d))) (sqrt (/ l h))) 2.0))))
   (fabs (/ d (sqrt (* h l))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (((pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * pow(((M * D_m) / (d * 2.0)), 2.0))))) <= 1e+242) {
		tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * pow(((D_m * (0.5 * (M / d))) / sqrt((l / h))), 2.0)));
	} else {
		tmp = fabs((d / sqrt((h * l))));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: tmp
    if (((((d / h) ** 0.5d0) * ((d / l) ** 0.5d0)) * (1.0d0 - ((h / l) * (0.5d0 * (((m * d_m) / (d * 2.0d0)) ** 2.0d0))))) <= 1d+242) then
        tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - (0.5d0 * (((d_m * (0.5d0 * (m / d))) / sqrt((l / h))) ** 2.0d0)))
    else
        tmp = abs((d / sqrt((h * l))))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (((Math.pow((d / h), 0.5) * Math.pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * Math.pow(((M * D_m) / (d * 2.0)), 2.0))))) <= 1e+242) {
		tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - (0.5 * Math.pow(((D_m * (0.5 * (M / d))) / Math.sqrt((l / h))), 2.0)));
	} else {
		tmp = Math.abs((d / Math.sqrt((h * l))));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	tmp = 0
	if ((math.pow((d / h), 0.5) * math.pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * math.pow(((M * D_m) / (d * 2.0)), 2.0))))) <= 1e+242:
		tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - (0.5 * math.pow(((D_m * (0.5 * (M / d))) / math.sqrt((l / h))), 2.0)))
	else:
		tmp = math.fabs((d / math.sqrt((h * l))))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	tmp = 0.0
	if (Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.5 * (Float64(Float64(M * D_m) / Float64(d * 2.0)) ^ 2.0))))) <= 1e+242)
		tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(0.5 * (Float64(Float64(D_m * Float64(0.5 * Float64(M / d))) / sqrt(Float64(l / h))) ^ 2.0))));
	else
		tmp = abs(Float64(d / sqrt(Float64(h * l))));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	tmp = 0.0;
	if (((((d / h) ^ 0.5) * ((d / l) ^ 0.5)) * (1.0 - ((h / l) * (0.5 * (((M * D_m) / (d * 2.0)) ^ 2.0))))) <= 1e+242)
		tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * (((D_m * (0.5 * (M / d))) / sqrt((l / h))) ^ 2.0)));
	else
		tmp = abs((d / sqrt((h * l))));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.5 * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+242], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[Power[N[(N[(D$95$m * N[(0.5 * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{M \cdot D_m}{d \cdot 2}\right)}^{2}\right)\right) \leq 10^{+242}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{D_m \cdot \left(0.5 \cdot \frac{M}{d}\right)}{\sqrt{\frac{\ell}{h}}}\right)}^{2}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < 1.00000000000000005e242

    1. Initial program 90.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. Simplified89.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. *-commutative89.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.00000000000000005e242 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l))))

    1. Initial program 23.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. Simplified23.1%

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr33.4%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt33.6%

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

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

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

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

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

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

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

        \[\leadsto \left|d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}}\right| \]
      7. div-inv62.8%

        \[\leadsto \left|\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}}\right| \]
    10. Applied egg-rr62.8%

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

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

Alternative 3: 76.2% accurate, 0.5× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} t_0 := \left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{M \cdot D_m}{d \cdot 2}\right)}^{2}\right)\right)\\ \mathbf{if}\;t_0 \leq 10^{+242}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{d}{\sqrt{h \cdot \ell}}\right|\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (let* ((t_0
         (*
          (* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
          (- 1.0 (* (/ h l) (* 0.5 (pow (/ (* M D_m) (* d 2.0)) 2.0)))))))
   (if (<= t_0 1e+242) t_0 (fabs (/ d (sqrt (* h l)))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double t_0 = (pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * pow(((M * D_m) / (d * 2.0)), 2.0))));
	double tmp;
	if (t_0 <= 1e+242) {
		tmp = t_0;
	} else {
		tmp = fabs((d / sqrt((h * l))));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (((d / h) ** 0.5d0) * ((d / l) ** 0.5d0)) * (1.0d0 - ((h / l) * (0.5d0 * (((m * d_m) / (d * 2.0d0)) ** 2.0d0))))
    if (t_0 <= 1d+242) then
        tmp = t_0
    else
        tmp = abs((d / sqrt((h * l))))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double t_0 = (Math.pow((d / h), 0.5) * Math.pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * Math.pow(((M * D_m) / (d * 2.0)), 2.0))));
	double tmp;
	if (t_0 <= 1e+242) {
		tmp = t_0;
	} else {
		tmp = Math.abs((d / Math.sqrt((h * l))));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	t_0 = (math.pow((d / h), 0.5) * math.pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * math.pow(((M * D_m) / (d * 2.0)), 2.0))))
	tmp = 0
	if t_0 <= 1e+242:
		tmp = t_0
	else:
		tmp = math.fabs((d / math.sqrt((h * l))))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	t_0 = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.5 * (Float64(Float64(M * D_m) / Float64(d * 2.0)) ^ 2.0)))))
	tmp = 0.0
	if (t_0 <= 1e+242)
		tmp = t_0;
	else
		tmp = abs(Float64(d / sqrt(Float64(h * l))));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	t_0 = (((d / h) ^ 0.5) * ((d / l) ^ 0.5)) * (1.0 - ((h / l) * (0.5 * (((M * D_m) / (d * 2.0)) ^ 2.0))));
	tmp = 0.0;
	if (t_0 <= 1e+242)
		tmp = t_0;
	else
		tmp = abs((d / sqrt((h * l))));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.5 * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+242], t$95$0, N[Abs[N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{M \cdot D_m}{d \cdot 2}\right)}^{2}\right)\right)\\
\mathbf{if}\;t_0 \leq 10^{+242}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < 1.00000000000000005e242

    1. Initial program 90.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

    if 1.00000000000000005e242 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l))))

    1. Initial program 23.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. Simplified23.1%

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr33.4%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt33.6%

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

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

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

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

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

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

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

        \[\leadsto \left|d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}}\right| \]
      7. div-inv62.8%

        \[\leadsto \left|\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}}\right| \]
    10. Applied egg-rr62.8%

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

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

Alternative 4: 79.8% accurate, 0.6× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -9.6 \cdot 10^{-300}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h \cdot \left({\left(\left(M \cdot 0.5\right) \cdot \frac{D_m}{d}\right)}^{2} \cdot -0.5\right)}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{D_m}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\right)\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (if (<= d -9.6e-300)
   (*
    (/ (sqrt (- d)) (sqrt (- h)))
    (*
     (sqrt (/ d l))
     (+ 1.0 (/ (* h (* (pow (* (* M 0.5) (/ D_m d)) 2.0) -0.5)) l))))
   (*
    (/ (sqrt d) (sqrt h))
    (*
     (/ (sqrt d) (sqrt l))
     (+ 1.0 (* (/ h l) (* -0.5 (pow (* (/ D_m d) (/ M 2.0)) 2.0))))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (d <= -9.6e-300) {
		tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0 + ((h * (pow(((M * 0.5) * (D_m / d)), 2.0) * -0.5)) / l)));
	} else {
		tmp = (sqrt(d) / sqrt(h)) * ((sqrt(d) / sqrt(l)) * (1.0 + ((h / l) * (-0.5 * pow(((D_m / d) * (M / 2.0)), 2.0)))));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: tmp
    if (d <= (-9.6d-300)) then
        tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0d0 + ((h * ((((m * 0.5d0) * (d_m / d)) ** 2.0d0) * (-0.5d0))) / l)))
    else
        tmp = (sqrt(d) / sqrt(h)) * ((sqrt(d) / sqrt(l)) * (1.0d0 + ((h / l) * ((-0.5d0) * (((d_m / d) * (m / 2.0d0)) ** 2.0d0)))))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (d <= -9.6e-300) {
		tmp = (Math.sqrt(-d) / Math.sqrt(-h)) * (Math.sqrt((d / l)) * (1.0 + ((h * (Math.pow(((M * 0.5) * (D_m / d)), 2.0) * -0.5)) / l)));
	} else {
		tmp = (Math.sqrt(d) / Math.sqrt(h)) * ((Math.sqrt(d) / Math.sqrt(l)) * (1.0 + ((h / l) * (-0.5 * Math.pow(((D_m / d) * (M / 2.0)), 2.0)))));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	tmp = 0
	if d <= -9.6e-300:
		tmp = (math.sqrt(-d) / math.sqrt(-h)) * (math.sqrt((d / l)) * (1.0 + ((h * (math.pow(((M * 0.5) * (D_m / d)), 2.0) * -0.5)) / l)))
	else:
		tmp = (math.sqrt(d) / math.sqrt(h)) * ((math.sqrt(d) / math.sqrt(l)) * (1.0 + ((h / l) * (-0.5 * math.pow(((D_m / d) * (M / 2.0)), 2.0)))))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	tmp = 0.0
	if (d <= -9.6e-300)
		tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(Float64(h * Float64((Float64(Float64(M * 0.5) * Float64(D_m / d)) ^ 2.0) * -0.5)) / l))));
	else
		tmp = Float64(Float64(sqrt(d) / sqrt(h)) * Float64(Float64(sqrt(d) / sqrt(l)) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(Float64(D_m / d) * Float64(M / 2.0)) ^ 2.0))))));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	tmp = 0.0;
	if (d <= -9.6e-300)
		tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0 + ((h * ((((M * 0.5) * (D_m / d)) ^ 2.0) * -0.5)) / l)));
	else
		tmp = (sqrt(d) / sqrt(h)) * ((sqrt(d) / sqrt(l)) * (1.0 + ((h / l) * (-0.5 * (((D_m / d) * (M / 2.0)) ^ 2.0)))));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[d, -9.6e-300], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(h * N[(N[Power[N[(N[(M * 0.5), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9.6 \cdot 10^{-300}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h \cdot \left({\left(\left(M \cdot 0.5\right) \cdot \frac{D_m}{d}\right)}^{2} \cdot -0.5\right)}{\ell}\right)\right)\\

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


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

    1. Initial program 65.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.59999999999999998e-300 < d

    1. Initial program 68.2%

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

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

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

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

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

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

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

Alternative 5: 79.4% accurate, 0.6× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} t_0 := {\left(\left(M \cdot 0.5\right) \cdot \frac{D_m}{d}\right)}^{2}\\ \mathbf{if}\;d \leq -9.6 \cdot 10^{-300}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h \cdot \left(t_0 \cdot -0.5\right)}{\ell}\right)\right)\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{-235}:\\ \;\;\;\;\frac{{\left(M \cdot D_m\right)}^{2}}{d} \cdot \left({\left(\frac{\sqrt[3]{\sqrt{h}}}{\sqrt{\ell}}\right)}^{3} \cdot -0.125\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot t_0\right)\right)\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (let* ((t_0 (pow (* (* M 0.5) (/ D_m d)) 2.0)))
   (if (<= d -9.6e-300)
     (*
      (/ (sqrt (- d)) (sqrt (- h)))
      (* (sqrt (/ d l)) (+ 1.0 (/ (* h (* t_0 -0.5)) l))))
     (if (<= d 2.5e-235)
       (*
        (/ (pow (* M D_m) 2.0) d)
        (* (pow (/ (cbrt (sqrt h)) (sqrt l)) 3.0) -0.125))
       (* (/ d (* (sqrt h) (sqrt l))) (- 1.0 (* (/ h l) (* 0.5 t_0))))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double t_0 = pow(((M * 0.5) * (D_m / d)), 2.0);
	double tmp;
	if (d <= -9.6e-300) {
		tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0 + ((h * (t_0 * -0.5)) / l)));
	} else if (d <= 2.5e-235) {
		tmp = (pow((M * D_m), 2.0) / d) * (pow((cbrt(sqrt(h)) / sqrt(l)), 3.0) * -0.125);
	} else {
		tmp = (d / (sqrt(h) * sqrt(l))) * (1.0 - ((h / l) * (0.5 * t_0)));
	}
	return tmp;
}
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double t_0 = Math.pow(((M * 0.5) * (D_m / d)), 2.0);
	double tmp;
	if (d <= -9.6e-300) {
		tmp = (Math.sqrt(-d) / Math.sqrt(-h)) * (Math.sqrt((d / l)) * (1.0 + ((h * (t_0 * -0.5)) / l)));
	} else if (d <= 2.5e-235) {
		tmp = (Math.pow((M * D_m), 2.0) / d) * (Math.pow((Math.cbrt(Math.sqrt(h)) / Math.sqrt(l)), 3.0) * -0.125);
	} else {
		tmp = (d / (Math.sqrt(h) * Math.sqrt(l))) * (1.0 - ((h / l) * (0.5 * t_0)));
	}
	return tmp;
}
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	t_0 = Float64(Float64(M * 0.5) * Float64(D_m / d)) ^ 2.0
	tmp = 0.0
	if (d <= -9.6e-300)
		tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(Float64(h * Float64(t_0 * -0.5)) / l))));
	elseif (d <= 2.5e-235)
		tmp = Float64(Float64((Float64(M * D_m) ^ 2.0) / d) * Float64((Float64(cbrt(sqrt(h)) / sqrt(l)) ^ 3.0) * -0.125));
	else
		tmp = Float64(Float64(d / Float64(sqrt(h) * sqrt(l))) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.5 * t_0))));
	end
	return tmp
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Power[N[(N[(M * 0.5), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[d, -9.6e-300], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(h * N[(t$95$0 * -0.5), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.5e-235], N[(N[(N[Power[N[(M * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision] * N[(N[Power[N[(N[Power[N[Sqrt[h], $MachinePrecision], 1/3], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := {\left(\left(M \cdot 0.5\right) \cdot \frac{D_m}{d}\right)}^{2}\\
\mathbf{if}\;d \leq -9.6 \cdot 10^{-300}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h \cdot \left(t_0 \cdot -0.5\right)}{\ell}\right)\right)\\

\mathbf{elif}\;d \leq 2.5 \cdot 10^{-235}:\\
\;\;\;\;\frac{{\left(M \cdot D_m\right)}^{2}}{d} \cdot \left({\left(\frac{\sqrt[3]{\sqrt{h}}}{\sqrt{\ell}}\right)}^{3} \cdot -0.125\right)\\

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


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

    1. Initial program 65.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.59999999999999998e-300 < d < 2.4999999999999999e-235

    1. Initial program 39.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 d around 0 38.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.4999999999999999e-235 < d

    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-rr90.3%

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

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

Alternative 6: 78.4% accurate, 0.8× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -9.6 \cdot 10^{-300}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{D_m}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\right)\\ \mathbf{elif}\;d \leq 5 \cdot 10^{-236}:\\ \;\;\;\;\frac{{\left(M \cdot D_m\right)}^{2} \cdot \left(-0.125 \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (if (<= d -9.6e-300)
   (*
    (/ (sqrt (- d)) (sqrt (- h)))
    (*
     (sqrt (/ d l))
     (+ 1.0 (* (/ h l) (* -0.5 (pow (* (/ D_m d) (/ M 2.0)) 2.0))))))
   (if (<= d 5e-236)
     (/ (* (pow (* M D_m) 2.0) (* -0.125 (/ (sqrt h) (pow l 1.5)))) d)
     (*
      (/ d (* (sqrt h) (sqrt l)))
      (- 1.0 (* (/ h l) (* 0.5 (pow (* (* M 0.5) (/ D_m d)) 2.0))))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (d <= -9.6e-300) {
		tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0 + ((h / l) * (-0.5 * pow(((D_m / d) * (M / 2.0)), 2.0)))));
	} else if (d <= 5e-236) {
		tmp = (pow((M * D_m), 2.0) * (-0.125 * (sqrt(h) / pow(l, 1.5)))) / d;
	} else {
		tmp = (d / (sqrt(h) * sqrt(l))) * (1.0 - ((h / l) * (0.5 * pow(((M * 0.5) * (D_m / d)), 2.0))));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: tmp
    if (d <= (-9.6d-300)) then
        tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0d0 + ((h / l) * ((-0.5d0) * (((d_m / d) * (m / 2.0d0)) ** 2.0d0)))))
    else if (d <= 5d-236) then
        tmp = (((m * d_m) ** 2.0d0) * ((-0.125d0) * (sqrt(h) / (l ** 1.5d0)))) / d
    else
        tmp = (d / (sqrt(h) * sqrt(l))) * (1.0d0 - ((h / l) * (0.5d0 * (((m * 0.5d0) * (d_m / d)) ** 2.0d0))))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (d <= -9.6e-300) {
		tmp = (Math.sqrt(-d) / Math.sqrt(-h)) * (Math.sqrt((d / l)) * (1.0 + ((h / l) * (-0.5 * Math.pow(((D_m / d) * (M / 2.0)), 2.0)))));
	} else if (d <= 5e-236) {
		tmp = (Math.pow((M * D_m), 2.0) * (-0.125 * (Math.sqrt(h) / Math.pow(l, 1.5)))) / d;
	} else {
		tmp = (d / (Math.sqrt(h) * Math.sqrt(l))) * (1.0 - ((h / l) * (0.5 * Math.pow(((M * 0.5) * (D_m / d)), 2.0))));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	tmp = 0
	if d <= -9.6e-300:
		tmp = (math.sqrt(-d) / math.sqrt(-h)) * (math.sqrt((d / l)) * (1.0 + ((h / l) * (-0.5 * math.pow(((D_m / d) * (M / 2.0)), 2.0)))))
	elif d <= 5e-236:
		tmp = (math.pow((M * D_m), 2.0) * (-0.125 * (math.sqrt(h) / math.pow(l, 1.5)))) / d
	else:
		tmp = (d / (math.sqrt(h) * math.sqrt(l))) * (1.0 - ((h / l) * (0.5 * math.pow(((M * 0.5) * (D_m / d)), 2.0))))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	tmp = 0.0
	if (d <= -9.6e-300)
		tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(Float64(D_m / d) * Float64(M / 2.0)) ^ 2.0))))));
	elseif (d <= 5e-236)
		tmp = Float64(Float64((Float64(M * D_m) ^ 2.0) * Float64(-0.125 * Float64(sqrt(h) / (l ^ 1.5)))) / d);
	else
		tmp = Float64(Float64(d / Float64(sqrt(h) * sqrt(l))) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.5 * (Float64(Float64(M * 0.5) * Float64(D_m / d)) ^ 2.0)))));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	tmp = 0.0;
	if (d <= -9.6e-300)
		tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0 + ((h / l) * (-0.5 * (((D_m / d) * (M / 2.0)) ^ 2.0)))));
	elseif (d <= 5e-236)
		tmp = (((M * D_m) ^ 2.0) * (-0.125 * (sqrt(h) / (l ^ 1.5)))) / d;
	else
		tmp = (d / (sqrt(h) * sqrt(l))) * (1.0 - ((h / l) * (0.5 * (((M * 0.5) * (D_m / d)) ^ 2.0))));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[d, -9.6e-300], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5e-236], N[(N[(N[Power[N[(M * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.125 * N[(N[Sqrt[h], $MachinePrecision] / N[Power[l, 1.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], N[(N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.5 * N[Power[N[(N[(M * 0.5), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9.6 \cdot 10^{-300}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{D_m}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\right)\\

\mathbf{elif}\;d \leq 5 \cdot 10^{-236}:\\
\;\;\;\;\frac{{\left(M \cdot D_m\right)}^{2} \cdot \left(-0.125 \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}\right)}{d}\\

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


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

    1. Initial program 65.3%

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

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

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

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

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

    if -9.59999999999999998e-300 < d < 4.9999999999999998e-236

    1. Initial program 39.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 d around 0 38.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.9999999999999998e-236 < d

    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-rr90.3%

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

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

Alternative 7: 79.3% accurate, 0.8× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} t_0 := {\left(\left(M \cdot 0.5\right) \cdot \frac{D_m}{d}\right)}^{2}\\ \mathbf{if}\;d \leq -9.6 \cdot 10^{-300}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h \cdot \left(t_0 \cdot -0.5\right)}{\ell}\right)\right)\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{-243}:\\ \;\;\;\;\frac{{\left(M \cdot D_m\right)}^{2} \cdot \left(-0.125 \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot t_0\right)\right)\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (let* ((t_0 (pow (* (* M 0.5) (/ D_m d)) 2.0)))
   (if (<= d -9.6e-300)
     (*
      (/ (sqrt (- d)) (sqrt (- h)))
      (* (sqrt (/ d l)) (+ 1.0 (/ (* h (* t_0 -0.5)) l))))
     (if (<= d 1.35e-243)
       (/ (* (pow (* M D_m) 2.0) (* -0.125 (/ (sqrt h) (pow l 1.5)))) d)
       (* (/ d (* (sqrt h) (sqrt l))) (- 1.0 (* (/ h l) (* 0.5 t_0))))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double t_0 = pow(((M * 0.5) * (D_m / d)), 2.0);
	double tmp;
	if (d <= -9.6e-300) {
		tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0 + ((h * (t_0 * -0.5)) / l)));
	} else if (d <= 1.35e-243) {
		tmp = (pow((M * D_m), 2.0) * (-0.125 * (sqrt(h) / pow(l, 1.5)))) / d;
	} else {
		tmp = (d / (sqrt(h) * sqrt(l))) * (1.0 - ((h / l) * (0.5 * t_0)));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((m * 0.5d0) * (d_m / d)) ** 2.0d0
    if (d <= (-9.6d-300)) then
        tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0d0 + ((h * (t_0 * (-0.5d0))) / l)))
    else if (d <= 1.35d-243) then
        tmp = (((m * d_m) ** 2.0d0) * ((-0.125d0) * (sqrt(h) / (l ** 1.5d0)))) / d
    else
        tmp = (d / (sqrt(h) * sqrt(l))) * (1.0d0 - ((h / l) * (0.5d0 * t_0)))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double t_0 = Math.pow(((M * 0.5) * (D_m / d)), 2.0);
	double tmp;
	if (d <= -9.6e-300) {
		tmp = (Math.sqrt(-d) / Math.sqrt(-h)) * (Math.sqrt((d / l)) * (1.0 + ((h * (t_0 * -0.5)) / l)));
	} else if (d <= 1.35e-243) {
		tmp = (Math.pow((M * D_m), 2.0) * (-0.125 * (Math.sqrt(h) / Math.pow(l, 1.5)))) / d;
	} else {
		tmp = (d / (Math.sqrt(h) * Math.sqrt(l))) * (1.0 - ((h / l) * (0.5 * t_0)));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	t_0 = math.pow(((M * 0.5) * (D_m / d)), 2.0)
	tmp = 0
	if d <= -9.6e-300:
		tmp = (math.sqrt(-d) / math.sqrt(-h)) * (math.sqrt((d / l)) * (1.0 + ((h * (t_0 * -0.5)) / l)))
	elif d <= 1.35e-243:
		tmp = (math.pow((M * D_m), 2.0) * (-0.125 * (math.sqrt(h) / math.pow(l, 1.5)))) / d
	else:
		tmp = (d / (math.sqrt(h) * math.sqrt(l))) * (1.0 - ((h / l) * (0.5 * t_0)))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	t_0 = Float64(Float64(M * 0.5) * Float64(D_m / d)) ^ 2.0
	tmp = 0.0
	if (d <= -9.6e-300)
		tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(Float64(h * Float64(t_0 * -0.5)) / l))));
	elseif (d <= 1.35e-243)
		tmp = Float64(Float64((Float64(M * D_m) ^ 2.0) * Float64(-0.125 * Float64(sqrt(h) / (l ^ 1.5)))) / d);
	else
		tmp = Float64(Float64(d / Float64(sqrt(h) * sqrt(l))) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.5 * t_0))));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	t_0 = ((M * 0.5) * (D_m / d)) ^ 2.0;
	tmp = 0.0;
	if (d <= -9.6e-300)
		tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0 + ((h * (t_0 * -0.5)) / l)));
	elseif (d <= 1.35e-243)
		tmp = (((M * D_m) ^ 2.0) * (-0.125 * (sqrt(h) / (l ^ 1.5)))) / d;
	else
		tmp = (d / (sqrt(h) * sqrt(l))) * (1.0 - ((h / l) * (0.5 * t_0)));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Power[N[(N[(M * 0.5), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[d, -9.6e-300], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(h * N[(t$95$0 * -0.5), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.35e-243], N[(N[(N[Power[N[(M * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.125 * N[(N[Sqrt[h], $MachinePrecision] / N[Power[l, 1.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], N[(N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := {\left(\left(M \cdot 0.5\right) \cdot \frac{D_m}{d}\right)}^{2}\\
\mathbf{if}\;d \leq -9.6 \cdot 10^{-300}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h \cdot \left(t_0 \cdot -0.5\right)}{\ell}\right)\right)\\

\mathbf{elif}\;d \leq 1.35 \cdot 10^{-243}:\\
\;\;\;\;\frac{{\left(M \cdot D_m\right)}^{2} \cdot \left(-0.125 \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}\right)}{d}\\

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


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

    1. Initial program 65.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.59999999999999998e-300 < d < 1.35000000000000005e-243

    1. Initial program 39.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 d around 0 38.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.35000000000000005e-243 < d

    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-rr90.3%

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

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

Alternative 8: 62.4% accurate, 1.0× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -2.4 \cdot 10^{-98}:\\ \;\;\;\;\left|\frac{d}{\sqrt{h \cdot \ell}}\right|\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D_m \cdot \frac{M}{d \cdot 2}\right)}^{2}\right)\right)\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (if (<= d -2.4e-98)
   (fabs (/ d (sqrt (* h l))))
   (if (<= d -2e-310)
     (* d (sqrt (log (exp (/ 1.0 (* h l))))))
     (*
      (/ (/ d (sqrt l)) (sqrt h))
      (- 1.0 (* 0.5 (* (/ h l) (pow (* D_m (/ M (* d 2.0))) 2.0))))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (d <= -2.4e-98) {
		tmp = fabs((d / sqrt((h * l))));
	} else if (d <= -2e-310) {
		tmp = d * sqrt(log(exp((1.0 / (h * l)))));
	} else {
		tmp = ((d / sqrt(l)) / sqrt(h)) * (1.0 - (0.5 * ((h / l) * pow((D_m * (M / (d * 2.0))), 2.0))));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: tmp
    if (d <= (-2.4d-98)) then
        tmp = abs((d / sqrt((h * l))))
    else if (d <= (-2d-310)) then
        tmp = d * sqrt(log(exp((1.0d0 / (h * l)))))
    else
        tmp = ((d / sqrt(l)) / sqrt(h)) * (1.0d0 - (0.5d0 * ((h / l) * ((d_m * (m / (d * 2.0d0))) ** 2.0d0))))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (d <= -2.4e-98) {
		tmp = Math.abs((d / Math.sqrt((h * l))));
	} else if (d <= -2e-310) {
		tmp = d * Math.sqrt(Math.log(Math.exp((1.0 / (h * l)))));
	} else {
		tmp = ((d / Math.sqrt(l)) / Math.sqrt(h)) * (1.0 - (0.5 * ((h / l) * Math.pow((D_m * (M / (d * 2.0))), 2.0))));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	tmp = 0
	if d <= -2.4e-98:
		tmp = math.fabs((d / math.sqrt((h * l))))
	elif d <= -2e-310:
		tmp = d * math.sqrt(math.log(math.exp((1.0 / (h * l)))))
	else:
		tmp = ((d / math.sqrt(l)) / math.sqrt(h)) * (1.0 - (0.5 * ((h / l) * math.pow((D_m * (M / (d * 2.0))), 2.0))))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	tmp = 0.0
	if (d <= -2.4e-98)
		tmp = abs(Float64(d / sqrt(Float64(h * l))));
	elseif (d <= -2e-310)
		tmp = Float64(d * sqrt(log(exp(Float64(1.0 / Float64(h * l))))));
	else
		tmp = Float64(Float64(Float64(d / sqrt(l)) / sqrt(h)) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(D_m * Float64(M / Float64(d * 2.0))) ^ 2.0)))));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	tmp = 0.0;
	if (d <= -2.4e-98)
		tmp = abs((d / sqrt((h * l))));
	elseif (d <= -2e-310)
		tmp = d * sqrt(log(exp((1.0 / (h * l)))));
	else
		tmp = ((d / sqrt(l)) / sqrt(h)) * (1.0 - (0.5 * ((h / l) * ((D_m * (M / (d * 2.0))) ^ 2.0))));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[d, -2.4e-98], N[Abs[N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -2e-310], N[(d * N[Sqrt[N[Log[N[Exp[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(D$95$m * N[(M / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.4 \cdot 10^{-98}:\\
\;\;\;\;\left|\frac{d}{\sqrt{h \cdot \ell}}\right|\\

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

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


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

    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. Simplified73.3%

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr6.5%

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

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt6.5%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr6.5%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt6.5%

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

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

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

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

        \[\leadsto \color{blue}{\left|d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      4. metadata-eval55.6%

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

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

        \[\leadsto \left|d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}}\right| \]
      7. div-inv55.6%

        \[\leadsto \left|\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}}\right| \]
    10. Applied egg-rr55.6%

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

    if -2.40000000000000005e-98 < d < -1.999999999999994e-310

    1. Initial program 45.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 d around inf 12.5%

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

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

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

    if -1.999999999999994e-310 < d

    1. Initial program 69.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 57.1% accurate, 1.0× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} t_0 := \frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{if}\;d \leq -4.9 \cdot 10^{-101}:\\ \;\;\;\;\left|t_0\right|\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \mathsf{fma}\left({\left(\frac{M}{\frac{\frac{d}{D_m}}{0.5}}\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (let* ((t_0 (/ d (sqrt (* h l)))))
   (if (<= d -4.9e-101)
     (fabs t_0)
     (if (<= d -2e-310)
       (* d (sqrt (log (exp (/ 1.0 (* h l))))))
       (* t_0 (fma (pow (/ M (/ (/ d D_m) 0.5)) 2.0) (* -0.5 (/ h l)) 1.0))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double t_0 = d / sqrt((h * l));
	double tmp;
	if (d <= -4.9e-101) {
		tmp = fabs(t_0);
	} else if (d <= -2e-310) {
		tmp = d * sqrt(log(exp((1.0 / (h * l)))));
	} else {
		tmp = t_0 * fma(pow((M / ((d / D_m) / 0.5)), 2.0), (-0.5 * (h / l)), 1.0);
	}
	return tmp;
}
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	t_0 = Float64(d / sqrt(Float64(h * l)))
	tmp = 0.0
	if (d <= -4.9e-101)
		tmp = abs(t_0);
	elseif (d <= -2e-310)
		tmp = Float64(d * sqrt(log(exp(Float64(1.0 / Float64(h * l))))));
	else
		tmp = Float64(t_0 * fma((Float64(M / Float64(Float64(d / D_m) / 0.5)) ^ 2.0), Float64(-0.5 * Float64(h / l)), 1.0));
	end
	return tmp
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.9e-101], N[Abs[t$95$0], $MachinePrecision], If[LessEqual[d, -2e-310], N[(d * N[Sqrt[N[Log[N[Exp[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[Power[N[(M / N[(N[(d / D$95$m), $MachinePrecision] / 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{d}{\sqrt{h \cdot \ell}}\\
\mathbf{if}\;d \leq -4.9 \cdot 10^{-101}:\\
\;\;\;\;\left|t_0\right|\\

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

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


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

    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. Simplified73.3%

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr6.5%

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

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt6.5%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr6.5%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt6.5%

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

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

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

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

        \[\leadsto \color{blue}{\left|d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      4. metadata-eval55.6%

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

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

        \[\leadsto \left|d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}}\right| \]
      7. div-inv55.6%

        \[\leadsto \left|\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}}\right| \]
    10. Applied egg-rr55.6%

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

    if -4.9e-101 < d < -1.999999999999994e-310

    1. Initial program 45.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 d around inf 12.5%

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

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

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

    if -1.999999999999994e-310 < d

    1. Initial program 69.2%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 71.8% accurate, 1.0× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -4.6 \cdot 10^{-296}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{D_m}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\right) \cdot \sqrt{\frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D_m \cdot \frac{M}{d \cdot 2}\right)}^{2}\right)\right)\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (if (<= l -4.6e-296)
   (*
    (*
     (sqrt (/ d l))
     (+ 1.0 (* (/ h l) (* -0.5 (pow (* (/ D_m d) (/ M 2.0)) 2.0)))))
    (sqrt (/ d h)))
   (*
    (/ (/ d (sqrt l)) (sqrt h))
    (- 1.0 (* 0.5 (* (/ h l) (pow (* D_m (/ M (* d 2.0))) 2.0)))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (l <= -4.6e-296) {
		tmp = (sqrt((d / l)) * (1.0 + ((h / l) * (-0.5 * pow(((D_m / d) * (M / 2.0)), 2.0))))) * sqrt((d / h));
	} else {
		tmp = ((d / sqrt(l)) / sqrt(h)) * (1.0 - (0.5 * ((h / l) * pow((D_m * (M / (d * 2.0))), 2.0))));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: tmp
    if (l <= (-4.6d-296)) then
        tmp = (sqrt((d / l)) * (1.0d0 + ((h / l) * ((-0.5d0) * (((d_m / d) * (m / 2.0d0)) ** 2.0d0))))) * sqrt((d / h))
    else
        tmp = ((d / sqrt(l)) / sqrt(h)) * (1.0d0 - (0.5d0 * ((h / l) * ((d_m * (m / (d * 2.0d0))) ** 2.0d0))))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (l <= -4.6e-296) {
		tmp = (Math.sqrt((d / l)) * (1.0 + ((h / l) * (-0.5 * Math.pow(((D_m / d) * (M / 2.0)), 2.0))))) * Math.sqrt((d / h));
	} else {
		tmp = ((d / Math.sqrt(l)) / Math.sqrt(h)) * (1.0 - (0.5 * ((h / l) * Math.pow((D_m * (M / (d * 2.0))), 2.0))));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	tmp = 0
	if l <= -4.6e-296:
		tmp = (math.sqrt((d / l)) * (1.0 + ((h / l) * (-0.5 * math.pow(((D_m / d) * (M / 2.0)), 2.0))))) * math.sqrt((d / h))
	else:
		tmp = ((d / math.sqrt(l)) / math.sqrt(h)) * (1.0 - (0.5 * ((h / l) * math.pow((D_m * (M / (d * 2.0))), 2.0))))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	tmp = 0.0
	if (l <= -4.6e-296)
		tmp = Float64(Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(Float64(D_m / d) * Float64(M / 2.0)) ^ 2.0))))) * sqrt(Float64(d / h)));
	else
		tmp = Float64(Float64(Float64(d / sqrt(l)) / sqrt(h)) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(D_m * Float64(M / Float64(d * 2.0))) ^ 2.0)))));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	tmp = 0.0;
	if (l <= -4.6e-296)
		tmp = (sqrt((d / l)) * (1.0 + ((h / l) * (-0.5 * (((D_m / d) * (M / 2.0)) ^ 2.0))))) * sqrt((d / h));
	else
		tmp = ((d / sqrt(l)) / sqrt(h)) * (1.0 - (0.5 * ((h / l) * ((D_m * (M / (d * 2.0))) ^ 2.0))));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[l, -4.6e-296], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(D$95$m * N[(M / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.6 \cdot 10^{-296}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{D_m}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\right) \cdot \sqrt{\frac{d}{h}}\\

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


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

    1. Initial program 64.8%

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

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

    if -4.60000000000000008e-296 < l

    1. Initial program 68.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. Applied egg-rr41.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 72.1% accurate, 1.0× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 4.6 \cdot 10^{-148}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h \cdot \left({\left(\left(M \cdot 0.5\right) \cdot \frac{D_m}{d}\right)}^{2} \cdot -0.5\right)}{\ell}\right)\right) \cdot \sqrt{\frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D_m \cdot \frac{M}{d \cdot 2}\right)}^{2}\right)\right)\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (if (<= l 4.6e-148)
   (*
    (*
     (sqrt (/ d l))
     (+ 1.0 (/ (* h (* (pow (* (* M 0.5) (/ D_m d)) 2.0) -0.5)) l)))
    (sqrt (/ d h)))
   (*
    (/ (/ d (sqrt l)) (sqrt h))
    (- 1.0 (* 0.5 (* (/ h l) (pow (* D_m (/ M (* d 2.0))) 2.0)))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (l <= 4.6e-148) {
		tmp = (sqrt((d / l)) * (1.0 + ((h * (pow(((M * 0.5) * (D_m / d)), 2.0) * -0.5)) / l))) * sqrt((d / h));
	} else {
		tmp = ((d / sqrt(l)) / sqrt(h)) * (1.0 - (0.5 * ((h / l) * pow((D_m * (M / (d * 2.0))), 2.0))));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: tmp
    if (l <= 4.6d-148) then
        tmp = (sqrt((d / l)) * (1.0d0 + ((h * ((((m * 0.5d0) * (d_m / d)) ** 2.0d0) * (-0.5d0))) / l))) * sqrt((d / h))
    else
        tmp = ((d / sqrt(l)) / sqrt(h)) * (1.0d0 - (0.5d0 * ((h / l) * ((d_m * (m / (d * 2.0d0))) ** 2.0d0))))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (l <= 4.6e-148) {
		tmp = (Math.sqrt((d / l)) * (1.0 + ((h * (Math.pow(((M * 0.5) * (D_m / d)), 2.0) * -0.5)) / l))) * Math.sqrt((d / h));
	} else {
		tmp = ((d / Math.sqrt(l)) / Math.sqrt(h)) * (1.0 - (0.5 * ((h / l) * Math.pow((D_m * (M / (d * 2.0))), 2.0))));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	tmp = 0
	if l <= 4.6e-148:
		tmp = (math.sqrt((d / l)) * (1.0 + ((h * (math.pow(((M * 0.5) * (D_m / d)), 2.0) * -0.5)) / l))) * math.sqrt((d / h))
	else:
		tmp = ((d / math.sqrt(l)) / math.sqrt(h)) * (1.0 - (0.5 * ((h / l) * math.pow((D_m * (M / (d * 2.0))), 2.0))))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	tmp = 0.0
	if (l <= 4.6e-148)
		tmp = Float64(Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(Float64(h * Float64((Float64(Float64(M * 0.5) * Float64(D_m / d)) ^ 2.0) * -0.5)) / l))) * sqrt(Float64(d / h)));
	else
		tmp = Float64(Float64(Float64(d / sqrt(l)) / sqrt(h)) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(D_m * Float64(M / Float64(d * 2.0))) ^ 2.0)))));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	tmp = 0.0;
	if (l <= 4.6e-148)
		tmp = (sqrt((d / l)) * (1.0 + ((h * ((((M * 0.5) * (D_m / d)) ^ 2.0) * -0.5)) / l))) * sqrt((d / h));
	else
		tmp = ((d / sqrt(l)) / sqrt(h)) * (1.0 - (0.5 * ((h / l) * ((D_m * (M / (d * 2.0))) ^ 2.0))));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[l, 4.6e-148], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(h * N[(N[Power[N[(N[(M * 0.5), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(D$95$m * N[(M / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 4.6 \cdot 10^{-148}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h \cdot \left({\left(\left(M \cdot 0.5\right) \cdot \frac{D_m}{d}\right)}^{2} \cdot -0.5\right)}{\ell}\right)\right) \cdot \sqrt{\frac{d}{h}}\\

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


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

    1. Initial program 64.8%

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

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

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

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

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

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

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

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

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

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

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

    if 4.59999999999999995e-148 < l

    1. Initial program 70.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 72.4% accurate, 1.0× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.95 \cdot 10^{-150}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{M}{\frac{d \cdot 2}{D_m}}\right)}^{2}}{\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(D_m \cdot \frac{M}{d \cdot 2}\right)}^{2}\right)\right)\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (if (<= l 1.95e-150)
   (*
    (* (sqrt (/ d l)) (sqrt (/ d h)))
    (- 1.0 (* 0.5 (/ (* h (pow (/ M (/ (* d 2.0) D_m)) 2.0)) l))))
   (*
    (/ (/ d (sqrt l)) (sqrt h))
    (- 1.0 (* 0.5 (* (/ h l) (pow (* D_m (/ M (* d 2.0))) 2.0)))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (l <= 1.95e-150) {
		tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * ((h * pow((M / ((d * 2.0) / D_m)), 2.0)) / l)));
	} else {
		tmp = ((d / sqrt(l)) / sqrt(h)) * (1.0 - (0.5 * ((h / l) * pow((D_m * (M / (d * 2.0))), 2.0))));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: tmp
    if (l <= 1.95d-150) then
        tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - (0.5d0 * ((h * ((m / ((d * 2.0d0) / d_m)) ** 2.0d0)) / l)))
    else
        tmp = ((d / sqrt(l)) / sqrt(h)) * (1.0d0 - (0.5d0 * ((h / l) * ((d_m * (m / (d * 2.0d0))) ** 2.0d0))))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (l <= 1.95e-150) {
		tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - (0.5 * ((h * Math.pow((M / ((d * 2.0) / D_m)), 2.0)) / l)));
	} else {
		tmp = ((d / Math.sqrt(l)) / Math.sqrt(h)) * (1.0 - (0.5 * ((h / l) * Math.pow((D_m * (M / (d * 2.0))), 2.0))));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	tmp = 0
	if l <= 1.95e-150:
		tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - (0.5 * ((h * math.pow((M / ((d * 2.0) / D_m)), 2.0)) / l)))
	else:
		tmp = ((d / math.sqrt(l)) / math.sqrt(h)) * (1.0 - (0.5 * ((h / l) * math.pow((D_m * (M / (d * 2.0))), 2.0))))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	tmp = 0.0
	if (l <= 1.95e-150)
		tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(M / Float64(Float64(d * 2.0) / D_m)) ^ 2.0)) / l))));
	else
		tmp = Float64(Float64(Float64(d / sqrt(l)) / sqrt(h)) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(D_m * Float64(M / Float64(d * 2.0))) ^ 2.0)))));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	tmp = 0.0;
	if (l <= 1.95e-150)
		tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * ((h * ((M / ((d * 2.0) / D_m)) ^ 2.0)) / l)));
	else
		tmp = ((d / sqrt(l)) / sqrt(h)) * (1.0 - (0.5 * ((h / l) * ((D_m * (M / (d * 2.0))) ^ 2.0))));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[l, 1.95e-150], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(M / N[(N[(d * 2.0), $MachinePrecision] / D$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(D$95$m * N[(M / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.95 \cdot 10^{-150}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{M}{\frac{d \cdot 2}{D_m}}\right)}^{2}}{\ell}\right)\\

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


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

    1. Initial program 64.8%

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

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

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

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

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

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

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

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

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

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

    if 1.9500000000000001e-150 < l

    1. Initial program 70.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 58.3% accurate, 1.0× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} t_0 := \frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{if}\;d \leq -1.45 \cdot 10^{-93}:\\ \;\;\;\;\left|t_0\right|\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}\\ \mathbf{elif}\;d \leq 2.15 \cdot 10^{-238}:\\ \;\;\;\;\frac{{\left(M \cdot D_m\right)}^{2} \cdot \left(-0.125 \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(1 + {\left(\frac{D_m}{d} \cdot \frac{M}{2}\right)}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right)\right)\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (let* ((t_0 (/ d (sqrt (* h l)))))
   (if (<= d -1.45e-93)
     (fabs t_0)
     (if (<= d -2e-310)
       (* d (sqrt (log (exp (/ 1.0 (* h l))))))
       (if (<= d 2.15e-238)
         (/ (* (pow (* M D_m) 2.0) (* -0.125 (/ (sqrt h) (pow l 1.5)))) d)
         (*
          t_0
          (+ 1.0 (* (pow (* (/ D_m d) (/ M 2.0)) 2.0) (* -0.5 (/ h l))))))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double t_0 = d / sqrt((h * l));
	double tmp;
	if (d <= -1.45e-93) {
		tmp = fabs(t_0);
	} else if (d <= -2e-310) {
		tmp = d * sqrt(log(exp((1.0 / (h * l)))));
	} else if (d <= 2.15e-238) {
		tmp = (pow((M * D_m), 2.0) * (-0.125 * (sqrt(h) / pow(l, 1.5)))) / d;
	} else {
		tmp = t_0 * (1.0 + (pow(((D_m / d) * (M / 2.0)), 2.0) * (-0.5 * (h / l))));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = d / sqrt((h * l))
    if (d <= (-1.45d-93)) then
        tmp = abs(t_0)
    else if (d <= (-2d-310)) then
        tmp = d * sqrt(log(exp((1.0d0 / (h * l)))))
    else if (d <= 2.15d-238) then
        tmp = (((m * d_m) ** 2.0d0) * ((-0.125d0) * (sqrt(h) / (l ** 1.5d0)))) / d
    else
        tmp = t_0 * (1.0d0 + ((((d_m / d) * (m / 2.0d0)) ** 2.0d0) * ((-0.5d0) * (h / l))))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double t_0 = d / Math.sqrt((h * l));
	double tmp;
	if (d <= -1.45e-93) {
		tmp = Math.abs(t_0);
	} else if (d <= -2e-310) {
		tmp = d * Math.sqrt(Math.log(Math.exp((1.0 / (h * l)))));
	} else if (d <= 2.15e-238) {
		tmp = (Math.pow((M * D_m), 2.0) * (-0.125 * (Math.sqrt(h) / Math.pow(l, 1.5)))) / d;
	} else {
		tmp = t_0 * (1.0 + (Math.pow(((D_m / d) * (M / 2.0)), 2.0) * (-0.5 * (h / l))));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	t_0 = d / math.sqrt((h * l))
	tmp = 0
	if d <= -1.45e-93:
		tmp = math.fabs(t_0)
	elif d <= -2e-310:
		tmp = d * math.sqrt(math.log(math.exp((1.0 / (h * l)))))
	elif d <= 2.15e-238:
		tmp = (math.pow((M * D_m), 2.0) * (-0.125 * (math.sqrt(h) / math.pow(l, 1.5)))) / d
	else:
		tmp = t_0 * (1.0 + (math.pow(((D_m / d) * (M / 2.0)), 2.0) * (-0.5 * (h / l))))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	t_0 = Float64(d / sqrt(Float64(h * l)))
	tmp = 0.0
	if (d <= -1.45e-93)
		tmp = abs(t_0);
	elseif (d <= -2e-310)
		tmp = Float64(d * sqrt(log(exp(Float64(1.0 / Float64(h * l))))));
	elseif (d <= 2.15e-238)
		tmp = Float64(Float64((Float64(M * D_m) ^ 2.0) * Float64(-0.125 * Float64(sqrt(h) / (l ^ 1.5)))) / d);
	else
		tmp = Float64(t_0 * Float64(1.0 + Float64((Float64(Float64(D_m / d) * Float64(M / 2.0)) ^ 2.0) * Float64(-0.5 * Float64(h / l)))));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	t_0 = d / sqrt((h * l));
	tmp = 0.0;
	if (d <= -1.45e-93)
		tmp = abs(t_0);
	elseif (d <= -2e-310)
		tmp = d * sqrt(log(exp((1.0 / (h * l)))));
	elseif (d <= 2.15e-238)
		tmp = (((M * D_m) ^ 2.0) * (-0.125 * (sqrt(h) / (l ^ 1.5)))) / d;
	else
		tmp = t_0 * (1.0 + ((((D_m / d) * (M / 2.0)) ^ 2.0) * (-0.5 * (h / l))));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.45e-93], N[Abs[t$95$0], $MachinePrecision], If[LessEqual[d, -2e-310], N[(d * N[Sqrt[N[Log[N[Exp[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.15e-238], N[(N[(N[Power[N[(M * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.125 * N[(N[Sqrt[h], $MachinePrecision] / N[Power[l, 1.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], N[(t$95$0 * N[(1.0 + N[(N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{d}{\sqrt{h \cdot \ell}}\\
\mathbf{if}\;d \leq -1.45 \cdot 10^{-93}:\\
\;\;\;\;\left|t_0\right|\\

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

\mathbf{elif}\;d \leq 2.15 \cdot 10^{-238}:\\
\;\;\;\;\frac{{\left(M \cdot D_m\right)}^{2} \cdot \left(-0.125 \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}\right)}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.4499999999999999e-93

    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. Simplified73.3%

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr6.5%

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

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt6.5%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr6.5%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt6.5%

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

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

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

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

        \[\leadsto \color{blue}{\left|d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      4. metadata-eval55.6%

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

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

        \[\leadsto \left|d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}}\right| \]
      7. div-inv55.6%

        \[\leadsto \left|\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}}\right| \]
    10. Applied egg-rr55.6%

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

    if -1.4499999999999999e-93 < d < -1.999999999999994e-310

    1. Initial program 45.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 d around inf 12.5%

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

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

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

    if -1.999999999999994e-310 < d < 2.14999999999999984e-238

    1. Initial program 44.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 d around 0 42.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.14999999999999984e-238 < d

    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. Simplified71.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 56.8% accurate, 1.0× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} t_0 := \frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{if}\;d \leq -3.7 \cdot 10^{-92}:\\ \;\;\;\;\left|t_0\right|\\ \mathbf{elif}\;d \leq 3 \cdot 10^{-297}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{1}{h \cdot \ell}}\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(1 + {\left(\frac{D_m}{d} \cdot \frac{M}{2}\right)}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right)\right)\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (let* ((t_0 (/ d (sqrt (* h l)))))
   (if (<= d -3.7e-92)
     (fabs t_0)
     (if (<= d 3e-297)
       (* d (sqrt (log (exp (/ 1.0 (* h l))))))
       (*
        t_0
        (+ 1.0 (* (pow (* (/ D_m d) (/ M 2.0)) 2.0) (* -0.5 (/ h l)))))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double t_0 = d / sqrt((h * l));
	double tmp;
	if (d <= -3.7e-92) {
		tmp = fabs(t_0);
	} else if (d <= 3e-297) {
		tmp = d * sqrt(log(exp((1.0 / (h * l)))));
	} else {
		tmp = t_0 * (1.0 + (pow(((D_m / d) * (M / 2.0)), 2.0) * (-0.5 * (h / l))));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = d / sqrt((h * l))
    if (d <= (-3.7d-92)) then
        tmp = abs(t_0)
    else if (d <= 3d-297) then
        tmp = d * sqrt(log(exp((1.0d0 / (h * l)))))
    else
        tmp = t_0 * (1.0d0 + ((((d_m / d) * (m / 2.0d0)) ** 2.0d0) * ((-0.5d0) * (h / l))))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double t_0 = d / Math.sqrt((h * l));
	double tmp;
	if (d <= -3.7e-92) {
		tmp = Math.abs(t_0);
	} else if (d <= 3e-297) {
		tmp = d * Math.sqrt(Math.log(Math.exp((1.0 / (h * l)))));
	} else {
		tmp = t_0 * (1.0 + (Math.pow(((D_m / d) * (M / 2.0)), 2.0) * (-0.5 * (h / l))));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	t_0 = d / math.sqrt((h * l))
	tmp = 0
	if d <= -3.7e-92:
		tmp = math.fabs(t_0)
	elif d <= 3e-297:
		tmp = d * math.sqrt(math.log(math.exp((1.0 / (h * l)))))
	else:
		tmp = t_0 * (1.0 + (math.pow(((D_m / d) * (M / 2.0)), 2.0) * (-0.5 * (h / l))))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	t_0 = Float64(d / sqrt(Float64(h * l)))
	tmp = 0.0
	if (d <= -3.7e-92)
		tmp = abs(t_0);
	elseif (d <= 3e-297)
		tmp = Float64(d * sqrt(log(exp(Float64(1.0 / Float64(h * l))))));
	else
		tmp = Float64(t_0 * Float64(1.0 + Float64((Float64(Float64(D_m / d) * Float64(M / 2.0)) ^ 2.0) * Float64(-0.5 * Float64(h / l)))));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	t_0 = d / sqrt((h * l));
	tmp = 0.0;
	if (d <= -3.7e-92)
		tmp = abs(t_0);
	elseif (d <= 3e-297)
		tmp = d * sqrt(log(exp((1.0 / (h * l)))));
	else
		tmp = t_0 * (1.0 + ((((D_m / d) * (M / 2.0)) ^ 2.0) * (-0.5 * (h / l))));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.7e-92], N[Abs[t$95$0], $MachinePrecision], If[LessEqual[d, 3e-297], N[(d * N[Sqrt[N[Log[N[Exp[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 + N[(N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{d}{\sqrt{h \cdot \ell}}\\
\mathbf{if}\;d \leq -3.7 \cdot 10^{-92}:\\
\;\;\;\;\left|t_0\right|\\

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

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


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

    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. Simplified73.3%

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr6.5%

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

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt6.5%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr6.5%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt6.5%

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

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

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

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

        \[\leadsto \color{blue}{\left|d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      4. metadata-eval55.6%

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

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

        \[\leadsto \left|d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}}\right| \]
      7. div-inv55.6%

        \[\leadsto \left|\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}}\right| \]
    10. Applied egg-rr55.6%

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

    if -3.69999999999999977e-92 < d < 2.99999999999999995e-297

    1. Initial program 46.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. Taylor expanded in d around inf 17.7%

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

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

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

    if 2.99999999999999995e-297 < d

    1. Initial program 69.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 56.8% accurate, 1.1× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} t_0 := \frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{if}\;d \leq -6.2 \cdot 10^{-97}:\\ \;\;\;\;\left|t_0\right|\\ \mathbf{elif}\;d \leq 3 \cdot 10^{-297}:\\ \;\;\;\;d \cdot \log \left(e^{{\left(h \cdot \ell\right)}^{-0.5}}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(1 + {\left(\frac{D_m}{d} \cdot \frac{M}{2}\right)}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right)\right)\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (let* ((t_0 (/ d (sqrt (* h l)))))
   (if (<= d -6.2e-97)
     (fabs t_0)
     (if (<= d 3e-297)
       (* d (log (exp (pow (* h l) -0.5))))
       (*
        t_0
        (+ 1.0 (* (pow (* (/ D_m d) (/ M 2.0)) 2.0) (* -0.5 (/ h l)))))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double t_0 = d / sqrt((h * l));
	double tmp;
	if (d <= -6.2e-97) {
		tmp = fabs(t_0);
	} else if (d <= 3e-297) {
		tmp = d * log(exp(pow((h * l), -0.5)));
	} else {
		tmp = t_0 * (1.0 + (pow(((D_m / d) * (M / 2.0)), 2.0) * (-0.5 * (h / l))));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = d / sqrt((h * l))
    if (d <= (-6.2d-97)) then
        tmp = abs(t_0)
    else if (d <= 3d-297) then
        tmp = d * log(exp(((h * l) ** (-0.5d0))))
    else
        tmp = t_0 * (1.0d0 + ((((d_m / d) * (m / 2.0d0)) ** 2.0d0) * ((-0.5d0) * (h / l))))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double t_0 = d / Math.sqrt((h * l));
	double tmp;
	if (d <= -6.2e-97) {
		tmp = Math.abs(t_0);
	} else if (d <= 3e-297) {
		tmp = d * Math.log(Math.exp(Math.pow((h * l), -0.5)));
	} else {
		tmp = t_0 * (1.0 + (Math.pow(((D_m / d) * (M / 2.0)), 2.0) * (-0.5 * (h / l))));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	t_0 = d / math.sqrt((h * l))
	tmp = 0
	if d <= -6.2e-97:
		tmp = math.fabs(t_0)
	elif d <= 3e-297:
		tmp = d * math.log(math.exp(math.pow((h * l), -0.5)))
	else:
		tmp = t_0 * (1.0 + (math.pow(((D_m / d) * (M / 2.0)), 2.0) * (-0.5 * (h / l))))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	t_0 = Float64(d / sqrt(Float64(h * l)))
	tmp = 0.0
	if (d <= -6.2e-97)
		tmp = abs(t_0);
	elseif (d <= 3e-297)
		tmp = Float64(d * log(exp((Float64(h * l) ^ -0.5))));
	else
		tmp = Float64(t_0 * Float64(1.0 + Float64((Float64(Float64(D_m / d) * Float64(M / 2.0)) ^ 2.0) * Float64(-0.5 * Float64(h / l)))));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	t_0 = d / sqrt((h * l));
	tmp = 0.0;
	if (d <= -6.2e-97)
		tmp = abs(t_0);
	elseif (d <= 3e-297)
		tmp = d * log(exp(((h * l) ^ -0.5)));
	else
		tmp = t_0 * (1.0 + ((((D_m / d) * (M / 2.0)) ^ 2.0) * (-0.5 * (h / l))));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -6.2e-97], N[Abs[t$95$0], $MachinePrecision], If[LessEqual[d, 3e-297], N[(d * N[Log[N[Exp[N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 + N[(N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{d}{\sqrt{h \cdot \ell}}\\
\mathbf{if}\;d \leq -6.2 \cdot 10^{-97}:\\
\;\;\;\;\left|t_0\right|\\

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

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


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

    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. Simplified73.3%

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr6.5%

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

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt6.5%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr6.5%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt6.5%

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

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

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

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

        \[\leadsto \color{blue}{\left|d \cdot {\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      4. metadata-eval55.6%

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

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

        \[\leadsto \left|d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}}\right| \]
      7. div-inv55.6%

        \[\leadsto \left|\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}}\right| \]
    10. Applied egg-rr55.6%

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

    if -6.20000000000000004e-97 < d < 2.99999999999999995e-297

    1. Initial program 46.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. Taylor expanded in d around inf 17.7%

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

        \[\leadsto d \cdot \color{blue}{\log \left(e^{\sqrt{\frac{1}{h \cdot \ell}}}\right)} \]
      2. inv-pow38.9%

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

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}}\right) \]
      4. metadata-eval38.9%

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

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

    if 2.99999999999999995e-297 < d

    1. Initial program 69.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 58.6% accurate, 1.1× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{h \cdot \ell}\\ t_1 := \frac{d}{t_0}\\ \mathbf{if}\;\ell \leq -1.65 \cdot 10^{-234}:\\ \;\;\;\;\left|t_1\right|\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\log \left(e^{t_0}\right)}\\ \mathbf{elif}\;\ell \leq 4 \cdot 10^{+136}:\\ \;\;\;\;t_1 \cdot \left(1 + {\left(\frac{D_m}{d} \cdot \frac{M}{2}\right)}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (let* ((t_0 (sqrt (* h l))) (t_1 (/ d t_0)))
   (if (<= l -1.65e-234)
     (fabs t_1)
     (if (<= l -5e-310)
       (/ d (log (exp t_0)))
       (if (<= l 4e+136)
         (* t_1 (+ 1.0 (* (pow (* (/ D_m d) (/ M 2.0)) 2.0) (* -0.5 (/ h l)))))
         (/ d (* (sqrt h) (sqrt l))))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double t_0 = sqrt((h * l));
	double t_1 = d / t_0;
	double tmp;
	if (l <= -1.65e-234) {
		tmp = fabs(t_1);
	} else if (l <= -5e-310) {
		tmp = d / log(exp(t_0));
	} else if (l <= 4e+136) {
		tmp = t_1 * (1.0 + (pow(((D_m / d) * (M / 2.0)), 2.0) * (-0.5 * (h / l))));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = sqrt((h * l))
    t_1 = d / t_0
    if (l <= (-1.65d-234)) then
        tmp = abs(t_1)
    else if (l <= (-5d-310)) then
        tmp = d / log(exp(t_0))
    else if (l <= 4d+136) then
        tmp = t_1 * (1.0d0 + ((((d_m / d) * (m / 2.0d0)) ** 2.0d0) * ((-0.5d0) * (h / l))))
    else
        tmp = d / (sqrt(h) * sqrt(l))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double t_0 = Math.sqrt((h * l));
	double t_1 = d / t_0;
	double tmp;
	if (l <= -1.65e-234) {
		tmp = Math.abs(t_1);
	} else if (l <= -5e-310) {
		tmp = d / Math.log(Math.exp(t_0));
	} else if (l <= 4e+136) {
		tmp = t_1 * (1.0 + (Math.pow(((D_m / d) * (M / 2.0)), 2.0) * (-0.5 * (h / l))));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	t_0 = math.sqrt((h * l))
	t_1 = d / t_0
	tmp = 0
	if l <= -1.65e-234:
		tmp = math.fabs(t_1)
	elif l <= -5e-310:
		tmp = d / math.log(math.exp(t_0))
	elif l <= 4e+136:
		tmp = t_1 * (1.0 + (math.pow(((D_m / d) * (M / 2.0)), 2.0) * (-0.5 * (h / l))))
	else:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	t_0 = sqrt(Float64(h * l))
	t_1 = Float64(d / t_0)
	tmp = 0.0
	if (l <= -1.65e-234)
		tmp = abs(t_1);
	elseif (l <= -5e-310)
		tmp = Float64(d / log(exp(t_0)));
	elseif (l <= 4e+136)
		tmp = Float64(t_1 * Float64(1.0 + Float64((Float64(Float64(D_m / d) * Float64(M / 2.0)) ^ 2.0) * Float64(-0.5 * Float64(h / l)))));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	t_0 = sqrt((h * l));
	t_1 = d / t_0;
	tmp = 0.0;
	if (l <= -1.65e-234)
		tmp = abs(t_1);
	elseif (l <= -5e-310)
		tmp = d / log(exp(t_0));
	elseif (l <= 4e+136)
		tmp = t_1 * (1.0 + ((((D_m / d) * (M / 2.0)) ^ 2.0) * (-0.5 * (h / l))));
	else
		tmp = d / (sqrt(h) * sqrt(l));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(d / t$95$0), $MachinePrecision]}, If[LessEqual[l, -1.65e-234], N[Abs[t$95$1], $MachinePrecision], If[LessEqual[l, -5e-310], N[(d / N[Log[N[Exp[t$95$0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4e+136], N[(t$95$1 * N[(1.0 + N[(N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{h \cdot \ell}\\
t_1 := \frac{d}{t_0}\\
\mathbf{if}\;\ell \leq -1.65 \cdot 10^{-234}:\\
\;\;\;\;\left|t_1\right|\\

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{d}{\log \left(e^{t_0}\right)}\\

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

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


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

    1. Initial program 65.0%

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt8.0%

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

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

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

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

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

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

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

        \[\leadsto \left|d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{\left(-0.5\right)}}\right| \]
      5. pow-flip47.7%

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

        \[\leadsto \left|d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}}\right| \]
      7. div-inv47.7%

        \[\leadsto \left|\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}}\right| \]
    10. Applied egg-rr47.7%

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

    if -1.65000000000000007e-234 < l < -4.999999999999985e-310

    1. Initial program 55.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. Simplified55.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\color{blue}{\log \left(e^{\sqrt{h \cdot \ell}}\right)}} \]
    14. Applied egg-rr56.3%

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

    if -4.999999999999985e-310 < l < 4.00000000000000023e136

    1. Initial program 76.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.00000000000000023e136 < l

    1. Initial program 47.9%

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt67.5%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr67.5%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt67.8%

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

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

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

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

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      4. div-inv67.8%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 \cdot d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. times-frac87.9%

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

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

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

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

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} \]
    16. Simplified88.0%

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

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

Alternative 17: 57.5% accurate, 1.4× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} t_0 := \frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left|t_0\right|\\ \mathbf{elif}\;\ell \leq 5 \cdot 10^{+136}:\\ \;\;\;\;t_0 \cdot \left(1 + {\left(\frac{D_m}{d} \cdot \frac{M}{2}\right)}^{2} \cdot \left(-0.5 \cdot \frac{h}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (let* ((t_0 (/ d (sqrt (* h l)))))
   (if (<= l -5e-310)
     (fabs t_0)
     (if (<= l 5e+136)
       (* t_0 (+ 1.0 (* (pow (* (/ D_m d) (/ M 2.0)) 2.0) (* -0.5 (/ h l)))))
       (/ d (* (sqrt h) (sqrt l)))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double t_0 = d / sqrt((h * l));
	double tmp;
	if (l <= -5e-310) {
		tmp = fabs(t_0);
	} else if (l <= 5e+136) {
		tmp = t_0 * (1.0 + (pow(((D_m / d) * (M / 2.0)), 2.0) * (-0.5 * (h / l))));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = d / sqrt((h * l))
    if (l <= (-5d-310)) then
        tmp = abs(t_0)
    else if (l <= 5d+136) then
        tmp = t_0 * (1.0d0 + ((((d_m / d) * (m / 2.0d0)) ** 2.0d0) * ((-0.5d0) * (h / l))))
    else
        tmp = d / (sqrt(h) * sqrt(l))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double t_0 = d / Math.sqrt((h * l));
	double tmp;
	if (l <= -5e-310) {
		tmp = Math.abs(t_0);
	} else if (l <= 5e+136) {
		tmp = t_0 * (1.0 + (Math.pow(((D_m / d) * (M / 2.0)), 2.0) * (-0.5 * (h / l))));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	t_0 = d / math.sqrt((h * l))
	tmp = 0
	if l <= -5e-310:
		tmp = math.fabs(t_0)
	elif l <= 5e+136:
		tmp = t_0 * (1.0 + (math.pow(((D_m / d) * (M / 2.0)), 2.0) * (-0.5 * (h / l))))
	else:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	t_0 = Float64(d / sqrt(Float64(h * l)))
	tmp = 0.0
	if (l <= -5e-310)
		tmp = abs(t_0);
	elseif (l <= 5e+136)
		tmp = Float64(t_0 * Float64(1.0 + Float64((Float64(Float64(D_m / d) * Float64(M / 2.0)) ^ 2.0) * Float64(-0.5 * Float64(h / l)))));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	t_0 = d / sqrt((h * l));
	tmp = 0.0;
	if (l <= -5e-310)
		tmp = abs(t_0);
	elseif (l <= 5e+136)
		tmp = t_0 * (1.0 + ((((D_m / d) * (M / 2.0)) ^ 2.0) * (-0.5 * (h / l))));
	else
		tmp = d / (sqrt(h) * sqrt(l));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5e-310], N[Abs[t$95$0], $MachinePrecision], If[LessEqual[l, 5e+136], N[(t$95$0 * N[(1.0 + N[(N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{d}{\sqrt{h \cdot \ell}}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left|t_0\right|\\

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

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


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

    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}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot -0.5\right)\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. sqrt-div0.0%

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

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

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

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

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

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

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

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr8.4%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt8.4%

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

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

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

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

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

        \[\leadsto \left|d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{\left(-0.5\right)}}\right| \]
      5. pow-flip45.2%

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

        \[\leadsto \left|d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}}\right| \]
      7. div-inv45.2%

        \[\leadsto \left|\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}}\right| \]
    10. Applied egg-rr45.2%

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

    if -4.999999999999985e-310 < l < 5.0000000000000002e136

    1. Initial program 76.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000002e136 < l

    1. Initial program 47.9%

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt67.5%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr67.5%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt67.8%

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

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

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

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

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      4. div-inv67.8%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 \cdot d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. times-frac87.9%

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

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

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

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

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} \]
    16. Simplified88.0%

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

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

Alternative 18: 50.3% accurate, 1.5× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\left|\frac{d}{\sqrt{h \cdot \ell}}\right|\\ \mathbf{elif}\;d \leq 1.65 \cdot 10^{-161}:\\ \;\;\;\;\left(\left(M \cdot D_m\right) \cdot \left(\left(M \cdot D_m\right) \cdot \frac{1}{d}\right)\right) \cdot \left(-0.125 \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (if (<= d -2e-310)
   (fabs (/ d (sqrt (* h l))))
   (if (<= d 1.65e-161)
     (*
      (* (* M D_m) (* (* M D_m) (/ 1.0 d)))
      (* -0.125 (sqrt (/ h (pow l 3.0)))))
     (/ d (* (sqrt h) (sqrt l))))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (d <= -2e-310) {
		tmp = fabs((d / sqrt((h * l))));
	} else if (d <= 1.65e-161) {
		tmp = ((M * D_m) * ((M * D_m) * (1.0 / d))) * (-0.125 * sqrt((h / pow(l, 3.0))));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: tmp
    if (d <= (-2d-310)) then
        tmp = abs((d / sqrt((h * l))))
    else if (d <= 1.65d-161) then
        tmp = ((m * d_m) * ((m * d_m) * (1.0d0 / d))) * ((-0.125d0) * sqrt((h / (l ** 3.0d0))))
    else
        tmp = d / (sqrt(h) * sqrt(l))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (d <= -2e-310) {
		tmp = Math.abs((d / Math.sqrt((h * l))));
	} else if (d <= 1.65e-161) {
		tmp = ((M * D_m) * ((M * D_m) * (1.0 / d))) * (-0.125 * Math.sqrt((h / Math.pow(l, 3.0))));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	tmp = 0
	if d <= -2e-310:
		tmp = math.fabs((d / math.sqrt((h * l))))
	elif d <= 1.65e-161:
		tmp = ((M * D_m) * ((M * D_m) * (1.0 / d))) * (-0.125 * math.sqrt((h / math.pow(l, 3.0))))
	else:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	tmp = 0.0
	if (d <= -2e-310)
		tmp = abs(Float64(d / sqrt(Float64(h * l))));
	elseif (d <= 1.65e-161)
		tmp = Float64(Float64(Float64(M * D_m) * Float64(Float64(M * D_m) * Float64(1.0 / d))) * Float64(-0.125 * sqrt(Float64(h / (l ^ 3.0)))));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	tmp = 0.0;
	if (d <= -2e-310)
		tmp = abs((d / sqrt((h * l))));
	elseif (d <= 1.65e-161)
		tmp = ((M * D_m) * ((M * D_m) * (1.0 / d))) * (-0.125 * sqrt((h / (l ^ 3.0))));
	else
		tmp = d / (sqrt(h) * sqrt(l));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[d, -2e-310], N[Abs[N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, 1.65e-161], N[(N[(N[(M * D$95$m), $MachinePrecision] * N[(N[(M * D$95$m), $MachinePrecision] * N[(1.0 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-0.125 * N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\left|\frac{d}{\sqrt{h \cdot \ell}}\right|\\

\mathbf{elif}\;d \leq 1.65 \cdot 10^{-161}:\\
\;\;\;\;\left(\left(M \cdot D_m\right) \cdot \left(\left(M \cdot D_m\right) \cdot \frac{1}{d}\right)\right) \cdot \left(-0.125 \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\

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


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

    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}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot -0.5\right)\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. sqrt-div0.0%

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

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

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

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

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

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

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

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr8.4%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt8.4%

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

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

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

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

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

        \[\leadsto \left|d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{\left(-0.5\right)}}\right| \]
      5. pow-flip45.2%

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

        \[\leadsto \left|d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}}\right| \]
      7. div-inv45.2%

        \[\leadsto \left|\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}}\right| \]
    10. Applied egg-rr45.2%

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

    if -1.999999999999994e-310 < d < 1.6499999999999999e-161

    1. Initial program 62.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 d around 0 52.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.6499999999999999e-161 < d

    1. Initial program 71.5%

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt63.7%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr63.7%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt63.9%

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

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

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

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

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      4. div-inv63.9%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 \cdot d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. times-frac74.9%

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

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

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

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

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

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

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

Alternative 19: 46.3% accurate, 1.6× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq 10^{-204}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (if (<= d 1e-204)
   (* (- d) (sqrt (/ 1.0 (* h l))))
   (/ d (* (sqrt h) (sqrt l)))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (d <= 1e-204) {
		tmp = -d * sqrt((1.0 / (h * l)));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: tmp
    if (d <= 1d-204) then
        tmp = -d * sqrt((1.0d0 / (h * l)))
    else
        tmp = d / (sqrt(h) * sqrt(l))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (d <= 1e-204) {
		tmp = -d * Math.sqrt((1.0 / (h * l)));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	tmp = 0
	if d <= 1e-204:
		tmp = -d * math.sqrt((1.0 / (h * l)))
	else:
		tmp = d / (math.sqrt(h) * math.sqrt(l))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	tmp = 0.0
	if (d <= 1e-204)
		tmp = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(h * l))));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	tmp = 0.0;
	if (d <= 1e-204)
		tmp = -d * sqrt((1.0 / (h * l)));
	else
		tmp = d / (sqrt(h) * sqrt(l));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[d, 1e-204], N[((-d) * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 10^{-204}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\\

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


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

    1. Initial program 62.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 d around inf 9.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      3. distribute-rgt-neg-in41.4%

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

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

    if 1e-204 < d

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt60.6%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr60.6%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt60.9%

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

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

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

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

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}} \]
      4. div-inv60.8%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 \cdot d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
      3. times-frac70.7%

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

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

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

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

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

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

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

Alternative 20: 42.8% accurate, 1.6× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \left|\frac{d}{\sqrt{h \cdot \ell}}\right| \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m) :precision binary64 (fabs (/ d (sqrt (* h l)))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	return fabs((d / sqrt((h * l))));
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    code = abs((d / sqrt((h * l))))
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	return Math.abs((d / Math.sqrt((h * l))));
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	return math.fabs((d / math.sqrt((h * l))))
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	return abs(Float64(d / sqrt(Float64(h * l))))
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp = code(d, h, l, M, D_m)
	tmp = abs((d / sqrt((h * l))));
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := N[Abs[N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\left|\frac{d}{\sqrt{h \cdot \ell}}\right|
\end{array}
Derivation
  1. Initial program 66.7%

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

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

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

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

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

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

      \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
    3. pow-sqr30.5%

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

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

      \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
    6. fabs-sqr30.4%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
    7. rem-square-sqrt30.5%

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

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

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

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

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

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

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

      \[\leadsto \left|d \cdot \frac{1}{\color{blue}{\sqrt{h \cdot \ell}}}\right| \]
    7. div-inv49.1%

      \[\leadsto \left|\color{blue}{\frac{d}{\sqrt{h \cdot \ell}}}\right| \]
  10. Applied egg-rr49.1%

    \[\leadsto \color{blue}{\left|\frac{d}{\sqrt{h \cdot \ell}}\right|} \]
  11. Final simplification49.1%

    \[\leadsto \left|\frac{d}{\sqrt{h \cdot \ell}}\right| \]
  12. Add Preprocessing

Alternative 21: 42.8% accurate, 2.9× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq 1.42 \cdot 10^{-204}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
 :precision binary64
 (if (<= d 1.42e-204)
   (* (- d) (sqrt (/ 1.0 (* h l))))
   (* d (sqrt (/ (/ 1.0 l) h)))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (d <= 1.42e-204) {
		tmp = -d * sqrt((1.0 / (h * l)));
	} else {
		tmp = d * sqrt(((1.0 / l) / h));
	}
	return tmp;
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    real(8) :: tmp
    if (d <= 1.42d-204) then
        tmp = -d * sqrt((1.0d0 / (h * l)))
    else
        tmp = d * sqrt(((1.0d0 / l) / h))
    end if
    code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	double tmp;
	if (d <= 1.42e-204) {
		tmp = -d * Math.sqrt((1.0 / (h * l)));
	} else {
		tmp = d * Math.sqrt(((1.0 / l) / h));
	}
	return tmp;
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	tmp = 0
	if d <= 1.42e-204:
		tmp = -d * math.sqrt((1.0 / (h * l)))
	else:
		tmp = d * math.sqrt(((1.0 / l) / h))
	return tmp
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	tmp = 0.0
	if (d <= 1.42e-204)
		tmp = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(h * l))));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / l) / h)));
	end
	return tmp
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
	tmp = 0.0;
	if (d <= 1.42e-204)
		tmp = -d * sqrt((1.0 / (h * l)));
	else
		tmp = d * sqrt(((1.0 / l) / h));
	end
	tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[d, 1.42e-204], N[((-d) * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 1.42 \cdot 10^{-204}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\\

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


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

    1. Initial program 62.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 d around inf 9.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot d} \]
      3. distribute-rgt-neg-in41.4%

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

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

    if 1.4200000000000001e-204 < d

    1. Initial program 72.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. Taylor expanded in d around inf 60.8%

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

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

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

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

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

Alternative 22: 26.4% accurate, 3.1× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ d \cdot {\left(h \cdot \ell\right)}^{-0.5} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m) :precision binary64 (* d (pow (* h l) -0.5)))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	return d * pow((h * l), -0.5);
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    code = d * ((h * l) ** (-0.5d0))
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	return d * Math.pow((h * l), -0.5);
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	return d * math.pow((h * l), -0.5)
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	return Float64(d * (Float64(h * l) ^ -0.5))
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp = code(d, h, l, M, D_m)
	tmp = d * ((h * l) ^ -0.5);
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
d \cdot {\left(h \cdot \ell\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 66.7%

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

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

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

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

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

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

      \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
    3. pow-sqr30.5%

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

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

      \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
    6. fabs-sqr30.4%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
    7. rem-square-sqrt30.5%

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

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

    \[\leadsto d \cdot {\left(h \cdot \ell\right)}^{-0.5} \]
  10. Add Preprocessing

Alternative 23: 26.4% accurate, 3.2× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\ \\ \frac{d}{\sqrt{h \cdot \ell}} \end{array} \]
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m) :precision binary64 (/ d (sqrt (* h l))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
	return d / sqrt((h * l));
}
D_m = abs(D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
    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_m
    code = d / sqrt((h * l))
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
	return d / Math.sqrt((h * l));
}
D_m = math.fabs(D)
[d, h, l, M, D_m] = sort([d, h, l, M, D_m])
def code(d, h, l, M, D_m):
	return d / math.sqrt((h * l))
D_m = abs(D)
d, h, l, M, D_m = sort([d, h, l, M, D_m])
function code(d, h, l, M, D_m)
	return Float64(d / sqrt(Float64(h * l)))
end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp = code(d, h, l, M, D_m)
	tmp = d / sqrt((h * l));
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\frac{d}{\sqrt{h \cdot \ell}}
\end{array}
Derivation
  1. Initial program 66.7%

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

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

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

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

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

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

      \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
    3. pow-sqr30.5%

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

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

      \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
    6. fabs-sqr30.4%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
    7. rem-square-sqrt30.5%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  13. Final simplification30.4%

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

Reproduce

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