Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.9% → 73.4%
Time: 41.1s
Alternatives: 21
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 21 alternatives:

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

Initial Program: 66.9% 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: 73.4% accurate, 0.6× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{\ell}}\\ t_1 := \sqrt{\frac{d}{h}}\\ \mathbf{if}\;\ell \leq -8.8 \cdot 10^{+109}:\\ \;\;\;\;\left(t_1 \cdot {\left({\left(\frac{-1}{\ell}\right)}^{0.25} \cdot {\left(-d\right)}^{0.25}\right)}^{2}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left(t_1 \cdot t_0\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\left(M \cdot D\right) \cdot \sqrt{\frac{h}{\ell}}}{d} \cdot -0.5\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D}{d} \cdot \left(0.5 \cdot M\right)\right)}^{2}}{\ell}\right)\\ \end{array} \end{array} \]
NOTE: M 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 h))))
   (if (<= l -8.8e+109)
     (*
      (* t_1 (pow (* (pow (/ -1.0 l) 0.25) (pow (- d) 0.25)) 2.0))
      (- 1.0 (* 0.5 (* (pow (* (/ M 2.0) (/ D d)) 2.0) (/ h l)))))
     (if (<= l -5e-310)
       (*
        (* t_1 t_0)
        (- 1.0 (* 0.5 (pow (* (/ (* (* M D) (sqrt (/ h l))) d) -0.5) 2.0))))
       (*
        (* t_0 (/ (sqrt d) (sqrt h)))
        (- 1.0 (* 0.5 (/ (* h (pow (* (/ D d) (* 0.5 M)) 2.0)) l))))))))
M = abs(M);
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 / h));
	double tmp;
	if (l <= -8.8e+109) {
		tmp = (t_1 * pow((pow((-1.0 / l), 0.25) * pow(-d, 0.25)), 2.0)) * (1.0 - (0.5 * (pow(((M / 2.0) * (D / d)), 2.0) * (h / l))));
	} else if (l <= -5e-310) {
		tmp = (t_1 * t_0) * (1.0 - (0.5 * pow(((((M * D) * sqrt((h / l))) / d) * -0.5), 2.0)));
	} else {
		tmp = (t_0 * (sqrt(d) / sqrt(h))) * (1.0 - (0.5 * ((h * pow(((D / d) * (0.5 * M)), 2.0)) / l)));
	}
	return tmp;
}
NOTE: M 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 / l))
    t_1 = sqrt((d / h))
    if (l <= (-8.8d+109)) then
        tmp = (t_1 * (((((-1.0d0) / l) ** 0.25d0) * (-d ** 0.25d0)) ** 2.0d0)) * (1.0d0 - (0.5d0 * ((((m / 2.0d0) * (d_1 / d)) ** 2.0d0) * (h / l))))
    else if (l <= (-5d-310)) then
        tmp = (t_1 * t_0) * (1.0d0 - (0.5d0 * (((((m * d_1) * sqrt((h / l))) / d) * (-0.5d0)) ** 2.0d0)))
    else
        tmp = (t_0 * (sqrt(d) / sqrt(h))) * (1.0d0 - (0.5d0 * ((h * (((d_1 / d) * (0.5d0 * m)) ** 2.0d0)) / l)))
    end if
    code = tmp
end function
M = Math.abs(M);
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 / h));
	double tmp;
	if (l <= -8.8e+109) {
		tmp = (t_1 * Math.pow((Math.pow((-1.0 / l), 0.25) * Math.pow(-d, 0.25)), 2.0)) * (1.0 - (0.5 * (Math.pow(((M / 2.0) * (D / d)), 2.0) * (h / l))));
	} else if (l <= -5e-310) {
		tmp = (t_1 * t_0) * (1.0 - (0.5 * Math.pow(((((M * D) * Math.sqrt((h / l))) / d) * -0.5), 2.0)));
	} else {
		tmp = (t_0 * (Math.sqrt(d) / Math.sqrt(h))) * (1.0 - (0.5 * ((h * Math.pow(((D / d) * (0.5 * M)), 2.0)) / l)));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt((d / l))
	t_1 = math.sqrt((d / h))
	tmp = 0
	if l <= -8.8e+109:
		tmp = (t_1 * math.pow((math.pow((-1.0 / l), 0.25) * math.pow(-d, 0.25)), 2.0)) * (1.0 - (0.5 * (math.pow(((M / 2.0) * (D / d)), 2.0) * (h / l))))
	elif l <= -5e-310:
		tmp = (t_1 * t_0) * (1.0 - (0.5 * math.pow(((((M * D) * math.sqrt((h / l))) / d) * -0.5), 2.0)))
	else:
		tmp = (t_0 * (math.sqrt(d) / math.sqrt(h))) * (1.0 - (0.5 * ((h * math.pow(((D / d) * (0.5 * M)), 2.0)) / l)))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(d / l))
	t_1 = sqrt(Float64(d / h))
	tmp = 0.0
	if (l <= -8.8e+109)
		tmp = Float64(Float64(t_1 * (Float64((Float64(-1.0 / l) ^ 0.25) * (Float64(-d) ^ 0.25)) ^ 2.0)) * Float64(1.0 - Float64(0.5 * Float64((Float64(Float64(M / 2.0) * Float64(D / d)) ^ 2.0) * Float64(h / l)))));
	elseif (l <= -5e-310)
		tmp = Float64(Float64(t_1 * t_0) * Float64(1.0 - Float64(0.5 * (Float64(Float64(Float64(Float64(M * D) * sqrt(Float64(h / l))) / d) * -0.5) ^ 2.0))));
	else
		tmp = Float64(Float64(t_0 * Float64(sqrt(d) / sqrt(h))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(D / d) * Float64(0.5 * M)) ^ 2.0)) / l))));
	end
	return tmp
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt((d / l));
	t_1 = sqrt((d / h));
	tmp = 0.0;
	if (l <= -8.8e+109)
		tmp = (t_1 * ((((-1.0 / l) ^ 0.25) * (-d ^ 0.25)) ^ 2.0)) * (1.0 - (0.5 * ((((M / 2.0) * (D / d)) ^ 2.0) * (h / l))));
	elseif (l <= -5e-310)
		tmp = (t_1 * t_0) * (1.0 - (0.5 * (((((M * D) * sqrt((h / l))) / d) * -0.5) ^ 2.0)));
	else
		tmp = (t_0 * (sqrt(d) / sqrt(h))) * (1.0 - (0.5 * ((h * (((D / d) * (0.5 * M)) ^ 2.0)) / l)));
	end
	tmp_2 = tmp;
end
NOTE: M 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[N[(d / h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -8.8e+109], N[(N[(t$95$1 * N[Power[N[(N[Power[N[(-1.0 / l), $MachinePrecision], 0.25], $MachinePrecision] * N[Power[(-d), 0.25], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-310], N[(N[(t$95$1 * t$95$0), $MachinePrecision] * N[(1.0 - N[(0.5 * N[Power[N[(N[(N[(N[(M * D), $MachinePrecision] * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * -0.5), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(D / d), $MachinePrecision] * N[(0.5 * M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \sqrt{\frac{d}{h}}\\
\mathbf{if}\;\ell \leq -8.8 \cdot 10^{+109}:\\
\;\;\;\;\left(t_1 \cdot {\left({\left(\frac{-1}{\ell}\right)}^{0.25} \cdot {\left(-d\right)}^{0.25}\right)}^{2}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\\

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left({\left(\frac{-1}{\ell}\right)}^{0.25} \cdot e^{\log \left(\color{blue}{{\left(\sqrt{-1}\right)}^{2}} \cdot d\right) \cdot 0.25}\right)}^{2}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      8. exp-to-pow0.0%

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

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

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

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

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

    if -8.7999999999999997e109 < l < -4.999999999999985e-310

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 74.9%

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

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

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

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

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

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

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

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

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

Alternative 2: 71.0% accurate, 0.4× speedup?

\[\begin{array}{l} M = |M|\\ [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 \infty:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\left(M \cdot D\right) \cdot \sqrt{\frac{h}{\ell}}}{d} \cdot -0.5\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{-1 + e^{\mathsf{fma}\left(h, \ell, -\log \left(\ell \cdot h\right)\right)}}\\ \end{array} \end{array} \]
NOTE: M 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)))))
      INFINITY)
   (*
    (* (sqrt (/ d h)) (sqrt (/ d l)))
    (- 1.0 (* 0.5 (pow (* (/ (* (* M D) (sqrt (/ h l))) d) -0.5) 2.0))))
   (* d (sqrt (+ -1.0 (exp (fma h l (- (log (* l h))))))))))
M = abs(M);
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))))) <= ((double) INFINITY)) {
		tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * pow(((((M * D) * sqrt((h / l))) / d) * -0.5), 2.0)));
	} else {
		tmp = d * sqrt((-1.0 + exp(fma(h, l, -log((l * h))))));
	}
	return tmp;
}
M = abs(M)
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))))) <= Inf)
		tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * (Float64(Float64(Float64(Float64(M * D) * sqrt(Float64(h / l))) / d) * -0.5) ^ 2.0))));
	else
		tmp = Float64(d * sqrt(Float64(-1.0 + exp(fma(h, l, Float64(-log(Float64(l * h))))))));
	end
	return tmp
end
NOTE: M 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], Infinity], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[Power[N[(N[(N[(N[(M * D), $MachinePrecision] * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * -0.5), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(-1.0 + N[Exp[N[(h * l + (-N[Log[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[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 \infty:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\left(M \cdot D\right) \cdot \sqrt{\frac{h}{\ell}}}{d} \cdot -0.5\right)}^{2}\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{-1 + e^{\mathsf{fma}\left(h, \ell, -\log \left(\ell \cdot h\right)\right)}}\\


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

    1. Initial program 83.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. Simplified81.9%

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

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

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

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

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

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

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

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

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

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

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

    if +inf.0 < (*.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 0.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. Simplified0.1%

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u4.4%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{\ell}}{h}\right)} - 1}} \]
      3. associate-/l/4.6%

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

      \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1}} \]
    8. Taylor expanded in h around 0 2.4%

      \[\leadsto d \cdot \sqrt{e^{\color{blue}{\ell \cdot h + \left(\log \left(\frac{1}{\ell}\right) + -1 \cdot \log h\right)}} - 1} \]
    9. Step-by-step derivation
      1. *-commutative2.4%

        \[\leadsto d \cdot \sqrt{e^{\color{blue}{h \cdot \ell} + \left(\log \left(\frac{1}{\ell}\right) + -1 \cdot \log h\right)} - 1} \]
      2. fma-def2.4%

        \[\leadsto d \cdot \sqrt{e^{\color{blue}{\mathsf{fma}\left(h, \ell, \log \left(\frac{1}{\ell}\right) + -1 \cdot \log h\right)}} - 1} \]
      3. log-rec2.4%

        \[\leadsto d \cdot \sqrt{e^{\mathsf{fma}\left(h, \ell, \color{blue}{\left(-\log \ell\right)} + -1 \cdot \log h\right)} - 1} \]
      4. mul-1-neg2.4%

        \[\leadsto d \cdot \sqrt{e^{\mathsf{fma}\left(h, \ell, \left(-\log \ell\right) + \color{blue}{\left(-\log h\right)}\right)} - 1} \]
      5. distribute-neg-out2.4%

        \[\leadsto d \cdot \sqrt{e^{\mathsf{fma}\left(h, \ell, \color{blue}{-\left(\log \ell + \log h\right)}\right)} - 1} \]
      6. +-commutative2.4%

        \[\leadsto d \cdot \sqrt{e^{\mathsf{fma}\left(h, \ell, -\color{blue}{\left(\log h + \log \ell\right)}\right)} - 1} \]
      7. log-prod18.5%

        \[\leadsto d \cdot \sqrt{e^{\mathsf{fma}\left(h, \ell, -\color{blue}{\log \left(h \cdot \ell\right)}\right)} - 1} \]
    10. Simplified18.5%

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

    \[\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 \infty:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\left(M \cdot D\right) \cdot \sqrt{\frac{h}{\ell}}}{d} \cdot -0.5\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{-1 + e^{\mathsf{fma}\left(h, \ell, -\log \left(\ell \cdot h\right)\right)}}\\ \end{array} \]

Alternative 3: 70.1% accurate, 0.5× speedup?

\[\begin{array}{l} M = |M|\\ [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 \infty:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{-1 + e^{\mathsf{fma}\left(h, \ell, -\log \left(\ell \cdot h\right)\right)}}\\ \end{array} \end{array} \]
NOTE: M 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 INFINITY)
     t_0
     (* d (sqrt (+ -1.0 (exp (fma h l (- (log (* l h)))))))))))
M = abs(M);
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 <= ((double) INFINITY)) {
		tmp = t_0;
	} else {
		tmp = d * sqrt((-1.0 + exp(fma(h, l, -log((l * h))))));
	}
	return tmp;
}
M = abs(M)
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 <= Inf)
		tmp = t_0;
	else
		tmp = Float64(d * sqrt(Float64(-1.0 + exp(fma(h, l, Float64(-log(Float64(l * h))))))));
	end
	return tmp
end
NOTE: M 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, Infinity], t$95$0, N[(d * N[Sqrt[N[(-1.0 + N[Exp[N[(h * l + (-N[Log[N[(l * h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M = |M|\\
[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 \infty:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{-1 + e^{\mathsf{fma}\left(h, \ell, -\log \left(\ell \cdot h\right)\right)}}\\


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

    1. Initial program 83.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) \]

    if +inf.0 < (*.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 0.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. Simplified0.1%

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

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

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u4.4%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{\ell}}{h}\right)} - 1}} \]
      3. associate-/l/4.6%

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

      \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1}} \]
    8. Taylor expanded in h around 0 2.4%

      \[\leadsto d \cdot \sqrt{e^{\color{blue}{\ell \cdot h + \left(\log \left(\frac{1}{\ell}\right) + -1 \cdot \log h\right)}} - 1} \]
    9. Step-by-step derivation
      1. *-commutative2.4%

        \[\leadsto d \cdot \sqrt{e^{\color{blue}{h \cdot \ell} + \left(\log \left(\frac{1}{\ell}\right) + -1 \cdot \log h\right)} - 1} \]
      2. fma-def2.4%

        \[\leadsto d \cdot \sqrt{e^{\color{blue}{\mathsf{fma}\left(h, \ell, \log \left(\frac{1}{\ell}\right) + -1 \cdot \log h\right)}} - 1} \]
      3. log-rec2.4%

        \[\leadsto d \cdot \sqrt{e^{\mathsf{fma}\left(h, \ell, \color{blue}{\left(-\log \ell\right)} + -1 \cdot \log h\right)} - 1} \]
      4. mul-1-neg2.4%

        \[\leadsto d \cdot \sqrt{e^{\mathsf{fma}\left(h, \ell, \left(-\log \ell\right) + \color{blue}{\left(-\log h\right)}\right)} - 1} \]
      5. distribute-neg-out2.4%

        \[\leadsto d \cdot \sqrt{e^{\mathsf{fma}\left(h, \ell, \color{blue}{-\left(\log \ell + \log h\right)}\right)} - 1} \]
      6. +-commutative2.4%

        \[\leadsto d \cdot \sqrt{e^{\mathsf{fma}\left(h, \ell, -\color{blue}{\left(\log h + \log \ell\right)}\right)} - 1} \]
      7. log-prod18.5%

        \[\leadsto d \cdot \sqrt{e^{\mathsf{fma}\left(h, \ell, -\color{blue}{\log \left(h \cdot \ell\right)}\right)} - 1} \]
    10. Simplified18.5%

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

    \[\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 \infty:\\ \;\;\;\;\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}:\\ \;\;\;\;d \cdot \sqrt{-1 + e^{\mathsf{fma}\left(h, \ell, -\log \left(\ell \cdot h\right)\right)}}\\ \end{array} \]

Alternative 4: 69.1% accurate, 0.5× speedup?

\[\begin{array}{l} M = |M|\\ [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 \infty:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-0.125 \cdot \left(\frac{M \cdot \left(M \cdot \left(D \cdot D\right)\right)}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \end{array} \end{array} \]
NOTE: M 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 INFINITY)
     t_0
     (* -0.125 (* (/ (* M (* M (* D D))) d) (sqrt (/ h (pow l 3.0))))))))
M = abs(M);
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 <= ((double) INFINITY)) {
		tmp = t_0;
	} else {
		tmp = -0.125 * (((M * (M * (D * D))) / d) * sqrt((h / pow(l, 3.0))));
	}
	return tmp;
}
M = Math.abs(M);
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 <= Double.POSITIVE_INFINITY) {
		tmp = t_0;
	} else {
		tmp = -0.125 * (((M * (M * (D * D))) / d) * Math.sqrt((h / Math.pow(l, 3.0))));
	}
	return tmp;
}
M = abs(M)
[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 <= math.inf:
		tmp = t_0
	else:
		tmp = -0.125 * (((M * (M * (D * D))) / d) * math.sqrt((h / math.pow(l, 3.0))))
	return tmp
M = abs(M)
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 <= Inf)
		tmp = t_0;
	else
		tmp = Float64(-0.125 * Float64(Float64(Float64(M * Float64(M * Float64(D * D))) / d) * sqrt(Float64(h / (l ^ 3.0)))));
	end
	return tmp
end
M = abs(M)
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 <= Inf)
		tmp = t_0;
	else
		tmp = -0.125 * (((M * (M * (D * D))) / d) * sqrt((h / (l ^ 3.0))));
	end
	tmp_2 = tmp;
end
NOTE: M 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, Infinity], t$95$0, N[(-0.125 * N[(N[(N[(M * N[(M * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M = |M|\\
[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 \infty:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 83.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) \]

    if +inf.0 < (*.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 0.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. Simplified0.1%

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

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

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

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

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

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

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

    \[\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 \infty:\\ \;\;\;\;\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}:\\ \;\;\;\;-0.125 \cdot \left(\frac{M \cdot \left(M \cdot \left(D \cdot D\right)\right)}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \end{array} \]

Alternative 5: 72.3% accurate, 0.8× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{\ell}}\\ \mathbf{if}\;d \leq 1.3 \cdot 10^{-258}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot t_0\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\left(M \cdot D\right) \cdot \sqrt{\frac{h}{\ell}}}{d} \cdot -0.5\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D}{d} \cdot \left(0.5 \cdot M\right)\right)}^{2}}{\ell}\right)\\ \end{array} \end{array} \]
NOTE: M 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 (<= d 1.3e-258)
     (*
      (* (sqrt (/ d h)) t_0)
      (- 1.0 (* 0.5 (pow (* (/ (* (* M D) (sqrt (/ h l))) d) -0.5) 2.0))))
     (*
      (* t_0 (/ (sqrt d) (sqrt h)))
      (- 1.0 (* 0.5 (/ (* h (pow (* (/ D d) (* 0.5 M)) 2.0)) l)))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / l));
	double tmp;
	if (d <= 1.3e-258) {
		tmp = (sqrt((d / h)) * t_0) * (1.0 - (0.5 * pow(((((M * D) * sqrt((h / l))) / d) * -0.5), 2.0)));
	} else {
		tmp = (t_0 * (sqrt(d) / sqrt(h))) * (1.0 - (0.5 * ((h * pow(((D / d) * (0.5 * M)), 2.0)) / l)));
	}
	return tmp;
}
NOTE: M 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 (d <= 1.3d-258) then
        tmp = (sqrt((d / h)) * t_0) * (1.0d0 - (0.5d0 * (((((m * d_1) * sqrt((h / l))) / d) * (-0.5d0)) ** 2.0d0)))
    else
        tmp = (t_0 * (sqrt(d) / sqrt(h))) * (1.0d0 - (0.5d0 * ((h * (((d_1 / d) * (0.5d0 * m)) ** 2.0d0)) / l)))
    end if
    code = tmp
end function
M = Math.abs(M);
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 (d <= 1.3e-258) {
		tmp = (Math.sqrt((d / h)) * t_0) * (1.0 - (0.5 * Math.pow(((((M * D) * Math.sqrt((h / l))) / d) * -0.5), 2.0)));
	} else {
		tmp = (t_0 * (Math.sqrt(d) / Math.sqrt(h))) * (1.0 - (0.5 * ((h * Math.pow(((D / d) * (0.5 * M)), 2.0)) / l)));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt((d / l))
	tmp = 0
	if d <= 1.3e-258:
		tmp = (math.sqrt((d / h)) * t_0) * (1.0 - (0.5 * math.pow(((((M * D) * math.sqrt((h / l))) / d) * -0.5), 2.0)))
	else:
		tmp = (t_0 * (math.sqrt(d) / math.sqrt(h))) * (1.0 - (0.5 * ((h * math.pow(((D / d) * (0.5 * M)), 2.0)) / l)))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(d / l))
	tmp = 0.0
	if (d <= 1.3e-258)
		tmp = Float64(Float64(sqrt(Float64(d / h)) * t_0) * Float64(1.0 - Float64(0.5 * (Float64(Float64(Float64(Float64(M * D) * sqrt(Float64(h / l))) / d) * -0.5) ^ 2.0))));
	else
		tmp = Float64(Float64(t_0 * Float64(sqrt(d) / sqrt(h))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(D / d) * Float64(0.5 * M)) ^ 2.0)) / l))));
	end
	return tmp
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt((d / l));
	tmp = 0.0;
	if (d <= 1.3e-258)
		tmp = (sqrt((d / h)) * t_0) * (1.0 - (0.5 * (((((M * D) * sqrt((h / l))) / d) * -0.5) ^ 2.0)));
	else
		tmp = (t_0 * (sqrt(d) / sqrt(h))) * (1.0 - (0.5 * ((h * (((D / d) * (0.5 * M)) ^ 2.0)) / l)));
	end
	tmp_2 = tmp;
end
NOTE: M 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[d, 1.3e-258], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] * N[(1.0 - N[(0.5 * N[Power[N[(N[(N[(N[(M * D), $MachinePrecision] * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * -0.5), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(D / d), $MachinePrecision] * N[(0.5 * M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;d \leq 1.3 \cdot 10^{-258}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot t_0\right) \cdot \left(1 - 0.5 \cdot {\left(\frac{\left(M \cdot D\right) \cdot \sqrt{\frac{h}{\ell}}}{d} \cdot -0.5\right)}^{2}\right)\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.30000000000000009e-258 < d

    1. Initial program 79.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. Simplified78.3%

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

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

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

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

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

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

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

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

Alternative 6: 57.9% accurate, 1.0× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{if}\;D \leq 4.5 \cdot 10^{-20}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;D \leq 2.9 \cdot 10^{+138}:\\ \;\;\;\;t_0 \cdot \left(1 - 0.5 \cdot \left(\frac{D}{\frac{\ell}{D}} \cdot \left(0.25 \cdot \frac{h}{\frac{d \cdot d}{M \cdot M}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(0.25 \cdot {\left(\sqrt{\frac{h}{\ell}} \cdot \frac{M \cdot D}{d}\right)}^{2}\right)\right)\\ \end{array} \end{array} \]
NOTE: M 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)) (sqrt (/ d l)))))
   (if (<= D 4.5e-20)
     t_0
     (if (<= D 2.9e+138)
       (*
        t_0
        (- 1.0 (* 0.5 (* (/ D (/ l D)) (* 0.25 (/ h (/ (* d d) (* M M))))))))
       (*
        (sqrt (* (/ d h) (/ d l)))
        (+
         1.0
         (* -0.5 (* 0.25 (pow (* (sqrt (/ h l)) (/ (* M D) d)) 2.0)))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / h)) * sqrt((d / l));
	double tmp;
	if (D <= 4.5e-20) {
		tmp = t_0;
	} else if (D <= 2.9e+138) {
		tmp = t_0 * (1.0 - (0.5 * ((D / (l / D)) * (0.25 * (h / ((d * d) / (M * M)))))));
	} else {
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * (0.25 * pow((sqrt((h / l)) * ((M * D) / d)), 2.0))));
	}
	return tmp;
}
NOTE: M 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)) * sqrt((d / l))
    if (d_1 <= 4.5d-20) then
        tmp = t_0
    else if (d_1 <= 2.9d+138) then
        tmp = t_0 * (1.0d0 - (0.5d0 * ((d_1 / (l / d_1)) * (0.25d0 * (h / ((d * d) / (m * m)))))))
    else
        tmp = sqrt(((d / h) * (d / l))) * (1.0d0 + ((-0.5d0) * (0.25d0 * ((sqrt((h / l)) * ((m * d_1) / d)) ** 2.0d0))))
    end if
    code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt((d / h)) * Math.sqrt((d / l));
	double tmp;
	if (D <= 4.5e-20) {
		tmp = t_0;
	} else if (D <= 2.9e+138) {
		tmp = t_0 * (1.0 - (0.5 * ((D / (l / D)) * (0.25 * (h / ((d * d) / (M * M)))))));
	} else {
		tmp = Math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * (0.25 * Math.pow((Math.sqrt((h / l)) * ((M * D) / d)), 2.0))));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt((d / h)) * math.sqrt((d / l))
	tmp = 0
	if D <= 4.5e-20:
		tmp = t_0
	elif D <= 2.9e+138:
		tmp = t_0 * (1.0 - (0.5 * ((D / (l / D)) * (0.25 * (h / ((d * d) / (M * M)))))))
	else:
		tmp = math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * (0.25 * math.pow((math.sqrt((h / l)) * ((M * D) / d)), 2.0))))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)))
	tmp = 0.0
	if (D <= 4.5e-20)
		tmp = t_0;
	elseif (D <= 2.9e+138)
		tmp = Float64(t_0 * Float64(1.0 - Float64(0.5 * Float64(Float64(D / Float64(l / D)) * Float64(0.25 * Float64(h / Float64(Float64(d * d) / Float64(M * M))))))));
	else
		tmp = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 + Float64(-0.5 * Float64(0.25 * (Float64(sqrt(Float64(h / l)) * Float64(Float64(M * D) / d)) ^ 2.0)))));
	end
	return tmp
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt((d / h)) * sqrt((d / l));
	tmp = 0.0;
	if (D <= 4.5e-20)
		tmp = t_0;
	elseif (D <= 2.9e+138)
		tmp = t_0 * (1.0 - (0.5 * ((D / (l / D)) * (0.25 * (h / ((d * d) / (M * M)))))));
	else
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * (0.25 * ((sqrt((h / l)) * ((M * D) / d)) ^ 2.0))));
	end
	tmp_2 = tmp;
end
NOTE: M 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[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[D, 4.5e-20], t$95$0, If[LessEqual[D, 2.9e+138], N[(t$95$0 * N[(1.0 - N[(0.5 * N[(N[(D / N[(l / D), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(h / N[(N[(d * d), $MachinePrecision] / N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(0.25 * N[Power[N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * N[(N[(M * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;D \leq 4.5 \cdot 10^{-20}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;D \leq 2.9 \cdot 10^{+138}:\\
\;\;\;\;t_0 \cdot \left(1 - 0.5 \cdot \left(\frac{D}{\frac{\ell}{D}} \cdot \left(0.25 \cdot \frac{h}{\frac{d \cdot d}{M \cdot M}}\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if D < 4.5000000000000001e-20

    1. Initial program 67.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. Simplified67.0%

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

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

    if 4.5000000000000001e-20 < D < 2.9000000000000001e138

    1. Initial program 70.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. Simplified70.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.9000000000000001e138 < D

    1. Initial program 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 57.9% accurate, 1.0× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{if}\;D \leq 4.5 \cdot 10^{-20}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;D \leq 1.7 \cdot 10^{+142}:\\ \;\;\;\;t_0 \cdot \left(1 - 0.5 \cdot \left(\frac{D}{\frac{\ell}{D}} \cdot \left(0.25 \cdot \frac{h}{\frac{d \cdot d}{M \cdot M}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.125 \cdot {\left(\sqrt{\frac{h}{\ell}} \cdot \frac{D}{\frac{d}{M}}\right)}^{2}\right)\\ \end{array} \end{array} \]
NOTE: M 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)) (sqrt (/ d l)))))
   (if (<= D 4.5e-20)
     t_0
     (if (<= D 1.7e+142)
       (*
        t_0
        (- 1.0 (* 0.5 (* (/ D (/ l D)) (* 0.25 (/ h (/ (* d d) (* M M))))))))
       (*
        (sqrt (* (/ d h) (/ d l)))
        (+ 1.0 (* -0.125 (pow (* (sqrt (/ h l)) (/ D (/ d M))) 2.0))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / h)) * sqrt((d / l));
	double tmp;
	if (D <= 4.5e-20) {
		tmp = t_0;
	} else if (D <= 1.7e+142) {
		tmp = t_0 * (1.0 - (0.5 * ((D / (l / D)) * (0.25 * (h / ((d * d) / (M * M)))))));
	} else {
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.125 * pow((sqrt((h / l)) * (D / (d / M))), 2.0)));
	}
	return tmp;
}
NOTE: M 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)) * sqrt((d / l))
    if (d_1 <= 4.5d-20) then
        tmp = t_0
    else if (d_1 <= 1.7d+142) then
        tmp = t_0 * (1.0d0 - (0.5d0 * ((d_1 / (l / d_1)) * (0.25d0 * (h / ((d * d) / (m * m)))))))
    else
        tmp = sqrt(((d / h) * (d / l))) * (1.0d0 + ((-0.125d0) * ((sqrt((h / l)) * (d_1 / (d / m))) ** 2.0d0)))
    end if
    code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt((d / h)) * Math.sqrt((d / l));
	double tmp;
	if (D <= 4.5e-20) {
		tmp = t_0;
	} else if (D <= 1.7e+142) {
		tmp = t_0 * (1.0 - (0.5 * ((D / (l / D)) * (0.25 * (h / ((d * d) / (M * M)))))));
	} else {
		tmp = Math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.125 * Math.pow((Math.sqrt((h / l)) * (D / (d / M))), 2.0)));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt((d / h)) * math.sqrt((d / l))
	tmp = 0
	if D <= 4.5e-20:
		tmp = t_0
	elif D <= 1.7e+142:
		tmp = t_0 * (1.0 - (0.5 * ((D / (l / D)) * (0.25 * (h / ((d * d) / (M * M)))))))
	else:
		tmp = math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.125 * math.pow((math.sqrt((h / l)) * (D / (d / M))), 2.0)))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)))
	tmp = 0.0
	if (D <= 4.5e-20)
		tmp = t_0;
	elseif (D <= 1.7e+142)
		tmp = Float64(t_0 * Float64(1.0 - Float64(0.5 * Float64(Float64(D / Float64(l / D)) * Float64(0.25 * Float64(h / Float64(Float64(d * d) / Float64(M * M))))))));
	else
		tmp = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 + Float64(-0.125 * (Float64(sqrt(Float64(h / l)) * Float64(D / Float64(d / M))) ^ 2.0))));
	end
	return tmp
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt((d / h)) * sqrt((d / l));
	tmp = 0.0;
	if (D <= 4.5e-20)
		tmp = t_0;
	elseif (D <= 1.7e+142)
		tmp = t_0 * (1.0 - (0.5 * ((D / (l / D)) * (0.25 * (h / ((d * d) / (M * M)))))));
	else
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.125 * ((sqrt((h / l)) * (D / (d / M))) ^ 2.0)));
	end
	tmp_2 = tmp;
end
NOTE: M 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[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[D, 4.5e-20], t$95$0, If[LessEqual[D, 1.7e+142], N[(t$95$0 * N[(1.0 - N[(0.5 * N[(N[(D / N[(l / D), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(h / N[(N[(d * d), $MachinePrecision] / N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.125 * N[Power[N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * N[(D / N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;D \leq 4.5 \cdot 10^{-20}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;D \leq 1.7 \cdot 10^{+142}:\\
\;\;\;\;t_0 \cdot \left(1 - 0.5 \cdot \left(\frac{D}{\frac{\ell}{D}} \cdot \left(0.25 \cdot \frac{h}{\frac{d \cdot d}{M \cdot M}}\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if D < 4.5000000000000001e-20

    1. Initial program 67.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. Simplified67.0%

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

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

    if 4.5000000000000001e-20 < D < 1.6999999999999999e142

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.6999999999999999e142 < D

    1. Initial program 66.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 57.3% accurate, 1.0× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{if}\;D \leq 1.9 \cdot 10^{-20}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;D \leq 3 \cdot 10^{+142}:\\ \;\;\;\;t_0 \cdot \left(1 - 0.5 \cdot \left(\frac{D}{\frac{\ell}{D}} \cdot \left(0.25 \cdot \frac{h}{\frac{d \cdot d}{M \cdot M}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, -0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}, 1\right)\\ \end{array} \end{array} \]
NOTE: M 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)) (sqrt (/ d l)))))
   (if (<= D 1.9e-20)
     t_0
     (if (<= D 3e+142)
       (*
        t_0
        (- 1.0 (* 0.5 (* (/ D (/ l D)) (* 0.25 (/ h (/ (* d d) (* M M))))))))
       (*
        (sqrt (* (/ d h) (/ d l)))
        (fma (/ h l) (* -0.125 (pow (* D (/ M d)) 2.0)) 1.0))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / h)) * sqrt((d / l));
	double tmp;
	if (D <= 1.9e-20) {
		tmp = t_0;
	} else if (D <= 3e+142) {
		tmp = t_0 * (1.0 - (0.5 * ((D / (l / D)) * (0.25 * (h / ((d * d) / (M * M)))))));
	} else {
		tmp = sqrt(((d / h) * (d / l))) * fma((h / l), (-0.125 * pow((D * (M / d)), 2.0)), 1.0);
	}
	return tmp;
}
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)))
	tmp = 0.0
	if (D <= 1.9e-20)
		tmp = t_0;
	elseif (D <= 3e+142)
		tmp = Float64(t_0 * Float64(1.0 - Float64(0.5 * Float64(Float64(D / Float64(l / D)) * Float64(0.25 * Float64(h / Float64(Float64(d * d) / Float64(M * M))))))));
	else
		tmp = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * fma(Float64(h / l), Float64(-0.125 * (Float64(D * Float64(M / d)) ^ 2.0)), 1.0));
	end
	return tmp
end
NOTE: M 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[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[D, 1.9e-20], t$95$0, If[LessEqual[D, 3e+142], N[(t$95$0 * N[(1.0 - N[(0.5 * N[(N[(D / N[(l / D), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(h / N[(N[(d * d), $MachinePrecision] / N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(-0.125 * N[Power[N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;D \leq 1.9 \cdot 10^{-20}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;D \leq 3 \cdot 10^{+142}:\\
\;\;\;\;t_0 \cdot \left(1 - 0.5 \cdot \left(\frac{D}{\frac{\ell}{D}} \cdot \left(0.25 \cdot \frac{h}{\frac{d \cdot d}{M \cdot M}}\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if D < 1.8999999999999999e-20

    1. Initial program 67.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. Simplified67.0%

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

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

    if 1.8999999999999999e-20 < D < 2.99999999999999975e142

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.99999999999999975e142 < D

    1. Initial program 66.5%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq 1.9 \cdot 10^{-20}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;D \leq 3 \cdot 10^{+142}:\\ \;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{D}{\frac{\ell}{D}} \cdot \left(0.25 \cdot \frac{h}{\frac{d \cdot d}{M \cdot M}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, -0.125 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}, 1\right)\\ \end{array} \]

Alternative 9: 66.4% accurate, 1.0× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \end{array} \]
NOTE: M 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
 (*
  (- 1.0 (* 0.5 (* (pow (* (/ M 2.0) (/ D d)) 2.0) (/ h l))))
  (* (sqrt (/ d h)) (sqrt (/ d l)))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return (1.0 - (0.5 * (pow(((M / 2.0) * (D / d)), 2.0) * (h / l)))) * (sqrt((d / h)) * sqrt((d / l)));
}
NOTE: M 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 = (1.0d0 - (0.5d0 * ((((m / 2.0d0) * (d_1 / d)) ** 2.0d0) * (h / l)))) * (sqrt((d / h)) * sqrt((d / l)))
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return (1.0 - (0.5 * (Math.pow(((M / 2.0) * (D / d)), 2.0) * (h / l)))) * (Math.sqrt((d / h)) * Math.sqrt((d / l)));
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return (1.0 - (0.5 * (math.pow(((M / 2.0) * (D / d)), 2.0) * (h / l)))) * (math.sqrt((d / h)) * math.sqrt((d / l)))
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(Float64(1.0 - Float64(0.5 * Float64((Float64(Float64(M / 2.0) * Float64(D / d)) ^ 2.0) * Float64(h / l)))) * Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))))
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = (1.0 - (0.5 * ((((M / 2.0) * (D / d)) ^ 2.0) * (h / l)))) * (sqrt((d / h)) * sqrt((d / l)));
end
NOTE: M 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[(N[(1.0 - N[(0.5 * N[(N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)
\end{array}
Derivation
  1. Initial program 67.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. Simplified66.9%

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

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

Alternative 10: 68.2% accurate, 1.0× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D}{d} \cdot \left(0.5 \cdot M\right)\right)}^{2}}{\ell}\right) \end{array} \]
NOTE: M 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
 (*
  (* (sqrt (/ d h)) (sqrt (/ d l)))
  (- 1.0 (* 0.5 (/ (* h (pow (* (/ D d) (* 0.5 M)) 2.0)) l)))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h * pow(((D / d) * (0.5 * M)), 2.0)) / l)));
}
NOTE: M 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 = (sqrt((d / h)) * sqrt((d / l))) * (1.0d0 - (0.5d0 * ((h * (((d_1 / d) * (0.5d0 * m)) ** 2.0d0)) / l)))
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return (Math.sqrt((d / h)) * Math.sqrt((d / l))) * (1.0 - (0.5 * ((h * Math.pow(((D / d) * (0.5 * M)), 2.0)) / l)));
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return (math.sqrt((d / h)) * math.sqrt((d / l))) * (1.0 - (0.5 * ((h * math.pow(((D / d) * (0.5 * M)), 2.0)) / l)))
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(D / d) * Float64(0.5 * M)) ^ 2.0)) / l))))
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * ((h * (((D / d) * (0.5 * M)) ^ 2.0)) / l)));
end
NOTE: M 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[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(D / d), $MachinePrecision] * N[(0.5 * M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\frac{D}{d} \cdot \left(0.5 \cdot M\right)\right)}^{2}}{\ell}\right)
\end{array}
Derivation
  1. Initial program 67.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. Simplified66.9%

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

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

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

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

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

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

Alternative 11: 57.0% accurate, 1.4× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{if}\;D \leq 3 \cdot 10^{-16}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;D \leq 1.65 \cdot 10^{+142}:\\ \;\;\;\;t_0 \cdot \left(1 - 0.5 \cdot \left(\frac{D}{\frac{\ell}{D}} \cdot \left(0.25 \cdot \frac{h}{\frac{d \cdot d}{M \cdot M}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)\\ \end{array} \end{array} \]
NOTE: M 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)) (sqrt (/ d l)))))
   (if (<= D 3e-16)
     t_0
     (if (<= D 1.65e+142)
       (*
        t_0
        (- 1.0 (* 0.5 (* (/ D (/ l D)) (* 0.25 (/ h (/ (* d d) (* M M))))))))
       (*
        (sqrt (* (/ d h) (/ d l)))
        (+ 1.0 (* -0.5 (* (/ h l) (pow (* M (* 0.5 (/ D d))) 2.0)))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / h)) * sqrt((d / l));
	double tmp;
	if (D <= 3e-16) {
		tmp = t_0;
	} else if (D <= 1.65e+142) {
		tmp = t_0 * (1.0 - (0.5 * ((D / (l / D)) * (0.25 * (h / ((d * d) / (M * M)))))));
	} else {
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * pow((M * (0.5 * (D / d))), 2.0))));
	}
	return tmp;
}
NOTE: M 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)) * sqrt((d / l))
    if (d_1 <= 3d-16) then
        tmp = t_0
    else if (d_1 <= 1.65d+142) then
        tmp = t_0 * (1.0d0 - (0.5d0 * ((d_1 / (l / d_1)) * (0.25d0 * (h / ((d * d) / (m * m)))))))
    else
        tmp = sqrt(((d / h) * (d / l))) * (1.0d0 + ((-0.5d0) * ((h / l) * ((m * (0.5d0 * (d_1 / d))) ** 2.0d0))))
    end if
    code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt((d / h)) * Math.sqrt((d / l));
	double tmp;
	if (D <= 3e-16) {
		tmp = t_0;
	} else if (D <= 1.65e+142) {
		tmp = t_0 * (1.0 - (0.5 * ((D / (l / D)) * (0.25 * (h / ((d * d) / (M * M)))))));
	} else {
		tmp = Math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * Math.pow((M * (0.5 * (D / d))), 2.0))));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt((d / h)) * math.sqrt((d / l))
	tmp = 0
	if D <= 3e-16:
		tmp = t_0
	elif D <= 1.65e+142:
		tmp = t_0 * (1.0 - (0.5 * ((D / (l / D)) * (0.25 * (h / ((d * d) / (M * M)))))))
	else:
		tmp = math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * math.pow((M * (0.5 * (D / d))), 2.0))))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)))
	tmp = 0.0
	if (D <= 3e-16)
		tmp = t_0;
	elseif (D <= 1.65e+142)
		tmp = Float64(t_0 * Float64(1.0 - Float64(0.5 * Float64(Float64(D / Float64(l / D)) * Float64(0.25 * Float64(h / Float64(Float64(d * d) / Float64(M * M))))))));
	else
		tmp = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0)))));
	end
	return tmp
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt((d / h)) * sqrt((d / l));
	tmp = 0.0;
	if (D <= 3e-16)
		tmp = t_0;
	elseif (D <= 1.65e+142)
		tmp = t_0 * (1.0 - (0.5 * ((D / (l / D)) * (0.25 * (h / ((d * d) / (M * M)))))));
	else
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * ((M * (0.5 * (D / d))) ^ 2.0))));
	end
	tmp_2 = tmp;
end
NOTE: M 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[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[D, 3e-16], t$95$0, If[LessEqual[D, 1.65e+142], N[(t$95$0 * N[(1.0 - N[(0.5 * N[(N[(D / N[(l / D), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(h / N[(N[(d * d), $MachinePrecision] / N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;D \leq 3 \cdot 10^{-16}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;D \leq 1.65 \cdot 10^{+142}:\\
\;\;\;\;t_0 \cdot \left(1 - 0.5 \cdot \left(\frac{D}{\frac{\ell}{D}} \cdot \left(0.25 \cdot \frac{h}{\frac{d \cdot d}{M \cdot M}}\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if D < 2.99999999999999994e-16

    1. Initial program 67.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. Simplified67.0%

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

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

    if 2.99999999999999994e-16 < D < 1.6500000000000001e142

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.6500000000000001e142 < D

    1. Initial program 66.5%

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

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

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

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

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

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

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

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

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

Alternative 12: 49.3% accurate, 1.4× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h}}\\ t_1 := \sqrt{\frac{d}{\ell}}\\ \mathbf{if}\;M \leq 2 \cdot 10^{-213}:\\ \;\;\;\;t_0 \cdot t_1\\ \mathbf{elif}\;M \leq 1.5 \cdot 10^{-15}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(t_0 \cdot \left(-0.125 \cdot \left(\left(\left(M \cdot \frac{M}{d}\right) \cdot \frac{h}{d}\right) \cdot \left(D \cdot \frac{D}{\ell}\right)\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: M 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 (sqrt (/ d l))))
   (if (<= M 2e-213)
     (* t_0 t_1)
     (if (<= M 1.5e-15)
       (*
        (sqrt (* (/ d h) (/ d l)))
        (+ 1.0 (* -0.5 (* (/ h l) (pow (* M (* 0.5 (/ D d))) 2.0)))))
       (*
        t_1
        (* t_0 (* -0.125 (* (* (* M (/ M d)) (/ h d)) (* D (/ D l))))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / h));
	double t_1 = sqrt((d / l));
	double tmp;
	if (M <= 2e-213) {
		tmp = t_0 * t_1;
	} else if (M <= 1.5e-15) {
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * pow((M * (0.5 * (D / d))), 2.0))));
	} else {
		tmp = t_1 * (t_0 * (-0.125 * (((M * (M / d)) * (h / d)) * (D * (D / l)))));
	}
	return tmp;
}
NOTE: M 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 = sqrt((d / l))
    if (m <= 2d-213) then
        tmp = t_0 * t_1
    else if (m <= 1.5d-15) then
        tmp = sqrt(((d / h) * (d / l))) * (1.0d0 + ((-0.5d0) * ((h / l) * ((m * (0.5d0 * (d_1 / d))) ** 2.0d0))))
    else
        tmp = t_1 * (t_0 * ((-0.125d0) * (((m * (m / d)) * (h / d)) * (d_1 * (d_1 / l)))))
    end if
    code = tmp
end function
M = Math.abs(M);
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 = Math.sqrt((d / l));
	double tmp;
	if (M <= 2e-213) {
		tmp = t_0 * t_1;
	} else if (M <= 1.5e-15) {
		tmp = Math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * Math.pow((M * (0.5 * (D / d))), 2.0))));
	} else {
		tmp = t_1 * (t_0 * (-0.125 * (((M * (M / d)) * (h / d)) * (D * (D / l)))));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt((d / h))
	t_1 = math.sqrt((d / l))
	tmp = 0
	if M <= 2e-213:
		tmp = t_0 * t_1
	elif M <= 1.5e-15:
		tmp = math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * math.pow((M * (0.5 * (D / d))), 2.0))))
	else:
		tmp = t_1 * (t_0 * (-0.125 * (((M * (M / d)) * (h / d)) * (D * (D / l)))))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(d / h))
	t_1 = sqrt(Float64(d / l))
	tmp = 0.0
	if (M <= 2e-213)
		tmp = Float64(t_0 * t_1);
	elseif (M <= 1.5e-15)
		tmp = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0)))));
	else
		tmp = Float64(t_1 * Float64(t_0 * Float64(-0.125 * Float64(Float64(Float64(M * Float64(M / d)) * Float64(h / d)) * Float64(D * Float64(D / l))))));
	end
	return tmp
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt((d / h));
	t_1 = sqrt((d / l));
	tmp = 0.0;
	if (M <= 2e-213)
		tmp = t_0 * t_1;
	elseif (M <= 1.5e-15)
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * ((M * (0.5 * (D / d))) ^ 2.0))));
	else
		tmp = t_1 * (t_0 * (-0.125 * (((M * (M / d)) * (h / d)) * (D * (D / l)))));
	end
	tmp_2 = tmp;
end
NOTE: M 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[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M, 2e-213], N[(t$95$0 * t$95$1), $MachinePrecision], If[LessEqual[M, 1.5e-15], N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(t$95$0 * N[(-0.125 * N[(N[(N[(M * N[(M / d), $MachinePrecision]), $MachinePrecision] * N[(h / d), $MachinePrecision]), $MachinePrecision] * N[(D * N[(D / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}}\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;M \leq 2 \cdot 10^{-213}:\\
\;\;\;\;t_0 \cdot t_1\\

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

\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(t_0 \cdot \left(-0.125 \cdot \left(\left(\left(M \cdot \frac{M}{d}\right) \cdot \frac{h}{d}\right) \cdot \left(D \cdot \frac{D}{\ell}\right)\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if M < 1.9999999999999999e-213

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

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

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

    if 1.9999999999999999e-213 < M < 1.5e-15

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

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

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

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

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

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

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

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

    if 1.5e-15 < M

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\left(-0.125 \cdot \left(\frac{D \cdot D}{\ell} \cdot \frac{\left(M \cdot M\right) \cdot h}{d \cdot d}\right)\right)}\right) \]
    6. Taylor expanded in D around 0 22.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(-0.125 \cdot \left(\left(\left(\frac{M}{d} \cdot M\right) \cdot \frac{h}{d}\right) \cdot \color{blue}{\left(\frac{D}{\ell} \cdot D\right)}\right)\right)\right) \]
      14. *-commutative35.7%

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

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

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

Alternative 13: 50.0% accurate, 1.5× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 3.2 \cdot 10^{-213}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)\\ \end{array} \end{array} \]
NOTE: M 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 (<= M 3.2e-213)
   (* (sqrt (/ d h)) (sqrt (/ d l)))
   (*
    (sqrt (* (/ d h) (/ d l)))
    (+ 1.0 (* -0.5 (* (/ h l) (pow (* M (* 0.5 (/ D d))) 2.0)))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (M <= 3.2e-213) {
		tmp = sqrt((d / h)) * sqrt((d / l));
	} else {
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * pow((M * (0.5 * (D / d))), 2.0))));
	}
	return tmp;
}
NOTE: M 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 (m <= 3.2d-213) then
        tmp = sqrt((d / h)) * sqrt((d / l))
    else
        tmp = sqrt(((d / h) * (d / l))) * (1.0d0 + ((-0.5d0) * ((h / l) * ((m * (0.5d0 * (d_1 / d))) ** 2.0d0))))
    end if
    code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (M <= 3.2e-213) {
		tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
	} else {
		tmp = Math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * Math.pow((M * (0.5 * (D / d))), 2.0))));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if M <= 3.2e-213:
		tmp = math.sqrt((d / h)) * math.sqrt((d / l))
	else:
		tmp = math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * math.pow((M * (0.5 * (D / d))), 2.0))))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (M <= 3.2e-213)
		tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)));
	else
		tmp = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0)))));
	end
	return tmp
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (M <= 3.2e-213)
		tmp = sqrt((d / h)) * sqrt((d / l));
	else
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((h / l) * ((M * (0.5 * (D / d))) ^ 2.0))));
	end
	tmp_2 = tmp;
end
NOTE: M 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[M, 3.2e-213], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 3.2 \cdot 10^{-213}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 3.19999999999999972e-213

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

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

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

    if 3.19999999999999972e-213 < M

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

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

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

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

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

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

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

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

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

Alternative 14: 45.7% accurate, 1.6× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\left(D \cdot \frac{D}{\ell}\right) \cdot \left(0.25 \cdot \frac{h \cdot \left(M \cdot M\right)}{d \cdot d}\right)\right)\right)\\ \mathbf{if}\;d \leq -1.02 \cdot 10^{-143}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 6.5 \cdot 10^{-163}:\\ \;\;\;\;d \cdot \frac{1}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 5.5 \cdot 10^{-16}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\ \end{array} \end{array} \]
NOTE: M 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) (/ d l)))
          (+
           1.0
           (* -0.5 (* (* D (/ D l)) (* 0.25 (/ (* h (* M M)) (* d d)))))))))
   (if (<= d -1.02e-143)
     t_0
     (if (<= d 6.5e-163)
       (* d (/ 1.0 (sqrt (* l h))))
       (if (<= d 5.5e-16) t_0 (* d (/ (sqrt (/ 1.0 l)) (sqrt h))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((D * (D / l)) * (0.25 * ((h * (M * M)) / (d * d))))));
	double tmp;
	if (d <= -1.02e-143) {
		tmp = t_0;
	} else if (d <= 6.5e-163) {
		tmp = d * (1.0 / sqrt((l * h)));
	} else if (d <= 5.5e-16) {
		tmp = t_0;
	} else {
		tmp = d * (sqrt((1.0 / l)) / sqrt(h));
	}
	return tmp;
}
NOTE: M 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) * (d / l))) * (1.0d0 + ((-0.5d0) * ((d_1 * (d_1 / l)) * (0.25d0 * ((h * (m * m)) / (d * d))))))
    if (d <= (-1.02d-143)) then
        tmp = t_0
    else if (d <= 6.5d-163) then
        tmp = d * (1.0d0 / sqrt((l * h)))
    else if (d <= 5.5d-16) then
        tmp = t_0
    else
        tmp = d * (sqrt((1.0d0 / l)) / sqrt(h))
    end if
    code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((D * (D / l)) * (0.25 * ((h * (M * M)) / (d * d))))));
	double tmp;
	if (d <= -1.02e-143) {
		tmp = t_0;
	} else if (d <= 6.5e-163) {
		tmp = d * (1.0 / Math.sqrt((l * h)));
	} else if (d <= 5.5e-16) {
		tmp = t_0;
	} else {
		tmp = d * (Math.sqrt((1.0 / l)) / Math.sqrt(h));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((D * (D / l)) * (0.25 * ((h * (M * M)) / (d * d))))))
	tmp = 0
	if d <= -1.02e-143:
		tmp = t_0
	elif d <= 6.5e-163:
		tmp = d * (1.0 / math.sqrt((l * h)))
	elif d <= 5.5e-16:
		tmp = t_0
	else:
		tmp = d * (math.sqrt((1.0 / l)) / math.sqrt(h))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(D * Float64(D / l)) * Float64(0.25 * Float64(Float64(h * Float64(M * M)) / Float64(d * d)))))))
	tmp = 0.0
	if (d <= -1.02e-143)
		tmp = t_0;
	elseif (d <= 6.5e-163)
		tmp = Float64(d * Float64(1.0 / sqrt(Float64(l * h))));
	elseif (d <= 5.5e-16)
		tmp = t_0;
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / l)) / sqrt(h)));
	end
	return tmp
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((D * (D / l)) * (0.25 * ((h * (M * M)) / (d * d))))));
	tmp = 0.0;
	if (d <= -1.02e-143)
		tmp = t_0;
	elseif (d <= 6.5e-163)
		tmp = d * (1.0 / sqrt((l * h)));
	elseif (d <= 5.5e-16)
		tmp = t_0;
	else
		tmp = d * (sqrt((1.0 / l)) / sqrt(h));
	end
	tmp_2 = tmp;
end
NOTE: M 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[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(D * N[(D / l), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.02e-143], t$95$0, If[LessEqual[d, 6.5e-163], N[(d * N[(1.0 / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.5e-16], t$95$0, N[(d * N[(N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\left(D \cdot \frac{D}{\ell}\right) \cdot \left(0.25 \cdot \frac{h \cdot \left(M \cdot M\right)}{d \cdot d}\right)\right)\right)\\
\mathbf{if}\;d \leq -1.02 \cdot 10^{-143}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 5.5 \cdot 10^{-16}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.02e-143 or 6.4999999999999999e-163 < d < 5.49999999999999964e-16

    1. Initial program 72.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.02e-143 < d < 6.4999999999999999e-163

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

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

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

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

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

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

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

    if 5.49999999999999964e-16 < d

    1. Initial program 88.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. Simplified86.3%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified61.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.02 \cdot 10^{-143}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\left(D \cdot \frac{D}{\ell}\right) \cdot \left(0.25 \cdot \frac{h \cdot \left(M \cdot M\right)}{d \cdot d}\right)\right)\right)\\ \mathbf{elif}\;d \leq 6.5 \cdot 10^{-163}:\\ \;\;\;\;d \cdot \frac{1}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 5.5 \cdot 10^{-16}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\left(D \cdot \frac{D}{\ell}\right) \cdot \left(0.25 \cdot \frac{h \cdot \left(M \cdot M\right)}{d \cdot d}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\ \end{array} \]

Alternative 15: 46.1% accurate, 1.6× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\left(D \cdot \frac{D}{\ell}\right) \cdot \left(0.25 \cdot \frac{h \cdot \left(M \cdot M\right)}{d \cdot d}\right)\right)\right)\\ \mathbf{if}\;d \leq -1.02 \cdot 10^{-143}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 1.45 \cdot 10^{-162}:\\ \;\;\;\;d \cdot \sqrt[3]{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}}\\ \mathbf{elif}\;d \leq 2.4 \cdot 10^{-15}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\ \end{array} \end{array} \]
NOTE: M 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) (/ d l)))
          (+
           1.0
           (* -0.5 (* (* D (/ D l)) (* 0.25 (/ (* h (* M M)) (* d d)))))))))
   (if (<= d -1.02e-143)
     t_0
     (if (<= d 1.45e-162)
       (* d (cbrt (pow (/ (/ 1.0 h) l) 1.5)))
       (if (<= d 2.4e-15) t_0 (* d (/ (sqrt (/ 1.0 l)) (sqrt h))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((D * (D / l)) * (0.25 * ((h * (M * M)) / (d * d))))));
	double tmp;
	if (d <= -1.02e-143) {
		tmp = t_0;
	} else if (d <= 1.45e-162) {
		tmp = d * cbrt(pow(((1.0 / h) / l), 1.5));
	} else if (d <= 2.4e-15) {
		tmp = t_0;
	} else {
		tmp = d * (sqrt((1.0 / l)) / sqrt(h));
	}
	return tmp;
}
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((D * (D / l)) * (0.25 * ((h * (M * M)) / (d * d))))));
	double tmp;
	if (d <= -1.02e-143) {
		tmp = t_0;
	} else if (d <= 1.45e-162) {
		tmp = d * Math.cbrt(Math.pow(((1.0 / h) / l), 1.5));
	} else if (d <= 2.4e-15) {
		tmp = t_0;
	} else {
		tmp = d * (Math.sqrt((1.0 / l)) / Math.sqrt(h));
	}
	return tmp;
}
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(D * Float64(D / l)) * Float64(0.25 * Float64(Float64(h * Float64(M * M)) / Float64(d * d)))))))
	tmp = 0.0
	if (d <= -1.02e-143)
		tmp = t_0;
	elseif (d <= 1.45e-162)
		tmp = Float64(d * cbrt((Float64(Float64(1.0 / h) / l) ^ 1.5)));
	elseif (d <= 2.4e-15)
		tmp = t_0;
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / l)) / sqrt(h)));
	end
	return tmp
end
NOTE: M 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[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(D * N[(D / l), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.02e-143], t$95$0, If[LessEqual[d, 1.45e-162], N[(d * N[Power[N[Power[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.4e-15], t$95$0, N[(d * N[(N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\left(D \cdot \frac{D}{\ell}\right) \cdot \left(0.25 \cdot \frac{h \cdot \left(M \cdot M\right)}{d \cdot d}\right)\right)\right)\\
\mathbf{if}\;d \leq -1.02 \cdot 10^{-143}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 2.4 \cdot 10^{-15}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.02e-143 or 1.4500000000000001e-162 < d < 2.39999999999999995e-15

    1. Initial program 72.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.02e-143 < d < 1.4500000000000001e-162

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified13.3%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u13.0%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{\ell}}{h}\right)} - 1}} \]
      3. associate-/l/11.8%

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

      \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1}} \]
    8. Step-by-step derivation
      1. add-cbrt-cube16.4%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{\left(\sqrt{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1} \cdot \sqrt{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1}\right) \cdot \sqrt{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1}}} \]
      2. add-sqr-sqrt16.4%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\left(e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1\right)} \cdot \sqrt{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1}} \]
      3. expm1-def16.4%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)\right)} \cdot \sqrt{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1}} \]
      4. expm1-log1p-u16.4%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\frac{1}{h \cdot \ell}} \cdot \sqrt{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1}} \]
      5. associate-/l/16.4%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\frac{\frac{1}{\ell}}{h}} \cdot \sqrt{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1}} \]
      6. expm1-def17.6%

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

        \[\leadsto d \cdot \sqrt[3]{\frac{\frac{1}{\ell}}{h} \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}}} \]
      8. associate-/l/17.8%

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

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

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot \frac{\frac{1}{\ell}}{h}}} \]
      2. unpow1/217.8%

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

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

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

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

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

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

    if 2.39999999999999995e-15 < d

    1. Initial program 88.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. Simplified86.3%

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified61.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.02 \cdot 10^{-143}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\left(D \cdot \frac{D}{\ell}\right) \cdot \left(0.25 \cdot \frac{h \cdot \left(M \cdot M\right)}{d \cdot d}\right)\right)\right)\\ \mathbf{elif}\;d \leq 1.45 \cdot 10^{-162}:\\ \;\;\;\;d \cdot \sqrt[3]{{\left(\frac{\frac{1}{h}}{\ell}\right)}^{1.5}}\\ \mathbf{elif}\;d \leq 2.4 \cdot 10^{-15}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\left(D \cdot \frac{D}{\ell}\right) \cdot \left(0.25 \cdot \frac{h \cdot \left(M \cdot M\right)}{d \cdot d}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}}\\ \end{array} \]

Alternative 16: 45.8% accurate, 1.6× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 9.2 \cdot 10^{-67}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\left(D \cdot \frac{D}{\ell}\right) \cdot \left(0.25 \cdot \frac{h \cdot \left(M \cdot M\right)}{d \cdot d}\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: M 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 (<= M 9.2e-67)
   (* (sqrt (/ d h)) (sqrt (/ d l)))
   (*
    (sqrt (* (/ d h) (/ d l)))
    (+ 1.0 (* -0.5 (* (* D (/ D l)) (* 0.25 (/ (* h (* M M)) (* d d)))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (M <= 9.2e-67) {
		tmp = sqrt((d / h)) * sqrt((d / l));
	} else {
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((D * (D / l)) * (0.25 * ((h * (M * M)) / (d * d))))));
	}
	return tmp;
}
NOTE: M 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 (m <= 9.2d-67) then
        tmp = sqrt((d / h)) * sqrt((d / l))
    else
        tmp = sqrt(((d / h) * (d / l))) * (1.0d0 + ((-0.5d0) * ((d_1 * (d_1 / l)) * (0.25d0 * ((h * (m * m)) / (d * d))))))
    end if
    code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (M <= 9.2e-67) {
		tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
	} else {
		tmp = Math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((D * (D / l)) * (0.25 * ((h * (M * M)) / (d * d))))));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if M <= 9.2e-67:
		tmp = math.sqrt((d / h)) * math.sqrt((d / l))
	else:
		tmp = math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((D * (D / l)) * (0.25 * ((h * (M * M)) / (d * d))))))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (M <= 9.2e-67)
		tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)));
	else
		tmp = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(D * Float64(D / l)) * Float64(0.25 * Float64(Float64(h * Float64(M * M)) / Float64(d * d)))))));
	end
	return tmp
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (M <= 9.2e-67)
		tmp = sqrt((d / h)) * sqrt((d / l));
	else
		tmp = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((D * (D / l)) * (0.25 * ((h * (M * M)) / (d * d))))));
	end
	tmp_2 = tmp;
end
NOTE: M 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[M, 9.2e-67], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(D * N[(D / l), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 9.2 \cdot 10^{-67}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 9.2000000000000002e-67

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

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

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

    if 9.2000000000000002e-67 < M

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 17: 44.6% accurate, 2.5× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\left(D \cdot \frac{D}{\ell}\right) \cdot \left(0.25 \cdot \frac{h \cdot \left(M \cdot M\right)}{d \cdot d}\right)\right)\right)\\ \mathbf{if}\;d \leq -1.02 \cdot 10^{-143}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 5.7 \cdot 10^{-152}:\\ \;\;\;\;d \cdot \frac{1}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 7 \cdot 10^{+131}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \end{array} \end{array} \]
NOTE: M 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) (/ d l)))
          (+
           1.0
           (* -0.5 (* (* D (/ D l)) (* 0.25 (/ (* h (* M M)) (* d d)))))))))
   (if (<= d -1.02e-143)
     t_0
     (if (<= d 5.7e-152)
       (* d (/ 1.0 (sqrt (* l h))))
       (if (<= d 7e+131) t_0 (* d (sqrt (/ 1.0 (* l h)))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((D * (D / l)) * (0.25 * ((h * (M * M)) / (d * d))))));
	double tmp;
	if (d <= -1.02e-143) {
		tmp = t_0;
	} else if (d <= 5.7e-152) {
		tmp = d * (1.0 / sqrt((l * h)));
	} else if (d <= 7e+131) {
		tmp = t_0;
	} else {
		tmp = d * sqrt((1.0 / (l * h)));
	}
	return tmp;
}
NOTE: M 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) * (d / l))) * (1.0d0 + ((-0.5d0) * ((d_1 * (d_1 / l)) * (0.25d0 * ((h * (m * m)) / (d * d))))))
    if (d <= (-1.02d-143)) then
        tmp = t_0
    else if (d <= 5.7d-152) then
        tmp = d * (1.0d0 / sqrt((l * h)))
    else if (d <= 7d+131) then
        tmp = t_0
    else
        tmp = d * sqrt((1.0d0 / (l * h)))
    end if
    code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((D * (D / l)) * (0.25 * ((h * (M * M)) / (d * d))))));
	double tmp;
	if (d <= -1.02e-143) {
		tmp = t_0;
	} else if (d <= 5.7e-152) {
		tmp = d * (1.0 / Math.sqrt((l * h)));
	} else if (d <= 7e+131) {
		tmp = t_0;
	} else {
		tmp = d * Math.sqrt((1.0 / (l * h)));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = math.sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((D * (D / l)) * (0.25 * ((h * (M * M)) / (d * d))))))
	tmp = 0
	if d <= -1.02e-143:
		tmp = t_0
	elif d <= 5.7e-152:
		tmp = d * (1.0 / math.sqrt((l * h)))
	elif d <= 7e+131:
		tmp = t_0
	else:
		tmp = d * math.sqrt((1.0 / (l * h)))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(sqrt(Float64(Float64(d / h) * Float64(d / l))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(D * Float64(D / l)) * Float64(0.25 * Float64(Float64(h * Float64(M * M)) / Float64(d * d)))))))
	tmp = 0.0
	if (d <= -1.02e-143)
		tmp = t_0;
	elseif (d <= 5.7e-152)
		tmp = Float64(d * Float64(1.0 / sqrt(Float64(l * h))));
	elseif (d <= 7e+131)
		tmp = t_0;
	else
		tmp = Float64(d * sqrt(Float64(1.0 / Float64(l * h))));
	end
	return tmp
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt(((d / h) * (d / l))) * (1.0 + (-0.5 * ((D * (D / l)) * (0.25 * ((h * (M * M)) / (d * d))))));
	tmp = 0.0;
	if (d <= -1.02e-143)
		tmp = t_0;
	elseif (d <= 5.7e-152)
		tmp = d * (1.0 / sqrt((l * h)));
	elseif (d <= 7e+131)
		tmp = t_0;
	else
		tmp = d * sqrt((1.0 / (l * h)));
	end
	tmp_2 = tmp;
end
NOTE: M 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[Sqrt[N[(N[(d / h), $MachinePrecision] * N[(d / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(D * N[(D / l), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.02e-143], t$95$0, If[LessEqual[d, 5.7e-152], N[(d * N[(1.0 / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7e+131], t$95$0, N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\left(D \cdot \frac{D}{\ell}\right) \cdot \left(0.25 \cdot \frac{h \cdot \left(M \cdot M\right)}{d \cdot d}\right)\right)\right)\\
\mathbf{if}\;d \leq -1.02 \cdot 10^{-143}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 7 \cdot 10^{+131}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.02e-143 or 5.7000000000000004e-152 < d < 6.9999999999999998e131

    1. Initial program 74.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.02e-143 < d < 5.7000000000000004e-152

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

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

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

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

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

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

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

    if 6.9999999999999998e131 < d

    1. Initial program 91.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. Simplified87.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.02 \cdot 10^{-143}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\left(D \cdot \frac{D}{\ell}\right) \cdot \left(0.25 \cdot \frac{h \cdot \left(M \cdot M\right)}{d \cdot d}\right)\right)\right)\\ \mathbf{elif}\;d \leq 5.7 \cdot 10^{-152}:\\ \;\;\;\;d \cdot \frac{1}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 7 \cdot 10^{+131}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\left(D \cdot \frac{D}{\ell}\right) \cdot \left(0.25 \cdot \frac{h \cdot \left(M \cdot M\right)}{d \cdot d}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \end{array} \]

Alternative 18: 27.4% accurate, 2.5× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \frac{\frac{1}{\ell}}{h}\\ t_1 := 1 + t_0\\ \mathbf{if}\;h \leq -1.02 \cdot 10^{-91}:\\ \;\;\;\;d \cdot \sqrt{\frac{-1 + t_1 \cdot t_1}{1 + t_1}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{t_0}\\ \end{array} \end{array} \]
NOTE: M 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 l) h)) (t_1 (+ 1.0 t_0)))
   (if (<= h -1.02e-91)
     (* d (sqrt (/ (+ -1.0 (* t_1 t_1)) (+ 1.0 t_1))))
     (* d (sqrt t_0)))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = (1.0 / l) / h;
	double t_1 = 1.0 + t_0;
	double tmp;
	if (h <= -1.02e-91) {
		tmp = d * sqrt(((-1.0 + (t_1 * t_1)) / (1.0 + t_1)));
	} else {
		tmp = d * sqrt(t_0);
	}
	return tmp;
}
NOTE: M 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 = (1.0d0 / l) / h
    t_1 = 1.0d0 + t_0
    if (h <= (-1.02d-91)) then
        tmp = d * sqrt((((-1.0d0) + (t_1 * t_1)) / (1.0d0 + t_1)))
    else
        tmp = d * sqrt(t_0)
    end if
    code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = (1.0 / l) / h;
	double t_1 = 1.0 + t_0;
	double tmp;
	if (h <= -1.02e-91) {
		tmp = d * Math.sqrt(((-1.0 + (t_1 * t_1)) / (1.0 + t_1)));
	} else {
		tmp = d * Math.sqrt(t_0);
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = (1.0 / l) / h
	t_1 = 1.0 + t_0
	tmp = 0
	if h <= -1.02e-91:
		tmp = d * math.sqrt(((-1.0 + (t_1 * t_1)) / (1.0 + t_1)))
	else:
		tmp = d * math.sqrt(t_0)
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(Float64(1.0 / l) / h)
	t_1 = Float64(1.0 + t_0)
	tmp = 0.0
	if (h <= -1.02e-91)
		tmp = Float64(d * sqrt(Float64(Float64(-1.0 + Float64(t_1 * t_1)) / Float64(1.0 + t_1))));
	else
		tmp = Float64(d * sqrt(t_0));
	end
	return tmp
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
	t_0 = (1.0 / l) / h;
	t_1 = 1.0 + t_0;
	tmp = 0.0;
	if (h <= -1.02e-91)
		tmp = d * sqrt(((-1.0 + (t_1 * t_1)) / (1.0 + t_1)));
	else
		tmp = d * sqrt(t_0);
	end
	tmp_2 = tmp;
end
NOTE: M 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[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + t$95$0), $MachinePrecision]}, If[LessEqual[h, -1.02e-91], N[(d * N[Sqrt[N[(N[(-1.0 + N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] / N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{\ell}}{h}\\
t_1 := 1 + t_0\\
\mathbf{if}\;h \leq -1.02 \cdot 10^{-91}:\\
\;\;\;\;d \cdot \sqrt{\frac{-1 + t_1 \cdot t_1}{1 + t_1}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{t_0}\\


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

    1. Initial program 65.5%

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified3.7%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u3.7%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{\ell}}{h}\right)} - 1}} \]
      3. associate-/l/3.8%

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

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

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

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

        \[\leadsto d \cdot \sqrt{\frac{\color{blue}{\left(1 + \frac{1}{h \cdot \ell}\right)} \cdot e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1 \cdot 1}{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} + 1}} \]
      4. associate-/l/9.0%

        \[\leadsto d \cdot \sqrt{\frac{\left(1 + \color{blue}{\frac{\frac{1}{\ell}}{h}}\right) \cdot e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1 \cdot 1}{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} + 1}} \]
      5. log1p-udef9.0%

        \[\leadsto d \cdot \sqrt{\frac{\left(1 + \frac{\frac{1}{\ell}}{h}\right) \cdot e^{\color{blue}{\log \left(1 + \frac{1}{h \cdot \ell}\right)}} - 1 \cdot 1}{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} + 1}} \]
      6. add-exp-log9.0%

        \[\leadsto d \cdot \sqrt{\frac{\left(1 + \frac{\frac{1}{\ell}}{h}\right) \cdot \color{blue}{\left(1 + \frac{1}{h \cdot \ell}\right)} - 1 \cdot 1}{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} + 1}} \]
      7. associate-/l/9.0%

        \[\leadsto d \cdot \sqrt{\frac{\left(1 + \frac{\frac{1}{\ell}}{h}\right) \cdot \left(1 + \color{blue}{\frac{\frac{1}{\ell}}{h}}\right) - 1 \cdot 1}{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} + 1}} \]
      8. metadata-eval9.0%

        \[\leadsto d \cdot \sqrt{\frac{\left(1 + \frac{\frac{1}{\ell}}{h}\right) \cdot \left(1 + \frac{\frac{1}{\ell}}{h}\right) - \color{blue}{1}}{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} + 1}} \]
      9. log1p-udef9.0%

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

        \[\leadsto d \cdot \sqrt{\frac{\left(1 + \frac{\frac{1}{\ell}}{h}\right) \cdot \left(1 + \frac{\frac{1}{\ell}}{h}\right) - 1}{\color{blue}{\left(1 + \frac{1}{h \cdot \ell}\right)} + 1}} \]
      11. associate-/l/9.0%

        \[\leadsto d \cdot \sqrt{\frac{\left(1 + \frac{\frac{1}{\ell}}{h}\right) \cdot \left(1 + \frac{\frac{1}{\ell}}{h}\right) - 1}{\left(1 + \color{blue}{\frac{\frac{1}{\ell}}{h}}\right) + 1}} \]
    9. Applied egg-rr9.0%

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

    if -1.01999999999999994e-91 < h

    1. Initial program 69.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. Simplified68.3%

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

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

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

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

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

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

Alternative 19: 26.0% accurate, 3.1× speedup?

\[\begin{array}{l} M = |M|\\ [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: 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);
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: 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);
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)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * math.sqrt((1.0 / (l * h)))
M = abs(M)
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)
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: 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|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot \sqrt{\frac{1}{\ell \cdot h}}
\end{array}
Derivation
  1. Initial program 67.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. Simplified66.9%

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

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

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

Alternative 20: 25.9% accurate, 3.1× speedup?

\[\begin{array}{l} M = |M|\\ [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: 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);
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: 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);
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)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * math.pow((l * h), -0.5)
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d * (Float64(l * h) ^ -0.5))
end
M = abs(M)
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: 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|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot {\left(\ell \cdot h\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 67.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. Simplified66.9%

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

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

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

      \[\leadsto \left(1 \cdot \sqrt{\frac{1}{\color{blue}{h \cdot \ell}}}\right) \cdot d \]
  5. Applied egg-rr22.4%

    \[\leadsto \color{blue}{\left(1 \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \cdot d \]
  6. Step-by-step derivation
    1. *-lft-identity22.4%

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

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

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

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

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

      \[\leadsto \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| \cdot d \]
    7. fabs-sqr22.4%

      \[\leadsto \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)} \cdot d \]
    8. sqr-pow22.4%

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

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

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

Alternative 21: 4.3% accurate, 3.2× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ d \cdot \sqrt{0} \end{array} \]
NOTE: M 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 0.0)))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	return d * sqrt(0.0);
}
NOTE: M 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(0.0d0)
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.sqrt(0.0);
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	return d * math.sqrt(0.0)
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	return Float64(d * sqrt(0.0))
end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt(0.0);
end
NOTE: M 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[0.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot \sqrt{0}
\end{array}
Derivation
  1. Initial program 67.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. Simplified66.9%

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

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

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

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

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}} \]
  6. Step-by-step derivation
    1. expm1-log1p-u22.0%

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

      \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{\ell}}{h}\right)} - 1}} \]
    3. associate-/l/15.5%

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

    \[\leadsto d \cdot \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{1}{h \cdot \ell}\right)} - 1}} \]
  8. Taylor expanded in h around inf 2.9%

    \[\leadsto d \cdot \sqrt{\color{blue}{1} - 1} \]
  9. Final simplification2.9%

    \[\leadsto d \cdot \sqrt{0} \]

Reproduce

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