Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.3% → 83.2%
Time: 1.7min
Alternatives: 19
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 19 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.3% 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: 83.2% accurate, 0.6× speedup?

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

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


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

    1. Initial program 64.4%

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

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

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\color{blue}{\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) \]
      2. sqrt-div75.3%

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

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

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

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

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

    if -1.000000000000002e-309 < l

    1. Initial program 57.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 80.7% accurate, 0.8× speedup?

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

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


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

    1. Initial program 64.4%

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

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

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\color{blue}{\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) \]
      2. sqrt-div75.3%

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

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

    if -1.000000000000002e-309 < l

    1. Initial program 57.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 81.0% accurate, 0.8× speedup?

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

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


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

    1. Initial program 64.4%

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

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

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\color{blue}{\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) \]
      2. sqrt-div75.3%

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

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

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

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

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

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

    if -1.000000000000002e-309 < l

    1. Initial program 57.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 76.4% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 56.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. Simplified53.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. Add Preprocessing
    4. Step-by-step derivation
      1. clear-num53.4%

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

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

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

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

    if -4.00000000000000033e-5 < l < -1.000000000000002e-309

    1. Initial program 73.6%

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

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

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

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

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

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

    if -1.000000000000002e-309 < l

    1. Initial program 57.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 76.0% accurate, 1.0× speedup?

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

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


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

    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. Simplified63.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.8e-303 < h

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 75.2% accurate, 1.0× speedup?

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

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


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

    1. Initial program 64.4%

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

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

    if -1.000000000000002e-309 < l

    1. Initial program 57.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 75.5% accurate, 1.0× speedup?

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

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


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

    1. Initial program 64.4%

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

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

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

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

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

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

    if -1.000000000000002e-309 < l

    1. Initial program 57.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 76.2% accurate, 1.0× speedup?

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

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


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

    1. Initial program 64.4%

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < l

    1. Initial program 57.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 76.1% accurate, 1.0× speedup?

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

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


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

    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. Simplified63.4%

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

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

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

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

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

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

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

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

    if -2.8e-303 < h

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 69.8% accurate, 1.0× speedup?

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

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


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

    1. Initial program 64.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < l

    1. Initial program 57.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 56.9% accurate, 1.1× speedup?

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

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

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

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


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

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.40000000000000008e-140 < d < -2.39999999999999993e-286

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

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

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

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

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}}\right) \]
      3. inv-pow41.2%

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

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

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

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

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

    if -2.39999999999999993e-286 < d < 3.34999999999999988e43

    1. Initial program 56.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. Simplified54.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.34999999999999988e43 < d

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.4 \cdot 10^{-140}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right)\right)\\ \mathbf{elif}\;d \leq -2.4 \cdot 10^{-286}:\\ \;\;\;\;d \cdot \log \left(e^{{\left(\ell \cdot h\right)}^{-0.5}}\right)\\ \mathbf{elif}\;d \leq 3.35 \cdot 10^{+43}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{\frac{d \cdot 2}{M}}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 55.9% accurate, 1.1× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + {\left(M\_m \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right)\right)\\ \mathbf{if}\;d \leq -4.5 \cdot 10^{-140}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.25 \cdot 10^{-226}:\\ \;\;\;\;d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left({\left(\ell \cdot h\right)}^{-0.5}\right)\right)\\ \mathbf{elif}\;d \leq 6 \cdot 10^{+43}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (let* ((t_0
         (*
          (sqrt (* (/ d l) (/ d h)))
          (+ 1.0 (* (pow (* M_m (* (/ D d) 0.5)) 2.0) (* (/ h l) -0.5))))))
   (if (<= d -4.5e-140)
     t_0
     (if (<= d 1.25e-226)
       (* d (log1p (expm1 (pow (* l h) -0.5))))
       (if (<= d 6e+43) t_0 (* d (* (pow l -0.5) (pow h -0.5))))))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double t_0 = sqrt(((d / l) * (d / h))) * (1.0 + (pow((M_m * ((D / d) * 0.5)), 2.0) * ((h / l) * -0.5)));
	double tmp;
	if (d <= -4.5e-140) {
		tmp = t_0;
	} else if (d <= 1.25e-226) {
		tmp = d * log1p(expm1(pow((l * h), -0.5)));
	} else if (d <= 6e+43) {
		tmp = t_0;
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double t_0 = Math.sqrt(((d / l) * (d / h))) * (1.0 + (Math.pow((M_m * ((D / d) * 0.5)), 2.0) * ((h / l) * -0.5)));
	double tmp;
	if (d <= -4.5e-140) {
		tmp = t_0;
	} else if (d <= 1.25e-226) {
		tmp = d * Math.log1p(Math.expm1(Math.pow((l * h), -0.5)));
	} else if (d <= 6e+43) {
		tmp = t_0;
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	t_0 = math.sqrt(((d / l) * (d / h))) * (1.0 + (math.pow((M_m * ((D / d) * 0.5)), 2.0) * ((h / l) * -0.5)))
	tmp = 0
	if d <= -4.5e-140:
		tmp = t_0
	elif d <= 1.25e-226:
		tmp = d * math.log1p(math.expm1(math.pow((l * h), -0.5)))
	elif d <= 6e+43:
		tmp = t_0
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	t_0 = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 + Float64((Float64(M_m * Float64(Float64(D / d) * 0.5)) ^ 2.0) * Float64(Float64(h / l) * -0.5))))
	tmp = 0.0
	if (d <= -4.5e-140)
		tmp = t_0;
	elseif (d <= 1.25e-226)
		tmp = Float64(d * log1p(expm1((Float64(l * h) ^ -0.5))));
	elseif (d <= 6e+43)
		tmp = t_0;
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[Power[N[(M$95$m * N[(N[(D / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.5e-140], t$95$0, If[LessEqual[d, 1.25e-226], N[(d * N[Log[1 + N[(Exp[N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6e+43], 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 = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + {\left(M\_m \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right)\right)\\
\mathbf{if}\;d \leq -4.5 \cdot 10^{-140}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 6 \cdot 10^{+43}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -4.50000000000000004e-140 or 1.2499999999999999e-226 < d < 6.00000000000000033e43

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.50000000000000004e-140 < d < 1.2499999999999999e-226

    1. Initial program 36.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. Simplified34.8%

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

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

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

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

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

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

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

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

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

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

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

    if 6.00000000000000033e43 < d

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.5 \cdot 10^{-140}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right)\right)\\ \mathbf{elif}\;d \leq 1.25 \cdot 10^{-226}:\\ \;\;\;\;d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left({\left(\ell \cdot h\right)}^{-0.5}\right)\right)\\ \mathbf{elif}\;d \leq 6 \cdot 10^{+43}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 57.0% accurate, 1.4× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 2.3000000000000001e46

    1. Initial program 61.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.3000000000000001e46 < d

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 47.3% accurate, 1.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -7.5 \cdot 10^{-161}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{elif}\;\ell \leq 1.4 \cdot 10^{-307}:\\ \;\;\;\;d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
 :precision binary64
 (if (<= l -7.5e-161)
   (* (- d) (pow (* l h) -0.5))
   (if (<= l 1.4e-307)
     (* d (pow (pow (* l h) 2.0) -0.25))
     (* d (* (pow l -0.5) (pow h -0.5))))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (l <= -7.5e-161) {
		tmp = -d * pow((l * h), -0.5);
	} else if (l <= 1.4e-307) {
		tmp = d * pow(pow((l * h), 2.0), -0.25);
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
M_m = abs(M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (l <= (-7.5d-161)) then
        tmp = -d * ((l * h) ** (-0.5d0))
    else if (l <= 1.4d-307) then
        tmp = d * (((l * h) ** 2.0d0) ** (-0.25d0))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	double tmp;
	if (l <= -7.5e-161) {
		tmp = -d * Math.pow((l * h), -0.5);
	} else if (l <= 1.4e-307) {
		tmp = d * Math.pow(Math.pow((l * h), 2.0), -0.25);
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	tmp = 0
	if l <= -7.5e-161:
		tmp = -d * math.pow((l * h), -0.5)
	elif l <= 1.4e-307:
		tmp = d * math.pow(math.pow((l * h), 2.0), -0.25)
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	tmp = 0.0
	if (l <= -7.5e-161)
		tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5));
	elseif (l <= 1.4e-307)
		tmp = Float64(d * ((Float64(l * h) ^ 2.0) ^ -0.25));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
	tmp = 0.0;
	if (l <= -7.5e-161)
		tmp = -d * ((l * h) ^ -0.5);
	elseif (l <= 1.4e-307)
		tmp = d * (((l * h) ^ 2.0) ^ -0.25);
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, -7.5e-161], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.4e-307], N[(d * N[Power[N[Power[N[(l * h), $MachinePrecision], 2.0], $MachinePrecision], -0.25], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7.5 \cdot 10^{-161}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\

\mathbf{elif}\;\ell \leq 1.4 \cdot 10^{-307}:\\
\;\;\;\;d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}\\

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


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

    1. Initial program 59.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
      4. unpow1/246.9%

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

        \[\leadsto d \cdot \left(-{\color{blue}{\left(\frac{1}{\ell \cdot h}\right)}}^{0.5}\right) \]
      6. rem-exp-log42.8%

        \[\leadsto d \cdot \left(-{\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{0.5}\right) \]
      7. exp-neg42.8%

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

        \[\leadsto d \cdot \left(-\color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}}\right) \]
      9. distribute-lft-neg-out42.8%

        \[\leadsto d \cdot \left(-e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}}\right) \]
      10. distribute-rgt-neg-in42.8%

        \[\leadsto d \cdot \left(-e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}}\right) \]
      11. metadata-eval42.8%

        \[\leadsto d \cdot \left(-e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}}\right) \]
      12. exp-to-pow45.0%

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

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

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

    if -7.49999999999999991e-161 < l < 1.4e-307

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

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

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

        \[\leadsto d \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \]
      2. expm1-undefine20.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-pow15.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. *-commutative15.4%

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

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

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

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

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

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

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

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

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

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

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

    if 1.4e-307 < l

    1. Initial program 56.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. Simplified57.5%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7.5 \cdot 10^{-161}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{elif}\;\ell \leq 1.4 \cdot 10^{-307}:\\ \;\;\;\;d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 46.5% accurate, 1.6× speedup?

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

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


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

    1. Initial program 64.5%

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000001e-248 < l

    1. Initial program 56.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 5 \cdot 10^{-248}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 42.9% accurate, 2.9× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

    if 6.89999999999999981e-220 < l

    1. Initial program 56.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. Simplified57.5%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 6.9 \cdot 10^{-220}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 43.0% accurate, 3.0× speedup?

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

\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\


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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}}\right) \]
      4. unpow1/238.8%

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

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

        \[\leadsto d \cdot \left(-{\left(\frac{1}{\color{blue}{e^{\log \left(\ell \cdot h\right)}}}\right)}^{0.5}\right) \]
      7. exp-neg36.1%

        \[\leadsto d \cdot \left(-{\color{blue}{\left(e^{-\log \left(\ell \cdot h\right)}\right)}}^{0.5}\right) \]
      8. exp-prod35.5%

        \[\leadsto d \cdot \left(-\color{blue}{e^{\left(-\log \left(\ell \cdot h\right)\right) \cdot 0.5}}\right) \]
      9. distribute-lft-neg-out35.5%

        \[\leadsto d \cdot \left(-e^{\color{blue}{-\log \left(\ell \cdot h\right) \cdot 0.5}}\right) \]
      10. distribute-rgt-neg-in35.5%

        \[\leadsto d \cdot \left(-e^{\color{blue}{\log \left(\ell \cdot h\right) \cdot \left(-0.5\right)}}\right) \]
      11. metadata-eval35.5%

        \[\leadsto d \cdot \left(-e^{\log \left(\ell \cdot h\right) \cdot \color{blue}{-0.5}}\right) \]
      12. exp-to-pow37.1%

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

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

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

    if 1.69999999999999993e-218 < l

    1. Initial program 56.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. Simplified57.5%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 1.7 \cdot 10^{-218}:\\ \;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 26.9% accurate, 3.1× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ d \cdot {\left(\ell \cdot h\right)}^{-0.5} \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D) :precision binary64 (* d (pow (* l h) -0.5)))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	return d * pow((l * h), -0.5);
}
M_m = abs(M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_1
    code = d * ((l * h) ** (-0.5d0))
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	return d * Math.pow((l * h), -0.5);
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	return d * math.pow((l * h), -0.5)
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	return Float64(d * (Float64(l * h) ^ -0.5))
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
	tmp = d * ((l * h) ^ -0.5);
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
d \cdot {\left(\ell \cdot h\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 60.7%

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

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

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

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

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

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}} \]
    4. *-commutative25.3%

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

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

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

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

Alternative 19: 4.3% accurate, 332.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ [d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\ \\ 0 \end{array} \]
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D) :precision binary64 0.0)
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
	return 0.0;
}
M_m = abs(M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_1
    code = 0.0d0
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
	return 0.0;
}
M_m = math.fabs(M)
[d, h, l, M_m, D] = sort([d, h, l, M_m, D])
def code(d, h, l, M_m, D):
	return 0.0
M_m = abs(M)
d, h, l, M_m, D = sort([d, h, l, M_m, D])
function code(d, h, l, M_m, D)
	return 0.0
end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
	tmp = 0.0;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := 0.0
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
0
\end{array}
Derivation
  1. Initial program 60.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -1 + e^{\color{blue}{\log \left(1 + d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right)}} \]
    5. rem-exp-log22.7%

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

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

      \[\leadsto -1 + \color{blue}{\mathsf{fma}\left(d, {\left(\ell \cdot h\right)}^{-0.5}, 1\right)} \]
    8. *-commutative22.7%

      \[\leadsto -1 + \mathsf{fma}\left(d, {\color{blue}{\left(h \cdot \ell\right)}}^{-0.5}, 1\right) \]
  8. Simplified22.7%

    \[\leadsto \color{blue}{-1 + \mathsf{fma}\left(d, {\left(h \cdot \ell\right)}^{-0.5}, 1\right)} \]
  9. Taylor expanded in d around 0 3.9%

    \[\leadsto -1 + \color{blue}{1} \]
  10. Final simplification3.9%

    \[\leadsto 0 \]
  11. Add Preprocessing

Reproduce

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