Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.2% → 79.3%
Time: 30.3s
Alternatives: 18
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 18 alternatives:

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

Initial Program: 66.2% 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.3% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 63.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < l < 2e185

    1. Initial program 72.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e185 < l

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow35.6%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow35.6%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval35.6%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr35.6%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def61.8%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p62.2%

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \]
      6. *-commutative62.0%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      8. rem-cbrt-cube45.6%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    10. Simplified62.0%

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

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

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

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

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

Alternative 2: 76.9% accurate, 0.3× speedup?

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

\mathbf{elif}\;t_1 \leq 0 \lor \neg \left(t_1 \leq 2 \cdot 10^{+229}\right):\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\

\mathbf{else}:\\
\;\;\;\;t_3 \cdot \left(\left(1 + \frac{\left(h \cdot {\left(\frac{t_2}{d}\right)}^{2}\right) \cdot -0.5}{\ell}\right) \cdot t_0\right)\\


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

    1. Initial program 89.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. Simplified86.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.9999999999999998e-86 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < 0.0 or 2e229 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l))))

    1. Initial program 22.4%

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

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow26.3%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval26.3%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr26.3%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def33.6%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p33.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      10. associate-/l/37.3%

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      11. sqrt-prod32.6%

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{\frac{1}{h}}{\ell}}} \]
      12. associate-/l/32.7%

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      15. add-sqr-sqrt32.7%

        \[\leadsto \sqrt{\color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \cdot \sqrt{\frac{{d}^{2}}{h \cdot \ell}}}} \]
      16. rem-sqrt-square32.7%

        \[\leadsto \color{blue}{\left|\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\right|} \]
      17. sqrt-div37.3%

        \[\leadsto \left|\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}}\right| \]
      18. unpow237.3%

        \[\leadsto \left|\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h \cdot \ell}}\right| \]
      19. sqrt-prod30.9%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right| \]
      20. add-sqr-sqrt58.2%

        \[\leadsto \left|\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right| \]
    8. Applied egg-rr58.2%

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

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

    1. Initial program 98.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 79.1% accurate, 0.8× speedup?

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

\mathbf{elif}\;\ell \leq 1.35 \cdot 10^{+184}:\\
\;\;\;\;t_1 \cdot \left(\frac{\sqrt{d}}{\sqrt{h}} \cdot t_0\right)\\

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


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

    1. Initial program 63.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < l < 1.35e184

    1. Initial program 72.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.35e184 < l

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow35.6%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow35.6%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval35.6%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr35.6%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def61.8%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p62.2%

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \]
      6. *-commutative62.0%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      8. rem-cbrt-cube45.6%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    10. Simplified62.0%

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

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

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

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

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

Alternative 4: 66.2% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 42.1%

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow8.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow8.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval8.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr8.4%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def8.1%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p8.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      10. associate-/l/39.6%

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

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{\frac{1}{h}}{\ell}}} \]
      12. associate-/l/34.8%

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

        \[\leadsto \sqrt{{d}^{2} \cdot \frac{1}{\color{blue}{h \cdot \ell}}} \]
      14. div-inv34.8%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      15. add-sqr-sqrt34.8%

        \[\leadsto \sqrt{\color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \cdot \sqrt{\frac{{d}^{2}}{h \cdot \ell}}}} \]
      16. rem-sqrt-square34.8%

        \[\leadsto \color{blue}{\left|\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\right|} \]
      17. sqrt-div39.8%

        \[\leadsto \left|\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}}\right| \]
      18. unpow239.8%

        \[\leadsto \left|\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h \cdot \ell}}\right| \]
      19. sqrt-prod0.0%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right| \]
      20. add-sqr-sqrt55.1%

        \[\leadsto \left|\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right| \]
    8. Applied egg-rr55.1%

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

    if -1.38000000000000001e119 < l < 2.5999999999999998e133

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

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

    if 2.5999999999999998e133 < l

    1. Initial program 56.5%

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow25.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow25.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval25.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr25.8%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def65.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      8. rem-cbrt-cube34.7%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}} \]
      10. expm1-log1p-u32.7%

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

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

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

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    10. Simplified65.8%

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

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

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

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

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

Alternative 5: 66.8% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 42.1%

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow8.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow8.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval8.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr8.4%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def8.1%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p8.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      10. associate-/l/39.6%

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

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{\frac{1}{h}}{\ell}}} \]
      12. associate-/l/34.8%

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

        \[\leadsto \sqrt{{d}^{2} \cdot \frac{1}{\color{blue}{h \cdot \ell}}} \]
      14. div-inv34.8%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      15. add-sqr-sqrt34.8%

        \[\leadsto \sqrt{\color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \cdot \sqrt{\frac{{d}^{2}}{h \cdot \ell}}}} \]
      16. rem-sqrt-square34.8%

        \[\leadsto \color{blue}{\left|\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\right|} \]
      17. sqrt-div39.8%

        \[\leadsto \left|\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}}\right| \]
      18. unpow239.8%

        \[\leadsto \left|\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h \cdot \ell}}\right| \]
      19. sqrt-prod0.0%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right| \]
      20. add-sqr-sqrt55.1%

        \[\leadsto \left|\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right| \]
    8. Applied egg-rr55.1%

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

    if -5.59999999999999995e117 < l < 2.1e133

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

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

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

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

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

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

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

    if 2.1e133 < l

    1. Initial program 56.5%

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow25.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow25.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval25.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr25.8%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def65.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      8. rem-cbrt-cube34.7%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}} \]
      10. expm1-log1p-u32.7%

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

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

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

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    10. Simplified65.8%

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

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

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

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

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

Alternative 6: 67.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 42.1%

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow8.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow8.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval8.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr8.4%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def8.1%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p8.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      10. associate-/l/39.6%

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

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{\frac{1}{h}}{\ell}}} \]
      12. associate-/l/34.8%

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

        \[\leadsto \sqrt{{d}^{2} \cdot \frac{1}{\color{blue}{h \cdot \ell}}} \]
      14. div-inv34.8%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      15. add-sqr-sqrt34.8%

        \[\leadsto \sqrt{\color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \cdot \sqrt{\frac{{d}^{2}}{h \cdot \ell}}}} \]
      16. rem-sqrt-square34.8%

        \[\leadsto \color{blue}{\left|\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\right|} \]
      17. sqrt-div39.8%

        \[\leadsto \left|\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}}\right| \]
      18. unpow239.8%

        \[\leadsto \left|\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h \cdot \ell}}\right| \]
      19. sqrt-prod0.0%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right| \]
      20. add-sqr-sqrt55.1%

        \[\leadsto \left|\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right| \]
    8. Applied egg-rr55.1%

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

    if -2.60000000000000016e118 < l < 2.2e133

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.2e133 < l

    1. Initial program 56.5%

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow25.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow25.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval25.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr25.8%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def65.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      8. rem-cbrt-cube34.7%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}} \]
      10. expm1-log1p-u32.7%

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

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

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

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    10. Simplified65.8%

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

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

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

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

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

Alternative 7: 69.5% accurate, 1.0× speedup?

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

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


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

    1. Initial program 67.8%

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

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

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

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

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

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

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

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

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

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

    if 5.5e132 < l

    1. Initial program 56.5%

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow25.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow25.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval25.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr25.8%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def65.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      8. rem-cbrt-cube34.7%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}} \]
      10. expm1-log1p-u32.7%

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

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

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

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    10. Simplified65.8%

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

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

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

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

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

Alternative 8: 49.9% accurate, 1.0× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := -0.125 \cdot \left(\sqrt{h \cdot {\ell}^{-3}} \cdot \frac{{\left(M \cdot D\right)}^{2}}{d}\right)\\ t_1 := \frac{d}{\sqrt{\ell \cdot h}}\\ \mathbf{if}\;d \leq -1.25 \cdot 10^{+60}:\\ \;\;\;\;\left|t_1\right|\\ \mathbf{elif}\;d \leq -1.9 \cdot 10^{-292}:\\ \;\;\;\;t_1 \cdot \mathsf{fma}\left({\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}, \frac{0.5}{\frac{\ell}{h}}, 1\right)\\ \mathbf{elif}\;d \leq 10^{-86}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 3 \cdot 10^{-24}:\\ \;\;\;\;{\ell}^{-0.5} \cdot \left(d \cdot {h}^{-0.5}\right)\\ \mathbf{elif}\;d \leq 2.85 \cdot 10^{+137}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (* -0.125 (* (sqrt (* h (pow l -3.0))) (/ (pow (* M D) 2.0) d))))
        (t_1 (/ d (sqrt (* l h)))))
   (if (<= d -1.25e+60)
     (fabs t_1)
     (if (<= d -1.9e-292)
       (* t_1 (fma (pow (* (/ D d) (* M 0.5)) 2.0) (/ 0.5 (/ l h)) 1.0))
       (if (<= d 1e-86)
         t_0
         (if (<= d 3e-24)
           (* (pow l -0.5) (* d (pow h -0.5)))
           (if (<= d 2.85e+137) t_0 (* d (* (pow l -0.5) (pow h -0.5))))))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = -0.125 * (sqrt((h * pow(l, -3.0))) * (pow((M * D), 2.0) / d));
	double t_1 = d / sqrt((l * h));
	double tmp;
	if (d <= -1.25e+60) {
		tmp = fabs(t_1);
	} else if (d <= -1.9e-292) {
		tmp = t_1 * fma(pow(((D / d) * (M * 0.5)), 2.0), (0.5 / (l / h)), 1.0);
	} else if (d <= 1e-86) {
		tmp = t_0;
	} else if (d <= 3e-24) {
		tmp = pow(l, -0.5) * (d * pow(h, -0.5));
	} else if (d <= 2.85e+137) {
		tmp = t_0;
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(-0.125 * Float64(sqrt(Float64(h * (l ^ -3.0))) * Float64((Float64(M * D) ^ 2.0) / d)))
	t_1 = Float64(d / sqrt(Float64(l * h)))
	tmp = 0.0
	if (d <= -1.25e+60)
		tmp = abs(t_1);
	elseif (d <= -1.9e-292)
		tmp = Float64(t_1 * fma((Float64(Float64(D / d) * Float64(M * 0.5)) ^ 2.0), Float64(0.5 / Float64(l / h)), 1.0));
	elseif (d <= 1e-86)
		tmp = t_0;
	elseif (d <= 3e-24)
		tmp = Float64((l ^ -0.5) * Float64(d * (h ^ -0.5)));
	elseif (d <= 2.85e+137)
		tmp = t_0;
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(-0.125 * N[(N[Sqrt[N[(h * N[Power[l, -3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.25e+60], N[Abs[t$95$1], $MachinePrecision], If[LessEqual[d, -1.9e-292], N[(t$95$1 * N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(0.5 / N[(l / h), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1e-86], t$95$0, If[LessEqual[d, 3e-24], N[(N[Power[l, -0.5], $MachinePrecision] * N[(d * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.85e+137], t$95$0, N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := -0.125 \cdot \left(\sqrt{h \cdot {\ell}^{-3}} \cdot \frac{{\left(M \cdot D\right)}^{2}}{d}\right)\\
t_1 := \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;d \leq -1.25 \cdot 10^{+60}:\\
\;\;\;\;\left|t_1\right|\\

\mathbf{elif}\;d \leq -1.9 \cdot 10^{-292}:\\
\;\;\;\;t_1 \cdot \mathsf{fma}\left({\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}, \frac{0.5}{\frac{\ell}{h}}, 1\right)\\

\mathbf{elif}\;d \leq 10^{-86}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 2.85 \cdot 10^{+137}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -1.24999999999999994e60

    1. Initial program 66.1%

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow5.6%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow5.6%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval5.6%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr5.6%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def5.5%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p5.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      10. associate-/l/42.6%

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      11. sqrt-prod32.4%

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{\frac{1}{h}}{\ell}}} \]
      12. associate-/l/32.4%

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

        \[\leadsto \sqrt{{d}^{2} \cdot \frac{1}{\color{blue}{h \cdot \ell}}} \]
      14. div-inv32.4%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      15. add-sqr-sqrt32.4%

        \[\leadsto \sqrt{\color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \cdot \sqrt{\frac{{d}^{2}}{h \cdot \ell}}}} \]
      16. rem-sqrt-square32.4%

        \[\leadsto \color{blue}{\left|\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\right|} \]
      17. sqrt-div42.6%

        \[\leadsto \left|\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}}\right| \]
      18. unpow242.6%

        \[\leadsto \left|\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h \cdot \ell}}\right| \]
      19. sqrt-prod0.0%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right| \]
      20. add-sqr-sqrt65.6%

        \[\leadsto \left|\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right| \]
    8. Applied egg-rr65.6%

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

    if -1.24999999999999994e60 < d < -1.9000000000000001e-292

    1. Initial program 64.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. Applied egg-rr15.4%

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

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

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

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

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

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

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

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

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

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

    if -1.9000000000000001e-292 < d < 1.00000000000000008e-86 or 2.99999999999999995e-24 < d < 2.8499999999999999e137

    1. Initial program 60.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\left(\color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{d}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \cdot -0.125\right)} - 1 \]
      5. pow-prod-down4.9%

        \[\leadsto e^{\mathsf{log1p}\left(\left(\frac{\color{blue}{{\left(D \cdot M\right)}^{2}}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \cdot -0.125\right)} - 1 \]
      6. div-inv4.9%

        \[\leadsto e^{\mathsf{log1p}\left(\left(\frac{{\left(D \cdot M\right)}^{2}}{d} \cdot \sqrt{\color{blue}{h \cdot \frac{1}{{\ell}^{3}}}}\right) \cdot -0.125\right)} - 1 \]
      7. pow-flip4.8%

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

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

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

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

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

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

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

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

    if 1.00000000000000008e-86 < d < 2.99999999999999995e-24

    1. Initial program 69.8%

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow23.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow23.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval23.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr23.8%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def55.4%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p57.2%

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      8. rem-cbrt-cube25.4%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}} \]
      10. expm1-log1p-u23.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\ell \cdot h\right)}^{\color{blue}{-0.5}} \cdot d \]
      7. pow-prod-down77.6%

        \[\leadsto \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \cdot d \]
      8. associate-*l*77.7%

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

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

    if 2.8499999999999999e137 < d

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow44.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow44.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval44.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr44.8%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def67.7%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p68.5%

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

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

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down77.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.25 \cdot 10^{+60}:\\ \;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\ \mathbf{elif}\;d \leq -1.9 \cdot 10^{-292}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \mathsf{fma}\left({\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}, \frac{0.5}{\frac{\ell}{h}}, 1\right)\\ \mathbf{elif}\;d \leq 10^{-86}:\\ \;\;\;\;-0.125 \cdot \left(\sqrt{h \cdot {\ell}^{-3}} \cdot \frac{{\left(M \cdot D\right)}^{2}}{d}\right)\\ \mathbf{elif}\;d \leq 3 \cdot 10^{-24}:\\ \;\;\;\;{\ell}^{-0.5} \cdot \left(d \cdot {h}^{-0.5}\right)\\ \mathbf{elif}\;d \leq 2.85 \cdot 10^{+137}:\\ \;\;\;\;-0.125 \cdot \left(\sqrt{h \cdot {\ell}^{-3}} \cdot \frac{{\left(M \cdot D\right)}^{2}}{d}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]

Alternative 9: 44.2% accurate, 1.0× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 5.9 \cdot 10^{-28}:\\ \;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\ \mathbf{elif}\;M \leq 1700000:\\ \;\;\;\;d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left({\left(\ell \cdot h\right)}^{-0.5}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-0.125 \cdot \left(\sqrt{h \cdot {\ell}^{-3}} \cdot \frac{{\left(M \cdot D\right)}^{2}}{d}\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (if (<= M 5.9e-28)
   (fabs (/ d (sqrt (* l h))))
   (if (<= M 1700000.0)
     (* d (log1p (expm1 (pow (* l h) -0.5))))
     (* -0.125 (* (sqrt (* h (pow l -3.0))) (/ (pow (* M D) 2.0) d))))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (M <= 5.9e-28) {
		tmp = fabs((d / sqrt((l * h))));
	} else if (M <= 1700000.0) {
		tmp = d * log1p(expm1(pow((l * h), -0.5)));
	} else {
		tmp = -0.125 * (sqrt((h * pow(l, -3.0))) * (pow((M * D), 2.0) / d));
	}
	return tmp;
}
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (M <= 5.9e-28) {
		tmp = Math.abs((d / Math.sqrt((l * h))));
	} else if (M <= 1700000.0) {
		tmp = d * Math.log1p(Math.expm1(Math.pow((l * h), -0.5)));
	} else {
		tmp = -0.125 * (Math.sqrt((h * Math.pow(l, -3.0))) * (Math.pow((M * D), 2.0) / d));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	tmp = 0
	if M <= 5.9e-28:
		tmp = math.fabs((d / math.sqrt((l * h))))
	elif M <= 1700000.0:
		tmp = d * math.log1p(math.expm1(math.pow((l * h), -0.5)))
	else:
		tmp = -0.125 * (math.sqrt((h * math.pow(l, -3.0))) * (math.pow((M * D), 2.0) / d))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	tmp = 0.0
	if (M <= 5.9e-28)
		tmp = abs(Float64(d / sqrt(Float64(l * h))));
	elseif (M <= 1700000.0)
		tmp = Float64(d * log1p(expm1((Float64(l * h) ^ -0.5))));
	else
		tmp = Float64(-0.125 * Float64(sqrt(Float64(h * (l ^ -3.0))) * Float64((Float64(M * D) ^ 2.0) / d)));
	end
	return tmp
end
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := If[LessEqual[M, 5.9e-28], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[M, 1700000.0], N[(d * N[Log[1 + N[(Exp[N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-0.125 * N[(N[Sqrt[N[(h * N[Power[l, -3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 5.9 \cdot 10^{-28}:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\

\mathbf{elif}\;M \leq 1700000:\\
\;\;\;\;d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left({\left(\ell \cdot h\right)}^{-0.5}\right)\right)\\

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


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

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow20.7%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow20.6%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval20.6%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr20.6%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def30.3%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p30.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      10. associate-/l/31.7%

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

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{\frac{1}{h}}{\ell}}} \]
      12. associate-/l/25.3%

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

        \[\leadsto \sqrt{{d}^{2} \cdot \frac{1}{\color{blue}{h \cdot \ell}}} \]
      14. div-inv25.6%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      15. add-sqr-sqrt25.6%

        \[\leadsto \sqrt{\color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \cdot \sqrt{\frac{{d}^{2}}{h \cdot \ell}}}} \]
      16. rem-sqrt-square25.6%

        \[\leadsto \color{blue}{\left|\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\right|} \]
      17. sqrt-div32.0%

        \[\leadsto \left|\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}}\right| \]
      18. unpow232.0%

        \[\leadsto \left|\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h \cdot \ell}}\right| \]
      19. sqrt-prod26.4%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right| \]
      20. add-sqr-sqrt51.5%

        \[\leadsto \left|\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right| \]
    8. Applied egg-rr51.5%

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

    if 5.9000000000000002e-28 < M < 1.7e6

    1. Initial program 74.5%

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow3.0%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow3.0%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval3.0%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr3.0%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def26.3%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p26.3%

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

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    7. Step-by-step derivation
      1. log1p-expm1-u38.3%

        \[\leadsto d \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
    8. Applied egg-rr38.3%

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

    if 1.7e6 < M

    1. Initial program 63.4%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\left(\color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{d}} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \cdot -0.125\right)} - 1 \]
      5. pow-prod-down3.9%

        \[\leadsto e^{\mathsf{log1p}\left(\left(\frac{\color{blue}{{\left(D \cdot M\right)}^{2}}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \cdot -0.125\right)} - 1 \]
      6. div-inv3.9%

        \[\leadsto e^{\mathsf{log1p}\left(\left(\frac{{\left(D \cdot M\right)}^{2}}{d} \cdot \sqrt{\color{blue}{h \cdot \frac{1}{{\ell}^{3}}}}\right) \cdot -0.125\right)} - 1 \]
      7. pow-flip3.8%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 5.9 \cdot 10^{-28}:\\ \;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\ \mathbf{elif}\;M \leq 1700000:\\ \;\;\;\;d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left({\left(\ell \cdot h\right)}^{-0.5}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-0.125 \cdot \left(\sqrt{h \cdot {\ell}^{-3}} \cdot \frac{{\left(M \cdot D\right)}^{2}}{d}\right)\\ \end{array} \]

Alternative 10: 47.3% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 58.6%

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

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

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

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

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

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

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

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

        \[\leadsto -d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right| \]
      7. pow-sqr52.8%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right| \]
      8. fabs-sqr52.8%

        \[\leadsto -d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      9. pow-sqr53.1%

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

        \[\leadsto -d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \]
      11. distribute-rgt-neg-in53.1%

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

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

    if -6.6000000000000003e-94 < l < -1.999999999999994e-310

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow21.9%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow17.7%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval17.7%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr17.7%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def17.8%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p17.8%

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \]
      6. *-commutative22.0%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      8. rem-cbrt-cube30.1%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}} \]
      10. expm1-log1p-u0.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}\right)\right)} \]
      11. expm1-udef0.2%

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

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

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    10. Simplified17.8%

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

        \[\leadsto \frac{d}{\color{blue}{\log \left(e^{\sqrt{h \cdot \ell}}\right)}} \]
    12. Applied egg-rr42.6%

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

    if -1.999999999999994e-310 < l

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow28.1%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow28.7%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval28.7%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr28.7%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def44.1%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p45.0%

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \]
      6. *-commutative44.4%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      8. rem-cbrt-cube27.6%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}} \]
      10. expm1-log1p-u26.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}\right)\right)} \]
      11. expm1-udef21.0%

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

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

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

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

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

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

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

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

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

Alternative 11: 42.9% accurate, 1.1× speedup?

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

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


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

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow20.6%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow20.5%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval20.5%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr20.5%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def30.7%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p31.2%

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.5 + -0.5\right)}}} \]
      7. metadata-eval32.0%

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

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

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      10. associate-/l/32.0%

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

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{\frac{1}{h}}{\ell}}} \]
      12. associate-/l/25.7%

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      15. add-sqr-sqrt26.0%

        \[\leadsto \sqrt{\color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \cdot \sqrt{\frac{{d}^{2}}{h \cdot \ell}}}} \]
      16. rem-sqrt-square26.0%

        \[\leadsto \color{blue}{\left|\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\right|} \]
      17. sqrt-div32.4%

        \[\leadsto \left|\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}}\right| \]
      18. unpow232.4%

        \[\leadsto \left|\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h \cdot \ell}}\right| \]
      19. sqrt-prod26.8%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right| \]
      20. add-sqr-sqrt51.8%

        \[\leadsto \left|\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right| \]
    8. Applied egg-rr51.8%

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

    if 7.2000000000000003e-26 < M

    1. Initial program 65.6%

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

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

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

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}}\right) \]
      3. inv-pow25.9%

        \[\leadsto d \cdot \log \left(e^{{\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}}\right) \]
      4. pow-pow25.9%

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}}\right) \]
      5. metadata-eval25.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 7.2 \cdot 10^{-26}:\\ \;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\ \mathbf{else}:\\ \;\;\;\;d \cdot \log \left(e^{{\left(\ell \cdot h\right)}^{-0.5}}\right)\\ \end{array} \]

Alternative 12: 43.1% accurate, 1.1× speedup?

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

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


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

    1. Initial program 66.5%

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow20.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow20.7%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval20.7%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr20.7%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def30.4%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p31.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      10. associate-/l/31.8%

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      11. sqrt-prod25.5%

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{\frac{1}{h}}{\ell}}} \]
      12. associate-/l/25.5%

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      15. add-sqr-sqrt25.7%

        \[\leadsto \sqrt{\color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \cdot \sqrt{\frac{{d}^{2}}{h \cdot \ell}}}} \]
      16. rem-sqrt-square25.7%

        \[\leadsto \color{blue}{\left|\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\right|} \]
      17. sqrt-div32.2%

        \[\leadsto \left|\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}}\right| \]
      18. unpow232.2%

        \[\leadsto \left|\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h \cdot \ell}}\right| \]
      19. sqrt-prod26.5%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right| \]
      20. add-sqr-sqrt51.8%

        \[\leadsto \left|\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right| \]
    8. Applied egg-rr51.8%

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

    if 2.5e-31 < M

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow17.0%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow15.7%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval15.7%

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

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def18.4%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p18.8%

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

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

        \[\leadsto d \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
    8. Applied egg-rr28.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 2.5 \cdot 10^{-31}:\\ \;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\ \mathbf{else}:\\ \;\;\;\;d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left({\left(\ell \cdot h\right)}^{-0.5}\right)\right)\\ \end{array} \]

Alternative 13: 42.4% accurate, 1.1× speedup?

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

\mathbf{else}:\\
\;\;\;\;\log \left(e^{t_0}\right)\\


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

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow20.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow20.3%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval20.3%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr20.3%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def30.9%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p31.4%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      10. associate-/l/32.2%

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      11. sqrt-prod25.5%

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{\frac{1}{h}}{\ell}}} \]
      12. associate-/l/25.5%

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

        \[\leadsto \sqrt{{d}^{2} \cdot \frac{1}{\color{blue}{h \cdot \ell}}} \]
      14. div-inv25.8%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      15. add-sqr-sqrt25.8%

        \[\leadsto \sqrt{\color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \cdot \sqrt{\frac{{d}^{2}}{h \cdot \ell}}}} \]
      16. rem-sqrt-square25.8%

        \[\leadsto \color{blue}{\left|\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\right|} \]
      17. sqrt-div32.5%

        \[\leadsto \left|\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}}\right| \]
      18. unpow232.5%

        \[\leadsto \left|\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h \cdot \ell}}\right| \]
      19. sqrt-prod27.1%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right| \]
      20. add-sqr-sqrt51.7%

        \[\leadsto \left|\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right| \]
    8. Applied egg-rr51.7%

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

    if 4.10000000000000029e-23 < M

    1. Initial program 64.6%

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow17.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow16.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval16.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr16.4%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def16.5%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p16.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      10. associate-/l/19.1%

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

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{\frac{1}{h}}{\ell}}} \]
      12. associate-/l/16.1%

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

        \[\leadsto \sqrt{{d}^{2} \cdot \frac{1}{\color{blue}{h \cdot \ell}}} \]
      14. div-inv16.1%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      15. add-log-exp7.5%

        \[\leadsto \color{blue}{\log \left(e^{\sqrt{\frac{{d}^{2}}{h \cdot \ell}}}\right)} \]
      16. sqrt-div7.5%

        \[\leadsto \log \left(e^{\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}}}\right) \]
      17. unpow27.5%

        \[\leadsto \log \left(e^{\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h \cdot \ell}}}\right) \]
      18. sqrt-prod6.4%

        \[\leadsto \log \left(e^{\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}}\right) \]
      19. add-sqr-sqrt23.7%

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

      \[\leadsto \color{blue}{\log \left(e^{\frac{d}{\sqrt{h \cdot \ell}}}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification44.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 4.1 \cdot 10^{-23}:\\ \;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{\frac{d}{\sqrt{\ell \cdot h}}}\right)\\ \end{array} \]

Alternative 14: 42.4% accurate, 1.1× speedup?

\[\begin{array}{l} M = |M|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \frac{d}{\sqrt{\ell \cdot h}}\\ \mathbf{if}\;M \leq 1.42 \cdot 10^{-28}:\\ \;\;\;\;\left|t_0\right|\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(t_0\right)\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (/ d (sqrt (* l h)))))
   (if (<= M 1.42e-28) (fabs t_0) (log1p (expm1 t_0)))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
	double t_0 = d / sqrt((l * h));
	double tmp;
	if (M <= 1.42e-28) {
		tmp = fabs(t_0);
	} else {
		tmp = log1p(expm1(t_0));
	}
	return tmp;
}
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = d / Math.sqrt((l * h));
	double tmp;
	if (M <= 1.42e-28) {
		tmp = Math.abs(t_0);
	} else {
		tmp = Math.log1p(Math.expm1(t_0));
	}
	return tmp;
}
M = abs(M)
[M, D] = sort([M, D])
def code(d, h, l, M, D):
	t_0 = d / math.sqrt((l * h))
	tmp = 0
	if M <= 1.42e-28:
		tmp = math.fabs(t_0)
	else:
		tmp = math.log1p(math.expm1(t_0))
	return tmp
M = abs(M)
M, D = sort([M, D])
function code(d, h, l, M, D)
	t_0 = Float64(d / sqrt(Float64(l * h)))
	tmp = 0.0
	if (M <= 1.42e-28)
		tmp = abs(t_0);
	else
		tmp = log1p(expm1(t_0));
	end
	return tmp
end
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 1.42e-28], N[Abs[t$95$0], $MachinePrecision], N[Log[1 + N[(Exp[t$95$0] - 1), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;M \leq 1.42 \cdot 10^{-28}:\\
\;\;\;\;\left|t_0\right|\\

\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(t_0\right)\right)\\


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

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow20.7%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow20.6%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval20.6%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr20.6%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def30.3%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p30.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      10. associate-/l/31.7%

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

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{\frac{1}{h}}{\ell}}} \]
      12. associate-/l/25.3%

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

        \[\leadsto \sqrt{{d}^{2} \cdot \frac{1}{\color{blue}{h \cdot \ell}}} \]
      14. div-inv25.6%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      15. add-sqr-sqrt25.6%

        \[\leadsto \sqrt{\color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \cdot \sqrt{\frac{{d}^{2}}{h \cdot \ell}}}} \]
      16. rem-sqrt-square25.6%

        \[\leadsto \color{blue}{\left|\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\right|} \]
      17. sqrt-div32.0%

        \[\leadsto \left|\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}}\right| \]
      18. unpow232.0%

        \[\leadsto \left|\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h \cdot \ell}}\right| \]
      19. sqrt-prod26.4%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right| \]
      20. add-sqr-sqrt51.5%

        \[\leadsto \left|\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right| \]
    8. Applied egg-rr51.5%

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

    if 1.42000000000000001e-28 < M

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow17.2%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow15.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval15.8%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr15.8%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def18.7%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p19.0%

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \]
      6. *-commutative20.4%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      8. rem-cbrt-cube23.0%

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}\right)\right)} \]
      11. expm1-udef7.9%

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

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

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    10. Simplified19.0%

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

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)\right)} \]
    12. Applied egg-rr27.0%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification44.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 1.42 \cdot 10^{-28}:\\ \;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{d}{\sqrt{\ell \cdot h}}\right)\right)\\ \end{array} \]

Alternative 15: 41.6% accurate, 1.6× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 2.09999999999999984e231

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow20.0%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow19.5%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval19.5%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr19.5%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def27.8%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p28.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      10. associate-/l/30.5%

        \[\leadsto \sqrt{{d}^{2}} \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      11. sqrt-prod24.4%

        \[\leadsto \color{blue}{\sqrt{{d}^{2} \cdot \frac{\frac{1}{h}}{\ell}}} \]
      12. associate-/l/24.4%

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

        \[\leadsto \sqrt{{d}^{2} \cdot \frac{1}{\color{blue}{h \cdot \ell}}} \]
      14. div-inv24.6%

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \]
      15. add-sqr-sqrt24.6%

        \[\leadsto \sqrt{\color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \cdot \sqrt{\frac{{d}^{2}}{h \cdot \ell}}}} \]
      16. rem-sqrt-square24.6%

        \[\leadsto \color{blue}{\left|\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\right|} \]
      17. sqrt-div30.8%

        \[\leadsto \left|\color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}}\right| \]
      18. unpow230.8%

        \[\leadsto \left|\frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h \cdot \ell}}\right| \]
      19. sqrt-prod24.2%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\sqrt{h \cdot \ell}}\right| \]
      20. add-sqr-sqrt46.7%

        \[\leadsto \left|\frac{\color{blue}{d}}{\sqrt{h \cdot \ell}}\right| \]
    8. Applied egg-rr46.7%

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

    if 2.09999999999999984e231 < D

    1. Initial program 86.6%

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

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

        \[\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}}}} \]
      2. pow1/328.2%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq 2.1 \cdot 10^{+231}:\\ \;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]

Alternative 16: 45.6% accurate, 1.6× speedup?

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

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


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

    1. Initial program 58.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. Applied egg-rr18.8%

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg40.3%

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

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

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

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

        \[\leadsto -d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      6. metadata-eval40.8%

        \[\leadsto -d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right| \]
      7. pow-sqr40.7%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right| \]
      8. fabs-sqr40.7%

        \[\leadsto -d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      9. pow-sqr40.8%

        \[\leadsto -d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(2 \cdot -0.25\right)}} \]
      10. metadata-eval40.8%

        \[\leadsto -d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \]
      11. distribute-rgt-neg-in40.8%

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

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

    if 2.30000000000000006e-236 < d

    1. Initial program 76.1%

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow29.5%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow30.2%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval30.2%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr30.2%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def47.9%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p49.0%

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      8. rem-cbrt-cube28.9%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}} \]
      10. expm1-log1p-u27.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}\right)\right)} \]
      11. expm1-udef22.2%

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

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

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

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    10. Simplified49.0%

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

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

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

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

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

Alternative 17: 40.8% accurate, 3.0× speedup?

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

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


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

    1. Initial program 64.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. Applied egg-rr21.7%

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg44.7%

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

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

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

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

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

        \[\leadsto -d \cdot \left|{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.25\right)}}\right| \]
      7. pow-sqr45.2%

        \[\leadsto -d \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}}\right| \]
      8. fabs-sqr45.2%

        \[\leadsto -d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      9. pow-sqr45.4%

        \[\leadsto -d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(2 \cdot -0.25\right)}} \]
      10. metadata-eval45.4%

        \[\leadsto -d \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.5}} \]
      11. distribute-rgt-neg-in45.4%

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

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

    if -5.99999999999999992e-283 < h

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
      4. inv-pow28.4%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
      5. pow-pow28.9%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
      6. metadata-eval28.9%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    4. Applied egg-rr28.9%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    5. Step-by-step derivation
      1. expm1-def43.6%

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p44.5%

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

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

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

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

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

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \]
      6. *-commutative43.8%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      8. rem-cbrt-cube28.5%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}} \]
      10. expm1-log1p-u25.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}\right)\right)} \]
      11. expm1-udef19.9%

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

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

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

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

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

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

Alternative 18: 26.2% accurate, 3.2× speedup?

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

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

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

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

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

      \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}\right)} - 1\right) \]
    4. inv-pow19.7%

      \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}\right)} - 1\right) \]
    5. pow-pow19.3%

      \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}\right)} - 1\right) \]
    6. metadata-eval19.3%

      \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
  4. Applied egg-rr19.3%

    \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
  5. Step-by-step derivation
    1. expm1-def27.1%

      \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]
    2. expm1-log1p27.6%

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

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

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

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

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

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

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \]
    6. *-commutative28.0%

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

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    8. rem-cbrt-cube22.4%

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

      \[\leadsto d \cdot \sqrt{\color{blue}{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}} \]
    10. expm1-log1p-u14.7%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(d \cdot \sqrt{{\left({\left(\frac{\frac{1}{h}}{\ell}\right)}^{3}\right)}^{0.3333333333333333}}\right)\right)} \]
    11. expm1-udef12.0%

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

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

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  10. Simplified27.6%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  11. Final simplification27.6%

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

Reproduce

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