Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.1% → 83.7%
Time: 24.0s
Alternatives: 17
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 17 alternatives:

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

Initial Program: 66.1% 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: 83.7% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;h \leq -1 \cdot 10^{-309}:\\
\;\;\;\;t\_1\\

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


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

    1. Initial program 56.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. Simplified57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.7499999999999999e131 < h < -7.80000000000000019e-106

    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. Simplified75.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-sqrt75.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. pow275.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-prod75.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-pow178.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-eval78.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. pow178.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-inv78.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-eval78.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) \]
      9. associate-*l*78.7%

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

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < h

    1. Initial program 66.6%

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

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

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

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

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

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

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

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

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

Alternative 2: 82.9% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;h \leq -1 \cdot 10^{-309}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 56.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. Simplified57.4%

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

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

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

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

    if -1.3500000000000001e133 < h < -7.20000000000000025e-106

    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. Simplified75.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-sqrt75.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. pow275.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-prod75.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-pow178.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-eval78.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. pow178.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-inv78.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-eval78.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) \]
      9. associate-*l*78.7%

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

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < h

    1. Initial program 66.6%

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

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

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

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

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

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

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

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

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

Alternative 3: 80.9% accurate, 0.8× speedup?

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

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


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

    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. Simplified63.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. Taylor expanded in d around 0 3.7%

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

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

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

      \[\leadsto \color{blue}{\left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \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) \]
    8. Step-by-step derivation
      1. associate-*l*0.0%

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

        \[\leadsto \left(d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\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. rem-square-sqrt68.7%

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

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

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

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

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

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

        \[\leadsto \left(d \cdot \left(-\color{blue}{\left|{\left(\ell \cdot h\right)}^{-0.5}\right|}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      10. rem-square-sqrt68.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.05000000000000005e-299 < d

    1. Initial program 66.1%

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

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

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

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

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

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

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

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

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

Alternative 4: 77.5% accurate, 1.0× speedup?

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

\mathbf{elif}\;d \leq 2.8 \cdot 10^{-172}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, t\_0, 1\right)}{\sqrt{h \cdot \ell}}\\

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


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

    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. Simplified63.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. Taylor expanded in d around 0 3.7%

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

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

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

      \[\leadsto \color{blue}{\left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \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) \]
    8. Step-by-step derivation
      1. associate-*l*0.0%

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

        \[\leadsto \left(d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\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. rem-square-sqrt68.7%

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

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

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

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

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

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

        \[\leadsto \left(d \cdot \left(-\color{blue}{\left|{\left(\ell \cdot h\right)}^{-0.5}\right|}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      10. rem-square-sqrt68.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.05000000000000005e-299 < d < 2.80000000000000011e-172

    1. Initial program 33.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. Simplified33.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-sqrt33.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 \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow233.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 \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod33.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-pow133.0%

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

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

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

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

        \[\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) \]
      9. associate-*l*33.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.80000000000000011e-172 < d

    1. Initial program 75.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. Simplified75.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. *-commutative76.3%

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

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

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

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

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

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

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

Alternative 5: 76.3% accurate, 1.0× speedup?

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

\mathbf{elif}\;\ell \leq 4.6 \cdot 10^{+166}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, t\_0, 1\right)}{\sqrt{h \cdot \ell}}\\

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


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

    1. Initial program 63.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \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) \]
    8. Step-by-step derivation
      1. associate-*l*0.0%

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

        \[\leadsto \left(d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\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. rem-square-sqrt68.2%

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

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

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

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

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

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

        \[\leadsto \left(d \cdot \left(-\color{blue}{\left|{\left(\ell \cdot h\right)}^{-0.5}\right|}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      10. rem-square-sqrt68.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.999999999999969e-311 < l < 4.60000000000000015e166

    1. Initial program 71.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. Simplified71.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-sqrt71.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. pow271.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-prod71.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 \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow173.0%

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

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

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

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

        \[\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) \]
      9. associate-*l*73.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.60000000000000015e166 < l

    1. Initial program 50.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. Simplified50.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-sqrt50.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. pow250.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-prod50.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-pow150.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-eval50.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. pow150.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-inv50.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-eval50.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) \]
      9. associate-*l*50.2%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 74.3% accurate, 1.4× speedup?

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

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

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


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

    1. Initial program 63.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \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) \]
    8. Step-by-step derivation
      1. associate-*l*0.0%

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

        \[\leadsto \left(d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\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. rem-square-sqrt68.2%

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

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

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

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

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

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

        \[\leadsto \left(d \cdot \left(-\color{blue}{\left|{\left(\ell \cdot h\right)}^{-0.5}\right|}\right)\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      10. rem-square-sqrt68.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.999999999999969e-311 < l < 1.10000000000000002e167

    1. Initial program 71.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. Simplified71.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. Taylor expanded in d around 0 77.9%

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

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

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

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

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

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

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

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

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

    if 1.10000000000000002e167 < l

    1. Initial program 50.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. Simplified50.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-sqrt50.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. pow250.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-prod50.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-pow150.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-eval50.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. pow150.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-inv50.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-eval50.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) \]
      9. associate-*l*50.2%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 71.8% accurate, 1.4× speedup?

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

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

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


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

    1. Initial program 63.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.999999999999969e-311 < l < 2.39999999999999999e167

    1. Initial program 71.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. Simplified71.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. Taylor expanded in d around 0 77.9%

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

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

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

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

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

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

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

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

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

    if 2.39999999999999999e167 < l

    1. Initial program 50.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. Simplified50.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-sqrt50.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. pow250.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-prod50.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-pow150.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-eval50.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. pow150.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-inv50.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-eval50.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) \]
      9. associate-*l*50.2%

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

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

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

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

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

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

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

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

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

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

Alternative 8: 61.6% accurate, 1.4× speedup?

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

\mathbf{elif}\;d \leq 6.8 \cdot 10^{-308}:\\
\;\;\;\;\frac{-0.125 \cdot \left({\left(M\_m \cdot D\right)}^{2} \cdot \frac{{\left(\frac{h}{\ell}\right)}^{1.5}}{d}\right)}{h}\\

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


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

    1. Initial program 74.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. Simplified74.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-0.125, \left({D}^{2} \cdot \frac{{M}^{2}}{d}\right) \cdot \sqrt{{\left(\frac{h}{\ell}\right)}^{3}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h}} \]
    7. Taylor expanded in D around 0 51.0%

      \[\leadsto \frac{\color{blue}{d \cdot \sqrt{\frac{h}{\ell}}}}{h} \]
    8. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

    if -2.55e-95 < d < 6.79999999999999998e-308

    1. Initial program 47.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. Simplified47.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-0.125 \cdot \left(\left({D}^{2} \cdot {M}^{2}\right) \cdot \frac{{\left(e^{\color{blue}{3 \cdot \log \left(\frac{h}{\ell}\right)}}\right)}^{0.5}}{d}\right)}{h} \]
      7. exp-prod37.0%

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

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

        \[\leadsto \frac{-0.125 \cdot \left(\left({D}^{2} \cdot {M}^{2}\right) \cdot \frac{e^{\color{blue}{\log \left(\frac{h}{\ell}\right) \cdot \left(3 \cdot 0.5\right)}}}{d}\right)}{h} \]
      10. metadata-eval37.0%

        \[\leadsto \frac{-0.125 \cdot \left(\left({D}^{2} \cdot {M}^{2}\right) \cdot \frac{e^{\log \left(\frac{h}{\ell}\right) \cdot \color{blue}{1.5}}}{d}\right)}{h} \]
      11. exp-to-pow37.4%

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

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

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

        \[\leadsto \frac{-0.125 \cdot \left(\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot \frac{{\left(\frac{h}{\ell}\right)}^{1.5}}{d}\right)}{h} \]
      15. unpow255.9%

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

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

    if 6.79999999999999998e-308 < d

    1. Initial program 66.6%

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

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt66.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. pow266.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-prod66.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-pow167.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-eval67.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. pow167.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-inv67.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-eval67.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) \]
      9. associate-*l*67.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 61.7% accurate, 1.4× speedup?

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

\mathbf{elif}\;d \leq 3.8 \cdot 10^{-307}:\\
\;\;\;\;\frac{-0.125 \cdot \left({\left(M\_m \cdot D\right)}^{2} \cdot \frac{{\left(\frac{h}{\ell}\right)}^{1.5}}{d}\right)}{h}\\

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


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

    1. Initial program 74.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. Simplified74.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-0.125, \left({D}^{2} \cdot \frac{{M}^{2}}{d}\right) \cdot \sqrt{{\left(\frac{h}{\ell}\right)}^{3}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h}} \]
    7. Taylor expanded in D around 0 51.0%

      \[\leadsto \frac{\color{blue}{d \cdot \sqrt{\frac{h}{\ell}}}}{h} \]
    8. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

    if -6.50000000000000001e-96 < d < 3.79999999999999985e-307

    1. Initial program 47.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. Simplified47.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-0.125 \cdot \left(\left({D}^{2} \cdot {M}^{2}\right) \cdot \frac{{\left(e^{\color{blue}{3 \cdot \log \left(\frac{h}{\ell}\right)}}\right)}^{0.5}}{d}\right)}{h} \]
      7. exp-prod37.0%

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

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

        \[\leadsto \frac{-0.125 \cdot \left(\left({D}^{2} \cdot {M}^{2}\right) \cdot \frac{e^{\color{blue}{\log \left(\frac{h}{\ell}\right) \cdot \left(3 \cdot 0.5\right)}}}{d}\right)}{h} \]
      10. metadata-eval37.0%

        \[\leadsto \frac{-0.125 \cdot \left(\left({D}^{2} \cdot {M}^{2}\right) \cdot \frac{e^{\log \left(\frac{h}{\ell}\right) \cdot \color{blue}{1.5}}}{d}\right)}{h} \]
      11. exp-to-pow37.4%

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

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

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

        \[\leadsto \frac{-0.125 \cdot \left(\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot \frac{{\left(\frac{h}{\ell}\right)}^{1.5}}{d}\right)}{h} \]
      15. unpow255.9%

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

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

    if 3.79999999999999985e-307 < d

    1. Initial program 66.6%

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

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt66.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. pow266.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-prod66.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-pow167.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-eval67.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. pow167.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-inv67.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-eval67.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) \]
      9. associate-*l*67.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 55.4% accurate, 1.5× speedup?

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

\mathbf{elif}\;d \leq 1.15 \cdot 10^{-196}:\\
\;\;\;\;\frac{-0.125 \cdot \left({\left(M\_m \cdot D\right)}^{2} \cdot \frac{{\left(\frac{h}{\ell}\right)}^{1.5}}{d}\right)}{h}\\

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


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

    1. Initial program 74.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. Simplified74.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-0.125, \left({D}^{2} \cdot \frac{{M}^{2}}{d}\right) \cdot \sqrt{{\left(\frac{h}{\ell}\right)}^{3}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h}} \]
    7. Taylor expanded in D around 0 51.0%

      \[\leadsto \frac{\color{blue}{d \cdot \sqrt{\frac{h}{\ell}}}}{h} \]
    8. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

    if -2.35000000000000003e-98 < d < 1.1500000000000001e-196

    1. Initial program 40.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. Simplified40.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-0.125 \cdot \left(\left({D}^{2} \cdot {M}^{2}\right) \cdot \frac{{\left(e^{\color{blue}{3 \cdot \log \left(\frac{h}{\ell}\right)}}\right)}^{0.5}}{d}\right)}{h} \]
      7. exp-prod43.0%

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

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

        \[\leadsto \frac{-0.125 \cdot \left(\left({D}^{2} \cdot {M}^{2}\right) \cdot \frac{e^{\color{blue}{\log \left(\frac{h}{\ell}\right) \cdot \left(3 \cdot 0.5\right)}}}{d}\right)}{h} \]
      10. metadata-eval43.0%

        \[\leadsto \frac{-0.125 \cdot \left(\left({D}^{2} \cdot {M}^{2}\right) \cdot \frac{e^{\log \left(\frac{h}{\ell}\right) \cdot \color{blue}{1.5}}}{d}\right)}{h} \]
      11. exp-to-pow43.4%

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

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

        \[\leadsto \frac{-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot \frac{{\left(\frac{h}{\ell}\right)}^{1.5}}{d}\right)}{h} \]
      14. swap-sqr58.0%

        \[\leadsto \frac{-0.125 \cdot \left(\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot \frac{{\left(\frac{h}{\ell}\right)}^{1.5}}{d}\right)}{h} \]
      15. unpow258.0%

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

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

    if 1.1500000000000001e-196 < d

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

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt74.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. pow274.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-prod74.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-pow175.8%

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

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

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

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

        \[\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) \]
      9. associate-*l*75.8%

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

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

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

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

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

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

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

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

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

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

Alternative 11: 46.2% accurate, 1.6× speedup?

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

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


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

    1. Initial program 63.6%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.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. Taylor expanded in h around 0 19.2%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-0.125, \left({D}^{2} \cdot \frac{{M}^{2}}{d}\right) \cdot \sqrt{{\left(\frac{h}{\ell}\right)}^{3}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h}} \]
    7. Taylor expanded in D around 0 33.8%

      \[\leadsto \frac{\color{blue}{d \cdot \sqrt{\frac{h}{\ell}}}}{h} \]
    8. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

    if 4.00000000000000022e-249 < l

    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. 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. add-sqr-sqrt66.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 \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow266.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 \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod66.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-pow167.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-eval67.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. pow167.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-inv67.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-eval67.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) \]
      9. associate-*l*67.4%

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

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

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

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

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

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

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

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

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

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

Alternative 12: 42.8% accurate, 2.9× speedup?

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

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


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

    1. Initial program 63.6%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified63.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. Taylor expanded in h around 0 19.2%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-0.125, \left({D}^{2} \cdot \frac{{M}^{2}}{d}\right) \cdot \sqrt{{\left(\frac{h}{\ell}\right)}^{3}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h}} \]
    7. Taylor expanded in D around 0 33.8%

      \[\leadsto \frac{\color{blue}{d \cdot \sqrt{\frac{h}{\ell}}}}{h} \]
    8. Taylor expanded in l around -inf 0.0%

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

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

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

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

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

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

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

    if 2.7e-244 < l

    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. Simplified65.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 42.8% accurate, 3.0× speedup?

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

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


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

    1. Initial program 63.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-1 \cdot d\right) \cdot \color{blue}{{\left(\ell \cdot h\right)}^{-0.5}} \]
      14. neg-mul-145.0%

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

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

    if 1.70000000000000004e-244 < l

    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. Simplified65.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 41.5% accurate, 3.0× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

    if -2.15e-271 < l

    1. Initial program 66.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 27.0% accurate, 3.1× speedup?

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-0.125, \left({D}^{2} \cdot \frac{{M}^{2}}{d}\right) \cdot \sqrt{{\left(\frac{h}{\ell}\right)}^{3}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h}} \]
  7. Taylor expanded in D around 0 38.4%

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

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

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

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

Alternative 16: 26.8% accurate, 3.1× speedup?

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-0.125, \left({D}^{2} \cdot \frac{{M}^{2}}{d}\right) \cdot \sqrt{{\left(\frac{h}{\ell}\right)}^{3}}, d \cdot \sqrt{\frac{h}{\ell}}\right)}{h}} \]
  7. Taylor expanded in D around 0 38.4%

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

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  9. Add Preprocessing

Alternative 17: 26.7% accurate, 3.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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