Henrywood and Agarwal, Equation (12)

Percentage Accurate: 65.8% → 79.6%
Time: 25.9s
Alternatives: 25
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 25 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: 65.8% 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.6% accurate, 0.6× speedup?

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

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

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


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

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*52.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
    7. Step-by-step derivation
      1. frac-2neg52.8%

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

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

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

    if -8.19999999999999987e-79 < l < -1.999999999999994e-310

    1. Initial program 68.6%

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*75.7%

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

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

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

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

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

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

    if -1.999999999999994e-310 < l

    1. Initial program 62.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. Simplified60.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d}}{\sqrt{h}} \cdot \left(\color{blue}{\left(\sqrt{d} \cdot \frac{1}{\sqrt{\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)\right) \]
    8. Applied egg-rr83.3%

      \[\leadsto \frac{\sqrt{d}}{\sqrt{h}} \cdot \left(\color{blue}{\left(\sqrt{d} \cdot \frac{1}{\sqrt{\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)\right) \]
    9. Step-by-step derivation
      1. associate-*r/83.4%

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

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

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

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

Alternative 2: 69.9% accurate, 0.4× speedup?

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

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


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

    1. Initial program 85.2%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      2. pow284.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. sqrt-prod84.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      4. sqrt-pow186.4%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      7. div-inv86.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 68.9% accurate, 0.5× speedup?

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

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


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

    1. Initial program 85.2%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 77.3% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 54.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. Simplified54.0%

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

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

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

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

    if -6.50000000000000006e-55 < l < -1.999999999999994e-310

    1. Initial program 65.7%

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*74.7%

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

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

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

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

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

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

    if -1.999999999999994e-310 < l

    1. Initial program 62.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. Simplified60.6%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*62.2%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 77.2% accurate, 0.8× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := 1 - 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\ell}\\ t_1 := \sqrt{\frac{d}{\ell}} \cdot t_0\\ t_2 := \sqrt{-d}\\ \mathbf{if}\;\ell \leq -9 \cdot 10^{-71}:\\ \;\;\;\;\frac{t_2}{\sqrt{-h}} \cdot t_1\\ \mathbf{elif}\;\ell \leq -1.7 \cdot 10^{-304}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{t_2}{\sqrt{-\ell}} \cdot t_0\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot t_1\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (- 1.0 (* 0.5 (/ (* h (pow (* M (* 0.5 (/ D d))) 2.0)) l))))
        (t_1 (* (sqrt (/ d l)) t_0))
        (t_2 (sqrt (- d))))
   (if (<= l -9e-71)
     (* (/ t_2 (sqrt (- h))) t_1)
     (if (<= l -1.7e-304)
       (* (sqrt (/ d h)) (* (/ t_2 (sqrt (- l))) t_0))
       (* (/ (sqrt d) (sqrt h)) t_1)))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = 1.0 - (0.5 * ((h * pow((M * (0.5 * (D / d))), 2.0)) / l));
	double t_1 = sqrt((d / l)) * t_0;
	double t_2 = sqrt(-d);
	double tmp;
	if (l <= -9e-71) {
		tmp = (t_2 / sqrt(-h)) * t_1;
	} else if (l <= -1.7e-304) {
		tmp = sqrt((d / h)) * ((t_2 / sqrt(-l)) * t_0);
	} else {
		tmp = (sqrt(d) / sqrt(h)) * t_1;
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = 1.0d0 - (0.5d0 * ((h * ((m * (0.5d0 * (d_1 / d))) ** 2.0d0)) / l))
    t_1 = sqrt((d / l)) * t_0
    t_2 = sqrt(-d)
    if (l <= (-9d-71)) then
        tmp = (t_2 / sqrt(-h)) * t_1
    else if (l <= (-1.7d-304)) then
        tmp = sqrt((d / h)) * ((t_2 / sqrt(-l)) * t_0)
    else
        tmp = (sqrt(d) / sqrt(h)) * t_1
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = 1.0 - (0.5 * ((h * Math.pow((M * (0.5 * (D / d))), 2.0)) / l));
	double t_1 = Math.sqrt((d / l)) * t_0;
	double t_2 = Math.sqrt(-d);
	double tmp;
	if (l <= -9e-71) {
		tmp = (t_2 / Math.sqrt(-h)) * t_1;
	} else if (l <= -1.7e-304) {
		tmp = Math.sqrt((d / h)) * ((t_2 / Math.sqrt(-l)) * t_0);
	} else {
		tmp = (Math.sqrt(d) / Math.sqrt(h)) * t_1;
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = 1.0 - (0.5 * ((h * math.pow((M * (0.5 * (D / d))), 2.0)) / l))
	t_1 = math.sqrt((d / l)) * t_0
	t_2 = math.sqrt(-d)
	tmp = 0
	if l <= -9e-71:
		tmp = (t_2 / math.sqrt(-h)) * t_1
	elif l <= -1.7e-304:
		tmp = math.sqrt((d / h)) * ((t_2 / math.sqrt(-l)) * t_0)
	else:
		tmp = (math.sqrt(d) / math.sqrt(h)) * t_1
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0)) / l)))
	t_1 = Float64(sqrt(Float64(d / l)) * t_0)
	t_2 = sqrt(Float64(-d))
	tmp = 0.0
	if (l <= -9e-71)
		tmp = Float64(Float64(t_2 / sqrt(Float64(-h))) * t_1);
	elseif (l <= -1.7e-304)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(t_2 / sqrt(Float64(-l))) * t_0));
	else
		tmp = Float64(Float64(sqrt(d) / sqrt(h)) * t_1);
	end
	return tmp
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = 1.0 - (0.5 * ((h * ((M * (0.5 * (D / d))) ^ 2.0)) / l));
	t_1 = sqrt((d / l)) * t_0;
	t_2 = sqrt(-d);
	tmp = 0.0;
	if (l <= -9e-71)
		tmp = (t_2 / sqrt(-h)) * t_1;
	elseif (l <= -1.7e-304)
		tmp = sqrt((d / h)) * ((t_2 / sqrt(-l)) * t_0);
	else
		tmp = (sqrt(d) / sqrt(h)) * t_1;
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[l, -9e-71], N[(N[(t$95$2 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[l, -1.7e-304], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(t$95$2 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := 1 - 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\ell}\\
t_1 := \sqrt{\frac{d}{\ell}} \cdot t_0\\
t_2 := \sqrt{-d}\\
\mathbf{if}\;\ell \leq -9 \cdot 10^{-71}:\\
\;\;\;\;\frac{t_2}{\sqrt{-h}} \cdot t_1\\

\mathbf{elif}\;\ell \leq -1.7 \cdot 10^{-304}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{t_2}{\sqrt{-\ell}} \cdot t_0\right)\\

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


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

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*52.8%

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

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

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

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

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

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

    if -9.0000000000000004e-71 < l < -1.6999999999999999e-304

    1. Initial program 70.2%

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*77.4%

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

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

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

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

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

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

    if -1.6999999999999999e-304 < l

    1. Initial program 61.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. Simplified60.2%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*61.8%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9 \cdot 10^{-71}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\ell}\right)\right)\\ \mathbf{elif}\;\ell \leq -1.7 \cdot 10^{-304}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\ell}\right)\right)\\ \end{array} \]

Alternative 6: 77.6% accurate, 0.8× speedup?

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

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

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


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

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*52.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
    7. Step-by-step derivation
      1. frac-2neg52.8%

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

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

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

    if -3.9999999999999999e-69 < l < -1.999999999999994e-310

    1. Initial program 68.6%

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*75.7%

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

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

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

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

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

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

    if -1.999999999999994e-310 < l

    1. Initial program 62.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. Simplified60.6%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*62.2%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 70.2% accurate, 0.8× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h}}\\ \mathbf{if}\;d \leq 1.12 \cdot 10^{-302}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{\left(0.5 \cdot M\right) \cdot D}{d}\right)}^{2}}{\ell}\right)\right) \cdot t_0\\ \mathbf{elif}\;d \leq 7 \cdot 10^{-211}:\\ \;\;\;\;-0.125 \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}} \cdot {D}^{2}}{\frac{d}{{M}^{2}}}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(\left(1 - 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\ell}\right) \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (/ d h))))
   (if (<= d 1.12e-302)
     (*
      (*
       (sqrt (/ d l))
       (- 1.0 (* 0.5 (/ (* h (pow (/ (* (* 0.5 M) D) d) 2.0)) l))))
      t_0)
     (if (<= d 7e-211)
       (*
        -0.125
        (/ (* (sqrt (/ h (pow l 3.0))) (pow D 2.0)) (/ d (pow M 2.0))))
       (*
        t_0
        (*
         (- 1.0 (* 0.5 (/ (* h (pow (* M (* 0.5 (/ D d))) 2.0)) l)))
         (/ (sqrt d) (sqrt l))))))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / h));
	double tmp;
	if (d <= 1.12e-302) {
		tmp = (sqrt((d / l)) * (1.0 - (0.5 * ((h * pow((((0.5 * M) * D) / d), 2.0)) / l)))) * t_0;
	} else if (d <= 7e-211) {
		tmp = -0.125 * ((sqrt((h / pow(l, 3.0))) * pow(D, 2.0)) / (d / pow(M, 2.0)));
	} else {
		tmp = t_0 * ((1.0 - (0.5 * ((h * pow((M * (0.5 * (D / d))), 2.0)) / l))) * (sqrt(d) / sqrt(l)));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((d / h))
    if (d <= 1.12d-302) then
        tmp = (sqrt((d / l)) * (1.0d0 - (0.5d0 * ((h * ((((0.5d0 * m) * d_1) / d) ** 2.0d0)) / l)))) * t_0
    else if (d <= 7d-211) then
        tmp = (-0.125d0) * ((sqrt((h / (l ** 3.0d0))) * (d_1 ** 2.0d0)) / (d / (m ** 2.0d0)))
    else
        tmp = t_0 * ((1.0d0 - (0.5d0 * ((h * ((m * (0.5d0 * (d_1 / d))) ** 2.0d0)) / l))) * (sqrt(d) / sqrt(l)))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt((d / h));
	double tmp;
	if (d <= 1.12e-302) {
		tmp = (Math.sqrt((d / l)) * (1.0 - (0.5 * ((h * Math.pow((((0.5 * M) * D) / d), 2.0)) / l)))) * t_0;
	} else if (d <= 7e-211) {
		tmp = -0.125 * ((Math.sqrt((h / Math.pow(l, 3.0))) * Math.pow(D, 2.0)) / (d / Math.pow(M, 2.0)));
	} else {
		tmp = t_0 * ((1.0 - (0.5 * ((h * Math.pow((M * (0.5 * (D / d))), 2.0)) / l))) * (Math.sqrt(d) / Math.sqrt(l)));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt((d / h))
	tmp = 0
	if d <= 1.12e-302:
		tmp = (math.sqrt((d / l)) * (1.0 - (0.5 * ((h * math.pow((((0.5 * M) * D) / d), 2.0)) / l)))) * t_0
	elif d <= 7e-211:
		tmp = -0.125 * ((math.sqrt((h / math.pow(l, 3.0))) * math.pow(D, 2.0)) / (d / math.pow(M, 2.0)))
	else:
		tmp = t_0 * ((1.0 - (0.5 * ((h * math.pow((M * (0.5 * (D / d))), 2.0)) / l))) * (math.sqrt(d) / math.sqrt(l)))
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(d / h))
	tmp = 0.0
	if (d <= 1.12e-302)
		tmp = Float64(Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(Float64(0.5 * M) * D) / d) ^ 2.0)) / l)))) * t_0);
	elseif (d <= 7e-211)
		tmp = Float64(-0.125 * Float64(Float64(sqrt(Float64(h / (l ^ 3.0))) * (D ^ 2.0)) / Float64(d / (M ^ 2.0))));
	else
		tmp = Float64(t_0 * Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0)) / l))) * Float64(sqrt(d) / sqrt(l))));
	end
	return tmp
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt((d / h));
	tmp = 0.0;
	if (d <= 1.12e-302)
		tmp = (sqrt((d / l)) * (1.0 - (0.5 * ((h * ((((0.5 * M) * D) / d) ^ 2.0)) / l)))) * t_0;
	elseif (d <= 7e-211)
		tmp = -0.125 * ((sqrt((h / (l ^ 3.0))) * (D ^ 2.0)) / (d / (M ^ 2.0)));
	else
		tmp = t_0 * ((1.0 - (0.5 * ((h * ((M * (0.5 * (D / d))) ^ 2.0)) / l))) * (sqrt(d) / sqrt(l)));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, 1.12e-302], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(N[(0.5 * M), $MachinePrecision] * D), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[d, 7e-211], N[(-0.125 * N[(N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Power[D, 2.0], $MachinePrecision]), $MachinePrecision] / N[(d / N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}}\\
\mathbf{if}\;d \leq 1.12 \cdot 10^{-302}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{\left(0.5 \cdot M\right) \cdot D}{d}\right)}^{2}}{\ell}\right)\right) \cdot t_0\\

\mathbf{elif}\;d \leq 7 \cdot 10^{-211}:\\
\;\;\;\;-0.125 \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}} \cdot {D}^{2}}{\frac{d}{{M}^{2}}}\\

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


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

    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. Simplified58.5%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*61.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]

    if 1.12e-302 < d < 7e-211

    1. Initial program 34.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. Simplified34.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -0.125 \cdot \color{blue}{\frac{\sqrt{\frac{h}{{\ell}^{3}}} \cdot {D}^{2}}{\frac{d}{{M}^{2}}}} \]
    9. Simplified63.6%

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

    if 7e-211 < d

    1. Initial program 69.2%

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*69.5%

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

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

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

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

        \[\leadsto \frac{\sqrt{d}}{\sqrt{h}} \cdot \left(\color{blue}{\left(\sqrt{d} \cdot \frac{1}{\sqrt{\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)\right) \]
    6. Applied egg-rr78.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 1.12 \cdot 10^{-302}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{\left(0.5 \cdot M\right) \cdot D}{d}\right)}^{2}}{\ell}\right)\right) \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 7 \cdot 10^{-211}:\\ \;\;\;\;-0.125 \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}} \cdot {D}^{2}}{\frac{d}{{M}^{2}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\left(1 - 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\ell}\right) \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right)\\ \end{array} \]

Alternative 8: 70.5% accurate, 0.8× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h}}\\ t_1 := 1 - 0.5 \cdot \frac{h \cdot {\left(\frac{\left(0.5 \cdot M\right) \cdot D}{d}\right)}^{2}}{\ell}\\ \mathbf{if}\;d \leq 7.6 \cdot 10^{-303}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot t_1\right) \cdot t_0\\ \mathbf{elif}\;d \leq 4.2 \cdot 10^{-211}:\\ \;\;\;\;-0.125 \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}} \cdot {D}^{2}}{\frac{d}{{M}^{2}}}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(t_1 \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (/ d h)))
        (t_1 (- 1.0 (* 0.5 (/ (* h (pow (/ (* (* 0.5 M) D) d) 2.0)) l)))))
   (if (<= d 7.6e-303)
     (* (* (sqrt (/ d l)) t_1) t_0)
     (if (<= d 4.2e-211)
       (*
        -0.125
        (/ (* (sqrt (/ h (pow l 3.0))) (pow D 2.0)) (/ d (pow M 2.0))))
       (* t_0 (* t_1 (/ (sqrt d) (sqrt l))))))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / h));
	double t_1 = 1.0 - (0.5 * ((h * pow((((0.5 * M) * D) / d), 2.0)) / l));
	double tmp;
	if (d <= 7.6e-303) {
		tmp = (sqrt((d / l)) * t_1) * t_0;
	} else if (d <= 4.2e-211) {
		tmp = -0.125 * ((sqrt((h / pow(l, 3.0))) * pow(D, 2.0)) / (d / pow(M, 2.0)));
	} else {
		tmp = t_0 * (t_1 * (sqrt(d) / sqrt(l)));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = sqrt((d / h))
    t_1 = 1.0d0 - (0.5d0 * ((h * ((((0.5d0 * m) * d_1) / d) ** 2.0d0)) / l))
    if (d <= 7.6d-303) then
        tmp = (sqrt((d / l)) * t_1) * t_0
    else if (d <= 4.2d-211) then
        tmp = (-0.125d0) * ((sqrt((h / (l ** 3.0d0))) * (d_1 ** 2.0d0)) / (d / (m ** 2.0d0)))
    else
        tmp = t_0 * (t_1 * (sqrt(d) / sqrt(l)))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt((d / h));
	double t_1 = 1.0 - (0.5 * ((h * Math.pow((((0.5 * M) * D) / d), 2.0)) / l));
	double tmp;
	if (d <= 7.6e-303) {
		tmp = (Math.sqrt((d / l)) * t_1) * t_0;
	} else if (d <= 4.2e-211) {
		tmp = -0.125 * ((Math.sqrt((h / Math.pow(l, 3.0))) * Math.pow(D, 2.0)) / (d / Math.pow(M, 2.0)));
	} else {
		tmp = t_0 * (t_1 * (Math.sqrt(d) / Math.sqrt(l)));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt((d / h))
	t_1 = 1.0 - (0.5 * ((h * math.pow((((0.5 * M) * D) / d), 2.0)) / l))
	tmp = 0
	if d <= 7.6e-303:
		tmp = (math.sqrt((d / l)) * t_1) * t_0
	elif d <= 4.2e-211:
		tmp = -0.125 * ((math.sqrt((h / math.pow(l, 3.0))) * math.pow(D, 2.0)) / (d / math.pow(M, 2.0)))
	else:
		tmp = t_0 * (t_1 * (math.sqrt(d) / math.sqrt(l)))
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(d / h))
	t_1 = Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(Float64(0.5 * M) * D) / d) ^ 2.0)) / l)))
	tmp = 0.0
	if (d <= 7.6e-303)
		tmp = Float64(Float64(sqrt(Float64(d / l)) * t_1) * t_0);
	elseif (d <= 4.2e-211)
		tmp = Float64(-0.125 * Float64(Float64(sqrt(Float64(h / (l ^ 3.0))) * (D ^ 2.0)) / Float64(d / (M ^ 2.0))));
	else
		tmp = Float64(t_0 * Float64(t_1 * Float64(sqrt(d) / sqrt(l))));
	end
	return tmp
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt((d / h));
	t_1 = 1.0 - (0.5 * ((h * ((((0.5 * M) * D) / d) ^ 2.0)) / l));
	tmp = 0.0;
	if (d <= 7.6e-303)
		tmp = (sqrt((d / l)) * t_1) * t_0;
	elseif (d <= 4.2e-211)
		tmp = -0.125 * ((sqrt((h / (l ^ 3.0))) * (D ^ 2.0)) / (d / (M ^ 2.0)));
	else
		tmp = t_0 * (t_1 * (sqrt(d) / sqrt(l)));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(N[(0.5 * M), $MachinePrecision] * D), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, 7.6e-303], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[d, 4.2e-211], N[(-0.125 * N[(N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Power[D, 2.0], $MachinePrecision]), $MachinePrecision] / N[(d / N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(t$95$1 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}}\\
t_1 := 1 - 0.5 \cdot \frac{h \cdot {\left(\frac{\left(0.5 \cdot M\right) \cdot D}{d}\right)}^{2}}{\ell}\\
\mathbf{if}\;d \leq 7.6 \cdot 10^{-303}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot t_1\right) \cdot t_0\\

\mathbf{elif}\;d \leq 4.2 \cdot 10^{-211}:\\
\;\;\;\;-0.125 \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}} \cdot {D}^{2}}{\frac{d}{{M}^{2}}}\\

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


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

    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. Simplified58.5%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*61.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]

    if 7.60000000000000018e-303 < d < 4.20000000000000015e-211

    1. Initial program 34.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. Simplified34.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -0.125 \cdot \color{blue}{\frac{\sqrt{\frac{h}{{\ell}^{3}}} \cdot {D}^{2}}{\frac{d}{{M}^{2}}}} \]
    9. Simplified63.6%

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

    if 4.20000000000000015e-211 < d

    1. Initial program 69.2%

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*69.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
    7. Step-by-step derivation
      1. sqrt-div84.3%

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

        \[\leadsto \frac{\sqrt{d}}{\sqrt{h}} \cdot \left(\color{blue}{\left(\sqrt{d} \cdot \frac{1}{\sqrt{\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)\right) \]
    8. Applied egg-rr79.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 7.6 \cdot 10^{-303}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{\left(0.5 \cdot M\right) \cdot D}{d}\right)}^{2}}{\ell}\right)\right) \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;d \leq 4.2 \cdot 10^{-211}:\\ \;\;\;\;-0.125 \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}} \cdot {D}^{2}}{\frac{d}{{M}^{2}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{\left(0.5 \cdot M\right) \cdot D}{d}\right)}^{2}}{\ell}\right) \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right)\\ \end{array} \]

Alternative 9: 73.8% accurate, 0.8× speedup?

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

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


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

    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. Simplified58.6%

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

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

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

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

    if -1.999999999999994e-310 < h

    1. Initial program 62.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. Simplified60.6%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*62.2%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 75.3% accurate, 0.8× speedup?

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

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


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

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*62.0%

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

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

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

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

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

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

    if -1.6999999999999999e-304 < l

    1. Initial program 61.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. Simplified60.2%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*61.8%

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

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

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

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

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

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

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

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

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

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

Alternative 11: 75.9% accurate, 0.8× speedup?

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

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


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

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*62.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
    7. Step-by-step derivation
      1. frac-2neg62.0%

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

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

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

    if -1.6999999999999999e-304 < l

    1. Initial program 61.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. Simplified60.2%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*61.8%

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

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

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

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

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

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

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

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

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

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

Alternative 12: 71.6% accurate, 0.8× speedup?

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

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


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

    1. Initial program 58.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. Simplified58.2%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*61.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
    7. Step-by-step derivation
      1. clear-num61.3%

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

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

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

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

    if 1.06e-240 < l

    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. Simplified61.2%

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

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

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

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

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

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

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

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

Alternative 13: 72.7% accurate, 0.8× speedup?

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

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


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

    1. Initial program 59.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. Simplified59.6%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*62.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
    7. Step-by-step derivation
      1. clear-num61.9%

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

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

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

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

    if 2.5500000000000001e-284 < h

    1. Initial program 61.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. Simplified59.8%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*61.5%

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

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

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

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

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

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

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

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

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

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

Alternative 14: 66.0% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 1.7e74

    1. Initial program 62.3%

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

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

    if 1.7e74 < l

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

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

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

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

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

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

Alternative 15: 66.9% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 1.79999999999999994e74

    1. Initial program 62.3%

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

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

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

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

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

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

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

    if 1.79999999999999994e74 < l

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

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

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

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

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

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

Alternative 16: 68.1% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 1.4500000000000001e74

    1. Initial program 62.3%

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*63.6%

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

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

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

    if 1.4500000000000001e74 < l

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

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

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

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

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

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

Alternative 17: 69.0% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 1.7e74

    1. Initial program 62.3%

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

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. associate-*l*63.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]

    if 1.7e74 < l

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

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

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

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

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

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

Alternative 18: 57.5% accurate, 1.5× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 3.39999999999999996e38

    1. Initial program 62.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.39999999999999996e38 < l

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

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

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

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

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

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

Alternative 19: 39.7% accurate, 1.6× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -1.05 \cdot 10^{-135}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -1 \cdot 10^{-311}:\\ \;\;\;\;d \cdot \sqrt[3]{\frac{1}{{\left(\ell \cdot h\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (if (<= d -1.05e-135)
   (sqrt (/ (pow d 2.0) (* l h)))
   (if (<= d -1e-311)
     (* d (cbrt (/ 1.0 (pow (* l h) 1.5))))
     (* d (/ (sqrt (/ 1.0 h)) (sqrt l))))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -1.05e-135) {
		tmp = sqrt((pow(d, 2.0) / (l * h)));
	} else if (d <= -1e-311) {
		tmp = d * cbrt((1.0 / pow((l * h), 1.5)));
	} else {
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	}
	return tmp;
}
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -1.05e-135) {
		tmp = Math.sqrt((Math.pow(d, 2.0) / (l * h)));
	} else if (d <= -1e-311) {
		tmp = d * Math.cbrt((1.0 / Math.pow((l * h), 1.5)));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= -1.05e-135)
		tmp = sqrt(Float64((d ^ 2.0) / Float64(l * h)));
	elseif (d <= -1e-311)
		tmp = Float64(d * cbrt(Float64(1.0 / (Float64(l * h) ^ 1.5))));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / h)) / sqrt(l)));
	end
	return tmp
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := If[LessEqual[d, -1.05e-135], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -1e-311], N[(d * N[Power[N[(1.0 / N[Power[N[(l * h), $MachinePrecision], 1.5], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.05 \cdot 10^{-135}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\

\mathbf{elif}\;d \leq -1 \cdot 10^{-311}:\\
\;\;\;\;d \cdot \sqrt[3]{\frac{1}{{\left(\ell \cdot h\right)}^{1.5}}}\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      7. pow1/25.5%

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

        \[\leadsto d \cdot {\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{\left(1.5 \cdot 0.3333333333333333\right)}} \]
      9. pow-pow6.6%

        \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
      10. add-sqr-sqrt0.7%

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

        \[\leadsto \color{blue}{\sqrt{\left(d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}\right) \cdot \left(d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}\right)}} \]
      12. *-commutative31.7%

        \[\leadsto \sqrt{\color{blue}{\left({\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333} \cdot d\right)} \cdot \left(d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}\right)} \]
      13. *-commutative31.7%

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

        \[\leadsto \sqrt{\color{blue}{\left({\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333} \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}\right) \cdot \left(d \cdot d\right)}} \]
    11. Applied egg-rr30.9%

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

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot {d}^{2}}{h \cdot \ell}}} \]
      2. *-lft-identity30.9%

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{h \cdot \ell}} \]
    13. Simplified30.9%

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

    if -1.05e-135 < d < -9.99999999999948e-312

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

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

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}}} \]
      2. pow1/321.8%

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

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

        \[\leadsto d \cdot {\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{1}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)}^{0.3333333333333333} \]
      5. pow1/221.8%

        \[\leadsto d \cdot {\left({\left(\frac{1}{h \cdot \ell}\right)}^{1} \cdot \color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)}^{0.3333333333333333} \]
      6. pow-prod-up21.8%

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

        \[\leadsto d \cdot {\left({\color{blue}{\left(\frac{\frac{1}{h}}{\ell}\right)}}^{\left(1 + 0.5\right)}\right)}^{0.3333333333333333} \]
      8. metadata-eval21.8%

        \[\leadsto d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    4. Applied egg-rr21.8%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    5. Taylor expanded in h around 0 0.0%

      \[\leadsto d \cdot \color{blue}{{\left(e^{1.5 \cdot \left(\log \left(\frac{1}{\ell}\right) + -1 \cdot \log h\right)}\right)}^{0.3333333333333333}} \]
    6. Step-by-step derivation
      1. exp-prod0.0%

        \[\leadsto d \cdot {\color{blue}{\left({\left(e^{1.5}\right)}^{\left(\log \left(\frac{1}{\ell}\right) + -1 \cdot \log h\right)}\right)}}^{0.3333333333333333} \]
      2. mul-1-neg0.0%

        \[\leadsto d \cdot {\left({\left(e^{1.5}\right)}^{\left(\log \left(\frac{1}{\ell}\right) + \color{blue}{\left(-\log h\right)}\right)}\right)}^{0.3333333333333333} \]
      3. log-rec0.0%

        \[\leadsto d \cdot {\left({\left(e^{1.5}\right)}^{\left(\log \left(\frac{1}{\ell}\right) + \color{blue}{\log \left(\frac{1}{h}\right)}\right)}\right)}^{0.3333333333333333} \]
      4. +-commutative0.0%

        \[\leadsto d \cdot {\left({\left(e^{1.5}\right)}^{\color{blue}{\left(\log \left(\frac{1}{h}\right) + \log \left(\frac{1}{\ell}\right)\right)}}\right)}^{0.3333333333333333} \]
      5. exp-prod0.0%

        \[\leadsto d \cdot {\color{blue}{\left(e^{1.5 \cdot \left(\log \left(\frac{1}{h}\right) + \log \left(\frac{1}{\ell}\right)\right)}\right)}}^{0.3333333333333333} \]
      6. unpow1/30.0%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{e^{1.5 \cdot \left(\log \left(\frac{1}{h}\right) + \log \left(\frac{1}{\ell}\right)\right)}}} \]
      7. exp-prod0.0%

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

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

        \[\leadsto d \cdot \sqrt[3]{{\left(e^{1.5}\right)}^{\left(\color{blue}{\left(-\log h\right)} + \left(-\log \ell\right)\right)}} \]
      10. distribute-neg-in0.0%

        \[\leadsto d \cdot \sqrt[3]{{\left(e^{1.5}\right)}^{\color{blue}{\left(-\left(\log h + \log \ell\right)\right)}}} \]
      11. log-prod21.8%

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

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{e^{1.5 \cdot \left(-\log \left(h \cdot \ell\right)\right)}}} \]
      13. distribute-rgt-neg-out21.8%

        \[\leadsto d \cdot \sqrt[3]{e^{\color{blue}{-1.5 \cdot \log \left(h \cdot \ell\right)}}} \]
      14. rec-exp21.8%

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

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

        \[\leadsto d \cdot \sqrt[3]{\frac{1}{\color{blue}{{\left(h \cdot \ell\right)}^{1.5}}}} \]
    7. Simplified21.8%

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

    if -9.99999999999948e-312 < d

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

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

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

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    4. Applied egg-rr52.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.05 \cdot 10^{-135}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{elif}\;d \leq -1 \cdot 10^{-311}:\\ \;\;\;\;d \cdot \sqrt[3]{\frac{1}{{\left(\ell \cdot h\right)}^{1.5}}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 20: 38.0% accurate, 1.6× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq 1.45 \cdot 10^{-290}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (if (<= d 1.45e-290)
   (sqrt (/ (pow d 2.0) (* l h)))
   (* d (/ (sqrt (/ 1.0 h)) (sqrt l)))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= 1.45e-290) {
		tmp = sqrt((pow(d, 2.0) / (l * h)));
	} else {
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (d <= 1.45d-290) then
        tmp = sqrt(((d ** 2.0d0) / (l * h)))
    else
        tmp = d * (sqrt((1.0d0 / h)) / sqrt(l))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= 1.45e-290) {
		tmp = Math.sqrt((Math.pow(d, 2.0) / (l * h)));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if d <= 1.45e-290:
		tmp = math.sqrt((math.pow(d, 2.0) / (l * h)))
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= 1.45e-290)
		tmp = sqrt(Float64((d ^ 2.0) / Float64(l * h)));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / h)) / sqrt(l)));
	end
	return tmp
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (d <= 1.45e-290)
		tmp = sqrt(((d ^ 2.0) / (l * h)));
	else
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := If[LessEqual[d, 1.45e-290], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 1.45 \cdot 10^{-290}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\

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


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

    1. Initial program 57.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. Simplified57.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      7. pow1/27.3%

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

        \[\leadsto d \cdot {\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{\left(1.5 \cdot 0.3333333333333333\right)}} \]
      9. pow-pow11.2%

        \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
      10. add-sqr-sqrt2.4%

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

        \[\leadsto \color{blue}{\sqrt{\left(d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}\right) \cdot \left(d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}\right)}} \]
      12. *-commutative24.6%

        \[\leadsto \sqrt{\color{blue}{\left({\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333} \cdot d\right)} \cdot \left(d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}\right)} \]
      13. *-commutative24.6%

        \[\leadsto \sqrt{\left({\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333} \cdot d\right) \cdot \color{blue}{\left({\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333} \cdot d\right)}} \]
      14. swap-sqr21.6%

        \[\leadsto \sqrt{\color{blue}{\left({\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333} \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}\right) \cdot \left(d \cdot d\right)}} \]
    11. Applied egg-rr24.1%

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

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot {d}^{2}}{h \cdot \ell}}} \]
      2. *-lft-identity24.2%

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{h \cdot \ell}} \]
    13. Simplified24.2%

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

    if 1.44999999999999997e-290 < d

    1. Initial program 62.8%

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

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

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

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    4. Applied egg-rr53.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 1.45 \cdot 10^{-290}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 21: 35.0% accurate, 1.6× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -2.45 \cdot 10^{-138}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (if (<= d -2.45e-138)
   (sqrt (/ (pow d 2.0) (* l h)))
   (* d (sqrt (/ (/ 1.0 h) l)))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -2.45e-138) {
		tmp = sqrt((pow(d, 2.0) / (l * h)));
	} else {
		tmp = d * sqrt(((1.0 / h) / l));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (d <= (-2.45d-138)) then
        tmp = sqrt(((d ** 2.0d0) / (l * h)))
    else
        tmp = d * sqrt(((1.0d0 / h) / l))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -2.45e-138) {
		tmp = Math.sqrt((Math.pow(d, 2.0) / (l * h)));
	} else {
		tmp = d * Math.sqrt(((1.0 / h) / l));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if d <= -2.45e-138:
		tmp = math.sqrt((math.pow(d, 2.0) / (l * h)))
	else:
		tmp = d * math.sqrt(((1.0 / h) / l))
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= -2.45e-138)
		tmp = sqrt(Float64((d ^ 2.0) / Float64(l * h)));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / h) / l)));
	end
	return tmp
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (d <= -2.45e-138)
		tmp = sqrt(((d ^ 2.0) / (l * h)));
	else
		tmp = d * sqrt(((1.0 / h) / l));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := If[LessEqual[d, -2.45e-138], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.45 \cdot 10^{-138}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      7. pow1/25.5%

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

        \[\leadsto d \cdot {\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{\left(1.5 \cdot 0.3333333333333333\right)}} \]
      9. pow-pow6.6%

        \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
      10. add-sqr-sqrt0.7%

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

        \[\leadsto \color{blue}{\sqrt{\left(d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}\right) \cdot \left(d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}\right)}} \]
      12. *-commutative31.7%

        \[\leadsto \sqrt{\color{blue}{\left({\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333} \cdot d\right)} \cdot \left(d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}\right)} \]
      13. *-commutative31.7%

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

        \[\leadsto \sqrt{\color{blue}{\left({\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333} \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}\right) \cdot \left(d \cdot d\right)}} \]
    11. Applied egg-rr30.9%

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

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot {d}^{2}}{h \cdot \ell}}} \]
      2. *-lft-identity30.9%

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{h \cdot \ell}} \]
    13. Simplified30.9%

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

    if -2.45000000000000008e-138 < d

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.45 \cdot 10^{-138}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]

Alternative 22: 38.0% accurate, 1.6× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq 2.7 \cdot 10^{-290}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (if (<= d 2.7e-290)
   (sqrt (/ (pow d 2.0) (* l h)))
   (* d (/ (pow h -0.5) (sqrt l)))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= 2.7e-290) {
		tmp = sqrt((pow(d, 2.0) / (l * h)));
	} else {
		tmp = d * (pow(h, -0.5) / sqrt(l));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (d <= 2.7d-290) then
        tmp = sqrt(((d ** 2.0d0) / (l * h)))
    else
        tmp = d * ((h ** (-0.5d0)) / sqrt(l))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= 2.7e-290) {
		tmp = Math.sqrt((Math.pow(d, 2.0) / (l * h)));
	} else {
		tmp = d * (Math.pow(h, -0.5) / Math.sqrt(l));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if d <= 2.7e-290:
		tmp = math.sqrt((math.pow(d, 2.0) / (l * h)))
	else:
		tmp = d * (math.pow(h, -0.5) / math.sqrt(l))
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= 2.7e-290)
		tmp = sqrt(Float64((d ^ 2.0) / Float64(l * h)));
	else
		tmp = Float64(d * Float64((h ^ -0.5) / sqrt(l)));
	end
	return tmp
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (d <= 2.7e-290)
		tmp = sqrt(((d ^ 2.0) / (l * h)));
	else
		tmp = d * ((h ^ -0.5) / sqrt(l));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := If[LessEqual[d, 2.7e-290], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(d * N[(N[Power[h, -0.5], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 2.7 \cdot 10^{-290}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\

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


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

    1. Initial program 57.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. Simplified57.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      7. pow1/27.3%

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

        \[\leadsto d \cdot {\left(\frac{\frac{1}{h}}{\ell}\right)}^{\color{blue}{\left(1.5 \cdot 0.3333333333333333\right)}} \]
      9. pow-pow11.2%

        \[\leadsto d \cdot \color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
      10. add-sqr-sqrt2.4%

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

        \[\leadsto \color{blue}{\sqrt{\left(d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}\right) \cdot \left(d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}\right)}} \]
      12. *-commutative24.6%

        \[\leadsto \sqrt{\color{blue}{\left({\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333} \cdot d\right)} \cdot \left(d \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}\right)} \]
      13. *-commutative24.6%

        \[\leadsto \sqrt{\left({\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333} \cdot d\right) \cdot \color{blue}{\left({\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333} \cdot d\right)}} \]
      14. swap-sqr21.6%

        \[\leadsto \sqrt{\color{blue}{\left({\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333} \cdot {\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}\right) \cdot \left(d \cdot d\right)}} \]
    11. Applied egg-rr24.1%

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

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot {d}^{2}}{h \cdot \ell}}} \]
      2. *-lft-identity24.2%

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{h \cdot \ell}} \]
    13. Simplified24.2%

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

    if 2.69999999999999999e-290 < d

    1. Initial program 62.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      7. sqrt-div53.3%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
      8. inv-pow53.3%

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

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

        \[\leadsto d \cdot \frac{{h}^{\color{blue}{-0.5}}}{\sqrt{\ell}} \]
    11. Applied egg-rr53.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 2.7 \cdot 10^{-290}:\\ \;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{{h}^{-0.5}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 23: 26.4% accurate, 3.1× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ d \cdot \sqrt{\frac{1}{\ell \cdot h}} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D) :precision binary64 (* d (sqrt (/ 1.0 (* l h)))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d * sqrt((1.0 / (l * h)));
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    code = d * sqrt((1.0d0 / (l * h)))
end function
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.sqrt((1.0 / (l * h)));
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * math.sqrt((1.0 / (l * h)))
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d * sqrt(Float64(1.0 / Float64(l * h))))
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt((1.0 / (l * h)));
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot \sqrt{\frac{1}{\ell \cdot h}}
\end{array}
Derivation
  1. Initial program 60.4%

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

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

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

Alternative 24: 26.6% accurate, 3.1× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D) :precision binary64 (* d (sqrt (/ (/ 1.0 h) l))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d * sqrt(((1.0 / h) / l));
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    code = d * sqrt(((1.0d0 / h) / l))
end function
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.sqrt(((1.0 / h) / l));
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * math.sqrt(((1.0 / h) / l))
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d * sqrt(Float64(Float64(1.0 / h) / l)))
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt(((1.0 / h) / l));
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}
\end{array}
Derivation
  1. Initial program 60.4%

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

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

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

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  5. Final simplification25.0%

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

Alternative 25: 26.3% accurate, 3.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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