Henrywood and Agarwal, Equation (12)

Percentage Accurate: 67.6% → 79.4%
Time: 23.8s
Alternatives: 22
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 22 alternatives:

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

Initial Program: 67.6% accurate, 1.0× speedup?

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

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

Alternative 1: 79.4% accurate, 0.5× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \left(\frac{\sqrt{d}}{\sqrt{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)\\


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

    1. Initial program 70.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. Simplified69.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. associate-*r/72.5%

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

        \[\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-eval72.5%

        \[\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-rr72.5%

      \[\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. pow1/272.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{0.5}}\right) \cdot \left(1 - 0.5 \cdot \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}\right) \]
      2. sqr-pow72.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 \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}\right) \]
      3. pow272.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 \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}\right) \]
      4. metadata-eval72.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 \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}\right) \]
    6. Applied egg-rr72.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 \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}\right) \]
    7. Taylor expanded in l around -inf 73.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\color{blue}{\left(e^{0.25 \cdot \left(\log \left(-1 \cdot d\right) + \log \left(\frac{-1}{\ell}\right)\right)}\right)}}^{2}\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) \]
    8. Step-by-step derivation
      1. distribute-lft-in73.7%

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\color{blue}{\left(e^{0.25 \cdot \log \left(-1 \cdot d\right)} \cdot e^{0.25 \cdot \log \left(\frac{-1}{\ell}\right)}\right)}}^{2}\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. *-commutative73.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(e^{\color{blue}{\log \left(-1 \cdot d\right) \cdot 0.25}} \cdot e^{0.25 \cdot \log \left(\frac{-1}{\ell}\right)}\right)}^{2}\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) \]
      4. rem-square-sqrt0.0%

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(e^{\log \left(\color{blue}{{\left(\sqrt{-1}\right)}^{2}} \cdot d\right) \cdot 0.25} \cdot e^{0.25 \cdot \log \left(\frac{-1}{\ell}\right)}\right)}^{2}\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. *-commutative0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(e^{\log \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \cdot 0.25} \cdot e^{0.25 \cdot \log \left(\frac{-1}{\ell}\right)}\right)}^{2}\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) \]
      7. exp-to-pow0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(\color{blue}{{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)}^{0.25}} \cdot e^{0.25 \cdot \log \left(\frac{-1}{\ell}\right)}\right)}^{2}\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) \]
      8. *-commutative0.0%

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left({\left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right)}^{0.25} \cdot e^{0.25 \cdot \log \left(\frac{-1}{\ell}\right)}\right)}^{2}\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) \]
      10. rem-square-sqrt74.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left({\left(\color{blue}{-1} \cdot d\right)}^{0.25} \cdot e^{0.25 \cdot \log \left(\frac{-1}{\ell}\right)}\right)}^{2}\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) \]
      11. mul-1-neg74.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left({\color{blue}{\left(-d\right)}}^{0.25} \cdot e^{0.25 \cdot \log \left(\frac{-1}{\ell}\right)}\right)}^{2}\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) \]
      12. *-commutative74.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left({\left(-d\right)}^{0.25} \cdot e^{\color{blue}{\log \left(\frac{-1}{\ell}\right) \cdot 0.25}}\right)}^{2}\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) \]
      13. exp-to-pow76.7%

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

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

    if -5.00000000000023e-311 < l

    1. Initial program 67.2%

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

      \[\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. Step-by-step derivation
      1. sqrt-div80.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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) \]
    4. Applied egg-rr80.0%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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) \]
    5. Step-by-step derivation
      1. sqrt-div87.8%

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

      \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \left(\frac{\sqrt{d}}{\sqrt{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. Recombined 2 regimes into one program.
  4. Final simplification82.6%

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

Alternative 2: 77.4% accurate, 0.6× speedup?

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

\mathbf{elif}\;d \leq 3.4 \cdot 10^{-184}:\\
\;\;\;\;-0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}}{d}\\

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


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

    1. Initial program 72.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. Simplified70.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. associate-*r/73.7%

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

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

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

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

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

        \[\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 \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}\right) \]
      3. pow273.6%

        \[\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 \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}\right) \]
      4. metadata-eval73.6%

        \[\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 \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}\right) \]
    6. Applied egg-rr73.6%

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\color{blue}{\left(e^{0.25 \cdot \left(\log \left(-1 \cdot d\right) + \log \left(\frac{-1}{\ell}\right)\right)}\right)}}^{2}\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) \]
    8. Step-by-step derivation
      1. distribute-lft-in74.9%

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\color{blue}{\left(e^{0.25 \cdot \log \left(-1 \cdot d\right)} \cdot e^{0.25 \cdot \log \left(\frac{-1}{\ell}\right)}\right)}}^{2}\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. *-commutative75.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(e^{\color{blue}{\log \left(-1 \cdot d\right) \cdot 0.25}} \cdot e^{0.25 \cdot \log \left(\frac{-1}{\ell}\right)}\right)}^{2}\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) \]
      4. rem-square-sqrt0.0%

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(e^{\log \left(\color{blue}{{\left(\sqrt{-1}\right)}^{2}} \cdot d\right) \cdot 0.25} \cdot e^{0.25 \cdot \log \left(\frac{-1}{\ell}\right)}\right)}^{2}\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. *-commutative0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(e^{\log \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \cdot 0.25} \cdot e^{0.25 \cdot \log \left(\frac{-1}{\ell}\right)}\right)}^{2}\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) \]
      7. exp-to-pow0.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left(\color{blue}{{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)}^{0.25}} \cdot e^{0.25 \cdot \log \left(\frac{-1}{\ell}\right)}\right)}^{2}\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) \]
      8. *-commutative0.0%

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left({\left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right)}^{0.25} \cdot e^{0.25 \cdot \log \left(\frac{-1}{\ell}\right)}\right)}^{2}\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) \]
      10. rem-square-sqrt75.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left({\left(\color{blue}{-1} \cdot d\right)}^{0.25} \cdot e^{0.25 \cdot \log \left(\frac{-1}{\ell}\right)}\right)}^{2}\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) \]
      11. mul-1-neg75.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left({\color{blue}{\left(-d\right)}}^{0.25} \cdot e^{0.25 \cdot \log \left(\frac{-1}{\ell}\right)}\right)}^{2}\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) \]
      12. *-commutative75.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot {\left({\left(-d\right)}^{0.25} \cdot e^{\color{blue}{\log \left(\frac{-1}{\ell}\right) \cdot 0.25}}\right)}^{2}\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) \]
      13. exp-to-pow78.0%

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

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

    if -1.95000000000000005e-296 < d < 3.40000000000000004e-184

    1. Initial program 35.0%

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

        \[\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-inv34.9%

        \[\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-eval34.9%

        \[\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-rr34.9%

      \[\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. Taylor expanded in d around 0 43.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.40000000000000004e-184 < d

    1. Initial program 75.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. Simplified75.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. Step-by-step derivation
      1. associate-*r/77.9%

        \[\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-inv77.9%

        \[\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-eval77.9%

        \[\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-rr77.9%

      \[\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-div86.4%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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) \]
    6. Applied egg-rr88.4%

      \[\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 simplification80.5%

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

Alternative 3: 73.8% accurate, 0.8× speedup?

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

\mathbf{elif}\;d \leq 1.3 \cdot 10^{-185}:\\
\;\;\;\;-0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}}{d}\\

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


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

    1. Initial program 72.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. Simplified70.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. associate-*r/73.7%

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

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

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

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

    if -1.95000000000000005e-296 < d < 1.29999999999999992e-185

    1. Initial program 35.0%

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

        \[\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-inv34.9%

        \[\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-eval34.9%

        \[\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-rr34.9%

      \[\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. Taylor expanded in d around 0 43.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.29999999999999992e-185 < d

    1. Initial program 75.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. Simplified75.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. Step-by-step derivation
      1. sqrt-div86.4%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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) \]
    4. Applied egg-rr86.4%

      \[\leadsto \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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. Recombined 3 regimes into one program.
  4. Final simplification77.6%

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

Alternative 4: 74.6% accurate, 0.8× speedup?

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

\mathbf{elif}\;d \leq 3.2 \cdot 10^{-187}:\\
\;\;\;\;-0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}}{d}\\

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


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

    1. Initial program 72.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. Simplified70.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. associate-*r/73.7%

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

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

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

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

    if -1.95000000000000005e-296 < d < 3.1999999999999998e-187

    1. Initial program 35.0%

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

        \[\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-inv34.9%

        \[\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-eval34.9%

        \[\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-rr34.9%

      \[\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. Taylor expanded in d around 0 43.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.1999999999999998e-187 < d

    1. Initial program 75.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. Simplified75.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. Step-by-step derivation
      1. associate-*r/77.9%

        \[\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-inv77.9%

        \[\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-eval77.9%

        \[\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-rr77.9%

      \[\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-div86.4%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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) \]
    6. Applied egg-rr88.4%

      \[\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 simplification78.5%

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

Alternative 5: 68.4% accurate, 1.0× speedup?

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

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


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

    1. Initial program 72.0%

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

    if 5.5000000000000003e118 < l

    1. Initial program 56.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. Simplified56.0%

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

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

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

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

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

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

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

Alternative 6: 70.4% accurate, 1.0× speedup?

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

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


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

    1. Initial program 72.0%

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

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

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

        \[\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-rr73.9%

      \[\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) \]

    if 2.50000000000000009e120 < l

    1. Initial program 56.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. Simplified56.0%

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

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

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

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

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

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

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

Alternative 7: 61.8% accurate, 1.1× speedup?

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

\mathbf{elif}\;d \leq 4.5 \cdot 10^{-305}:\\
\;\;\;\;d \cdot \log \left(e^{{\left(\ell \cdot h\right)}^{-0.5}}\right)\\

\mathbf{elif}\;d \leq 6 \cdot 10^{-58}:\\
\;\;\;\;-0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}}{d}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -3.8000000000000001e-196

    1. Initial program 76.7%

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

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

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

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

      \[\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. Applied egg-rr65.4%

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

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

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

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

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

    if -3.8000000000000001e-196 < d < 4.5000000000000002e-305

    1. Initial program 51.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. Simplified51.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. associate-*r/51.6%

        \[\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-inv51.6%

        \[\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-eval51.6%

        \[\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-rr51.6%

      \[\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. Taylor expanded in d around inf 24.3%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. add-log-exp49.6%

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

        \[\leadsto d \cdot \log \left(e^{{\color{blue}{\left(\ell \cdot h\right)}}^{-0.5}}\right) \]
    9. Applied egg-rr49.6%

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

    if 4.5000000000000002e-305 < d < 6.00000000000000015e-58

    1. Initial program 48.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. Simplified48.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. associate-*r/46.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.00000000000000015e-58 < d < 4.5000000000000003e87

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

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

        \[\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. associate-*r/70.1%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{d}{h} \cdot 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) \]
      4. *-commutative70.1%

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

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

    if 4.5000000000000003e87 < d

    1. Initial program 78.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. Simplified78.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 68.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.8 \cdot 10^{-196}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)\\ \mathbf{elif}\;d \leq 4.5 \cdot 10^{-305}:\\ \;\;\;\;d \cdot \log \left(e^{{\left(\ell \cdot h\right)}^{-0.5}}\right)\\ \mathbf{elif}\;d \leq 6 \cdot 10^{-58}:\\ \;\;\;\;-0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}}{d}\\ \mathbf{elif}\;d \leq 4.5 \cdot 10^{+87}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{h}}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 8: 61.2% accurate, 1.4× speedup?

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

\mathbf{elif}\;d \leq -1.95 \cdot 10^{-296}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(-0.125 \cdot \left(\left(D \cdot \frac{D}{d}\right) \cdot \left(\frac{M}{d} \cdot \left(M \cdot \frac{h}{\ell}\right)\right)\right)\right)\right)\\

\mathbf{elif}\;d \leq 8.5 \cdot 10^{-60}:\\
\;\;\;\;-0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}}{d}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -6.5000000000000004e-196

    1. Initial program 76.7%

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

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

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

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

      \[\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. Applied egg-rr65.4%

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

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

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

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

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

    if -6.5000000000000004e-196 < d < -1.95000000000000005e-296

    1. Initial program 57.1%

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

      \[\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. times-frac28.6%

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

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

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

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

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

      \[\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. *-commutative32.1%

        \[\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)}}{{d}^{2} \cdot \ell}\right)\right) \]
      2. unpow232.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.95000000000000005e-296 < d < 8.50000000000000044e-60

    1. Initial program 45.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. Simplified45.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. Step-by-step derivation
      1. associate-*r/44.1%

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

        \[\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-eval44.1%

        \[\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-rr44.1%

      \[\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. Taylor expanded in d around 0 37.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.50000000000000044e-60 < d < 2.4999999999999999e87

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

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

        \[\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. associate-*r/70.1%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{d}{h} \cdot 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) \]
      4. *-commutative70.1%

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

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

    if 2.4999999999999999e87 < d

    1. Initial program 78.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. Simplified78.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 68.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.5 \cdot 10^{-196}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)\\ \mathbf{elif}\;d \leq -1.95 \cdot 10^{-296}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(-0.125 \cdot \left(\left(D \cdot \frac{D}{d}\right) \cdot \left(\frac{M}{d} \cdot \left(M \cdot \frac{h}{\ell}\right)\right)\right)\right)\right)\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{-60}:\\ \;\;\;\;-0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}}{d}\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{+87}:\\ \;\;\;\;\sqrt{\frac{d \cdot \frac{d}{h}}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 9: 61.0% accurate, 1.4× speedup?

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

\mathbf{elif}\;d \leq 8.5 \cdot 10^{-60}:\\
\;\;\;\;-0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}}{d}\\

\mathbf{elif}\;d \leq 3.6 \cdot 10^{+87}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.0500000000000001e-280 or 8.50000000000000044e-60 < d < 3.59999999999999994e87

    1. Initial program 75.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. 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. associate-*r/77.6%

        \[\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-inv77.6%

        \[\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-eval77.6%

        \[\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-rr77.6%

      \[\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. Applied egg-rr63.5%

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

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

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

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

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

    if -2.0500000000000001e-280 < d < 8.50000000000000044e-60

    1. Initial program 43.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. Simplified43.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. associate-*r/42.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-inv42.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-eval42.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-rr42.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. Taylor expanded in d around 0 34.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.59999999999999994e87 < d

    1. Initial program 78.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. Simplified78.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 68.9%

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

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

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

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

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

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

Alternative 10: 60.8% accurate, 1.4× speedup?

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

\mathbf{elif}\;d \leq 6.2 \cdot 10^{-60}:\\
\;\;\;\;-0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}}{d}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -2.0500000000000001e-280

    1. Initial program 74.3%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified72.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. associate-*r/76.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-inv76.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-eval76.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-rr76.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. Applied egg-rr61.8%

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

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

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

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

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

    if -2.0500000000000001e-280 < d < 6.19999999999999976e-60

    1. Initial program 43.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. Simplified43.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. associate-*r/42.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-inv42.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-eval42.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-rr42.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. Taylor expanded in d around 0 34.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.19999999999999976e-60 < d < 2.2000000000000001e87

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

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

        \[\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. associate-*r/70.1%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{d}{h} \cdot 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) \]
      4. *-commutative70.1%

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

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

    if 2.2000000000000001e87 < d

    1. Initial program 78.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. Simplified78.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 68.9%

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

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

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

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

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

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

Alternative 11: 51.7% accurate, 1.5× speedup?

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

\mathbf{elif}\;d \leq 4.5 \cdot 10^{-305}:\\
\;\;\;\;d \cdot \sqrt{\sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)}}\\

\mathbf{elif}\;d \leq 7.8 \cdot 10^{-56}:\\
\;\;\;\;-0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -5.3999999999999999e-161

    1. Initial program 76.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. Simplified74.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. Step-by-step derivation
      1. sqrt-div0.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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) \]
    4. Applied egg-rr0.0%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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) \]
    5. Taylor expanded in M around 0 55.7%

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

    if -5.3999999999999999e-161 < d < 4.5000000000000002e-305

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

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

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

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

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

    if 4.5000000000000002e-305 < d < 7.8e-56

    1. Initial program 48.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. Simplified48.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. associate-*r/46.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.8e-56 < 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. Simplified79.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. Taylor expanded in d around inf 60.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5.4 \cdot 10^{-161}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;d \leq 4.5 \cdot 10^{-305}:\\ \;\;\;\;d \cdot \sqrt{\sqrt[3]{\frac{1}{\ell \cdot h} \cdot \left(\frac{1}{\ell \cdot h} \cdot \frac{1}{\ell \cdot h}\right)}}\\ \mathbf{elif}\;d \leq 7.8 \cdot 10^{-56}:\\ \;\;\;\;-0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}}{d}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 12: 48.3% accurate, 1.5× speedup?

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

\mathbf{elif}\;d \leq 9.5 \cdot 10^{-304}:\\
\;\;\;\;d \cdot \sqrt[3]{t_0 \cdot \sqrt{t_0}}\\

\mathbf{elif}\;d \leq 4.5 \cdot 10^{-65}:\\
\;\;\;\;-0.125 \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(M \cdot \left(M \cdot \left(D \cdot D\right)\right)\right)}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -9.99999999999999954e-163

    1. Initial program 76.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. Simplified74.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. Step-by-step derivation
      1. sqrt-div0.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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) \]
    4. Applied egg-rr0.0%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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) \]
    5. Taylor expanded in M around 0 55.7%

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

    if -9.99999999999999954e-163 < d < 9.50000000000000023e-304

    1. Initial program 51.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. Simplified51.0%

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

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

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

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

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

    if 9.50000000000000023e-304 < d < 4.4999999999999998e-65

    1. Initial program 50.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. Simplified50.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 0 43.5%

      \[\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. associate-*l/43.5%

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

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

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

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

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

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

    if 4.4999999999999998e-65 < d

    1. Initial program 79.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. Simplified79.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 59.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1 \cdot 10^{-162}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;d \leq 9.5 \cdot 10^{-304}:\\ \;\;\;\;d \cdot \sqrt[3]{\frac{1}{\ell \cdot h} \cdot \sqrt{\frac{1}{\ell \cdot h}}}\\ \mathbf{elif}\;d \leq 4.5 \cdot 10^{-65}:\\ \;\;\;\;-0.125 \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(M \cdot \left(M \cdot \left(D \cdot D\right)\right)\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 13: 48.9% accurate, 1.5× speedup?

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

\mathbf{elif}\;d \leq 9.5 \cdot 10^{-304}:\\
\;\;\;\;d \cdot \sqrt[3]{t_0 \cdot \sqrt{t_0}}\\

\mathbf{elif}\;d \leq 2.1 \cdot 10^{-66}:\\
\;\;\;\;-0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.24999999999999994e-163

    1. Initial program 76.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. Simplified74.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. Step-by-step derivation
      1. sqrt-div0.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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) \]
    4. Applied egg-rr0.0%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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) \]
    5. Taylor expanded in M around 0 55.7%

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

    if -1.24999999999999994e-163 < d < 9.50000000000000023e-304

    1. Initial program 51.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. Simplified51.0%

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

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

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

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

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

    if 9.50000000000000023e-304 < d < 2.1e-66

    1. Initial program 50.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. Simplified50.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. associate-*r/48.5%

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

        \[\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-eval48.5%

        \[\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-rr48.5%

      \[\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. Taylor expanded in d around 0 43.5%

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

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

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

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

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

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

    if 2.1e-66 < d

    1. Initial program 79.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. Simplified79.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 59.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.25 \cdot 10^{-163}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;d \leq 9.5 \cdot 10^{-304}:\\ \;\;\;\;d \cdot \sqrt[3]{\frac{1}{\ell \cdot h} \cdot \sqrt{\frac{1}{\ell \cdot h}}}\\ \mathbf{elif}\;d \leq 2.1 \cdot 10^{-66}:\\ \;\;\;\;-0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}}{d}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 14: 51.0% accurate, 1.5× speedup?

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

\mathbf{elif}\;d \leq 4.5 \cdot 10^{-305}:\\
\;\;\;\;d \cdot \sqrt[3]{t_0 \cdot \sqrt{t_0}}\\

\mathbf{elif}\;d \leq 1.3 \cdot 10^{-57}:\\
\;\;\;\;-0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -4.79999999999999998e-161

    1. Initial program 76.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. Simplified74.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. Step-by-step derivation
      1. sqrt-div0.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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) \]
    4. Applied egg-rr0.0%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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) \]
    5. Taylor expanded in M around 0 55.7%

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

    if -4.79999999999999998e-161 < d < 4.5000000000000002e-305

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

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

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

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

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

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

    if 4.5000000000000002e-305 < d < 1.29999999999999993e-57

    1. Initial program 48.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. Simplified48.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. associate-*r/46.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.29999999999999993e-57 < 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. Simplified79.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. Taylor expanded in d around inf 60.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.8 \cdot 10^{-161}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;d \leq 4.5 \cdot 10^{-305}:\\ \;\;\;\;d \cdot \sqrt[3]{\frac{1}{\ell \cdot h} \cdot \sqrt{\frac{1}{\ell \cdot h}}}\\ \mathbf{elif}\;d \leq 1.3 \cdot 10^{-57}:\\ \;\;\;\;-0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}}{d}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 15: 44.5% accurate, 1.5× speedup?

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

\mathbf{elif}\;d \leq 1.96 \cdot 10^{-230}:\\
\;\;\;\;d \cdot \sqrt[3]{t_0 \cdot \sqrt{t_0}}\\

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


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

    1. Initial program 76.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. Simplified74.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. Step-by-step derivation
      1. sqrt-div0.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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) \]
    4. Applied egg-rr0.0%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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) \]
    5. Taylor expanded in M around 0 55.7%

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

    if -1.8500000000000001e-162 < d < 1.96000000000000001e-230

    1. Initial program 47.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. Simplified46.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 27.2%

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

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}}} \]
      2. add-sqr-sqrt32.9%

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

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

    if 1.96000000000000001e-230 < d

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.85 \cdot 10^{-162}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;d \leq 1.96 \cdot 10^{-230}:\\ \;\;\;\;d \cdot \sqrt[3]{\frac{1}{\ell \cdot h} \cdot \sqrt{\frac{1}{\ell \cdot h}}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 16: 45.4% accurate, 1.6× speedup?

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

\mathbf{elif}\;d \leq 4 \cdot 10^{-282}:\\
\;\;\;\;d \cdot t_0\\

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


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

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

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

        \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\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)\right) \cdot \left(\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)\right)\right) \cdot \left(\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)\right)}} \]
      2. pow355.0%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(\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)\right)}^{3}}} \]
    4. Applied egg-rr55.1%

      \[\leadsto \color{blue}{\sqrt[3]{{\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)}^{3}}} \]
    5. Taylor expanded in d around -inf 54.2%

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

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

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

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

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

    if -7.99999999999999987e-170 < d < 4.0000000000000001e-282

    1. Initial program 48.1%

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

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

    if 4.0000000000000001e-282 < d

    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.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/72.6%

        \[\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-inv72.6%

        \[\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-eval72.6%

        \[\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-rr72.6%

      \[\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. Taylor expanded in d around inf 46.8%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. sqr-pow46.8%

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

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

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

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

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

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

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. unpow-prod-down57.9%

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

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

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

Alternative 17: 45.4% accurate, 1.6× speedup?

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

\mathbf{elif}\;d \leq 4 \cdot 10^{-284}:\\
\;\;\;\;d \cdot t_0\\

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


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

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

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

        \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\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)\right) \cdot \left(\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)\right)\right) \cdot \left(\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)\right)}} \]
      2. pow355.0%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(\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)\right)}^{3}}} \]
    4. Applied egg-rr55.1%

      \[\leadsto \color{blue}{\sqrt[3]{{\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)}^{3}}} \]
    5. Taylor expanded in d around -inf 54.2%

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

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

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

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

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

    if -7.99999999999999987e-170 < d < 4.00000000000000015e-284

    1. Initial program 48.1%

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

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

    if 4.00000000000000015e-284 < d

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -8 \cdot 10^{-170}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{elif}\;d \leq 4 \cdot 10^{-284}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 18: 44.3% accurate, 1.6× speedup?

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

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

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


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

    1. Initial program 76.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. Simplified74.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. Step-by-step derivation
      1. sqrt-div0.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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) \]
    4. Applied egg-rr0.0%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{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) \]
    5. Taylor expanded in M around 0 55.4%

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

    if -7.99999999999999987e-170 < d < 5.0000000000000001e-282

    1. Initial program 48.1%

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

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

    if 5.0000000000000001e-282 < d

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -8 \cdot 10^{-170}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;d \leq 5 \cdot 10^{-282}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 19: 41.6% accurate, 3.0× speedup?

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

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


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

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

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

        \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\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)\right) \cdot \left(\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)\right)\right) \cdot \left(\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)\right)}} \]
      2. pow355.0%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(\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)\right)}^{3}}} \]
    4. Applied egg-rr55.1%

      \[\leadsto \color{blue}{\sqrt[3]{{\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)}^{3}}} \]
    5. Taylor expanded in d around -inf 54.2%

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

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

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

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

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

    if -8.5e-170 < d

    1. Initial program 65.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. Simplified65.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. Taylor expanded in d around inf 41.0%

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

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

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

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

Alternative 20: 26.2% accurate, 3.1× speedup?

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

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

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

Alternative 21: 26.5% accurate, 3.1× speedup?

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

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

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

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

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

Alternative 22: 26.0% accurate, 3.1× speedup?

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

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

      \[\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-eval70.5%

      \[\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-rr70.5%

    \[\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. Taylor expanded in d around inf 30.5%

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

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

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

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

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

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

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

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

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

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

Reproduce

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