Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.7% → 79.0%
Time: 1.3min
Alternatives: 23
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 23 alternatives:

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

Initial Program: 66.7% accurate, 1.0× speedup?

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

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

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

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

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


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

    1. Initial program 45.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. Simplified41.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-sqrt41.1%

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. add-sqr-sqrt48.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. frac-times52.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*48.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 \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative48.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr48.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 \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/52.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e86 < l < -3.999999999999988e-310

    1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.999999999999988e-310 < l

    1. Initial program 64.0%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 78.1% 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 \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(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(M\_m \cdot \frac{D}{d \cdot 2}\right)}^{2}, 1\right)\\ \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 -1e-309)
   (*
    (sqrt (/ d l))
    (*
     (/ (sqrt (- d)) (sqrt (- h)))
     (+ 1.0 (* (/ h l) (* -0.5 (pow (* (/ D d) (/ M_m 2.0)) 2.0))))))
   (*
    (/ d (* (sqrt l) (sqrt h)))
    (fma (/ h l) (* -0.5 (pow (* M_m (/ D (* d 2.0))) 2.0)) 1.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 tmp;
	if (d <= -1e-309) {
		tmp = sqrt((d / l)) * ((sqrt(-d) / sqrt(-h)) * (1.0 + ((h / l) * (-0.5 * pow(((D / d) * (M_m / 2.0)), 2.0)))));
	} else {
		tmp = (d / (sqrt(l) * sqrt(h))) * fma((h / l), (-0.5 * pow((M_m * (D / (d * 2.0))), 2.0)), 1.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)
	tmp = 0.0
	if (d <= -1e-309)
		tmp = Float64(sqrt(Float64(d / l)) * Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(Float64(D / d) * Float64(M_m / 2.0)) ^ 2.0))))));
	else
		tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * fma(Float64(h / l), Float64(-0.5 * (Float64(M_m * Float64(D / Float64(d * 2.0))) ^ 2.0)), 1.0));
	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, -1e-309], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(M$95$m * N[(D / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $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 \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(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right)\right)\right)\\

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


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

    1. Initial program 62.7%

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

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

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

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

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

    if -1.000000000000002e-309 < d

    1. Initial program 64.0%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 72.5% 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}\;h \leq -2.1 \cdot 10^{-130}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D \cdot \left(0.5 \cdot M\_m\right)}{d}\right)}^{2}}{\ell}\right)\\ \mathbf{elif}\;h \leq -1 \cdot 10^{-311}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot {\left(M\_m \cdot \frac{D}{d \cdot 2}\right)}^{2}, 1\right)\\ \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 (<= h -2.1e-130)
   (*
    (* (sqrt (/ d h)) (sqrt (/ d l)))
    (- 1.0 (* 0.5 (/ (* h (pow (/ (* D (* 0.5 M_m)) d) 2.0)) l))))
   (if (<= h -1e-311)
     (/ d (- (sqrt (* l h))))
     (*
      (/ d (* (sqrt l) (sqrt h)))
      (fma (/ h l) (* -0.5 (pow (* M_m (/ D (* d 2.0))) 2.0)) 1.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 tmp;
	if (h <= -2.1e-130) {
		tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h * pow(((D * (0.5 * M_m)) / d), 2.0)) / l)));
	} else if (h <= -1e-311) {
		tmp = d / -sqrt((l * h));
	} else {
		tmp = (d / (sqrt(l) * sqrt(h))) * fma((h / l), (-0.5 * pow((M_m * (D / (d * 2.0))), 2.0)), 1.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)
	tmp = 0.0
	if (h <= -2.1e-130)
		tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(D * Float64(0.5 * M_m)) / d) ^ 2.0)) / l))));
	elseif (h <= -1e-311)
		tmp = Float64(d / Float64(-sqrt(Float64(l * h))));
	else
		tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * fma(Float64(h / l), Float64(-0.5 * (Float64(M_m * Float64(D / Float64(d * 2.0))) ^ 2.0)), 1.0));
	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[h, -2.1e-130], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(D * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -1e-311], N[(d / (-N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(M$95$m * N[(D / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $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}\;h \leq -2.1 \cdot 10^{-130}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D \cdot \left(0.5 \cdot M\_m\right)}{d}\right)}^{2}}{\ell}\right)\\

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

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


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

    1. Initial program 68.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.10000000000000002e-130 < h < -9.99999999999948e-312

    1. Initial program 46.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. Simplified46.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-sqrt46.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. pow246.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-prod46.5%

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*49.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 \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative49.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr49.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 \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/49.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999948e-312 < h

    1. Initial program 64.0%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 67.0% 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} \mathbf{if}\;h \leq -8 \cdot 10^{-67}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M\_m \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\\ \mathbf{elif}\;h \leq -1 \cdot 10^{-311}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot \left(0.5 \cdot M\_m\right)\right)}^{2} \cdot -0.5\right)\right)\\ \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 (<= h -8e-67)
   (*
    (sqrt (* (/ d h) (/ d l)))
    (+ 1.0 (* -0.5 (* (/ h l) (pow (* M_m (/ D (* d 2.0))) 2.0)))))
   (if (<= h -1e-311)
     (* (- d) (pow (* l h) -0.5))
     (*
      (/ d (* (sqrt l) (sqrt h)))
      (+ 1.0 (* (/ h l) (* (pow (* (/ D d) (* 0.5 M_m)) 2.0) -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 (h <= -8e-67) {
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * pow((M_m * (D / (d * 2.0))), 2.0))));
	} else if (h <= -1e-311) {
		tmp = -d * pow((l * h), -0.5);
	} else {
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + ((h / l) * (pow(((D / d) * (0.5 * M_m)), 2.0) * -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 (h <= (-8d-67)) then
        tmp = sqrt(((d / h) * (d / l))) * (1.0d0 + ((-0.5d0) * ((h / l) * ((m_m * (d_1 / (d * 2.0d0))) ** 2.0d0))))
    else if (h <= (-1d-311)) then
        tmp = -d * ((l * h) ** (-0.5d0))
    else
        tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + ((h / l) * ((((d_1 / d) * (0.5d0 * m_m)) ** 2.0d0) * (-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 (h <= -8e-67) {
		tmp = Math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * Math.pow((M_m * (D / (d * 2.0))), 2.0))));
	} else if (h <= -1e-311) {
		tmp = -d * Math.pow((l * h), -0.5);
	} else {
		tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + ((h / l) * (Math.pow(((D / d) * (0.5 * M_m)), 2.0) * -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 h <= -8e-67:
		tmp = math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * math.pow((M_m * (D / (d * 2.0))), 2.0))))
	elif h <= -1e-311:
		tmp = -d * math.pow((l * h), -0.5)
	else:
		tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + ((h / l) * (math.pow(((D / d) * (0.5 * M_m)), 2.0) * -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 (h <= -8e-67)
		tmp = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(M_m * Float64(D / Float64(d * 2.0))) ^ 2.0)))));
	elseif (h <= -1e-311)
		tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5));
	else
		tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(D / d) * Float64(0.5 * M_m)) ^ 2.0) * -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 (h <= -8e-67)
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * ((M_m * (D / (d * 2.0))) ^ 2.0))));
	elseif (h <= -1e-311)
		tmp = -d * ((l * h) ^ -0.5);
	else
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + ((h / l) * ((((D / d) * (0.5 * M_m)) ^ 2.0) * -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[h, -8e-67], N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M$95$m * N[(D / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -1e-311], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $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}\;h \leq -8 \cdot 10^{-67}:\\
\;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M\_m \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\\

\mathbf{elif}\;h \leq -1 \cdot 10^{-311}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

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


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

    1. Initial program 65.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified64.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. Step-by-step derivation
      1. add-sqr-sqrt64.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. pow264.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-prod64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.99999999999999954e-67 < h < -9.99999999999948e-312

    1. Initial program 58.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. Simplified54.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-sqrt54.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. pow254.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-prod54.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. unpow254.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \]
    13. Applied egg-rr60.7%

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

    if -9.99999999999948e-312 < h

    1. Initial program 64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 67.0% 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} \mathbf{if}\;h \leq -4.2 \cdot 10^{-67}:\\ \;\;\;\;\mathsf{fma}\left({\left(M\_m \cdot \frac{\frac{D}{2}}{d}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \cdot \sqrt{d \cdot \frac{\frac{d}{\ell}}{h}}\\ \mathbf{elif}\;h \leq -1 \cdot 10^{-311}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot \left(0.5 \cdot M\_m\right)\right)}^{2} \cdot -0.5\right)\right)\\ \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 (<= h -4.2e-67)
   (*
    (fma (pow (* M_m (/ (/ D 2.0) d)) 2.0) (* (/ h l) -0.5) 1.0)
    (sqrt (* d (/ (/ d l) h))))
   (if (<= h -1e-311)
     (* (- d) (pow (* l h) -0.5))
     (*
      (/ d (* (sqrt l) (sqrt h)))
      (+ 1.0 (* (/ h l) (* (pow (* (/ D d) (* 0.5 M_m)) 2.0) -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 (h <= -4.2e-67) {
		tmp = fma(pow((M_m * ((D / 2.0) / d)), 2.0), ((h / l) * -0.5), 1.0) * sqrt((d * ((d / l) / h)));
	} else if (h <= -1e-311) {
		tmp = -d * pow((l * h), -0.5);
	} else {
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + ((h / l) * (pow(((D / d) * (0.5 * M_m)), 2.0) * -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 (h <= -4.2e-67)
		tmp = Float64(fma((Float64(M_m * Float64(Float64(D / 2.0) / d)) ^ 2.0), Float64(Float64(h / l) * -0.5), 1.0) * sqrt(Float64(d * Float64(Float64(d / l) / h))));
	elseif (h <= -1e-311)
		tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5));
	else
		tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(D / d) * Float64(0.5 * M_m)) ^ 2.0) * -0.5))));
	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[h, -4.2e-67], N[(N[(N[Power[N[(M$95$m * N[(N[(D / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d * N[(N[(d / l), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -1e-311], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $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}\;h \leq -4.2 \cdot 10^{-67}:\\
\;\;\;\;\mathsf{fma}\left({\left(M\_m \cdot \frac{\frac{D}{2}}{d}\right)}^{2}, \frac{h}{\ell} \cdot -0.5, 1\right) \cdot \sqrt{d \cdot \frac{\frac{d}{\ell}}{h}}\\

\mathbf{elif}\;h \leq -1 \cdot 10^{-311}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

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


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

    1. Initial program 65.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified64.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. Step-by-step derivation
      1. add-sqr-sqrt64.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. pow264.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-prod64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.2000000000000003e-67 < h < -9.99999999999948e-312

    1. Initial program 58.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. Simplified54.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-sqrt54.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. pow254.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-prod54.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. unpow254.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \]
    13. Applied egg-rr60.7%

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

    if -9.99999999999948e-312 < h

    1. Initial program 64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 71.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} \mathbf{if}\;h \leq -2.2 \cdot 10^{-130}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right)\right)\right)\\ \mathbf{elif}\;h \leq -1 \cdot 10^{-311}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot \left(0.5 \cdot M\_m\right)\right)}^{2} \cdot -0.5\right)\right)\\ \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 (<= h -2.2e-130)
   (*
    (sqrt (/ d l))
    (*
     (sqrt (/ d h))
     (+ 1.0 (* (/ h l) (* -0.5 (pow (* (/ D d) (/ M_m 2.0)) 2.0))))))
   (if (<= h -1e-311)
     (/ d (- (sqrt (* l h))))
     (*
      (/ d (* (sqrt l) (sqrt h)))
      (+ 1.0 (* (/ h l) (* (pow (* (/ D d) (* 0.5 M_m)) 2.0) -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 (h <= -2.2e-130) {
		tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * pow(((D / d) * (M_m / 2.0)), 2.0)))));
	} else if (h <= -1e-311) {
		tmp = d / -sqrt((l * h));
	} else {
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + ((h / l) * (pow(((D / d) * (0.5 * M_m)), 2.0) * -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 (h <= (-2.2d-130)) then
        tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0d0 + ((h / l) * ((-0.5d0) * (((d_1 / d) * (m_m / 2.0d0)) ** 2.0d0)))))
    else if (h <= (-1d-311)) then
        tmp = d / -sqrt((l * h))
    else
        tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + ((h / l) * ((((d_1 / d) * (0.5d0 * m_m)) ** 2.0d0) * (-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 (h <= -2.2e-130) {
		tmp = Math.sqrt((d / l)) * (Math.sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * Math.pow(((D / d) * (M_m / 2.0)), 2.0)))));
	} else if (h <= -1e-311) {
		tmp = d / -Math.sqrt((l * h));
	} else {
		tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + ((h / l) * (Math.pow(((D / d) * (0.5 * M_m)), 2.0) * -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 h <= -2.2e-130:
		tmp = math.sqrt((d / l)) * (math.sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * math.pow(((D / d) * (M_m / 2.0)), 2.0)))))
	elif h <= -1e-311:
		tmp = d / -math.sqrt((l * h))
	else:
		tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + ((h / l) * (math.pow(((D / d) * (0.5 * M_m)), 2.0) * -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 (h <= -2.2e-130)
		tmp = Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(Float64(D / d) * Float64(M_m / 2.0)) ^ 2.0))))));
	elseif (h <= -1e-311)
		tmp = Float64(d / Float64(-sqrt(Float64(l * h))));
	else
		tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(D / d) * Float64(0.5 * M_m)) ^ 2.0) * -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 (h <= -2.2e-130)
		tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * (((D / d) * (M_m / 2.0)) ^ 2.0)))));
	elseif (h <= -1e-311)
		tmp = d / -sqrt((l * h));
	else
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + ((h / l) * ((((D / d) * (0.5 * M_m)) ^ 2.0) * -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[h, -2.2e-130], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -1e-311], N[(d / (-N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $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}\;h \leq -2.2 \cdot 10^{-130}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right)\right)\right)\\

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

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


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

    1. Initial program 68.4%

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

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

    if -2.1999999999999999e-130 < h < -9.99999999999948e-312

    1. Initial program 46.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. Simplified46.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-sqrt46.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. pow246.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-prod46.5%

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*49.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 \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative49.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr49.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 \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/49.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999948e-312 < h

    1. Initial program 64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 71.6% 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} \mathbf{if}\;h \leq -2.1 \cdot 10^{-130}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{M\_m}{2 \cdot \frac{d}{D}}\right)}^{2}\right)\right)\right)\\ \mathbf{elif}\;h \leq -1 \cdot 10^{-311}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot \left(0.5 \cdot M\_m\right)\right)}^{2} \cdot -0.5\right)\right)\\ \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 (<= h -2.1e-130)
   (*
    (sqrt (/ d l))
    (*
     (sqrt (/ d h))
     (+ 1.0 (* (/ h l) (* -0.5 (pow (/ M_m (* 2.0 (/ d D))) 2.0))))))
   (if (<= h -1e-311)
     (/ d (- (sqrt (* l h))))
     (*
      (/ d (* (sqrt l) (sqrt h)))
      (+ 1.0 (* (/ h l) (* (pow (* (/ D d) (* 0.5 M_m)) 2.0) -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 (h <= -2.1e-130) {
		tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * pow((M_m / (2.0 * (d / D))), 2.0)))));
	} else if (h <= -1e-311) {
		tmp = d / -sqrt((l * h));
	} else {
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + ((h / l) * (pow(((D / d) * (0.5 * M_m)), 2.0) * -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 (h <= (-2.1d-130)) then
        tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0d0 + ((h / l) * ((-0.5d0) * ((m_m / (2.0d0 * (d / d_1))) ** 2.0d0)))))
    else if (h <= (-1d-311)) then
        tmp = d / -sqrt((l * h))
    else
        tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + ((h / l) * ((((d_1 / d) * (0.5d0 * m_m)) ** 2.0d0) * (-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 (h <= -2.1e-130) {
		tmp = Math.sqrt((d / l)) * (Math.sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * Math.pow((M_m / (2.0 * (d / D))), 2.0)))));
	} else if (h <= -1e-311) {
		tmp = d / -Math.sqrt((l * h));
	} else {
		tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + ((h / l) * (Math.pow(((D / d) * (0.5 * M_m)), 2.0) * -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 h <= -2.1e-130:
		tmp = math.sqrt((d / l)) * (math.sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * math.pow((M_m / (2.0 * (d / D))), 2.0)))))
	elif h <= -1e-311:
		tmp = d / -math.sqrt((l * h))
	else:
		tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + ((h / l) * (math.pow(((D / d) * (0.5 * M_m)), 2.0) * -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 (h <= -2.1e-130)
		tmp = Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(M_m / Float64(2.0 * Float64(d / D))) ^ 2.0))))));
	elseif (h <= -1e-311)
		tmp = Float64(d / Float64(-sqrt(Float64(l * h))));
	else
		tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(D / d) * Float64(0.5 * M_m)) ^ 2.0) * -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 (h <= -2.1e-130)
		tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * ((M_m / (2.0 * (d / D))) ^ 2.0)))));
	elseif (h <= -1e-311)
		tmp = d / -sqrt((l * h));
	else
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + ((h / l) * ((((D / d) * (0.5 * M_m)) ^ 2.0) * -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[h, -2.1e-130], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(M$95$m / N[(2.0 * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -1e-311], N[(d / (-N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $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}\;h \leq -2.1 \cdot 10^{-130}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{M\_m}{2 \cdot \frac{d}{D}}\right)}^{2}\right)\right)\right)\\

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

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


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

    1. Initial program 68.4%

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

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

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

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

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

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

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

    if -2.10000000000000002e-130 < h < -9.99999999999948e-312

    1. Initial program 46.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. Simplified46.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-sqrt46.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. pow246.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-prod46.5%

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*49.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 \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative49.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr49.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 \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/49.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999948e-312 < h

    1. Initial program 64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 72.7% 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} \mathbf{if}\;h \leq -2.1 \cdot 10^{-130}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \left(M\_m \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}\right)\right)\\ \mathbf{elif}\;h \leq -1 \cdot 10^{-311}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot \left(0.5 \cdot M\_m\right)\right)}^{2} \cdot -0.5\right)\right)\\ \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 (<= h -2.1e-130)
   (*
    (* (sqrt (/ d h)) (sqrt (/ d l)))
    (- 1.0 (* 0.5 (* h (/ (pow (* D (* M_m (/ 0.5 d))) 2.0) l)))))
   (if (<= h -1e-311)
     (/ d (- (sqrt (* l h))))
     (*
      (/ d (* (sqrt l) (sqrt h)))
      (+ 1.0 (* (/ h l) (* (pow (* (/ D d) (* 0.5 M_m)) 2.0) -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 (h <= -2.1e-130) {
		tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * (h * (pow((D * (M_m * (0.5 / d))), 2.0) / l))));
	} else if (h <= -1e-311) {
		tmp = d / -sqrt((l * h));
	} else {
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + ((h / l) * (pow(((D / d) * (0.5 * M_m)), 2.0) * -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 (h <= (-2.1d-130)) then
        tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0d0 - (0.5d0 * (h * (((d_1 * (m_m * (0.5d0 / d))) ** 2.0d0) / l))))
    else if (h <= (-1d-311)) then
        tmp = d / -sqrt((l * h))
    else
        tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + ((h / l) * ((((d_1 / d) * (0.5d0 * m_m)) ** 2.0d0) * (-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 (h <= -2.1e-130) {
		tmp = (Math.sqrt((d / h)) * Math.sqrt((d / l))) * (1.0 - (0.5 * (h * (Math.pow((D * (M_m * (0.5 / d))), 2.0) / l))));
	} else if (h <= -1e-311) {
		tmp = d / -Math.sqrt((l * h));
	} else {
		tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + ((h / l) * (Math.pow(((D / d) * (0.5 * M_m)), 2.0) * -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 h <= -2.1e-130:
		tmp = (math.sqrt((d / h)) * math.sqrt((d / l))) * (1.0 - (0.5 * (h * (math.pow((D * (M_m * (0.5 / d))), 2.0) / l))))
	elif h <= -1e-311:
		tmp = d / -math.sqrt((l * h))
	else:
		tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + ((h / l) * (math.pow(((D / d) * (0.5 * M_m)), 2.0) * -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 (h <= -2.1e-130)
		tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * Float64(h * Float64((Float64(D * Float64(M_m * Float64(0.5 / d))) ^ 2.0) / l)))));
	elseif (h <= -1e-311)
		tmp = Float64(d / Float64(-sqrt(Float64(l * h))));
	else
		tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(D / d) * Float64(0.5 * M_m)) ^ 2.0) * -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 (h <= -2.1e-130)
		tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * (h * (((D * (M_m * (0.5 / d))) ^ 2.0) / l))));
	elseif (h <= -1e-311)
		tmp = d / -sqrt((l * h));
	else
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + ((h / l) * ((((D / d) * (0.5 * M_m)) ^ 2.0) * -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[h, -2.1e-130], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(h * N[(N[Power[N[(D * N[(M$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -1e-311], N[(d / (-N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $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}\;h \leq -2.1 \cdot 10^{-130}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(D \cdot \left(M\_m \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}\right)\right)\\

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

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


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

    1. Initial program 68.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified65.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. associate-*r/67.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.10000000000000002e-130 < h < -9.99999999999948e-312

    1. Initial program 46.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. Simplified46.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-sqrt46.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. pow246.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-prod46.5%

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*49.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 \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative49.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr49.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 \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/49.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999948e-312 < h

    1. Initial program 64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 72.2% 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} \mathbf{if}\;h \leq -2.1 \cdot 10^{-130}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(M\_m \cdot \frac{D}{d \cdot 2}\right)}^{2}}{\ell}\right)\\ \mathbf{elif}\;h \leq -1 \cdot 10^{-311}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot \left(0.5 \cdot M\_m\right)\right)}^{2} \cdot -0.5\right)\right)\\ \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 (<= h -2.1e-130)
   (*
    (* (sqrt (/ d h)) (sqrt (/ d l)))
    (- 1.0 (* 0.5 (/ (* h (pow (* M_m (/ D (* d 2.0))) 2.0)) l))))
   (if (<= h -1e-311)
     (/ d (- (sqrt (* l h))))
     (*
      (/ d (* (sqrt l) (sqrt h)))
      (+ 1.0 (* (/ h l) (* (pow (* (/ D d) (* 0.5 M_m)) 2.0) -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 (h <= -2.1e-130) {
		tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h * pow((M_m * (D / (d * 2.0))), 2.0)) / l)));
	} else if (h <= -1e-311) {
		tmp = d / -sqrt((l * h));
	} else {
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + ((h / l) * (pow(((D / d) * (0.5 * M_m)), 2.0) * -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 (h <= (-2.1d-130)) then
        tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0d0 - (0.5d0 * ((h * ((m_m * (d_1 / (d * 2.0d0))) ** 2.0d0)) / l)))
    else if (h <= (-1d-311)) then
        tmp = d / -sqrt((l * h))
    else
        tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + ((h / l) * ((((d_1 / d) * (0.5d0 * m_m)) ** 2.0d0) * (-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 (h <= -2.1e-130) {
		tmp = (Math.sqrt((d / h)) * Math.sqrt((d / l))) * (1.0 - (0.5 * ((h * Math.pow((M_m * (D / (d * 2.0))), 2.0)) / l)));
	} else if (h <= -1e-311) {
		tmp = d / -Math.sqrt((l * h));
	} else {
		tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + ((h / l) * (Math.pow(((D / d) * (0.5 * M_m)), 2.0) * -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 h <= -2.1e-130:
		tmp = (math.sqrt((d / h)) * math.sqrt((d / l))) * (1.0 - (0.5 * ((h * math.pow((M_m * (D / (d * 2.0))), 2.0)) / l)))
	elif h <= -1e-311:
		tmp = d / -math.sqrt((l * h))
	else:
		tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + ((h / l) * (math.pow(((D / d) * (0.5 * M_m)), 2.0) * -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 (h <= -2.1e-130)
		tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(M_m * Float64(D / Float64(d * 2.0))) ^ 2.0)) / l))));
	elseif (h <= -1e-311)
		tmp = Float64(d / Float64(-sqrt(Float64(l * h))));
	else
		tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(D / d) * Float64(0.5 * M_m)) ^ 2.0) * -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 (h <= -2.1e-130)
		tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h * ((M_m * (D / (d * 2.0))) ^ 2.0)) / l)));
	elseif (h <= -1e-311)
		tmp = d / -sqrt((l * h));
	else
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + ((h / l) * ((((D / d) * (0.5 * M_m)) ^ 2.0) * -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[h, -2.1e-130], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(M$95$m * N[(D / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -1e-311], N[(d / (-N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $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}\;h \leq -2.1 \cdot 10^{-130}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(M\_m \cdot \frac{D}{d \cdot 2}\right)}^{2}}{\ell}\right)\\

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

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


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

    1. Initial program 68.4%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified65.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. associate-*r/67.7%

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

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

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

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

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

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

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

    if -2.10000000000000002e-130 < h < -9.99999999999948e-312

    1. Initial program 46.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. Simplified46.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-sqrt46.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. pow246.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-prod46.5%

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*49.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 \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative49.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr49.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 \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/49.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999948e-312 < h

    1. Initial program 64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 72.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} \mathbf{if}\;h \leq -7.6 \cdot 10^{-130}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D \cdot \left(0.5 \cdot M\_m\right)}{d}\right)}^{2}}{\ell}\right)\\ \mathbf{elif}\;h \leq -1 \cdot 10^{-311}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot \left(0.5 \cdot M\_m\right)\right)}^{2} \cdot -0.5\right)\right)\\ \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 (<= h -7.6e-130)
   (*
    (* (sqrt (/ d h)) (sqrt (/ d l)))
    (- 1.0 (* 0.5 (/ (* h (pow (/ (* D (* 0.5 M_m)) d) 2.0)) l))))
   (if (<= h -1e-311)
     (/ d (- (sqrt (* l h))))
     (*
      (/ d (* (sqrt l) (sqrt h)))
      (+ 1.0 (* (/ h l) (* (pow (* (/ D d) (* 0.5 M_m)) 2.0) -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 (h <= -7.6e-130) {
		tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h * pow(((D * (0.5 * M_m)) / d), 2.0)) / l)));
	} else if (h <= -1e-311) {
		tmp = d / -sqrt((l * h));
	} else {
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + ((h / l) * (pow(((D / d) * (0.5 * M_m)), 2.0) * -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 (h <= (-7.6d-130)) then
        tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0d0 - (0.5d0 * ((h * (((d_1 * (0.5d0 * m_m)) / d) ** 2.0d0)) / l)))
    else if (h <= (-1d-311)) then
        tmp = d / -sqrt((l * h))
    else
        tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + ((h / l) * ((((d_1 / d) * (0.5d0 * m_m)) ** 2.0d0) * (-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 (h <= -7.6e-130) {
		tmp = (Math.sqrt((d / h)) * Math.sqrt((d / l))) * (1.0 - (0.5 * ((h * Math.pow(((D * (0.5 * M_m)) / d), 2.0)) / l)));
	} else if (h <= -1e-311) {
		tmp = d / -Math.sqrt((l * h));
	} else {
		tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + ((h / l) * (Math.pow(((D / d) * (0.5 * M_m)), 2.0) * -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 h <= -7.6e-130:
		tmp = (math.sqrt((d / h)) * math.sqrt((d / l))) * (1.0 - (0.5 * ((h * math.pow(((D * (0.5 * M_m)) / d), 2.0)) / l)))
	elif h <= -1e-311:
		tmp = d / -math.sqrt((l * h))
	else:
		tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + ((h / l) * (math.pow(((D / d) * (0.5 * M_m)), 2.0) * -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 (h <= -7.6e-130)
		tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(D * Float64(0.5 * M_m)) / d) ^ 2.0)) / l))));
	elseif (h <= -1e-311)
		tmp = Float64(d / Float64(-sqrt(Float64(l * h))));
	else
		tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(D / d) * Float64(0.5 * M_m)) ^ 2.0) * -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 (h <= -7.6e-130)
		tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h * (((D * (0.5 * M_m)) / d) ^ 2.0)) / l)));
	elseif (h <= -1e-311)
		tmp = d / -sqrt((l * h));
	else
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + ((h / l) * ((((D / d) * (0.5 * M_m)) ^ 2.0) * -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[h, -7.6e-130], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(D * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -1e-311], N[(d / (-N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $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}\;h \leq -7.6 \cdot 10^{-130}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D \cdot \left(0.5 \cdot M\_m\right)}{d}\right)}^{2}}{\ell}\right)\\

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

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


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

    1. Initial program 68.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.5999999999999997e-130 < h < -9.99999999999948e-312

    1. Initial program 46.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. Simplified46.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-sqrt46.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. pow246.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-prod46.5%

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*49.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 \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative49.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr49.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 \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/49.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999948e-312 < h

    1. Initial program 64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 61.4% 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 := {\left(M\_m \cdot \frac{D}{d \cdot 2}\right)}^{2}\\ \mathbf{if}\;h \leq -7.5 \cdot 10^{-68}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot t\_0\right)\right)\\ \mathbf{elif}\;h \leq -1 \cdot 10^{-311}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{h}{\ell}, -0.5 \cdot t\_0, 1\right) \cdot \frac{d}{\sqrt{\ell \cdot 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 (* M_m (/ D (* d 2.0))) 2.0)))
   (if (<= h -7.5e-68)
     (* (sqrt (* (/ d h) (/ d l))) (+ 1.0 (* -0.5 (* (/ h l) t_0))))
     (if (<= h -1e-311)
       (* (- d) (pow (* l h) -0.5))
       (* (fma (/ h l) (* -0.5 t_0) 1.0) (/ d (sqrt (* l 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((M_m * (D / (d * 2.0))), 2.0);
	double tmp;
	if (h <= -7.5e-68) {
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * t_0)));
	} else if (h <= -1e-311) {
		tmp = -d * pow((l * h), -0.5);
	} else {
		tmp = fma((h / l), (-0.5 * t_0), 1.0) * (d / sqrt((l * 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(D / Float64(d * 2.0))) ^ 2.0
	tmp = 0.0
	if (h <= -7.5e-68)
		tmp = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * t_0))));
	elseif (h <= -1e-311)
		tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5));
	else
		tmp = Float64(fma(Float64(h / l), Float64(-0.5 * t_0), 1.0) * Float64(d / sqrt(Float64(l * 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[Power[N[(M$95$m * N[(D / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[h, -7.5e-68], N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -1e-311], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(N[(h / l), $MachinePrecision] * N[(-0.5 * t$95$0), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[Sqrt[N[(l * 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 := {\left(M\_m \cdot \frac{D}{d \cdot 2}\right)}^{2}\\
\mathbf{if}\;h \leq -7.5 \cdot 10^{-68}:\\
\;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot t\_0\right)\right)\\

\mathbf{elif}\;h \leq -1 \cdot 10^{-311}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

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


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

    1. Initial program 65.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified64.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. Step-by-step derivation
      1. add-sqr-sqrt64.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. pow264.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-prod64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.50000000000000081e-68 < h < -9.99999999999948e-312

    1. Initial program 58.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. Simplified54.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-sqrt54.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. pow254.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-prod54.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. unpow254.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \]
    13. Applied egg-rr60.7%

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

    if -9.99999999999948e-312 < h

    1. Initial program 64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 62.0% 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} \mathbf{if}\;h \leq -2.7 \cdot 10^{-68}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M\_m \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\\ \mathbf{elif}\;h \leq -1 \cdot 10^{-311}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{d \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(\frac{D}{d} \cdot \left(0.5 \cdot M\_m\right)\right)}^{2} \cdot -0.5, 1\right)}{\sqrt{\ell \cdot 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 (<= h -2.7e-68)
   (*
    (sqrt (* (/ d h) (/ d l)))
    (+ 1.0 (* -0.5 (* (/ h l) (pow (* M_m (/ D (* d 2.0))) 2.0)))))
   (if (<= h -1e-311)
     (* (- d) (pow (* l h) -0.5))
     (/
      (* d (fma (/ h l) (* (pow (* (/ D d) (* 0.5 M_m)) 2.0) -0.5) 1.0))
      (sqrt (* l 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 (h <= -2.7e-68) {
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * pow((M_m * (D / (d * 2.0))), 2.0))));
	} else if (h <= -1e-311) {
		tmp = -d * pow((l * h), -0.5);
	} else {
		tmp = (d * fma((h / l), (pow(((D / d) * (0.5 * M_m)), 2.0) * -0.5), 1.0)) / sqrt((l * 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 (h <= -2.7e-68)
		tmp = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(M_m * Float64(D / Float64(d * 2.0))) ^ 2.0)))));
	elseif (h <= -1e-311)
		tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5));
	else
		tmp = Float64(Float64(d * fma(Float64(h / l), Float64((Float64(Float64(D / d) * Float64(0.5 * M_m)) ^ 2.0) * -0.5), 1.0)) / sqrt(Float64(l * 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[h, -2.7e-68], N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M$95$m * N[(D / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -1e-311], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(d * N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l * 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}\;h \leq -2.7 \cdot 10^{-68}:\\
\;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M\_m \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\\

\mathbf{elif}\;h \leq -1 \cdot 10^{-311}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

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


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

    1. Initial program 65.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified64.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. Step-by-step derivation
      1. add-sqr-sqrt64.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. pow264.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-prod64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.7000000000000002e-68 < h < -9.99999999999948e-312

    1. Initial program 58.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. Simplified54.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-sqrt54.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. pow254.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-prod54.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. unpow254.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \]
    13. Applied egg-rr60.7%

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

    if -9.99999999999948e-312 < h

    1. Initial program 64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 57.9% 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 -4.4 \cdot 10^{-141}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{elif}\;\ell \leq 1.65 \cdot 10^{-307}:\\ \;\;\;\;d \cdot \sqrt{e^{\frac{1}{\ell \cdot h}} + -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot \left(0.5 \cdot M\_m\right)\right)}^{2} \cdot -0.5\right)\right)\\ \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 -4.4e-141)
   (* (- d) (pow (* l h) -0.5))
   (if (<= l 1.65e-307)
     (* d (sqrt (+ (exp (/ 1.0 (* l h))) -1.0)))
     (*
      (/ d (sqrt (* l h)))
      (+ 1.0 (* (/ h l) (* (pow (* (/ D d) (* 0.5 M_m)) 2.0) -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 <= -4.4e-141) {
		tmp = -d * pow((l * h), -0.5);
	} else if (l <= 1.65e-307) {
		tmp = d * sqrt((exp((1.0 / (l * h))) + -1.0));
	} else {
		tmp = (d / sqrt((l * h))) * (1.0 + ((h / l) * (pow(((D / d) * (0.5 * M_m)), 2.0) * -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 <= (-4.4d-141)) then
        tmp = -d * ((l * h) ** (-0.5d0))
    else if (l <= 1.65d-307) then
        tmp = d * sqrt((exp((1.0d0 / (l * h))) + (-1.0d0)))
    else
        tmp = (d / sqrt((l * h))) * (1.0d0 + ((h / l) * ((((d_1 / d) * (0.5d0 * m_m)) ** 2.0d0) * (-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 <= -4.4e-141) {
		tmp = -d * Math.pow((l * h), -0.5);
	} else if (l <= 1.65e-307) {
		tmp = d * Math.sqrt((Math.exp((1.0 / (l * h))) + -1.0));
	} else {
		tmp = (d / Math.sqrt((l * h))) * (1.0 + ((h / l) * (Math.pow(((D / d) * (0.5 * M_m)), 2.0) * -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 <= -4.4e-141:
		tmp = -d * math.pow((l * h), -0.5)
	elif l <= 1.65e-307:
		tmp = d * math.sqrt((math.exp((1.0 / (l * h))) + -1.0))
	else:
		tmp = (d / math.sqrt((l * h))) * (1.0 + ((h / l) * (math.pow(((D / d) * (0.5 * M_m)), 2.0) * -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 <= -4.4e-141)
		tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5));
	elseif (l <= 1.65e-307)
		tmp = Float64(d * sqrt(Float64(exp(Float64(1.0 / Float64(l * h))) + -1.0)));
	else
		tmp = Float64(Float64(d / sqrt(Float64(l * h))) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(D / d) * Float64(0.5 * M_m)) ^ 2.0) * -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 <= -4.4e-141)
		tmp = -d * ((l * h) ^ -0.5);
	elseif (l <= 1.65e-307)
		tmp = d * sqrt((exp((1.0 / (l * h))) + -1.0));
	else
		tmp = (d / sqrt((l * h))) * (1.0 + ((h / l) * ((((D / d) * (0.5 * M_m)) ^ 2.0) * -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, -4.4e-141], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.65e-307], N[(d * N[Sqrt[N[(N[Exp[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $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}\;\ell \leq -4.4 \cdot 10^{-141}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

\mathbf{elif}\;\ell \leq 1.65 \cdot 10^{-307}:\\
\;\;\;\;d \cdot \sqrt{e^{\frac{1}{\ell \cdot h}} + -1}\\

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


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

    1. Initial program 58.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. Simplified55.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-sqrt55.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. pow255.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-prod55.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. unpow255.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]
    12. Step-by-step derivation
      1. div-inv45.3%

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

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

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

        \[\leadsto -d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \]
    13. Applied egg-rr45.3%

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

    if -4.40000000000000018e-141 < l < 1.65e-307

    1. Initial program 73.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. Simplified73.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 d around inf 23.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. expm1-log1p-u23.2%

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

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

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

      \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{h}}{\ell}\right)} - 1}} \]
    7. Taylor expanded in h around inf 40.0%

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

    if 1.65e-307 < l

    1. Initial program 64.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 61.4% 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}\;h \leq -6 \cdot 10^{-68}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M\_m \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\\ \mathbf{elif}\;h \leq -1 \cdot 10^{-311}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot \left(0.5 \cdot M\_m\right)\right)}^{2} \cdot -0.5\right)\right)\\ \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 (<= h -6e-68)
   (*
    (sqrt (* (/ d h) (/ d l)))
    (+ 1.0 (* -0.5 (* (/ h l) (pow (* M_m (/ D (* d 2.0))) 2.0)))))
   (if (<= h -1e-311)
     (* (- d) (pow (* l h) -0.5))
     (*
      (/ d (sqrt (* l h)))
      (+ 1.0 (* (/ h l) (* (pow (* (/ D d) (* 0.5 M_m)) 2.0) -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 (h <= -6e-68) {
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * pow((M_m * (D / (d * 2.0))), 2.0))));
	} else if (h <= -1e-311) {
		tmp = -d * pow((l * h), -0.5);
	} else {
		tmp = (d / sqrt((l * h))) * (1.0 + ((h / l) * (pow(((D / d) * (0.5 * M_m)), 2.0) * -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 (h <= (-6d-68)) then
        tmp = sqrt(((d / h) * (d / l))) * (1.0d0 + ((-0.5d0) * ((h / l) * ((m_m * (d_1 / (d * 2.0d0))) ** 2.0d0))))
    else if (h <= (-1d-311)) then
        tmp = -d * ((l * h) ** (-0.5d0))
    else
        tmp = (d / sqrt((l * h))) * (1.0d0 + ((h / l) * ((((d_1 / d) * (0.5d0 * m_m)) ** 2.0d0) * (-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 (h <= -6e-68) {
		tmp = Math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * Math.pow((M_m * (D / (d * 2.0))), 2.0))));
	} else if (h <= -1e-311) {
		tmp = -d * Math.pow((l * h), -0.5);
	} else {
		tmp = (d / Math.sqrt((l * h))) * (1.0 + ((h / l) * (Math.pow(((D / d) * (0.5 * M_m)), 2.0) * -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 h <= -6e-68:
		tmp = math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * math.pow((M_m * (D / (d * 2.0))), 2.0))))
	elif h <= -1e-311:
		tmp = -d * math.pow((l * h), -0.5)
	else:
		tmp = (d / math.sqrt((l * h))) * (1.0 + ((h / l) * (math.pow(((D / d) * (0.5 * M_m)), 2.0) * -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 (h <= -6e-68)
		tmp = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(M_m * Float64(D / Float64(d * 2.0))) ^ 2.0)))));
	elseif (h <= -1e-311)
		tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5));
	else
		tmp = Float64(Float64(d / sqrt(Float64(l * h))) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(D / d) * Float64(0.5 * M_m)) ^ 2.0) * -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 (h <= -6e-68)
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * ((M_m * (D / (d * 2.0))) ^ 2.0))));
	elseif (h <= -1e-311)
		tmp = -d * ((l * h) ^ -0.5);
	else
		tmp = (d / sqrt((l * h))) * (1.0 + ((h / l) * ((((D / d) * (0.5 * M_m)) ^ 2.0) * -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[h, -6e-68], N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M$95$m * N[(D / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -1e-311], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(0.5 * M$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $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}\;h \leq -6 \cdot 10^{-68}:\\
\;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M\_m \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\\

\mathbf{elif}\;h \leq -1 \cdot 10^{-311}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

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


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

    1. Initial program 65.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified64.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. Step-by-step derivation
      1. add-sqr-sqrt64.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. pow264.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-prod64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6e-68 < h < -9.99999999999948e-312

    1. Initial program 58.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. Simplified54.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-sqrt54.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. pow254.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-prod54.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. unpow254.7%

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. add-sqr-sqrt56.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. frac-times60.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*56.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative56.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr56.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/60.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. remove-double-neg60.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{M \cdot D}{\color{blue}{-\left(-d \cdot 2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. distribute-frac-neg260.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(-\frac{M \cdot D}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. distribute-frac-neg60.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{-M \cdot D}{-d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. distribute-lft-neg-in60.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(-M\right) \cdot D}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. *-commutative60.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot \left(-M\right)}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*58.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{-M}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-*l*58.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{-M}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
      9. neg-mul-158.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{\color{blue}{-1 \cdot M}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      10. distribute-rgt-neg-in58.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{d \cdot \left(-2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      11. metadata-eval58.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{d \cdot \color{blue}{-2}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      12. *-commutative58.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{-2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      13. times-frac58.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(\frac{-1}{-2} \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      14. metadata-eval58.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(\color{blue}{0.5} \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    7. Simplified58.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Step-by-step derivation
      1. clear-num58.4%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      2. sqrt-div61.6%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      3. metadata-eval61.6%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    9. Applied egg-rr61.6%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    10. Taylor expanded in d around -inf 60.7%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    11. Simplified60.7%

      \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]
    12. Step-by-step derivation
      1. div-inv60.7%

        \[\leadsto -\color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. pow1/260.7%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      3. pow-flip60.7%

        \[\leadsto -d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.5\right)}} \]
      4. metadata-eval60.7%

        \[\leadsto -d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \]
    13. Applied egg-rr60.7%

      \[\leadsto -\color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]

    if -9.99999999999948e-312 < h

    1. Initial program 64.0%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified64.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-rr81.9%

      \[\leadsto \color{blue}{{\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
    5. Step-by-step derivation
      1. unpow181.9%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)} \]
      2. +-commutative81.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \color{blue}{\left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right) + 1\right)} \]
      3. *-commutative81.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(\color{blue}{\left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right) \cdot -0.5} + 1\right) \]
      4. associate-*r*81.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(\color{blue}{\frac{h}{\ell} \cdot \left({\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2} \cdot -0.5\right)} + 1\right) \]
      5. fma-define81.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \color{blue}{\mathsf{fma}\left(\frac{h}{\ell}, {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2} \cdot -0.5, 1\right)} \]
      6. *-commutative81.9%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(M \cdot \frac{D}{\color{blue}{2 \cdot d}}\right)}^{2} \cdot -0.5, 1\right) \]
    6. Simplified81.9%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(M \cdot \frac{D}{2 \cdot d}\right)}^{2} \cdot -0.5, 1\right)} \]
    7. Step-by-step derivation
      1. sqrt-unprod71.5%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(M \cdot \frac{D}{2 \cdot d}\right)}^{2} \cdot -0.5, 1\right) \]
      2. *-commutative71.5%

        \[\leadsto \frac{d}{\sqrt{\color{blue}{h \cdot \ell}}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(M \cdot \frac{D}{2 \cdot d}\right)}^{2} \cdot -0.5, 1\right) \]
      3. pow1/271.5%

        \[\leadsto \frac{d}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(M \cdot \frac{D}{2 \cdot d}\right)}^{2} \cdot -0.5, 1\right) \]
    8. Applied egg-rr71.5%

      \[\leadsto \frac{d}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(M \cdot \frac{D}{2 \cdot d}\right)}^{2} \cdot -0.5, 1\right) \]
    9. Step-by-step derivation
      1. unpow1/271.5%

        \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(M \cdot \frac{D}{2 \cdot d}\right)}^{2} \cdot -0.5, 1\right) \]
    10. Simplified71.5%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(M \cdot \frac{D}{2 \cdot d}\right)}^{2} \cdot -0.5, 1\right) \]
    11. Step-by-step derivation
      1. fma-undefine71.5%

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \cdot \color{blue}{\left(\frac{h}{\ell} \cdot \left({\left(M \cdot \frac{D}{2 \cdot d}\right)}^{2} \cdot -0.5\right) + 1\right)} \]
      2. associate-*r/71.5%

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \cdot \left(\frac{h}{\ell} \cdot \left({\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot -0.5\right) + 1\right) \]
      3. frac-times71.5%

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \cdot \left(\frac{h}{\ell} \cdot \left({\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot -0.5\right) + 1\right) \]
      4. div-inv71.5%

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \cdot \left(\frac{h}{\ell} \cdot \left({\left(\color{blue}{\left(M \cdot \frac{1}{2}\right)} \cdot \frac{D}{d}\right)}^{2} \cdot -0.5\right) + 1\right) \]
      5. metadata-eval71.5%

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \cdot \left(\frac{h}{\ell} \cdot \left({\left(\left(M \cdot \color{blue}{0.5}\right) \cdot \frac{D}{d}\right)}^{2} \cdot -0.5\right) + 1\right) \]
    12. Applied egg-rr71.5%

      \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \cdot \color{blue}{\left(\frac{h}{\ell} \cdot \left({\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot -0.5\right) + 1\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification64.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -6 \cdot 10^{-68}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\\ \mathbf{elif}\;h \leq -1 \cdot 10^{-311}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot \left(0.5 \cdot M\right)\right)}^{2} \cdot -0.5\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 46.9% 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}\;d \leq 2.5 \cdot 10^{-183}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \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.5e-183) (* (- d) (pow (* l h) -0.5)) (/ 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.5e-183) {
		tmp = -d * pow((l * h), -0.5);
	} 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.5d-183) then
        tmp = -d * ((l * h) ** (-0.5d0))
    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.5e-183) {
		tmp = -d * Math.pow((l * h), -0.5);
	} 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.5e-183:
		tmp = -d * math.pow((l * h), -0.5)
	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.5e-183)
		tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5));
	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.5e-183)
		tmp = -d * ((l * h) ^ -0.5);
	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.5e-183], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $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}\;d \leq 2.5 \cdot 10^{-183}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 2.5000000000000001e-183

    1. Initial program 57.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. Simplified55.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt55.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow255.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod55.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. unpow255.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\sqrt{\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right) \cdot \left(\frac{M}{2} \cdot \frac{D}{d}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. sqrt-prod31.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. add-sqr-sqrt57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. frac-times60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr57.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. remove-double-neg60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{M \cdot D}{\color{blue}{-\left(-d \cdot 2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. distribute-frac-neg260.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(-\frac{M \cdot D}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. distribute-frac-neg60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{-M \cdot D}{-d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. distribute-lft-neg-in60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(-M\right) \cdot D}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. *-commutative60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot \left(-M\right)}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{-M}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-*l*58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{-M}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
      9. neg-mul-158.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{\color{blue}{-1 \cdot M}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      10. distribute-rgt-neg-in58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{d \cdot \left(-2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      11. metadata-eval58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{d \cdot \color{blue}{-2}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      12. *-commutative58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{-2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      13. times-frac57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(\frac{-1}{-2} \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      14. metadata-eval57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(\color{blue}{0.5} \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    7. Simplified57.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Step-by-step derivation
      1. clear-num57.9%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      2. sqrt-div58.9%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      3. metadata-eval58.9%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    9. Applied egg-rr58.9%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    10. Taylor expanded in d around -inf 36.1%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    11. Simplified36.5%

      \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]
    12. Step-by-step derivation
      1. div-inv36.5%

        \[\leadsto -\color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. pow1/236.5%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      3. pow-flip36.5%

        \[\leadsto -d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.5\right)}} \]
      4. metadata-eval36.5%

        \[\leadsto -d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \]
    13. Applied egg-rr36.5%

      \[\leadsto -\color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]

    if 2.5000000000000001e-183 < d

    1. Initial program 73.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified73.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 d around inf 46.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. sqrt-div46.1%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      2. metadata-eval46.1%

        \[\leadsto d \cdot \frac{\color{blue}{1}}{\sqrt{h \cdot \ell}} \]
      3. *-commutative46.1%

        \[\leadsto d \cdot \frac{1}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-unprod53.0%

        \[\leadsto d \cdot \frac{1}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. div-inv53.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      6. associate-/r*52.0%

        \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    6. Applied egg-rr52.0%

      \[\leadsto \color{blue}{\frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}} \]
    7. Step-by-step derivation
      1. associate-/l/53.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Simplified53.0%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification42.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 2.5 \cdot 10^{-183}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 43.3% 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(\ell \cdot h\right)}^{-0.5}\\ \mathbf{if}\;d \leq 6.2 \cdot 10^{-184}:\\ \;\;\;\;\left(-d\right) \cdot t\_0\\ \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 (* l h) -0.5)))
   (if (<= d 6.2e-184) (* (- 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((l * h), -0.5);
	double tmp;
	if (d <= 6.2e-184) {
		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 = (l * h) ** (-0.5d0)
    if (d <= 6.2d-184) 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((l * h), -0.5);
	double tmp;
	if (d <= 6.2e-184) {
		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((l * h), -0.5)
	tmp = 0
	if d <= 6.2e-184:
		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(l * h) ^ -0.5
	tmp = 0.0
	if (d <= 6.2e-184)
		tmp = Float64(Float64(-d) * 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 = (l * h) ^ -0.5;
	tmp = 0.0;
	if (d <= 6.2e-184)
		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[(l * h), $MachinePrecision], -0.5], $MachinePrecision]}, If[LessEqual[d, 6.2e-184], 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(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;d \leq 6.2 \cdot 10^{-184}:\\
\;\;\;\;\left(-d\right) \cdot t\_0\\

\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 6.2000000000000004e-184

    1. Initial program 57.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. Simplified55.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt55.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow255.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod55.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. unpow255.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\sqrt{\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right) \cdot \left(\frac{M}{2} \cdot \frac{D}{d}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. sqrt-prod31.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. add-sqr-sqrt57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. frac-times60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr57.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. remove-double-neg60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{M \cdot D}{\color{blue}{-\left(-d \cdot 2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. distribute-frac-neg260.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(-\frac{M \cdot D}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. distribute-frac-neg60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{-M \cdot D}{-d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. distribute-lft-neg-in60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(-M\right) \cdot D}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. *-commutative60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot \left(-M\right)}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{-M}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-*l*58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{-M}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
      9. neg-mul-158.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{\color{blue}{-1 \cdot M}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      10. distribute-rgt-neg-in58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{d \cdot \left(-2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      11. metadata-eval58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{d \cdot \color{blue}{-2}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      12. *-commutative58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{-2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      13. times-frac57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(\frac{-1}{-2} \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      14. metadata-eval57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(\color{blue}{0.5} \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    7. Simplified57.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Step-by-step derivation
      1. clear-num57.9%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      2. sqrt-div58.9%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      3. metadata-eval58.9%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    9. Applied egg-rr58.9%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    10. Taylor expanded in d around -inf 36.1%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    11. Simplified36.5%

      \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]
    12. Step-by-step derivation
      1. div-inv36.5%

        \[\leadsto -\color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. pow1/236.5%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      3. pow-flip36.5%

        \[\leadsto -d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.5\right)}} \]
      4. metadata-eval36.5%

        \[\leadsto -d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \]
    13. Applied egg-rr36.5%

      \[\leadsto -\color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]

    if 6.2000000000000004e-184 < d

    1. Initial program 73.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified73.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt73.9%

        \[\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. pow273.9%

        \[\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-prod73.9%

        \[\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. unpow273.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\sqrt{\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right) \cdot \left(\frac{M}{2} \cdot \frac{D}{d}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. sqrt-prod39.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. add-sqr-sqrt73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. frac-times73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr73.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. remove-double-neg73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{M \cdot D}{\color{blue}{-\left(-d \cdot 2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. distribute-frac-neg273.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(-\frac{M \cdot D}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. distribute-frac-neg73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{-M \cdot D}{-d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. distribute-lft-neg-in73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(-M\right) \cdot D}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. *-commutative73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot \left(-M\right)}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{-M}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-*l*73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{-M}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
      9. neg-mul-173.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{\color{blue}{-1 \cdot M}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      10. distribute-rgt-neg-in73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{d \cdot \left(-2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      11. metadata-eval73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{d \cdot \color{blue}{-2}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      12. *-commutative73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{-2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      13. times-frac73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(\frac{-1}{-2} \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      14. metadata-eval73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(\color{blue}{0.5} \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    7. Simplified73.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Taylor expanded in d around inf 46.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. unpow-146.2%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. metadata-eval46.2%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr46.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square46.1%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt45.9%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr45.9%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt46.1%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Simplified46.1%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification40.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 6.2 \cdot 10^{-184}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 43.2% 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}\;d \leq 1.85 \cdot 10^{-184}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot 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.85e-184)
   (* (- d) (pow (* l h) -0.5))
   (* d (sqrt (/ 1.0 (* l 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.85e-184) {
		tmp = -d * pow((l * h), -0.5);
	} else {
		tmp = d * sqrt((1.0 / (l * 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 <= 1.85d-184) then
        tmp = -d * ((l * h) ** (-0.5d0))
    else
        tmp = d * sqrt((1.0d0 / (l * h)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
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 <= 1.85e-184) {
		tmp = -d * Math.pow((l * h), -0.5);
	} else {
		tmp = d * Math.sqrt((1.0 / (l * h)));
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	tmp = 0
	if d <= 1.85e-184:
		tmp = -d * math.pow((l * h), -0.5)
	else:
		tmp = d * math.sqrt((1.0 / (l * 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.85e-184)
		tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5));
	else
		tmp = Float64(d * sqrt(Float64(1.0 / Float64(l * 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 <= 1.85e-184)
		tmp = -d * ((l * h) ^ -0.5);
	else
		tmp = d * sqrt((1.0 / (l * h)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
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.85e-184], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(1.0 / N[(l * 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.85 \cdot 10^{-184}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 1.8499999999999999e-184

    1. Initial program 57.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. Simplified55.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt55.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow255.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod55.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. unpow255.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\sqrt{\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right) \cdot \left(\frac{M}{2} \cdot \frac{D}{d}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. sqrt-prod31.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. add-sqr-sqrt57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. frac-times60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr57.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. remove-double-neg60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{M \cdot D}{\color{blue}{-\left(-d \cdot 2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. distribute-frac-neg260.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(-\frac{M \cdot D}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. distribute-frac-neg60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{-M \cdot D}{-d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. distribute-lft-neg-in60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(-M\right) \cdot D}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. *-commutative60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot \left(-M\right)}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{-M}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-*l*58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{-M}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
      9. neg-mul-158.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{\color{blue}{-1 \cdot M}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      10. distribute-rgt-neg-in58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{d \cdot \left(-2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      11. metadata-eval58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{d \cdot \color{blue}{-2}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      12. *-commutative58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{-2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      13. times-frac57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(\frac{-1}{-2} \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      14. metadata-eval57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(\color{blue}{0.5} \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    7. Simplified57.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Step-by-step derivation
      1. clear-num57.9%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      2. sqrt-div58.9%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      3. metadata-eval58.9%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    9. Applied egg-rr58.9%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    10. Taylor expanded in d around -inf 36.1%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    11. Simplified36.5%

      \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]
    12. Step-by-step derivation
      1. div-inv36.5%

        \[\leadsto -\color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. pow1/236.5%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      3. pow-flip36.5%

        \[\leadsto -d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.5\right)}} \]
      4. metadata-eval36.5%

        \[\leadsto -d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \]
    13. Applied egg-rr36.5%

      \[\leadsto -\color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]

    if 1.8499999999999999e-184 < d

    1. Initial program 73.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified73.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 d around inf 46.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification40.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 1.85 \cdot 10^{-184}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 43.3% 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}\;d \leq 7 \cdot 10^{-183}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\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 7e-183) (* (- d) (pow (* l h) -0.5)) (* 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) {
	double tmp;
	if (d <= 7e-183) {
		tmp = -d * pow((l * h), -0.5);
	} else {
		tmp = d * sqrt(((1.0 / 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 <= 7d-183) then
        tmp = -d * ((l * h) ** (-0.5d0))
    else
        tmp = d * sqrt(((1.0d0 / 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 <= 7e-183) {
		tmp = -d * Math.pow((l * h), -0.5);
	} else {
		tmp = d * Math.sqrt(((1.0 / 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 <= 7e-183:
		tmp = -d * math.pow((l * h), -0.5)
	else:
		tmp = d * math.sqrt(((1.0 / 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 <= 7e-183)
		tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / 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 <= 7e-183)
		tmp = -d * ((l * h) ^ -0.5);
	else
		tmp = d * sqrt(((1.0 / 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, 7e-183], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], 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])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 7 \cdot 10^{-183}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 6.99999999999999983e-183

    1. Initial program 57.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. Simplified55.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt55.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow255.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod55.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. unpow255.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\sqrt{\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right) \cdot \left(\frac{M}{2} \cdot \frac{D}{d}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. sqrt-prod31.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. add-sqr-sqrt57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. frac-times60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr57.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. remove-double-neg60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{M \cdot D}{\color{blue}{-\left(-d \cdot 2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. distribute-frac-neg260.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(-\frac{M \cdot D}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. distribute-frac-neg60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{-M \cdot D}{-d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. distribute-lft-neg-in60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(-M\right) \cdot D}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. *-commutative60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot \left(-M\right)}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{-M}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-*l*58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{-M}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
      9. neg-mul-158.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{\color{blue}{-1 \cdot M}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      10. distribute-rgt-neg-in58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{d \cdot \left(-2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      11. metadata-eval58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{d \cdot \color{blue}{-2}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      12. *-commutative58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{-2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      13. times-frac57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(\frac{-1}{-2} \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      14. metadata-eval57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(\color{blue}{0.5} \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    7. Simplified57.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Step-by-step derivation
      1. clear-num57.9%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      2. sqrt-div58.9%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      3. metadata-eval58.9%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    9. Applied egg-rr58.9%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    10. Taylor expanded in d around -inf 36.1%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    11. Simplified36.5%

      \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]
    12. Step-by-step derivation
      1. div-inv36.5%

        \[\leadsto -\color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. pow1/236.5%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      3. pow-flip36.5%

        \[\leadsto -d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.5\right)}} \]
      4. metadata-eval36.5%

        \[\leadsto -d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \]
    13. Applied egg-rr36.5%

      \[\leadsto -\color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]

    if 6.99999999999999983e-183 < d

    1. Initial program 73.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified73.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 d around inf 46.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. expm1-log1p-u44.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)\right)}} \]
      2. expm1-undefine28.2%

        \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1}} \]
      3. associate-/r*28.2%

        \[\leadsto d \cdot \sqrt{e^{\mathsf{log1p}\left(\color{blue}{\frac{\frac{1}{h}}{\ell}}\right)} - 1} \]
    6. Applied egg-rr28.2%

      \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{h}}{\ell}\right)} - 1}} \]
    7. Step-by-step derivation
      1. expm1-define45.3%

        \[\leadsto d \cdot \sqrt{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{1}{h}}{\ell}\right)\right)}} \]
      2. expm1-log1p-u47.0%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    8. Applied egg-rr47.0%

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification40.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 7 \cdot 10^{-183}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 43.3% 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}\;d \leq 2.5 \cdot 10^{-183}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
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.5e-183)
   (* (- d) (pow (* l h) -0.5))
   (* d (sqrt (/ (/ 1.0 l) 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.5e-183) {
		tmp = -d * pow((l * h), -0.5);
	} else {
		tmp = d * sqrt(((1.0 / l) / 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.5d-183) then
        tmp = -d * ((l * h) ** (-0.5d0))
    else
        tmp = d * sqrt(((1.0d0 / l) / h))
    end if
    code = tmp
end function
M_m = Math.abs(M);
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.5e-183) {
		tmp = -d * Math.pow((l * h), -0.5);
	} else {
		tmp = d * Math.sqrt(((1.0 / l) / h));
	}
	return tmp;
}
M_m = math.fabs(M)
[d, 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.5e-183:
		tmp = -d * math.pow((l * h), -0.5)
	else:
		tmp = d * math.sqrt(((1.0 / l) / 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.5e-183)
		tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / l) / h)));
	end
	return tmp
end
M_m = abs(M);
d, 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.5e-183)
		tmp = -d * ((l * h) ^ -0.5);
	else
		tmp = d * sqrt(((1.0 / l) / h));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
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.5e-183], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 2.5 \cdot 10^{-183}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 2.5000000000000001e-183

    1. Initial program 57.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. Simplified55.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt55.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow255.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod55.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. unpow255.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\sqrt{\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right) \cdot \left(\frac{M}{2} \cdot \frac{D}{d}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. sqrt-prod31.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. add-sqr-sqrt57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. frac-times60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr57.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. remove-double-neg60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{M \cdot D}{\color{blue}{-\left(-d \cdot 2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. distribute-frac-neg260.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(-\frac{M \cdot D}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. distribute-frac-neg60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{-M \cdot D}{-d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. distribute-lft-neg-in60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(-M\right) \cdot D}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. *-commutative60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot \left(-M\right)}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{-M}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-*l*58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{-M}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
      9. neg-mul-158.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{\color{blue}{-1 \cdot M}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      10. distribute-rgt-neg-in58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{d \cdot \left(-2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      11. metadata-eval58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{d \cdot \color{blue}{-2}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      12. *-commutative58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{-2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      13. times-frac57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(\frac{-1}{-2} \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      14. metadata-eval57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(\color{blue}{0.5} \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    7. Simplified57.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Step-by-step derivation
      1. clear-num57.9%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      2. sqrt-div58.9%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      3. metadata-eval58.9%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    9. Applied egg-rr58.9%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    10. Taylor expanded in d around -inf 36.1%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    11. Simplified36.5%

      \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]
    12. Step-by-step derivation
      1. div-inv36.5%

        \[\leadsto -\color{blue}{d \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      2. pow1/236.5%

        \[\leadsto -d \cdot \frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{0.5}}} \]
      3. pow-flip36.5%

        \[\leadsto -d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.5\right)}} \]
      4. metadata-eval36.5%

        \[\leadsto -d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \]
    13. Applied egg-rr36.5%

      \[\leadsto -\color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]

    if 2.5000000000000001e-183 < d

    1. Initial program 73.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified73.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 d around inf 46.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative46.2%

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*47.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    6. Simplified47.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification40.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 2.5 \cdot 10^{-183}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 43.3% 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 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;d \leq 6.8 \cdot 10^{-184}:\\ \;\;\;\;\frac{d}{-t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{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 (sqrt (* l h)))) (if (<= d 6.8e-184) (/ 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 = sqrt((l * h));
	double tmp;
	if (d <= 6.8e-184) {
		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 = sqrt((l * h))
    if (d <= 6.8d-184) 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.sqrt((l * h));
	double tmp;
	if (d <= 6.8e-184) {
		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.sqrt((l * h))
	tmp = 0
	if d <= 6.8e-184:
		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 = sqrt(Float64(l * h))
	tmp = 0.0
	if (d <= 6.8e-184)
		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 = sqrt((l * h));
	tmp = 0.0;
	if (d <= 6.8e-184)
		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[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, 6.8e-184], 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 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;d \leq 6.8 \cdot 10^{-184}:\\
\;\;\;\;\frac{d}{-t\_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 6.80000000000000008e-184

    1. Initial program 57.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. Simplified55.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt55.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow255.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod55.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. unpow255.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\sqrt{\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right) \cdot \left(\frac{M}{2} \cdot \frac{D}{d}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. sqrt-prod31.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. add-sqr-sqrt57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. frac-times60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr57.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. remove-double-neg60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{M \cdot D}{\color{blue}{-\left(-d \cdot 2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. distribute-frac-neg260.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(-\frac{M \cdot D}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. distribute-frac-neg60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{-M \cdot D}{-d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. distribute-lft-neg-in60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(-M\right) \cdot D}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. *-commutative60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot \left(-M\right)}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{-M}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-*l*58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{-M}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
      9. neg-mul-158.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{\color{blue}{-1 \cdot M}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      10. distribute-rgt-neg-in58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{d \cdot \left(-2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      11. metadata-eval58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{d \cdot \color{blue}{-2}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      12. *-commutative58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{-2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      13. times-frac57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(\frac{-1}{-2} \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      14. metadata-eval57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(\color{blue}{0.5} \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    7. Simplified57.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Step-by-step derivation
      1. clear-num57.9%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      2. sqrt-div58.9%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      3. metadata-eval58.9%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    9. Applied egg-rr58.9%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    10. Taylor expanded in d around -inf 36.1%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    11. Simplified36.5%

      \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]

    if 6.80000000000000008e-184 < d

    1. Initial program 73.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified73.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt73.9%

        \[\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. pow273.9%

        \[\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-prod73.9%

        \[\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. unpow273.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\sqrt{\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right) \cdot \left(\frac{M}{2} \cdot \frac{D}{d}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. sqrt-prod39.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. add-sqr-sqrt73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. frac-times73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr73.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. remove-double-neg73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{M \cdot D}{\color{blue}{-\left(-d \cdot 2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. distribute-frac-neg273.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(-\frac{M \cdot D}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. distribute-frac-neg73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{-M \cdot D}{-d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. distribute-lft-neg-in73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(-M\right) \cdot D}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. *-commutative73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot \left(-M\right)}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{-M}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-*l*73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{-M}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
      9. neg-mul-173.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{\color{blue}{-1 \cdot M}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      10. distribute-rgt-neg-in73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{d \cdot \left(-2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      11. metadata-eval73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{d \cdot \color{blue}{-2}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      12. *-commutative73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{-2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      13. times-frac73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(\frac{-1}{-2} \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      14. metadata-eval73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(\color{blue}{0.5} \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    7. Simplified73.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Taylor expanded in d around inf 46.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. unpow-146.2%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. metadata-eval46.2%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr46.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square46.1%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt45.9%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr45.9%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt46.1%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      8. rem-exp-log42.6%

        \[\leadsto \color{blue}{e^{\log d}} \cdot {\left(h \cdot \ell\right)}^{-0.5} \]
      9. rem-exp-log42.4%

        \[\leadsto e^{\log d} \cdot \color{blue}{e^{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      10. exp-sum41.9%

        \[\leadsto \color{blue}{e^{\log d + \log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      11. log-pow41.9%

        \[\leadsto e^{\log d + \color{blue}{-0.5 \cdot \log \left(h \cdot \ell\right)}} \]
      12. metadata-eval41.9%

        \[\leadsto e^{\log d + \color{blue}{\left(0.5 \cdot -1\right)} \cdot \log \left(h \cdot \ell\right)} \]
      13. associate-*r*41.9%

        \[\leadsto e^{\log d + \color{blue}{0.5 \cdot \left(-1 \cdot \log \left(h \cdot \ell\right)\right)}} \]
      14. neg-mul-141.9%

        \[\leadsto e^{\log d + 0.5 \cdot \color{blue}{\left(-\log \left(h \cdot \ell\right)\right)}} \]
      15. distribute-rgt-neg-out41.9%

        \[\leadsto e^{\log d + \color{blue}{\left(-0.5 \cdot \log \left(h \cdot \ell\right)\right)}} \]
      16. log-pow41.9%

        \[\leadsto e^{\log d + \left(-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}\right)} \]
      17. unpow1/241.9%

        \[\leadsto e^{\log d + \left(-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}\right)} \]
      18. sub-neg41.9%

        \[\leadsto e^{\color{blue}{\log d - \log \left(\sqrt{h \cdot \ell}\right)}} \]
      19. log-div42.6%

        \[\leadsto e^{\color{blue}{\log \left(\frac{d}{\sqrt{h \cdot \ell}}\right)}} \]
    10. Simplified46.1%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification40.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 6.8 \cdot 10^{-184}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 21: 43.3% 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}\;d \leq 1.1 \cdot 10^{-182}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\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 (<= d 1.1e-182) (/ d (- (sqrt (* l h)))) (* d (pow (* l h) -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 (d <= 1.1e-182) {
		tmp = d / -sqrt((l * h));
	} else {
		tmp = d * pow((l * h), -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 (d <= 1.1d-182) then
        tmp = d / -sqrt((l * h))
    else
        tmp = d * ((l * h) ** (-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 (d <= 1.1e-182) {
		tmp = d / -Math.sqrt((l * h));
	} else {
		tmp = d * Math.pow((l * h), -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 d <= 1.1e-182:
		tmp = d / -math.sqrt((l * h))
	else:
		tmp = d * math.pow((l * h), -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 (d <= 1.1e-182)
		tmp = Float64(d / Float64(-sqrt(Float64(l * h))));
	else
		tmp = Float64(d * (Float64(l * h) ^ -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 (d <= 1.1e-182)
		tmp = d / -sqrt((l * h));
	else
		tmp = d * ((l * h) ^ -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[d, 1.1e-182], N[(d / (-N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d * N[Power[N[(l * h), $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}\;d \leq 1.1 \cdot 10^{-182}:\\
\;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 1.1e-182

    1. Initial program 57.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. Simplified55.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt55.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow255.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod55.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. unpow255.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\sqrt{\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right) \cdot \left(\frac{M}{2} \cdot \frac{D}{d}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. sqrt-prod31.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. add-sqr-sqrt57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. frac-times60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative57.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr57.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. remove-double-neg60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{M \cdot D}{\color{blue}{-\left(-d \cdot 2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. distribute-frac-neg260.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(-\frac{M \cdot D}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. distribute-frac-neg60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{-M \cdot D}{-d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. distribute-lft-neg-in60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(-M\right) \cdot D}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. *-commutative60.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot \left(-M\right)}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{-M}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-*l*58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{-M}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
      9. neg-mul-158.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{\color{blue}{-1 \cdot M}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      10. distribute-rgt-neg-in58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{d \cdot \left(-2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      11. metadata-eval58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{d \cdot \color{blue}{-2}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      12. *-commutative58.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{-2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      13. times-frac57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(\frac{-1}{-2} \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      14. metadata-eval57.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(\color{blue}{0.5} \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    7. Simplified57.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Step-by-step derivation
      1. clear-num57.9%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      2. sqrt-div58.9%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      3. metadata-eval58.9%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    9. Applied egg-rr58.9%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    10. Taylor expanded in d around -inf 36.1%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    11. Simplified36.5%

      \[\leadsto \color{blue}{-\frac{d}{\sqrt{h \cdot \ell}}} \]

    if 1.1e-182 < d

    1. Initial program 73.9%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified73.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt73.9%

        \[\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. pow273.9%

        \[\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-prod73.9%

        \[\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. unpow273.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\sqrt{\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right) \cdot \left(\frac{M}{2} \cdot \frac{D}{d}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. sqrt-prod39.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. add-sqr-sqrt73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. frac-times73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-/l*73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. *-commutative73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr73.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(M \cdot \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. associate-*r/73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. remove-double-neg73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{M \cdot D}{\color{blue}{-\left(-d \cdot 2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. distribute-frac-neg273.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(-\frac{M \cdot D}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      4. distribute-frac-neg73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{-M \cdot D}{-d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. distribute-lft-neg-in73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(-M\right) \cdot D}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. *-commutative73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot \left(-M\right)}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. associate-/l*73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{-M}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. associate-*l*73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{-M}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
      9. neg-mul-173.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{\color{blue}{-1 \cdot M}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      10. distribute-rgt-neg-in73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{d \cdot \left(-2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      11. metadata-eval73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{d \cdot \color{blue}{-2}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      12. *-commutative73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{-2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      13. times-frac73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(\frac{-1}{-2} \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
      14. metadata-eval73.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(\color{blue}{0.5} \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    7. Simplified73.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
    8. Taylor expanded in d around inf 46.2%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. unpow-146.2%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. metadata-eval46.2%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr46.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square46.1%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt45.9%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr45.9%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt46.1%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    10. Simplified46.1%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification40.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 1.1 \cdot 10^{-182}:\\ \;\;\;\;\frac{d}{-\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 22: 26.4% accurate, 3.2× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \frac{d}{\sqrt{\ell \cdot h}} \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 (* l 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) {
	return d / sqrt((l * h));
}
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((l * h))
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((l * h));
}
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((l * h))
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(l * h)))
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((l * h));
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[(l * 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])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Derivation
  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. Simplified62.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-sqrt62.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. pow262.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-prod62.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. unpow262.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\sqrt{\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right) \cdot \left(\frac{M}{2} \cdot \frac{D}{d}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. sqrt-prod34.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    6. add-sqr-sqrt63.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. frac-times65.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    8. associate-/l*63.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 \frac{D}{2 \cdot d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    9. *-commutative63.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \frac{D}{\color{blue}{d \cdot 2}}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
  5. Applied egg-rr63.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 \frac{D}{d \cdot 2}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
  6. Step-by-step derivation
    1. associate-*r/65.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{M \cdot D}{d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    2. remove-double-neg65.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{M \cdot D}{\color{blue}{-\left(-d \cdot 2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    3. distribute-frac-neg265.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 \cdot D}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    4. distribute-frac-neg65.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\frac{-M \cdot D}{-d \cdot 2}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. distribute-lft-neg-in65.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{\left(-M\right) \cdot D}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    6. *-commutative65.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\color{blue}{D \cdot \left(-M\right)}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    7. associate-/l*63.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(D \cdot \frac{-M}{-d \cdot 2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    8. associate-*l*63.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(D \cdot \left(\frac{-M}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}}^{2}\right) \]
    9. neg-mul-163.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{\color{blue}{-1 \cdot M}}{-d \cdot 2} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    10. distribute-rgt-neg-in63.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{d \cdot \left(-2\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    11. metadata-eval63.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{d \cdot \color{blue}{-2}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    12. *-commutative63.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\frac{-1 \cdot M}{\color{blue}{-2 \cdot d}} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    13. times-frac63.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\color{blue}{\left(\frac{-1}{-2} \cdot \frac{M}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
    14. metadata-eval63.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(D \cdot \left(\left(\color{blue}{0.5} \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}\right) \]
  7. Simplified63.8%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(D \cdot \left(\left(0.5 \cdot \frac{M}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)\right)}^{2}}\right) \]
  8. Taylor expanded in d around inf 22.5%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  9. Step-by-step derivation
    1. unpow-122.5%

      \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
    2. metadata-eval22.5%

      \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
    3. pow-sqr22.5%

      \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
    4. rem-sqrt-square22.1%

      \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
    5. rem-square-sqrt22.0%

      \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
    6. fabs-sqr22.0%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
    7. rem-square-sqrt22.1%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. rem-exp-log16.4%

      \[\leadsto \color{blue}{e^{\log d}} \cdot {\left(h \cdot \ell\right)}^{-0.5} \]
    9. rem-exp-log16.3%

      \[\leadsto e^{\log d} \cdot \color{blue}{e^{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
    10. exp-sum16.1%

      \[\leadsto \color{blue}{e^{\log d + \log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
    11. log-pow16.1%

      \[\leadsto e^{\log d + \color{blue}{-0.5 \cdot \log \left(h \cdot \ell\right)}} \]
    12. metadata-eval16.1%

      \[\leadsto e^{\log d + \color{blue}{\left(0.5 \cdot -1\right)} \cdot \log \left(h \cdot \ell\right)} \]
    13. associate-*r*16.1%

      \[\leadsto e^{\log d + \color{blue}{0.5 \cdot \left(-1 \cdot \log \left(h \cdot \ell\right)\right)}} \]
    14. neg-mul-116.1%

      \[\leadsto e^{\log d + 0.5 \cdot \color{blue}{\left(-\log \left(h \cdot \ell\right)\right)}} \]
    15. distribute-rgt-neg-out16.1%

      \[\leadsto e^{\log d + \color{blue}{\left(-0.5 \cdot \log \left(h \cdot \ell\right)\right)}} \]
    16. log-pow16.1%

      \[\leadsto e^{\log d + \left(-\color{blue}{\log \left({\left(h \cdot \ell\right)}^{0.5}\right)}\right)} \]
    17. unpow1/216.1%

      \[\leadsto e^{\log d + \left(-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}\right)} \]
    18. sub-neg16.1%

      \[\leadsto e^{\color{blue}{\log d - \log \left(\sqrt{h \cdot \ell}\right)}} \]
    19. log-div17.4%

      \[\leadsto e^{\color{blue}{\log \left(\frac{d}{\sqrt{h \cdot \ell}}\right)}} \]
  10. Simplified22.1%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  11. Final simplification22.1%

    \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
  12. Add Preprocessing

Alternative 23: 4.5% accurate, 3.2× 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{0} \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 0.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) {
	return d * sqrt(0.0);
}
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(0.0d0)
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(0.0);
}
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(0.0)
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(0.0))
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(0.0);
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[0.0], $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{0}
\end{array}
Derivation
  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. Simplified62.2%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in d around inf 22.5%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  5. Step-by-step derivation
    1. expm1-log1p-u21.8%

      \[\leadsto d \cdot \sqrt{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)\right)}} \]
    2. expm1-undefine15.8%

      \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1}} \]
    3. associate-/r*15.8%

      \[\leadsto d \cdot \sqrt{e^{\mathsf{log1p}\left(\color{blue}{\frac{\frac{1}{h}}{\ell}}\right)} - 1} \]
  6. Applied egg-rr15.8%

    \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{h}}{\ell}\right)} - 1}} \]
  7. Taylor expanded in h around inf 3.7%

    \[\leadsto d \cdot \sqrt{\color{blue}{1} - 1} \]
  8. Final simplification3.7%

    \[\leadsto d \cdot \sqrt{0} \]
  9. Add Preprocessing

Reproduce

?
herbie shell --seed 2024052 
(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)))))