Henrywood and Agarwal, Equation (12)

Percentage Accurate: 67.0% → 82.7%
Time: 1.6min
Alternatives: 13
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 13 alternatives:

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

Initial Program: 67.0% accurate, 1.0× speedup?

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

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

Alternative 1: 82.7% accurate, 0.6× speedup?

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

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

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


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

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

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \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. clear-num71.1%

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < d < 1.32e-176

    1. Initial program 37.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. Simplified35.7%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \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. clear-num35.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.32e-176 < d

    1. Initial program 75.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. Simplified76.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 81.0% accurate, 0.8× speedup?

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

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


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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{-d}}{\sqrt{-h}}} \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.999999999999969e-311 < h

    1. Initial program 64.6%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified64.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. sub-neg64.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 81.2% accurate, 0.8× speedup?

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

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


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

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

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \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. clear-num71.1%

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

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

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

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

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

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

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

    if -9.999999999999969e-311 < h

    1. Initial program 64.6%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified64.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. sub-neg64.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 76.6% accurate, 0.8× speedup?

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

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


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

    1. Initial program 71.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. Simplified71.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + h \cdot \left(-0.125 \cdot \frac{\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \color{blue}{\left(M \cdot M\right)}}{\ell}\right)\right)\right) \]
      7. swap-sqr74.1%

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

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

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

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

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

    if 2.3499999999999999e-303 < l

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 70.8% accurate, 1.0× speedup?

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

\mathbf{elif}\;d \leq 2.55 \cdot 10^{-269}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.125 \cdot \frac{h \cdot {\left(\frac{D\_m \cdot M\_m}{d}\right)}^{2}}{\ell}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -5.59999999999999977e88

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow180.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}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval80.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow180.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}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. div-inv80.4%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in66.9%

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

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

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

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

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

        \[\leadsto d \cdot \left(-\left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right|\right) \]
      8. fabs-sqr68.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) \]
      9. rem-square-sqrt68.7%

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

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    11. Taylor expanded in l around -inf 81.4%

      \[\leadsto d \cdot \left(-\color{blue}{e^{-0.5 \cdot \left(\log \left(-1 \cdot h\right) + -1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}}\right) \]
    12. Step-by-step derivation
      1. distribute-lft-in81.4%

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

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

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

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

        \[\leadsto d \cdot \left(-{\color{blue}{\left(-h\right)}}^{-0.5} \cdot e^{-0.5 \cdot \left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}\right) \]
      6. *-commutative82.4%

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right) \cdot -0.5}}\right) \]
      7. *-commutative82.4%

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(\log \left(\frac{-1}{\ell}\right) \cdot -1\right)} \cdot -0.5}\right) \]
      8. associate-*l*82.4%

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

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

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

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

    if -5.59999999999999977e88 < d < 2.5500000000000001e-269

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow166.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}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval66.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow166.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}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. div-inv66.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}}{d \cdot d} \cdot \frac{h}{\ell}\right)\right) \]
      6. unswap-sqr53.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{\color{blue}{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}}{d \cdot d} \cdot \frac{h}{\ell}\right)\right) \]
      7. times-frac59.0%

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

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

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.125 \cdot \left(\left(\left(\frac{D}{d} \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot M\right)}\right) \cdot \frac{h}{\ell}\right)\right) \]
      10. unpow257.9%

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

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

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

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

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

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

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

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

    if 2.5500000000000001e-269 < d

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\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)} \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. associate-*l/82.1%

        \[\leadsto \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) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      4. associate-/l*82.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + h \cdot \left(\frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\color{blue}{d \cdot d}} \cdot \frac{-0.125}{\ell}\right)\right) \cdot \frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}} \]
      8. times-frac78.6%

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

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

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

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

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

Alternative 6: 76.0% accurate, 1.0× speedup?

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

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


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

    1. Initial program 71.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. Simplified71.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + h \cdot \left(-0.125 \cdot \frac{\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \color{blue}{\left(M \cdot M\right)}}{\ell}\right)\right)\right) \]
      7. swap-sqr74.1%

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

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

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

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

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

    if 2.3499999999999999e-303 < l

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\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)} \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. associate-*l/79.9%

        \[\leadsto \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) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      4. associate-/l*80.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + h \cdot \left(\frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\color{blue}{d \cdot d}} \cdot \frac{-0.125}{\ell}\right)\right) \cdot \frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}} \]
      8. times-frac75.9%

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

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

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

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

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

Alternative 7: 61.4% accurate, 1.4× speedup?

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

\mathbf{elif}\;\ell \leq 1.45 \cdot 10^{+16}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


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

    1. Initial program 61.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in50.4%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    11. Taylor expanded in l around -inf 63.4%

      \[\leadsto d \cdot \left(-\color{blue}{e^{-0.5 \cdot \left(\log \left(-1 \cdot h\right) + -1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}}\right) \]
    12. Step-by-step derivation
      1. distribute-lft-in63.4%

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

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

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

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

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

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(-1 \cdot \log \left(\frac{-1}{\ell}\right)\right) \cdot -0.5}}\right) \]
      7. *-commutative63.6%

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(\log \left(\frac{-1}{\ell}\right) \cdot -1\right)} \cdot -0.5}\right) \]
      8. associate-*l*63.6%

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

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

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

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

    if -4.19999999999999981e130 < l < 1.45e16

    1. Initial program 77.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{\color{blue}{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}}{d \cdot d} \cdot \frac{h}{\ell}\right)\right) \]
      7. times-frac71.7%

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

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

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

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

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

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

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

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

    if 1.45e16 < l

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification66.8%

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

Alternative 8: 63.6% accurate, 1.4× speedup?

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

\mathbf{elif}\;\ell \leq 2.55 \cdot 10^{+16}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.125 \cdot \frac{h \cdot {\left(\frac{D\_m \cdot M\_m}{d}\right)}^{2}}{\ell}\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow171.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}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval71.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow171.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}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. div-inv71.4%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in51.7%

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

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

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

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

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

        \[\leadsto d \cdot \left(-\left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right|\right) \]
      8. fabs-sqr51.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) \]
      9. rem-square-sqrt51.7%

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

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    11. Taylor expanded in l around -inf 66.0%

      \[\leadsto d \cdot \left(-\color{blue}{e^{-0.5 \cdot \left(\log \left(-1 \cdot h\right) + -1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}}\right) \]
    12. Step-by-step derivation
      1. distribute-lft-in66.0%

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

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

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

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

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

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

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(\log \left(\frac{-1}{\ell}\right) \cdot -1\right)} \cdot -0.5}\right) \]
      8. associate-*l*66.1%

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

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

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

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

    if -1.39999999999999999e143 < l < 2.55e16

    1. Initial program 75.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}}{d \cdot d} \cdot \frac{h}{\ell}\right)\right) \]
      6. unswap-sqr62.8%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{\color{blue}{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}}{d \cdot d} \cdot \frac{h}{\ell}\right)\right) \]
      7. times-frac70.3%

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

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

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

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

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

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

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

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

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

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

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

    if 2.55e16 < l

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification67.7%

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

Alternative 9: 48.5% accurate, 1.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


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

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in48.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]
    11. Taylor expanded in l around -inf 55.6%

      \[\leadsto d \cdot \left(-\color{blue}{e^{-0.5 \cdot \left(\log \left(-1 \cdot h\right) + -1 \cdot \log \left(\frac{-1}{\ell}\right)\right)}}\right) \]
    12. Step-by-step derivation
      1. distribute-lft-in55.6%

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

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

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

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

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

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

        \[\leadsto d \cdot \left(-{\left(-h\right)}^{-0.5} \cdot e^{\color{blue}{\left(\log \left(\frac{-1}{\ell}\right) \cdot -1\right)} \cdot -0.5}\right) \]
      8. associate-*l*56.3%

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

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

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

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

    if -2.39999999999999999e-300 < l < 1.7500000000000001e-169

    1. Initial program 77.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.7500000000000001e-169 < l

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification54.9%

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

Alternative 10: 44.7% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 2.25 \cdot 10^{-169}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (if (<= l 2.25e-169)
   (* (- d) (pow (* l h) -0.5))
   (* d (* (pow l -0.5) (pow h -0.5)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 2.25e-169) {
		tmp = -d * pow((l * h), -0.5);
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: tmp
    if (l <= 2.25d-169) then
        tmp = -d * ((l * h) ** (-0.5d0))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double tmp;
	if (l <= 2.25e-169) {
		tmp = -d * Math.pow((l * h), -0.5);
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	tmp = 0
	if l <= 2.25e-169:
		tmp = -d * math.pow((l * h), -0.5)
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	tmp = 0.0
	if (l <= 2.25e-169)
		tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	tmp = 0.0;
	if (l <= 2.25e-169)
		tmp = -d * ((l * h) ^ -0.5);
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, 2.25e-169], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2.25 \cdot 10^{-169}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in46.3%

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

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

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

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

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

        \[\leadsto d \cdot \left(-\left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right|\right) \]
      8. fabs-sqr47.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) \]
      9. rem-square-sqrt47.2%

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

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

    if 2.2499999999999999e-169 < l

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 41.8% accurate, 3.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{if}\;\ell \leq 2.5 \cdot 10^{-169}:\\ \;\;\;\;\left(-d\right) \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot t\_0\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
 :precision binary64
 (let* ((t_0 (pow (* l h) -0.5)))
   (if (<= l 2.5e-169) (* (- d) t_0) (* d t_0))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = pow((l * h), -0.5);
	double tmp;
	if (l <= 2.5e-169) {
		tmp = -d * t_0;
	} else {
		tmp = d * t_0;
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (l * h) ** (-0.5d0)
    if (l <= 2.5d-169) then
        tmp = -d * t_0
    else
        tmp = d * t_0
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	double t_0 = Math.pow((l * h), -0.5);
	double tmp;
	if (l <= 2.5e-169) {
		tmp = -d * t_0;
	} else {
		tmp = d * t_0;
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	t_0 = math.pow((l * h), -0.5)
	tmp = 0
	if l <= 2.5e-169:
		tmp = -d * t_0
	else:
		tmp = d * t_0
	return tmp
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	t_0 = Float64(l * h) ^ -0.5
	tmp = 0.0
	if (l <= 2.5e-169)
		tmp = Float64(Float64(-d) * t_0);
	else
		tmp = Float64(d * t_0);
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
	t_0 = (l * h) ^ -0.5;
	tmp = 0.0;
	if (l <= 2.5e-169)
		tmp = -d * t_0;
	else
		tmp = d * t_0;
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]}, If[LessEqual[l, 2.5e-169], N[((-d) * t$95$0), $MachinePrecision], N[(d * t$95$0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;\ell \leq 2.5 \cdot 10^{-169}:\\
\;\;\;\;\left(-d\right) \cdot t\_0\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in46.3%

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

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

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

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

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

        \[\leadsto d \cdot \left(-\left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right|\right) \]
      8. fabs-sqr47.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) \]
      9. rem-square-sqrt47.2%

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

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

    if 2.5000000000000001e-169 < l

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 41.9% accurate, 3.0× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in46.3%

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

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

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

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

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

        \[\leadsto d \cdot \left(-\left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right|\right) \]
      8. fabs-sqr47.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) \]
      9. rem-square-sqrt47.2%

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

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

    if 2.0499999999999999e-169 < l

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

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

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

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

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

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

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

Alternative 13: 26.6% accurate, 3.1× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\ \\ d \cdot {\left(\ell \cdot h\right)}^{-0.5} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m) :precision binary64 (* d (pow (* l h) -0.5)))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
	return d * pow((l * h), -0.5);
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    code = d * ((l * h) ** (-0.5d0))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
	return d * Math.pow((l * h), -0.5);
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m])
def code(d, h, l, M_m, D_m):
	return d * math.pow((l * h), -0.5)
M_m = abs(M)
D_m = abs(D)
d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m])
function code(d, h, l, M_m, D_m)
	return Float64(d * (Float64(l * h) ^ -0.5))
end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
	tmp = d * ((l * h) ^ -0.5);
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
d \cdot {\left(\ell \cdot h\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 67.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. Simplified67.7%

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
    4. sqrt-pow170.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}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. metadata-eval70.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    6. pow170.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}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    7. div-inv70.4%

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

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

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

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

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

      \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
    3. pow-sqr26.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-square26.6%

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

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

      \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
    7. sqr-pow26.6%

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

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

    \[\leadsto d \cdot {\left(\ell \cdot h\right)}^{-0.5} \]
  10. Add Preprocessing

Reproduce

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